Lines Matching refs:psmouse

124 static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)  in hgpk_discard_decay_hack()  argument
126 struct hgpk_data *priv = psmouse->private; in hgpk_discard_decay_hack()
136 psmouse_warn(psmouse, "detected %dpx jump in x\n", x); in hgpk_discard_decay_hack()
139 psmouse_warn(psmouse, "detected secondary %dpx jump in x\n", x); in hgpk_discard_decay_hack()
151 psmouse_warn(psmouse, "detected %dpx jump in y\n", y); in hgpk_discard_decay_hack()
154 psmouse_warn(psmouse, "detected secondary %dpx jump in y\n", y); in hgpk_discard_decay_hack()
168 psmouse_warn(psmouse, "scheduling recalibration\n"); in hgpk_discard_decay_hack()
169 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_discard_decay_hack()
185 static void hgpk_reset_hack_state(struct psmouse *psmouse) in hgpk_reset_hack_state() argument
187 struct hgpk_data *priv = psmouse->private; in hgpk_reset_hack_state()
211 static void hgpk_spewing_hack(struct psmouse *psmouse, in hgpk_spewing_hack() argument
214 struct hgpk_data *priv = psmouse->private; in hgpk_spewing_hack()
260 psmouse_warn(psmouse, "packet spew detected (%d,%d)\n", in hgpk_spewing_hack()
263 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_spewing_hack()
306 static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) in hgpk_is_byte_valid() argument
308 struct hgpk_data *priv = psmouse->private; in hgpk_is_byte_valid()
309 int pktcnt = psmouse->pktcnt; in hgpk_is_byte_valid()
333 psmouse_dbg(psmouse, in hgpk_is_byte_valid()
335 priv->mode, pktcnt, 6, psmouse->packet); in hgpk_is_byte_valid()
340 static void hgpk_process_advanced_packet(struct psmouse *psmouse) in hgpk_process_advanced_packet() argument
342 struct hgpk_data *priv = psmouse->private; in hgpk_process_advanced_packet()
343 struct input_dev *idev = psmouse->dev; in hgpk_process_advanced_packet()
344 unsigned char *packet = psmouse->packet; in hgpk_process_advanced_packet()
358 psmouse_dbg(psmouse, "pd=%d fd=%d z=%d", in hgpk_process_advanced_packet()
366 psmouse_dbg(psmouse, "pd=%d ", down); in hgpk_process_advanced_packet()
370 psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", in hgpk_process_advanced_packet()
382 hgpk_reset_hack_state(psmouse); in hgpk_process_advanced_packet()
393 psmouse_dbg(psmouse, "hard spew detected\n"); in hgpk_process_advanced_packet()
395 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_process_advanced_packet()
408 if (hgpk_discard_decay_hack(psmouse, x_diff, y_diff)) { in hgpk_process_advanced_packet()
410 psmouse_dbg(psmouse, "discarding\n"); in hgpk_process_advanced_packet()
413 hgpk_spewing_hack(psmouse, left, right, x_diff, y_diff); in hgpk_process_advanced_packet()
425 static void hgpk_process_simple_packet(struct psmouse *psmouse) in hgpk_process_simple_packet() argument
427 struct input_dev *dev = psmouse->dev; in hgpk_process_simple_packet()
428 unsigned char *packet = psmouse->packet; in hgpk_process_simple_packet()
435 psmouse_dbg(psmouse, in hgpk_process_simple_packet()
439 if (hgpk_discard_decay_hack(psmouse, x, y)) { in hgpk_process_simple_packet()
441 psmouse_dbg(psmouse, "discarding\n"); in hgpk_process_simple_packet()
445 hgpk_spewing_hack(psmouse, left, right, x, y); in hgpk_process_simple_packet()
448 psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", in hgpk_process_simple_packet()
460 static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse) in hgpk_process_byte() argument
462 struct hgpk_data *priv = psmouse->private; in hgpk_process_byte()
464 if (!hgpk_is_byte_valid(psmouse, psmouse->packet)) in hgpk_process_byte()
467 if (psmouse->pktcnt >= psmouse->pktsize) { in hgpk_process_byte()
469 hgpk_process_simple_packet(psmouse); in hgpk_process_byte()
471 hgpk_process_advanced_packet(psmouse); in hgpk_process_byte()
481 psmouse_dbg(psmouse, in hgpk_process_byte()
483 psmouse_queue_work(psmouse, &priv->recalib_wq, in hgpk_process_byte()
492 static int hgpk_select_mode(struct psmouse *psmouse) in hgpk_select_mode() argument
494 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_select_mode()
495 struct hgpk_data *priv = psmouse->private; in hgpk_select_mode()
511 psmouse->pktsize = 3; in hgpk_select_mode()
516 psmouse->pktsize = 6; in hgpk_select_mode()
603 static int hgpk_reset_device(struct psmouse *psmouse, bool recalibrate) in hgpk_reset_device() argument
607 psmouse_reset(psmouse); in hgpk_reset_device()
610 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_reset_device()
624 err = hgpk_select_mode(psmouse); in hgpk_reset_device()
626 psmouse_err(psmouse, "failed to select mode\n"); in hgpk_reset_device()
630 hgpk_reset_hack_state(psmouse); in hgpk_reset_device()
635 static int hgpk_force_recalibrate(struct psmouse *psmouse) in hgpk_force_recalibrate() argument
637 struct hgpk_data *priv = psmouse->private; in hgpk_force_recalibrate()
641 if (psmouse->model < HGPK_MODEL_C) in hgpk_force_recalibrate()
645 psmouse_dbg(psmouse, "recalibration disabled, ignoring\n"); in hgpk_force_recalibrate()
649 psmouse_dbg(psmouse, "recalibrating touchpad..\n"); in hgpk_force_recalibrate()
652 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); in hgpk_force_recalibrate()
655 err = hgpk_reset_device(psmouse, true); in hgpk_force_recalibrate()
665 if (psmouse_activate(psmouse)) in hgpk_force_recalibrate()
669 psmouse_dbg(psmouse, "touchpad reactivated\n"); in hgpk_force_recalibrate()
692 static int hgpk_toggle_powersave(struct psmouse *psmouse, int enable) in hgpk_toggle_powersave() argument
694 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_toggle_powersave()
699 if (psmouse->model < HGPK_MODEL_D) in hgpk_toggle_powersave()
703 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); in hgpk_toggle_powersave()
718 err = hgpk_reset_device(psmouse, false); in hgpk_toggle_powersave()
720 psmouse_err(psmouse, "Failed to reset device!\n"); in hgpk_toggle_powersave()
725 psmouse_activate(psmouse); in hgpk_toggle_powersave()
726 psmouse_dbg(psmouse, "Touchpad powered up.\n"); in hgpk_toggle_powersave()
728 psmouse_dbg(psmouse, "Powering off touchpad.\n"); in hgpk_toggle_powersave()
736 psmouse_set_state(psmouse, PSMOUSE_IGNORE); in hgpk_toggle_powersave()
745 static int hgpk_poll(struct psmouse *psmouse) in hgpk_poll() argument
751 static int hgpk_reconnect(struct psmouse *psmouse) in hgpk_reconnect() argument
753 struct hgpk_data *priv = psmouse->private; in hgpk_reconnect()
761 if (psmouse->ps2dev.serio->dev.power.power_state.event != in hgpk_reconnect()
766 return hgpk_reset_device(psmouse, false); in hgpk_reconnect()
769 static ssize_t hgpk_show_powered(struct psmouse *psmouse, void *data, char *buf) in hgpk_show_powered() argument
771 struct hgpk_data *priv = psmouse->private; in hgpk_show_powered()
776 static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, in hgpk_set_powered() argument
779 struct hgpk_data *priv = psmouse->private; in hgpk_set_powered()
795 err = hgpk_toggle_powersave(psmouse, value); in hgpk_set_powered()
806 static ssize_t attr_show_mode(struct psmouse *psmouse, void *data, char *buf) in attr_show_mode() argument
808 struct hgpk_data *priv = psmouse->private; in attr_show_mode()
813 static ssize_t attr_set_mode(struct psmouse *psmouse, void *data, in attr_set_mode() argument
816 struct hgpk_data *priv = psmouse->private; in attr_set_mode()
819 struct input_dev *old_dev = psmouse->dev; in attr_set_mode()
833 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); in attr_set_mode()
837 err = hgpk_reset_device(psmouse, false); in attr_set_mode()
843 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); in attr_set_mode()
849 psmouse->dev = new_dev; in attr_set_mode()
857 hgpk_reset_device(psmouse, false); in attr_set_mode()
865 static ssize_t hgpk_trigger_recal_show(struct psmouse *psmouse, in hgpk_trigger_recal_show() argument
871 static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data, in hgpk_trigger_recal() argument
874 struct hgpk_data *priv = psmouse->private; in hgpk_trigger_recal()
890 psmouse_queue_work(psmouse, &priv->recalib_wq, 0); in hgpk_trigger_recal()
897 static void hgpk_disconnect(struct psmouse *psmouse) in hgpk_disconnect() argument
899 struct hgpk_data *priv = psmouse->private; in hgpk_disconnect()
901 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
903 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
906 if (psmouse->model >= HGPK_MODEL_C) in hgpk_disconnect()
907 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_disconnect()
910 psmouse_reset(psmouse); in hgpk_disconnect()
918 struct psmouse *psmouse = priv->psmouse; in hgpk_recalib_work() local
920 if (hgpk_force_recalibrate(psmouse)) in hgpk_recalib_work()
921 psmouse_err(psmouse, "recalibration failed!\n"); in hgpk_recalib_work()
924 static int hgpk_register(struct psmouse *psmouse) in hgpk_register() argument
926 struct hgpk_data *priv = psmouse->private; in hgpk_register()
930 psmouse->protocol_handler = hgpk_process_byte; in hgpk_register()
931 psmouse->poll = hgpk_poll; in hgpk_register()
932 psmouse->disconnect = hgpk_disconnect; in hgpk_register()
933 psmouse->reconnect = hgpk_reconnect; in hgpk_register()
936 psmouse->resync_time = 0; in hgpk_register()
938 psmouse->resetafter = 1024; in hgpk_register()
940 hgpk_setup_input_device(psmouse->dev, NULL, priv->mode); in hgpk_register()
942 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
945 psmouse_err(psmouse, "Failed creating 'powered' sysfs node\n"); in hgpk_register()
949 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
952 psmouse_err(psmouse, in hgpk_register()
958 if (psmouse->model >= HGPK_MODEL_C) { in hgpk_register()
959 err = device_create_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
962 psmouse_err(psmouse, in hgpk_register()
971 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
974 device_remove_file(&psmouse->ps2dev.serio->dev, in hgpk_register()
979 int hgpk_init(struct psmouse *psmouse) in hgpk_init() argument
990 psmouse->private = priv; in hgpk_init()
992 priv->psmouse = psmouse; in hgpk_init()
997 err = hgpk_reset_device(psmouse, false); in hgpk_init()
1001 err = hgpk_register(psmouse); in hgpk_init()
1013 static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse) in hgpk_get_model() argument
1015 struct ps2dev *ps2dev = &psmouse->ps2dev; in hgpk_get_model()
1026 psmouse_dbg(psmouse, "ID: %*ph\n", 3, param); in hgpk_get_model()
1032 psmouse_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]); in hgpk_get_model()
1037 int hgpk_detect(struct psmouse *psmouse, bool set_properties) in hgpk_detect() argument
1041 version = hgpk_get_model(psmouse); in hgpk_detect()
1046 psmouse->vendor = "ALPS"; in hgpk_detect()
1047 psmouse->name = "HGPK"; in hgpk_detect()
1048 psmouse->model = version; in hgpk_detect()