aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-11-17 01:12:21 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-11-20 03:52:12 -0500
commit315eb996d5505112b22452ccbc7e01fb02eaae81 (patch)
tree86abf8a390575efe1bc0b678dbd27310ff351f59
parent0cc1770b66ddc2524ab5f0ed6ba5f2df19d6414a (diff)
Input: psmouse - rework setting of BTN_MIDDLE capability
Do not start protocol detection assuming that middle mouse is present, instead let individual protocols explicitly set this capability. This fixes issue with Synaptics touchpads pretending that they have middle button when hardware clearly reports otherwise. Reported-and-tested-by: Andrey Borzenkov <arvidjaar@mail.ru> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/mouse/hgpk.c13
-rw-r--r--drivers/input/mouse/logips2pp.c4
-rw-r--r--drivers/input/mouse/psmouse-base.c38
-rw-r--r--drivers/input/mouse/sentelic.c1
-rw-r--r--drivers/input/mouse/trackpoint.c13
5 files changed, 38 insertions, 31 deletions
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index de1e553028b7..b146237266d8 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -430,19 +430,6 @@ static int hgpk_register(struct psmouse *psmouse)
430 struct input_dev *dev = psmouse->dev; 430 struct input_dev *dev = psmouse->dev;
431 int err; 431 int err;
432 432
433 /* unset the things that psmouse-base sets which we don't have */
434 __clear_bit(BTN_MIDDLE, dev->keybit);
435
436 /* set the things we do have */
437 __set_bit(EV_KEY, dev->evbit);
438 __set_bit(EV_REL, dev->evbit);
439
440 __set_bit(REL_X, dev->relbit);
441 __set_bit(REL_Y, dev->relbit);
442
443 __set_bit(BTN_LEFT, dev->keybit);
444 __set_bit(BTN_RIGHT, dev->keybit);
445
446 /* register handlers */ 433 /* register handlers */
447 psmouse->protocol_handler = hgpk_process_byte; 434 psmouse->protocol_handler = hgpk_process_byte;
448 psmouse->poll = hgpk_poll; 435 psmouse->poll = hgpk_poll;
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index ab5dc5f5fd83..543c240a85f2 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -404,8 +404,8 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties)
404 } 404 }
405 } 405 }
406 406
407 if (buttons < 3) 407 if (buttons >= 3)
408 __clear_bit(BTN_MIDDLE, psmouse->dev->keybit); 408 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
409 409
410 if (model_info) 410 if (model_info)
411 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); 411 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 690aed905436..e1c9fe210083 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -425,6 +425,7 @@ static int genius_detect(struct psmouse *psmouse, bool set_properties)
425 return -1; 425 return -1;
426 426
427 if (set_properties) { 427 if (set_properties) {
428 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
428 __set_bit(BTN_EXTRA, psmouse->dev->keybit); 429 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
429 __set_bit(BTN_SIDE, psmouse->dev->keybit); 430 __set_bit(BTN_SIDE, psmouse->dev->keybit);
430 __set_bit(REL_WHEEL, psmouse->dev->relbit); 431 __set_bit(REL_WHEEL, psmouse->dev->relbit);
@@ -460,8 +461,10 @@ static int intellimouse_detect(struct psmouse *psmouse, bool set_properties)
460 __set_bit(BTN_MIDDLE, psmouse->dev->keybit); 461 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
461 __set_bit(REL_WHEEL, psmouse->dev->relbit); 462 __set_bit(REL_WHEEL, psmouse->dev->relbit);
462 463
463 if (!psmouse->vendor) psmouse->vendor = "Generic"; 464 if (!psmouse->vendor)
464 if (!psmouse->name) psmouse->name = "Wheel Mouse"; 465 psmouse->vendor = "Generic";
466 if (!psmouse->name)
467 psmouse->name = "Wheel Mouse";
465 psmouse->pktsize = 4; 468 psmouse->pktsize = 4;
466 } 469 }
467 470
@@ -504,8 +507,10 @@ static int im_explorer_detect(struct psmouse *psmouse, bool set_properties)
504 __set_bit(BTN_SIDE, psmouse->dev->keybit); 507 __set_bit(BTN_SIDE, psmouse->dev->keybit);
505 __set_bit(BTN_EXTRA, psmouse->dev->keybit); 508 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
506 509
507 if (!psmouse->vendor) psmouse->vendor = "Generic"; 510 if (!psmouse->vendor)
508 if (!psmouse->name) psmouse->name = "Explorer Mouse"; 511 psmouse->vendor = "Generic";
512 if (!psmouse->name)
513 psmouse->name = "Explorer Mouse";
509 psmouse->pktsize = 4; 514 psmouse->pktsize = 4;
510 } 515 }
511 516
@@ -536,6 +541,7 @@ static int thinking_detect(struct psmouse *psmouse, bool set_properties)
536 return -1; 541 return -1;
537 542
538 if (set_properties) { 543 if (set_properties) {
544 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
539 __set_bit(BTN_EXTRA, psmouse->dev->keybit); 545 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
540 546
541 psmouse->vendor = "Kensington"; 547 psmouse->vendor = "Kensington";
@@ -551,8 +557,16 @@ static int thinking_detect(struct psmouse *psmouse, bool set_properties)
551static int ps2bare_detect(struct psmouse *psmouse, bool set_properties) 557static int ps2bare_detect(struct psmouse *psmouse, bool set_properties)
552{ 558{
553 if (set_properties) { 559 if (set_properties) {
554 if (!psmouse->vendor) psmouse->vendor = "Generic"; 560 if (!psmouse->vendor)
555 if (!psmouse->name) psmouse->name = "Mouse"; 561 psmouse->vendor = "Generic";
562 if (!psmouse->name)
563 psmouse->name = "Mouse";
564
565/*
566 * We have no way of figuring true number of buttons so let's
567 * assume that the device has 3.
568 */
569 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
556 } 570 }
557 571
558 return 0; 572 return 0;
@@ -567,6 +581,8 @@ static int cortron_detect(struct psmouse *psmouse, bool set_properties)
567 if (set_properties) { 581 if (set_properties) {
568 psmouse->vendor = "Cortron"; 582 psmouse->vendor = "Cortron";
569 psmouse->name = "PS/2 Trackball"; 583 psmouse->name = "PS/2 Trackball";
584
585 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
570 __set_bit(BTN_SIDE, psmouse->dev->keybit); 586 __set_bit(BTN_SIDE, psmouse->dev->keybit);
571 } 587 }
572 588
@@ -1184,15 +1200,16 @@ static void psmouse_disconnect(struct serio *serio)
1184 mutex_unlock(&psmouse_mutex); 1200 mutex_unlock(&psmouse_mutex);
1185} 1201}
1186 1202
1187static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse_protocol *proto) 1203static int psmouse_switch_protocol(struct psmouse *psmouse,
1204 const struct psmouse_protocol *proto)
1188{ 1205{
1189 struct input_dev *input_dev = psmouse->dev; 1206 struct input_dev *input_dev = psmouse->dev;
1190 1207
1191 input_dev->dev.parent = &psmouse->ps2dev.serio->dev; 1208 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
1192 1209
1193 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 1210 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
1194 input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 1211 input_dev->keybit[BIT_WORD(BTN_MOUSE)] =
1195 BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); 1212 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
1196 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 1213 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
1197 1214
1198 psmouse->set_rate = psmouse_set_rate; 1215 psmouse->set_rate = psmouse_set_rate;
@@ -1209,8 +1226,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse
1209 return -1; 1226 return -1;
1210 1227
1211 psmouse->type = proto->type; 1228 psmouse->type = proto->type;
1212 } 1229 } else
1213 else
1214 psmouse->type = psmouse_extensions(psmouse, 1230 psmouse->type = psmouse_extensions(psmouse,
1215 psmouse_max_proto, true); 1231 psmouse_max_proto, true);
1216 1232
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index f84cbd97c884..77b9fd0b3fbf 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -836,6 +836,7 @@ int fsp_init(struct psmouse *psmouse)
836 priv->flags |= FSPDRV_FLAG_EN_OPC; 836 priv->flags |= FSPDRV_FLAG_EN_OPC;
837 837
838 /* Set up various supported input event bits */ 838 /* Set up various supported input event bits */
839 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
839 __set_bit(BTN_BACK, psmouse->dev->keybit); 840 __set_bit(BTN_BACK, psmouse->dev->keybit);
840 __set_bit(BTN_FORWARD, psmouse->dev->keybit); 841 __set_bit(BTN_FORWARD, psmouse->dev->keybit);
841 __set_bit(REL_WHEEL, psmouse->dev->relbit); 842 __set_bit(REL_WHEEL, psmouse->dev->relbit);
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index e354362f2971..63d4a67830f2 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -284,7 +284,6 @@ static int trackpoint_reconnect(struct psmouse *psmouse)
284 284
285int trackpoint_detect(struct psmouse *psmouse, bool set_properties) 285int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
286{ 286{
287 struct trackpoint_data *priv;
288 struct ps2dev *ps2dev = &psmouse->ps2dev; 287 struct ps2dev *ps2dev = &psmouse->ps2dev;
289 unsigned char firmware_id; 288 unsigned char firmware_id;
290 unsigned char button_info; 289 unsigned char button_info;
@@ -301,8 +300,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
301 button_info = 0; 300 button_info = 0;
302 } 301 }
303 302
304 psmouse->private = priv = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); 303 psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
305 if (!priv) 304 if (!psmouse->private)
306 return -1; 305 return -1;
307 306
308 psmouse->vendor = "IBM"; 307 psmouse->vendor = "IBM";
@@ -311,7 +310,10 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
311 psmouse->reconnect = trackpoint_reconnect; 310 psmouse->reconnect = trackpoint_reconnect;
312 psmouse->disconnect = trackpoint_disconnect; 311 psmouse->disconnect = trackpoint_disconnect;
313 312
314 trackpoint_defaults(priv); 313 if ((button_info & 0x0f) >= 3)
314 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
315
316 trackpoint_defaults(psmouse->private);
315 trackpoint_sync(psmouse); 317 trackpoint_sync(psmouse);
316 318
317 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); 319 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
@@ -319,7 +321,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
319 printk(KERN_ERR 321 printk(KERN_ERR
320 "trackpoint.c: failed to create sysfs attributes, error: %d\n", 322 "trackpoint.c: failed to create sysfs attributes, error: %d\n",
321 error); 323 error);
322 kfree(priv); 324 kfree(psmouse->private);
325 psmouse->private = NULL;
323 return -1; 326 return -1;
324 } 327 }
325 328