Commit a62f0d27 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: psmouse - small formatting changes to better follow coding style

Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 83ba9ea8
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#include "psmouse.h" #include "psmouse.h"
#include "hgpk.h" #include "hgpk.h"
static int tpdebug; static bool tpdebug;
module_param(tpdebug, int, 0644); module_param(tpdebug, bool, 0644);
MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG."); MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG.");
static int recalib_delta = 100; static int recalib_delta = 100;
......
...@@ -56,36 +56,36 @@ static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse) ...@@ -56,36 +56,36 @@ static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse)
/* Logitech extended packet */ /* Logitech extended packet */
switch ((packet[1] >> 4) | (packet[0] & 0x30)) { switch ((packet[1] >> 4) | (packet[0] & 0x30)) {
case 0x0d: /* Mouse extra info */ case 0x0d: /* Mouse extra info */
input_report_rel(dev, packet[2] & 0x80 ? REL_HWHEEL : REL_WHEEL, input_report_rel(dev, packet[2] & 0x80 ? REL_HWHEEL : REL_WHEEL,
(int) (packet[2] & 8) - (int) (packet[2] & 7)); (int) (packet[2] & 8) - (int) (packet[2] & 7));
input_report_key(dev, BTN_SIDE, (packet[2] >> 4) & 1); input_report_key(dev, BTN_SIDE, (packet[2] >> 4) & 1);
input_report_key(dev, BTN_EXTRA, (packet[2] >> 5) & 1); input_report_key(dev, BTN_EXTRA, (packet[2] >> 5) & 1);
break; break;
case 0x0e: /* buttons 4, 5, 6, 7, 8, 9, 10 info */ case 0x0e: /* buttons 4, 5, 6, 7, 8, 9, 10 info */
input_report_key(dev, BTN_SIDE, (packet[2]) & 1); input_report_key(dev, BTN_SIDE, (packet[2]) & 1);
input_report_key(dev, BTN_EXTRA, (packet[2] >> 1) & 1); input_report_key(dev, BTN_EXTRA, (packet[2] >> 1) & 1);
input_report_key(dev, BTN_BACK, (packet[2] >> 3) & 1); input_report_key(dev, BTN_BACK, (packet[2] >> 3) & 1);
input_report_key(dev, BTN_FORWARD, (packet[2] >> 4) & 1); input_report_key(dev, BTN_FORWARD, (packet[2] >> 4) & 1);
input_report_key(dev, BTN_TASK, (packet[2] >> 2) & 1); input_report_key(dev, BTN_TASK, (packet[2] >> 2) & 1);
break; break;
case 0x0f: /* TouchPad extra info */ case 0x0f: /* TouchPad extra info */
input_report_rel(dev, packet[2] & 0x08 ? REL_HWHEEL : REL_WHEEL, input_report_rel(dev, packet[2] & 0x08 ? REL_HWHEEL : REL_WHEEL,
(int) ((packet[2] >> 4) & 8) - (int) ((packet[2] >> 4) & 7)); (int) ((packet[2] >> 4) & 8) - (int) ((packet[2] >> 4) & 7));
packet[0] = packet[2] | 0x08; packet[0] = packet[2] | 0x08;
break; break;
#ifdef DEBUG #ifdef DEBUG
default: default:
printk(KERN_WARNING "psmouse.c: Received PS2++ packet #%x, but don't know how to handle.\n", printk(KERN_WARNING "psmouse.c: Received PS2++ packet #%x, but don't know how to handle.\n",
(packet[1] >> 4) | (packet[0] & 0x30)); (packet[1] >> 4) | (packet[0] & 0x30));
#endif #endif
} }
} else { } else {
...@@ -250,7 +250,6 @@ static const struct ps2pp_info *get_model_info(unsigned char model) ...@@ -250,7 +250,6 @@ static const struct ps2pp_info *get_model_info(unsigned char model)
if (model == ps2pp_list[i].model) if (model == ps2pp_list[i].model)
return &ps2pp_list[i]; return &ps2pp_list[i];
printk(KERN_WARNING "logips2pp: Detected unknown logitech mouse model %d\n", model);
return NULL; return NULL;
} }
...@@ -285,31 +284,32 @@ static void ps2pp_set_model_properties(struct psmouse *psmouse, ...@@ -285,31 +284,32 @@ static void ps2pp_set_model_properties(struct psmouse *psmouse,
__set_bit(REL_HWHEEL, input_dev->relbit); __set_bit(REL_HWHEEL, input_dev->relbit);
switch (model_info->kind) { switch (model_info->kind) {
case PS2PP_KIND_WHEEL:
psmouse->name = "Wheel Mouse";
break;
case PS2PP_KIND_MX:
psmouse->name = "MX Mouse";
break;
case PS2PP_KIND_TP3: case PS2PP_KIND_WHEEL:
psmouse->name = "TouchPad 3"; psmouse->name = "Wheel Mouse";
break; break;
case PS2PP_KIND_TRACKMAN: case PS2PP_KIND_MX:
psmouse->name = "TrackMan"; psmouse->name = "MX Mouse";
break; break;
default: case PS2PP_KIND_TP3:
/* psmouse->name = "TouchPad 3";
* Set name to "Mouse" only when using PS2++, break;
* otherwise let other protocols define suitable
* name case PS2PP_KIND_TRACKMAN:
*/ psmouse->name = "TrackMan";
if (using_ps2pp) break;
psmouse->name = "Mouse";
break; default:
/*
* Set name to "Mouse" only when using PS2++,
* otherwise let other protocols define suitable
* name
*/
if (using_ps2pp)
psmouse->name = "Mouse";
break;
} }
} }
...@@ -343,7 +343,8 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties) ...@@ -343,7 +343,8 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties)
if (!model || !buttons) if (!model || !buttons)
return -1; return -1;
if ((model_info = get_model_info(model)) != NULL) { model_info = get_model_info(model);
if (model_info) {
/* /*
* Do Logitech PS2++ / PS2T++ magic init. * Do Logitech PS2++ / PS2T++ magic init.
...@@ -379,6 +380,9 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties) ...@@ -379,6 +380,9 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties)
use_ps2pp = true; use_ps2pp = true;
} }
} }
} else {
printk(KERN_WARNING "logips2pp: Detected unknown logitech mouse model %d\n", model);
} }
if (set_properties) { if (set_properties) {
......
...@@ -147,18 +147,18 @@ static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) ...@@ -147,18 +147,18 @@ static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
if (psmouse->type == PSMOUSE_IMEX) { if (psmouse->type == PSMOUSE_IMEX) {
switch (packet[3] & 0xC0) { switch (packet[3] & 0xC0) {
case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */ case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */
input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31)); input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
break; break;
case 0x40: /* horizontal scroll on IntelliMouse Explorer 4.0 */ case 0x40: /* horizontal scroll on IntelliMouse Explorer 4.0 */
input_report_rel(dev, REL_HWHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31)); input_report_rel(dev, REL_HWHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
break; break;
case 0x00: case 0x00:
case 0xC0: case 0xC0:
input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7)); input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7));
input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1); input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1); input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
break; break;
} }
} }
...@@ -247,31 +247,31 @@ static int psmouse_handle_byte(struct psmouse *psmouse) ...@@ -247,31 +247,31 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
psmouse_ret_t rc = psmouse->protocol_handler(psmouse); psmouse_ret_t rc = psmouse->protocol_handler(psmouse);
switch (rc) { switch (rc) {
case PSMOUSE_BAD_DATA: case PSMOUSE_BAD_DATA:
if (psmouse->state == PSMOUSE_ACTIVATED) { if (psmouse->state == PSMOUSE_ACTIVATED) {
printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n", printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
psmouse->name, psmouse->phys, psmouse->pktcnt); psmouse->name, psmouse->phys, psmouse->pktcnt);
if (++psmouse->out_of_sync_cnt == psmouse->resetafter) { if (++psmouse->out_of_sync_cnt == psmouse->resetafter) {
__psmouse_set_state(psmouse, PSMOUSE_IGNORE); __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n"); printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
serio_reconnect(psmouse->ps2dev.serio); serio_reconnect(psmouse->ps2dev.serio);
return -1; return -1;
}
}
psmouse->pktcnt = 0;
break;
case PSMOUSE_FULL_PACKET:
psmouse->pktcnt = 0;
if (psmouse->out_of_sync_cnt) {
psmouse->out_of_sync_cnt = 0;
printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
psmouse->name, psmouse->phys);
} }
break; }
psmouse->pktcnt = 0;
break;
case PSMOUSE_FULL_PACKET:
psmouse->pktcnt = 0;
if (psmouse->out_of_sync_cnt) {
psmouse->out_of_sync_cnt = 0;
printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
psmouse->name, psmouse->phys);
}
break;
case PSMOUSE_GOOD_DATA: case PSMOUSE_GOOD_DATA:
break; break;
} }
return 0; return 0;
} }
...@@ -1245,7 +1245,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, ...@@ -1245,7 +1245,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
psmouse->pktsize = 3; psmouse->pktsize = 3;
if (proto && (proto->detect || proto->init)) { if (proto && (proto->detect || proto->init)) {
if (proto->detect && proto->detect(psmouse, 1) < 0) if (proto->detect && proto->detect(psmouse, true) < 0)
return -1; return -1;
if (proto->init && proto->init(psmouse) < 0) if (proto->init && proto->init(psmouse) < 0)
......
...@@ -532,19 +532,20 @@ static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned cha ...@@ -532,19 +532,20 @@ static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned cha
return 0; return 0;
switch (pkt_type) { switch (pkt_type) {
case SYN_NEWABS:
case SYN_NEWABS_RELAXED:
return (packet[idx] & newabs_rel_mask[idx]) == newabs_rslt[idx];
case SYN_NEWABS_STRICT: case SYN_NEWABS:
return (packet[idx] & newabs_mask[idx]) == newabs_rslt[idx]; case SYN_NEWABS_RELAXED:
return (packet[idx] & newabs_rel_mask[idx]) == newabs_rslt[idx];
case SYN_OLDABS: case SYN_NEWABS_STRICT:
return (packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx]; return (packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
default: case SYN_OLDABS:
printk(KERN_ERR "synaptics: unknown packet type %d\n", pkt_type); return (packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
return 0;
default:
printk(KERN_ERR "synaptics: unknown packet type %d\n", pkt_type);
return 0;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment