Lines Matching refs:psmouse

29 static void cypress_set_packet_size(struct psmouse *psmouse, unsigned int n)  in cypress_set_packet_size()  argument
31 struct cytp_data *cytp = psmouse->private; in cypress_set_packet_size()
38 static int cypress_ps2_sendbyte(struct psmouse *psmouse, int value) in cypress_ps2_sendbyte() argument
40 struct ps2dev *ps2dev = &psmouse->ps2dev; in cypress_ps2_sendbyte()
43 psmouse_dbg(psmouse, in cypress_ps2_sendbyte()
53 psmouse_dbg(psmouse, "sending command 0x%02x succeeded, resp 0xfa\n", in cypress_ps2_sendbyte()
60 static int cypress_ps2_ext_cmd(struct psmouse *psmouse, unsigned short cmd, in cypress_ps2_ext_cmd() argument
63 struct ps2dev *ps2dev = &psmouse->ps2dev; in cypress_ps2_ext_cmd()
75 rc = cypress_ps2_sendbyte(psmouse, cmd & 0xff); in cypress_ps2_ext_cmd()
77 rc = cypress_ps2_sendbyte(psmouse, 0x00); in cypress_ps2_ext_cmd()
79 rc = cypress_ps2_sendbyte(psmouse, 0x0a); in cypress_ps2_ext_cmd()
84 rc = cypress_ps2_sendbyte(psmouse, data); in cypress_ps2_ext_cmd()
86 rc = cypress_ps2_sendbyte(psmouse, data); in cypress_ps2_ext_cmd()
98 static int cypress_ps2_read_cmd_status(struct psmouse *psmouse, in cypress_ps2_read_cmd_status() argument
103 struct ps2dev *ps2dev = &psmouse->ps2dev; in cypress_ps2_read_cmd_status()
109 old_state = psmouse->state; in cypress_ps2_read_cmd_status()
110 psmouse->state = PSMOUSE_CMD_MODE; in cypress_ps2_read_cmd_status()
111 psmouse->pktcnt = 0; in cypress_ps2_read_cmd_status()
116 rc = cypress_ps2_sendbyte(psmouse, 0xe9); in cypress_ps2_read_cmd_status()
121 (psmouse->pktcnt >= pktsize), in cypress_ps2_read_cmd_status()
124 memcpy(param, psmouse->packet, pktsize); in cypress_ps2_read_cmd_status()
126 psmouse_dbg(psmouse, "Command 0x%02x response data (0x): %*ph\n", in cypress_ps2_read_cmd_status()
130 psmouse->state = old_state; in cypress_ps2_read_cmd_status()
131 psmouse->pktcnt = 0; in cypress_ps2_read_cmd_status()
138 static bool cypress_verify_cmd_state(struct psmouse *psmouse, in cypress_verify_cmd_state() argument
165 psmouse_dbg(psmouse, "verify cmd state failed.\n"); in cypress_verify_cmd_state()
169 static int cypress_send_ext_cmd(struct psmouse *psmouse, unsigned char cmd, in cypress_send_ext_cmd() argument
175 psmouse_dbg(psmouse, "send extension cmd 0x%02x, [%d %d %d %d]\n", in cypress_send_ext_cmd()
180 cypress_ps2_ext_cmd(psmouse, in cypress_send_ext_cmd()
182 cypress_ps2_ext_cmd(psmouse, in cypress_send_ext_cmd()
184 cypress_ps2_ext_cmd(psmouse, in cypress_send_ext_cmd()
186 cypress_ps2_ext_cmd(psmouse, in cypress_send_ext_cmd()
189 rc = cypress_ps2_read_cmd_status(psmouse, cmd, param); in cypress_send_ext_cmd()
193 if (cypress_verify_cmd_state(psmouse, cmd, param)) in cypress_send_ext_cmd()
201 int cypress_detect(struct psmouse *psmouse, bool set_properties) in cypress_detect() argument
205 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) in cypress_detect()
213 psmouse->vendor = "Cypress"; in cypress_detect()
214 psmouse->name = "Trackpad"; in cypress_detect()
220 static int cypress_read_fw_version(struct psmouse *psmouse) in cypress_read_fw_version() argument
222 struct cytp_data *cytp = psmouse->private; in cypress_read_fw_version()
225 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) in cypress_read_fw_version()
242 psmouse_dbg(psmouse, "cytp->fw_version = %d\n", cytp->fw_version); in cypress_read_fw_version()
243 psmouse_dbg(psmouse, "cytp->tp_metrics_supported = %d\n", in cypress_read_fw_version()
249 static int cypress_read_tp_metrics(struct psmouse *psmouse) in cypress_read_tp_metrics() argument
251 struct cytp_data *cytp = psmouse->private; in cypress_read_tp_metrics()
268 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_TP_METRICS, param) == 0) { in cypress_read_tp_metrics()
289 psmouse_dbg(psmouse, "Dump trackpad hardware configuration as below:\n"); in cypress_read_tp_metrics()
290 psmouse_dbg(psmouse, "cytp->tp_width = %d\n", cytp->tp_width); in cypress_read_tp_metrics()
291 psmouse_dbg(psmouse, "cytp->tp_high = %d\n", cytp->tp_high); in cypress_read_tp_metrics()
292 psmouse_dbg(psmouse, "cytp->tp_max_abs_x = %d\n", cytp->tp_max_abs_x); in cypress_read_tp_metrics()
293 psmouse_dbg(psmouse, "cytp->tp_max_abs_y = %d\n", cytp->tp_max_abs_y); in cypress_read_tp_metrics()
294 psmouse_dbg(psmouse, "cytp->tp_min_pressure = %d\n", cytp->tp_min_pressure); in cypress_read_tp_metrics()
295 psmouse_dbg(psmouse, "cytp->tp_max_pressure = %d\n", cytp->tp_max_pressure); in cypress_read_tp_metrics()
296 psmouse_dbg(psmouse, "cytp->tp_res_x = %d\n", cytp->tp_res_x); in cypress_read_tp_metrics()
297 psmouse_dbg(psmouse, "cytp->tp_res_y = %d\n", cytp->tp_res_y); in cypress_read_tp_metrics()
299 psmouse_dbg(psmouse, "tp_type_APA = %d\n", in cypress_read_tp_metrics()
301 psmouse_dbg(psmouse, "tp_type_MTG = %d\n", in cypress_read_tp_metrics()
303 psmouse_dbg(psmouse, "tp_palm = %d\n", in cypress_read_tp_metrics()
305 psmouse_dbg(psmouse, "tp_stubborn = %d\n", in cypress_read_tp_metrics()
307 psmouse_dbg(psmouse, "tp_1f_jitter = %d\n", in cypress_read_tp_metrics()
309 psmouse_dbg(psmouse, "tp_2f_jitter = %d\n", in cypress_read_tp_metrics()
311 psmouse_dbg(psmouse, "tp_1f_spike = %d\n", in cypress_read_tp_metrics()
313 psmouse_dbg(psmouse, "tp_2f_spike = %d\n", in cypress_read_tp_metrics()
315 psmouse_dbg(psmouse, "tp_abs_packet_format_set = %d\n", in cypress_read_tp_metrics()
322 static int cypress_query_hardware(struct psmouse *psmouse) in cypress_query_hardware() argument
326 ret = cypress_read_fw_version(psmouse); in cypress_query_hardware()
330 ret = cypress_read_tp_metrics(psmouse); in cypress_query_hardware()
337 static int cypress_set_absolute_mode(struct psmouse *psmouse) in cypress_set_absolute_mode() argument
339 struct cytp_data *cytp = psmouse->private; in cypress_set_absolute_mode()
342 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, param) < 0) in cypress_set_absolute_mode()
347 cypress_set_packet_size(psmouse, 5); in cypress_set_absolute_mode()
356 static void cypress_reset(struct psmouse *psmouse) in cypress_reset() argument
358 struct cytp_data *cytp = psmouse->private; in cypress_reset()
362 psmouse_reset(psmouse); in cypress_reset()
443 static int cypress_parse_packet(struct psmouse *psmouse, in cypress_parse_packet() argument
446 unsigned char *packet = psmouse->packet; in cypress_parse_packet()
494 psmouse_dbg(psmouse, "Dump parsed report data as below:\n"); in cypress_parse_packet()
495 psmouse_dbg(psmouse, "contact_cnt = %d\n", in cypress_parse_packet()
500 psmouse_dbg(psmouse, "contacts[%d] = {%d, %d, %d}\n", i, in cypress_parse_packet()
504 psmouse_dbg(psmouse, "left = %d\n", report_data->left); in cypress_parse_packet()
505 psmouse_dbg(psmouse, "right = %d\n", report_data->right); in cypress_parse_packet()
506 psmouse_dbg(psmouse, "middle = %d\n", report_data->middle); in cypress_parse_packet()
513 static void cypress_process_packet(struct psmouse *psmouse, bool zero_pkt) in cypress_process_packet() argument
516 struct input_dev *input = psmouse->dev; in cypress_process_packet()
517 struct cytp_data *cytp = psmouse->private; in cypress_process_packet()
524 cypress_parse_packet(psmouse, cytp, &report_data); in cypress_process_packet()
558 static psmouse_ret_t cypress_validate_byte(struct psmouse *psmouse) in cypress_validate_byte() argument
561 int index = psmouse->pktcnt - 1; in cypress_validate_byte()
562 unsigned char *packet = psmouse->packet; in cypress_validate_byte()
563 struct cytp_data *cytp = psmouse->private; in cypress_validate_byte()
570 cypress_process_packet(psmouse, 1); in cypress_validate_byte()
593 cypress_set_packet_size(psmouse, contact_cnt == 2 ? 7 : 4); in cypress_validate_byte()
595 cypress_set_packet_size(psmouse, contact_cnt == 2 ? 8 : 5); in cypress_validate_byte()
600 static psmouse_ret_t cypress_protocol_handler(struct psmouse *psmouse) in cypress_protocol_handler() argument
602 struct cytp_data *cytp = psmouse->private; in cypress_protocol_handler()
604 if (psmouse->pktcnt >= cytp->pkt_size) { in cypress_protocol_handler()
605 cypress_process_packet(psmouse, 0); in cypress_protocol_handler()
609 return cypress_validate_byte(psmouse); in cypress_protocol_handler()
612 static void cypress_set_rate(struct psmouse *psmouse, unsigned int rate) in cypress_set_rate() argument
614 struct cytp_data *cytp = psmouse->private; in cypress_set_rate()
617 psmouse->rate = 80; in cypress_set_rate()
620 psmouse->rate = 40; in cypress_set_rate()
624 ps2_command(&psmouse->ps2dev, (unsigned char *)&psmouse->rate, in cypress_set_rate()
628 static void cypress_disconnect(struct psmouse *psmouse) in cypress_disconnect() argument
630 cypress_reset(psmouse); in cypress_disconnect()
631 kfree(psmouse->private); in cypress_disconnect()
632 psmouse->private = NULL; in cypress_disconnect()
635 static int cypress_reconnect(struct psmouse *psmouse) in cypress_reconnect() argument
641 cypress_reset(psmouse); in cypress_reconnect()
642 rc = cypress_detect(psmouse, false); in cypress_reconnect()
646 psmouse_err(psmouse, "Reconnect: unable to detect trackpad.\n"); in cypress_reconnect()
650 if (cypress_set_absolute_mode(psmouse)) { in cypress_reconnect()
651 psmouse_err(psmouse, "Reconnect: Unable to initialize Cypress absolute mode.\n"); in cypress_reconnect()
658 int cypress_init(struct psmouse *psmouse) in cypress_init() argument
666 psmouse->private = cytp; in cypress_init()
667 psmouse->pktsize = 8; in cypress_init()
669 cypress_reset(psmouse); in cypress_init()
671 if (cypress_query_hardware(psmouse)) { in cypress_init()
672 psmouse_err(psmouse, "Unable to query Trackpad hardware.\n"); in cypress_init()
676 if (cypress_set_absolute_mode(psmouse)) { in cypress_init()
677 psmouse_err(psmouse, "init: Unable to initialize Cypress absolute mode.\n"); in cypress_init()
681 if (cypress_set_input_params(psmouse->dev, cytp) < 0) { in cypress_init()
682 psmouse_err(psmouse, "init: Unable to set input params.\n"); in cypress_init()
686 psmouse->model = 1; in cypress_init()
687 psmouse->protocol_handler = cypress_protocol_handler; in cypress_init()
688 psmouse->set_rate = cypress_set_rate; in cypress_init()
689 psmouse->disconnect = cypress_disconnect; in cypress_init()
690 psmouse->reconnect = cypress_reconnect; in cypress_init()
691 psmouse->cleanup = cypress_reset; in cypress_init()
692 psmouse->resync_time = 0; in cypress_init()
701 cypress_reset(psmouse); in cypress_init()
703 psmouse->private = NULL; in cypress_init()