aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/hgpk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mouse/hgpk.c')
-rw-r--r--drivers/input/mouse/hgpk.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 4d17d9f3320b..0470dd46b566 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -136,10 +136,10 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)
136 /* discard if too big, or half that but > 4 times the prev delta */ 136 /* discard if too big, or half that but > 4 times the prev delta */
137 if (avx > recalib_delta || 137 if (avx > recalib_delta ||
138 (avx > recalib_delta / 2 && ((avx / 4) > priv->xlast))) { 138 (avx > recalib_delta / 2 && ((avx / 4) > priv->xlast))) {
139 hgpk_err(psmouse, "detected %dpx jump in x\n", x); 139 psmouse_warn(psmouse, "detected %dpx jump in x\n", x);
140 priv->xbigj = avx; 140 priv->xbigj = avx;
141 } else if (approx_half(avx, priv->xbigj)) { 141 } else if (approx_half(avx, priv->xbigj)) {
142 hgpk_err(psmouse, "detected secondary %dpx jump in x\n", x); 142 psmouse_warn(psmouse, "detected secondary %dpx jump in x\n", x);
143 priv->xbigj = avx; 143 priv->xbigj = avx;
144 priv->xsaw_secondary++; 144 priv->xsaw_secondary++;
145 } else { 145 } else {
@@ -151,10 +151,10 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)
151 151
152 if (avy > recalib_delta || 152 if (avy > recalib_delta ||
153 (avy > recalib_delta / 2 && ((avy / 4) > priv->ylast))) { 153 (avy > recalib_delta / 2 && ((avy / 4) > priv->ylast))) {
154 hgpk_err(psmouse, "detected %dpx jump in y\n", y); 154 psmouse_warn(psmouse, "detected %dpx jump in y\n", y);
155 priv->ybigj = avy; 155 priv->ybigj = avy;
156 } else if (approx_half(avy, priv->ybigj)) { 156 } else if (approx_half(avy, priv->ybigj)) {
157 hgpk_err(psmouse, "detected secondary %dpx jump in y\n", y); 157 psmouse_warn(psmouse, "detected secondary %dpx jump in y\n", y);
158 priv->ybigj = avy; 158 priv->ybigj = avy;
159 priv->ysaw_secondary++; 159 priv->ysaw_secondary++;
160 } else { 160 } else {
@@ -168,7 +168,7 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)
168 priv->ylast = avy; 168 priv->ylast = avy;
169 169
170 if (do_recal && jumpy_delay) { 170 if (do_recal && jumpy_delay) {
171 hgpk_err(psmouse, "scheduling recalibration\n"); 171 psmouse_warn(psmouse, "scheduling recalibration\n");
172 psmouse_queue_work(psmouse, &priv->recalib_wq, 172 psmouse_queue_work(psmouse, &priv->recalib_wq,
173 msecs_to_jiffies(jumpy_delay)); 173 msecs_to_jiffies(jumpy_delay));
174 } 174 }
@@ -260,8 +260,8 @@ static void hgpk_spewing_hack(struct psmouse *psmouse,
260 * movement, it is probably a case of the user moving the 260 * movement, it is probably a case of the user moving the
261 * cursor very slowly across the screen. */ 261 * cursor very slowly across the screen. */
262 if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) { 262 if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) {
263 hgpk_err(psmouse, "packet spew detected (%d,%d)\n", 263 psmouse_warn(psmouse, "packet spew detected (%d,%d)\n",
264 priv->x_tally, priv->y_tally); 264 priv->x_tally, priv->y_tally);
265 priv->spew_flag = RECALIBRATING; 265 priv->spew_flag = RECALIBRATING;
266 psmouse_queue_work(psmouse, &priv->recalib_wq, 266 psmouse_queue_work(psmouse, &priv->recalib_wq,
267 msecs_to_jiffies(spew_delay)); 267 msecs_to_jiffies(spew_delay));
@@ -333,12 +333,12 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet)
333 } 333 }
334 334
335 if (!valid) 335 if (!valid)
336 hgpk_dbg(psmouse, 336 psmouse_dbg(psmouse,
337 "bad data, mode %d (%d) %02x %02x %02x %02x %02x %02x\n", 337 "bad data, mode %d (%d) %02x %02x %02x %02x %02x %02x\n",
338 priv->mode, pktcnt, 338 priv->mode, pktcnt,
339 psmouse->packet[0], psmouse->packet[1], 339 psmouse->packet[0], psmouse->packet[1],
340 psmouse->packet[2], psmouse->packet[3], 340 psmouse->packet[2], psmouse->packet[3],
341 psmouse->packet[4], psmouse->packet[5]); 341 psmouse->packet[4], psmouse->packet[5]);
342 342
343 return valid; 343 return valid;
344} 344}
@@ -361,19 +361,20 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
361 361
362 input_report_abs(idev, ABS_PRESSURE, z); 362 input_report_abs(idev, ABS_PRESSURE, z);
363 if (tpdebug) 363 if (tpdebug)
364 hgpk_dbg(psmouse, "pd=%d fd=%d z=%d", 364 psmouse_dbg(psmouse, "pd=%d fd=%d z=%d",
365 pt_down, finger_down, z); 365 pt_down, finger_down, z);
366 } else { 366 } else {
367 /* 367 /*
368 * PenTablet mode does not report pressure, so we don't 368 * PenTablet mode does not report pressure, so we don't
369 * report it here 369 * report it here
370 */ 370 */
371 if (tpdebug) 371 if (tpdebug)
372 hgpk_dbg(psmouse, "pd=%d ", down); 372 psmouse_dbg(psmouse, "pd=%d ", down);
373 } 373 }
374 374
375 if (tpdebug) 375 if (tpdebug)
376 hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y); 376 psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n",
377 left, right, x, y);
377 378
378 input_report_key(idev, BTN_TOUCH, down); 379 input_report_key(idev, BTN_TOUCH, down);
379 input_report_key(idev, BTN_LEFT, left); 380 input_report_key(idev, BTN_LEFT, left);
@@ -395,7 +396,7 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
395 if (x == priv->abs_x && y == priv->abs_y) { 396 if (x == priv->abs_x && y == priv->abs_y) {
396 if (++priv->dupe_count > SPEW_WATCH_COUNT) { 397 if (++priv->dupe_count > SPEW_WATCH_COUNT) {
397 if (tpdebug) 398 if (tpdebug)
398 hgpk_dbg(psmouse, "hard spew detected\n"); 399 psmouse_dbg(psmouse, "hard spew detected\n");
399 priv->spew_flag = RECALIBRATING; 400 priv->spew_flag = RECALIBRATING;
400 psmouse_queue_work(psmouse, &priv->recalib_wq, 401 psmouse_queue_work(psmouse, &priv->recalib_wq,
401 msecs_to_jiffies(spew_delay)); 402 msecs_to_jiffies(spew_delay));
@@ -412,7 +413,7 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
412 int y_diff = priv->abs_y - y; 413 int y_diff = priv->abs_y - y;
413 if (hgpk_discard_decay_hack(psmouse, x_diff, y_diff)) { 414 if (hgpk_discard_decay_hack(psmouse, x_diff, y_diff)) {
414 if (tpdebug) 415 if (tpdebug)
415 hgpk_dbg(psmouse, "discarding\n"); 416 psmouse_dbg(psmouse, "discarding\n");
416 goto done; 417 goto done;
417 } 418 }
418 hgpk_spewing_hack(psmouse, left, right, x_diff, y_diff); 419 hgpk_spewing_hack(psmouse, left, right, x_diff, y_diff);
@@ -437,20 +438,21 @@ static void hgpk_process_simple_packet(struct psmouse *psmouse)
437 int y = ((packet[0] << 3) & 0x100) - packet[2]; 438 int y = ((packet[0] << 3) & 0x100) - packet[2];
438 439
439 if (packet[0] & 0xc0) 440 if (packet[0] & 0xc0)
440 hgpk_dbg(psmouse, 441 psmouse_dbg(psmouse,
441 "overflow -- 0x%02x 0x%02x 0x%02x\n", 442 "overflow -- 0x%02x 0x%02x 0x%02x\n",
442 packet[0], packet[1], packet[2]); 443 packet[0], packet[1], packet[2]);
443 444
444 if (hgpk_discard_decay_hack(psmouse, x, y)) { 445 if (hgpk_discard_decay_hack(psmouse, x, y)) {
445 if (tpdebug) 446 if (tpdebug)
446 hgpk_dbg(psmouse, "discarding\n"); 447 psmouse_dbg(psmouse, "discarding\n");
447 return; 448 return;
448 } 449 }
449 450
450 hgpk_spewing_hack(psmouse, left, right, x, y); 451 hgpk_spewing_hack(psmouse, left, right, x, y);
451 452
452 if (tpdebug) 453 if (tpdebug)
453 hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y); 454 psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n",
455 left, right, x, y);
454 456
455 input_report_key(dev, BTN_LEFT, left); 457 input_report_key(dev, BTN_LEFT, left);
456 input_report_key(dev, BTN_RIGHT, right); 458 input_report_key(dev, BTN_RIGHT, right);
@@ -482,9 +484,8 @@ static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse)
482 * ugh, got a packet inside our recalibration 484 * ugh, got a packet inside our recalibration
483 * window, schedule another recalibration. 485 * window, schedule another recalibration.
484 */ 486 */
485 hgpk_dbg(psmouse, 487 psmouse_dbg(psmouse,
486 "packet inside calibration window, " 488 "packet inside calibration window, queueing another recalibration\n");
487 "queueing another recalibration\n");
488 psmouse_queue_work(psmouse, &priv->recalib_wq, 489 psmouse_queue_work(psmouse, &priv->recalib_wq,
489 msecs_to_jiffies(post_interrupt_delay)); 490 msecs_to_jiffies(post_interrupt_delay));
490 } 491 }
@@ -628,7 +629,7 @@ static int hgpk_reset_device(struct psmouse *psmouse, bool recalibrate)
628 629
629 err = hgpk_select_mode(psmouse); 630 err = hgpk_select_mode(psmouse);
630 if (err) { 631 if (err) {
631 hgpk_err(psmouse, "failed to select mode\n"); 632 psmouse_err(psmouse, "failed to select mode\n");
632 return err; 633 return err;
633 } 634 }
634 635
@@ -648,11 +649,11 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)
648 return 0; 649 return 0;
649 650
650 if (!autorecal) { 651 if (!autorecal) {
651 hgpk_dbg(psmouse, "recalibrations disabled, ignoring\n"); 652 psmouse_dbg(psmouse, "recalibration disabled, ignoring\n");
652 return 0; 653 return 0;
653 } 654 }
654 655
655 hgpk_dbg(psmouse, "recalibrating touchpad..\n"); 656 psmouse_dbg(psmouse, "recalibrating touchpad..\n");
656 657
657 /* we don't want to race with the irq handler, nor with resyncs */ 658 /* we don't want to race with the irq handler, nor with resyncs */
658 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 659 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -675,7 +676,7 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)
675 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); 676 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
676 677
677 if (tpdebug) 678 if (tpdebug)
678 hgpk_dbg(psmouse, "touchpad reactivated\n"); 679 psmouse_dbg(psmouse, "touchpad reactivated\n");
679 680
680 /* 681 /*
681 * If we get packets right away after recalibrating, it's likely 682 * If we get packets right away after recalibrating, it's likely
@@ -727,16 +728,16 @@ static int hgpk_toggle_powersave(struct psmouse *psmouse, int enable)
727 728
728 err = hgpk_reset_device(psmouse, false); 729 err = hgpk_reset_device(psmouse, false);
729 if (err) { 730 if (err) {
730 hgpk_err(psmouse, "Failed to reset device!\n"); 731 psmouse_err(psmouse, "Failed to reset device!\n");
731 return err; 732 return err;
732 } 733 }
733 734
734 /* should be all set, enable the touchpad */ 735 /* should be all set, enable the touchpad */
735 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); 736 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
736 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); 737 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
737 hgpk_dbg(psmouse, "Touchpad powered up.\n"); 738 psmouse_dbg(psmouse, "Touchpad powered up.\n");
738 } else { 739 } else {
739 hgpk_dbg(psmouse, "Powering off touchpad.\n"); 740 psmouse_dbg(psmouse, "Powering off touchpad.\n");
740 741
741 if (ps2_command(ps2dev, NULL, 0xec) || 742 if (ps2_command(ps2dev, NULL, 0xec) ||
742 ps2_command(ps2dev, NULL, 0xec) || 743 ps2_command(ps2dev, NULL, 0xec) ||
@@ -923,7 +924,7 @@ static void hgpk_recalib_work(struct work_struct *work)
923 struct psmouse *psmouse = priv->psmouse; 924 struct psmouse *psmouse = priv->psmouse;
924 925
925 if (hgpk_force_recalibrate(psmouse)) 926 if (hgpk_force_recalibrate(psmouse))
926 hgpk_err(psmouse, "recalibration failed!\n"); 927 psmouse_err(psmouse, "recalibration failed!\n");
927} 928}
928 929
929static int hgpk_register(struct psmouse *psmouse) 930static int hgpk_register(struct psmouse *psmouse)
@@ -947,14 +948,15 @@ static int hgpk_register(struct psmouse *psmouse)
947 err = device_create_file(&psmouse->ps2dev.serio->dev, 948 err = device_create_file(&psmouse->ps2dev.serio->dev,
948 &psmouse_attr_powered.dattr); 949 &psmouse_attr_powered.dattr);
949 if (err) { 950 if (err) {
950 hgpk_err(psmouse, "Failed creating 'powered' sysfs node\n"); 951 psmouse_err(psmouse, "Failed creating 'powered' sysfs node\n");
951 return err; 952 return err;
952 } 953 }
953 954
954 err = device_create_file(&psmouse->ps2dev.serio->dev, 955 err = device_create_file(&psmouse->ps2dev.serio->dev,
955 &psmouse_attr_hgpk_mode.dattr); 956 &psmouse_attr_hgpk_mode.dattr);
956 if (err) { 957 if (err) {
957 hgpk_err(psmouse, "Failed creating 'hgpk_mode' sysfs node\n"); 958 psmouse_err(psmouse,
959 "Failed creating 'hgpk_mode' sysfs node\n");
958 goto err_remove_powered; 960 goto err_remove_powered;
959 } 961 }
960 962
@@ -963,8 +965,8 @@ static int hgpk_register(struct psmouse *psmouse)
963 err = device_create_file(&psmouse->ps2dev.serio->dev, 965 err = device_create_file(&psmouse->ps2dev.serio->dev,
964 &psmouse_attr_recalibrate.dattr); 966 &psmouse_attr_recalibrate.dattr);
965 if (err) { 967 if (err) {
966 hgpk_err(psmouse, 968 psmouse_err(psmouse,
967 "Failed creating 'recalibrate' sysfs node\n"); 969 "Failed creating 'recalibrate' sysfs node\n");
968 goto err_remove_mode; 970 goto err_remove_mode;
969 } 971 }
970 } 972 }
@@ -1027,13 +1029,13 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)
1027 return -EIO; 1029 return -EIO;
1028 } 1030 }
1029 1031
1030 hgpk_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]); 1032 psmouse_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]);
1031 1033
1032 /* HGPK signature: 0x67, 0x00, 0x<model> */ 1034 /* HGPK signature: 0x67, 0x00, 0x<model> */
1033 if (param[0] != 0x67 || param[1] != 0x00) 1035 if (param[0] != 0x67 || param[1] != 0x00)
1034 return -ENODEV; 1036 return -ENODEV;
1035 1037
1036 hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]); 1038 psmouse_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]);
1037 1039
1038 return param[2]; 1040 return param[2];
1039} 1041}