• Home
  • Raw
  • Download

Lines Matching +full:long +full:- +full:press +full:- +full:ms

2  * OLPC HGPK (XO-1) touchpad PS/2 mouse driver
4 * Copyright (c) 2006-2008 One Laptop Per Child
12 * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
59 "delay (ms) before recal after jumpiness detected");
64 "delay (ms) before recal after packet spew detected");
69 "interval (ms) during which recal will be restarted if packet received");
74 "delay (ms) before recal after recal interrupt detected");
129 struct hgpk_data *priv = psmouse->private; in hgpk_discard_decay_hack()
138 (avx > recalib_delta / 2 && ((avx / 4) > priv->xlast))) { in hgpk_discard_decay_hack()
140 priv->xbigj = avx; in hgpk_discard_decay_hack()
141 } else if (approx_half(avx, priv->xbigj)) { in hgpk_discard_decay_hack()
143 priv->xbigj = avx; in hgpk_discard_decay_hack()
144 priv->xsaw_secondary++; in hgpk_discard_decay_hack()
146 if (priv->xbigj && priv->xsaw_secondary > 1) in hgpk_discard_decay_hack()
148 priv->xbigj = 0; in hgpk_discard_decay_hack()
149 priv->xsaw_secondary = 0; in hgpk_discard_decay_hack()
153 (avy > recalib_delta / 2 && ((avy / 4) > priv->ylast))) { in hgpk_discard_decay_hack()
155 priv->ybigj = avy; in hgpk_discard_decay_hack()
156 } else if (approx_half(avy, priv->ybigj)) { in hgpk_discard_decay_hack()
158 priv->ybigj = avy; in hgpk_discard_decay_hack()
159 priv->ysaw_secondary++; in hgpk_discard_decay_hack()
161 if (priv->ybigj && priv->ysaw_secondary > 1) in hgpk_discard_decay_hack()
163 priv->ybigj = 0; in hgpk_discard_decay_hack()
164 priv->ysaw_secondary = 0; in hgpk_discard_decay_hack()
167 priv->xlast = avx; in hgpk_discard_decay_hack()
168 priv->ylast = avy; in hgpk_discard_decay_hack()
172 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_discard_decay_hack()
176 return priv->xbigj || priv->ybigj; in hgpk_discard_decay_hack()
181 priv->spew_count = 0; in hgpk_reset_spew_detection()
182 priv->dupe_count = 0; in hgpk_reset_spew_detection()
183 priv->x_tally = 0; in hgpk_reset_spew_detection()
184 priv->y_tally = 0; in hgpk_reset_spew_detection()
185 priv->spew_flag = NO_SPEW; in hgpk_reset_spew_detection()
190 struct hgpk_data *priv = psmouse->private; in hgpk_reset_hack_state()
192 priv->abs_x = priv->abs_y = -1; in hgpk_reset_hack_state()
193 priv->xlast = priv->ylast = ILLEGAL_XY; in hgpk_reset_hack_state()
194 priv->xbigj = priv->ybigj = 0; in hgpk_reset_hack_state()
195 priv->xsaw_secondary = priv->ysaw_secondary = 0; in hgpk_reset_hack_state()
206 * The packets that are spewed tend to all have deltas between -2 and 2, and
217 struct hgpk_data *priv = psmouse->private; in hgpk_spewing_hack()
219 /* ignore button press packets; many in a row could trigger in hgpk_spewing_hack()
220 * a false-positive! */ in hgpk_spewing_hack()
236 priv->x_tally += x; in hgpk_spewing_hack()
237 priv->y_tally += y; in hgpk_spewing_hack()
239 switch (priv->spew_flag) { in hgpk_spewing_hack()
242 priv->spew_flag = MAYBE_SPEWING; in hgpk_spewing_hack()
244 /* fall-through */ in hgpk_spewing_hack()
247 priv->spew_count++; in hgpk_spewing_hack()
249 if (priv->spew_count < SPEW_WATCH_COUNT) in hgpk_spewing_hack()
253 priv->spew_flag = SPEW_DETECTED; in hgpk_spewing_hack()
255 /* fall-through */ in hgpk_spewing_hack()
262 if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) { in hgpk_spewing_hack()
264 priv->x_tally, priv->y_tally); in hgpk_spewing_hack()
265 priv->spew_flag = RECALIBRATING; in hgpk_spewing_hack()
266 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_spewing_hack()
281 * byte 0: y-over x-over y-neg x-neg 1 0 swr swl
286 * x-neg/y-neg are the x and y delta negative bits
287 * x-over/y-over are the x and y overflow bits
289 * ---
291 * HGPK Advanced Mode - single-mode format
296 * byte 2(PT): 0 0 x9 x8 x7 ? pt-dsw 0
297 * byte 2(GS): 0 x10 x9 x8 x7 ? gs-dsw pt-dsw
306 * pt-dsw/gs-dsw indicate that the pt/gs sensor is detecting a
311 struct hgpk_data *priv = psmouse->private; in hgpk_is_byte_valid()
312 int pktcnt = psmouse->pktcnt; in hgpk_is_byte_valid()
315 switch (priv->mode) { in hgpk_is_byte_valid()
322 packet[0] == HGPK_GS : !(packet[pktcnt - 1] & 0x80); in hgpk_is_byte_valid()
327 packet[0] == HGPK_PT : !(packet[pktcnt - 1] & 0x80); in hgpk_is_byte_valid()
338 priv->mode, pktcnt, 6, psmouse->packet); in hgpk_is_byte_valid()
345 struct hgpk_data *priv = psmouse->private; in hgpk_process_advanced_packet()
346 struct input_dev *idev = psmouse->dev; in hgpk_process_advanced_packet()
347 unsigned char *packet = psmouse->packet; in hgpk_process_advanced_packet()
354 if (priv->mode == HGPK_MODE_GLIDESENSOR) { in hgpk_process_advanced_packet()
382 * tracking so that we don't erroneously detect a jump on next press. in hgpk_process_advanced_packet()
393 if (x == priv->abs_x && y == priv->abs_y) { in hgpk_process_advanced_packet()
394 if (++priv->dupe_count > SPEW_WATCH_COUNT) { in hgpk_process_advanced_packet()
397 priv->spew_flag = RECALIBRATING; in hgpk_process_advanced_packet()
398 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_process_advanced_packet()
405 priv->dupe_count = 0; in hgpk_process_advanced_packet()
408 if (priv->mode != HGPK_MODE_PENTABLET && priv->abs_x != -1) { in hgpk_process_advanced_packet()
409 int x_diff = priv->abs_x - x; in hgpk_process_advanced_packet()
410 int y_diff = priv->abs_y - y; in hgpk_process_advanced_packet()
421 priv->abs_x = x; in hgpk_process_advanced_packet()
422 priv->abs_y = y; in hgpk_process_advanced_packet()
430 struct input_dev *dev = psmouse->dev; in hgpk_process_simple_packet()
431 unsigned char *packet = psmouse->packet; in hgpk_process_simple_packet()
434 int x = packet[1] - ((packet[0] << 4) & 0x100); in hgpk_process_simple_packet()
435 int y = ((packet[0] << 3) & 0x100) - packet[2]; in hgpk_process_simple_packet()
439 "overflow -- 0x%02x 0x%02x 0x%02x\n", in hgpk_process_simple_packet()
465 struct hgpk_data *priv = psmouse->private; in hgpk_process_byte()
467 if (!hgpk_is_byte_valid(psmouse, psmouse->packet)) in hgpk_process_byte()
470 if (psmouse->pktcnt >= psmouse->pktsize) { in hgpk_process_byte()
471 if (priv->mode == HGPK_MODE_MOUSE) in hgpk_process_byte()
478 if (priv->recalib_window) { in hgpk_process_byte()
479 if (time_before(jiffies, priv->recalib_window)) { in hgpk_process_byte()
486 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_process_byte()
489 priv->recalib_window = 0; in hgpk_process_byte()
497 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_select_mode()
498 struct hgpk_data *priv = psmouse->private; in hgpk_select_mode()
512 switch (priv->mode) { in hgpk_select_mode()
514 psmouse->pktsize = 3; in hgpk_select_mode()
519 psmouse->pktsize = 6; in hgpk_select_mode()
524 return -EIO; in hgpk_select_mode()
527 cmd = priv->mode == HGPK_MODE_GLIDESENSOR ? in hgpk_select_mode()
531 return -EIO; in hgpk_select_mode()
535 return -EINVAL; in hgpk_select_mode()
546 input->name = old_input->name; in hgpk_setup_input_device()
547 input->phys = old_input->phys; in hgpk_setup_input_device()
548 input->id = old_input->id; in hgpk_setup_input_device()
549 input->dev.parent = old_input->dev.parent; in hgpk_setup_input_device()
552 memset(input->evbit, 0, sizeof(input->evbit)); in hgpk_setup_input_device()
553 memset(input->relbit, 0, sizeof(input->relbit)); in hgpk_setup_input_device()
554 memset(input->keybit, 0, sizeof(input->keybit)); in hgpk_setup_input_device()
557 __set_bit(EV_KEY, input->evbit); in hgpk_setup_input_device()
558 __set_bit(BTN_LEFT, input->keybit); in hgpk_setup_input_device()
559 __set_bit(BTN_RIGHT, input->keybit); in hgpk_setup_input_device()
563 __set_bit(EV_REL, input->evbit); in hgpk_setup_input_device()
564 __set_bit(REL_X, input->relbit); in hgpk_setup_input_device()
565 __set_bit(REL_Y, input->relbit); in hgpk_setup_input_device()
569 __set_bit(BTN_TOUCH, input->keybit); in hgpk_setup_input_device()
570 __set_bit(BTN_TOOL_FINGER, input->keybit); in hgpk_setup_input_device()
572 __set_bit(EV_ABS, input->evbit); in hgpk_setup_input_device()
587 __set_bit(BTN_TOUCH, input->keybit); in hgpk_setup_input_device()
588 __set_bit(BTN_TOOL_FINGER, input->keybit); in hgpk_setup_input_device()
590 __set_bit(EV_ABS, input->evbit); in hgpk_setup_input_device()
613 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_reset_device()
620 return -1; in hgpk_reset_device()
623 /* according to ALPS, 150mS is required for recalibration */ in hgpk_reset_device()
640 struct hgpk_data *priv = psmouse->private; in hgpk_force_recalibrate()
643 /* C-series touchpads added the recalibrate command */ in hgpk_force_recalibrate()
644 if (psmouse->model < HGPK_MODEL_C) in hgpk_force_recalibrate()
669 return -1; in hgpk_force_recalibrate()
680 priv->recalib_window = jiffies + in hgpk_force_recalibrate()
689 * we drive MS-DAT low. Measuring with a 1mA resolution ammeter says that
692 * We have no formal spec that details this operation -- the low-power
693 * sequence came from a long-lost email trail.
697 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_toggle_powersave()
701 /* Added on D-series touchpads */ in hgpk_toggle_powersave()
702 if (psmouse->model < HGPK_MODEL_D) in hgpk_toggle_powersave()
709 * Sending a byte will drive MS-DAT low; this will wake up in hgpk_toggle_powersave()
711 * means we can continue with the touchpad re-init. ALPS in hgpk_toggle_powersave()
712 * tells us that 1s should be long enough, so set that as in hgpk_toggle_powersave()
715 for (timeo = 20; timeo > 0; timeo--) { in hgpk_toggle_powersave()
736 return -1; in hgpk_toggle_powersave()
751 return -1; in hgpk_poll()
756 struct hgpk_data *priv = psmouse->private; in hgpk_reconnect()
764 if (psmouse->ps2dev.serio->dev.power.power_state.event != in hgpk_reconnect()
768 priv->powered = 1; in hgpk_reconnect()
774 struct hgpk_data *priv = psmouse->private; in hgpk_show_powered()
776 return sprintf(buf, "%d\n", priv->powered); in hgpk_show_powered()
782 struct hgpk_data *priv = psmouse->private; in hgpk_set_powered()
791 return -EINVAL; in hgpk_set_powered()
793 if (value != priv->powered) { in hgpk_set_powered()
800 priv->powered = value; in hgpk_set_powered()
811 struct hgpk_data *priv = psmouse->private; in attr_show_mode()
813 return sprintf(buf, "%s\n", hgpk_mode_names[priv->mode]); in attr_show_mode()
819 struct hgpk_data *priv = psmouse->private; in attr_set_mode()
820 enum hgpk_mode old_mode = priv->mode; in attr_set_mode()
822 struct input_dev *old_dev = psmouse->dev; in attr_set_mode()
827 return -EINVAL; in attr_set_mode()
834 return -ENOMEM; in attr_set_mode()
839 priv->mode = new_mode; in attr_set_mode()
852 psmouse->dev = new_dev; in attr_set_mode()
859 priv->mode = old_mode; in attr_set_mode()
871 return -EINVAL; in hgpk_trigger_recal_show()
877 struct hgpk_data *priv = psmouse->private; in hgpk_trigger_recal()
886 return -EINVAL; in hgpk_trigger_recal()
893 psmouse_queue_work(psmouse, &priv->recalib_wq, 0); in hgpk_trigger_recal()
902 struct hgpk_data *priv = psmouse->private; in hgpk_disconnect()
904 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
906 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
909 if (psmouse->model >= HGPK_MODEL_C) in hgpk_disconnect()
910 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
921 struct psmouse *psmouse = priv->psmouse; in hgpk_recalib_work()
929 struct hgpk_data *priv = psmouse->private; in hgpk_register()
933 psmouse->protocol_handler = hgpk_process_byte; in hgpk_register()
934 psmouse->poll = hgpk_poll; in hgpk_register()
935 psmouse->disconnect = hgpk_disconnect; in hgpk_register()
936 psmouse->reconnect = hgpk_reconnect; in hgpk_register()
939 psmouse->resync_time = 0; in hgpk_register()
941 psmouse->resetafter = 1024; in hgpk_register()
943 hgpk_setup_input_device(psmouse->dev, NULL, priv->mode); in hgpk_register()
945 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
952 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
960 /* C-series touchpads added the recalibrate command */ in hgpk_register()
961 if (psmouse->model >= HGPK_MODEL_C) { in hgpk_register()
962 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
974 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
977 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
989 err = -ENOMEM; in hgpk_init()
993 psmouse->private = priv; in hgpk_init()
995 priv->psmouse = psmouse; in hgpk_init()
996 priv->powered = true; in hgpk_init()
997 priv->mode = hgpk_default_mode; in hgpk_init()
998 INIT_DELAYED_WORK(&priv->recalib_wq, hgpk_recalib_work); in hgpk_init()
1018 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_get_model()
1026 return -EIO; in hgpk_get_model()
1033 return -ENODEV; in hgpk_get_model()
1049 psmouse->vendor = "ALPS"; in hgpk_detect()
1050 psmouse->name = "HGPK"; in hgpk_detect()
1051 psmouse->model = version; in hgpk_detect()