Lines Matching +full:touchscreen +full:- +full:x +full:- +full:mm

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
27 if (etd->info.debug) \
38 if (ps2_sliced_command(&psmouse->ps2dev, c) || in synaptics_send_cmd()
39 ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) { in synaptics_send_cmd()
40 psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c); in synaptics_send_cmd()
41 return -1; in synaptics_send_cmd()
53 struct ps2dev *ps2dev = &psmouse->ps2dev; in elantech_send_cmd()
58 psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c); in elantech_send_cmd()
59 return -1; in elantech_send_cmd()
71 struct ps2dev *ps2dev = &psmouse->ps2dev; in elantech_ps2_command()
72 struct elantech_data *etd = psmouse->private; in elantech_ps2_command()
80 tries--; in elantech_ps2_command()
81 elantech_debug("retrying ps2 command 0x%02x (%d).\n", in elantech_ps2_command()
87 psmouse_err(psmouse, "ps2 command 0x%02x failed.\n", command); in elantech_ps2_command()
103 "failed to read register %#02x\n", reg); in elantech_read_reg_params()
104 return -EIO; in elantech_read_reg_params()
125 "failed to write register %#02x with value %#02x%#02x\n", in elantech_write_reg_params()
127 return -EIO; in elantech_write_reg_params()
139 struct elantech_data *etd = psmouse->private; in elantech_read_reg()
144 return -1; in elantech_read_reg()
147 return -1; in elantech_read_reg()
149 switch (etd->info.hw_version) { in elantech_read_reg()
151 if (ps2_sliced_command(&psmouse->ps2dev, ETP_REGISTER_READ) || in elantech_read_reg()
152 ps2_sliced_command(&psmouse->ps2dev, reg) || in elantech_read_reg()
153 ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) { in elantech_read_reg()
154 rc = -1; in elantech_read_reg()
164 rc = -1; in elantech_read_reg()
174 rc = -1; in elantech_read_reg()
180 psmouse_err(psmouse, "failed to read register 0x%02x.\n", reg); in elantech_read_reg()
181 else if (etd->info.hw_version != 4) in elantech_read_reg()
195 struct elantech_data *etd = psmouse->private; in elantech_write_reg()
199 return -1; in elantech_write_reg()
202 return -1; in elantech_write_reg()
204 switch (etd->info.hw_version) { in elantech_write_reg()
206 if (ps2_sliced_command(&psmouse->ps2dev, ETP_REGISTER_WRITE) || in elantech_write_reg()
207 ps2_sliced_command(&psmouse->ps2dev, reg) || in elantech_write_reg()
208 ps2_sliced_command(&psmouse->ps2dev, val) || in elantech_write_reg()
209 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11)) { in elantech_write_reg()
210 rc = -1; in elantech_write_reg()
222 rc = -1; in elantech_write_reg()
234 rc = -1; in elantech_write_reg()
248 rc = -1; in elantech_write_reg()
255 "failed to write register 0x%02x with value 0x%02x.\n", in elantech_write_reg()
267 psmouse->pktsize, psmouse->packet); in elantech_packet_dump()
274 * Laptop-model: fw_version: caps: buttons:
276 * Acer S7-392 0x581f01 50, 17, 0d clickpad
277 * Acer V5-131 0x461f02 01, 16, 0c clickpad
278 * Acer V5-551 0x461f00 ? clickpad
286 * Avatar AVIU-145A2 0x361f00 ? clickpad
302 * Samsung NP900X3E-A02 0x575f03 ? clickpad
303 * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad
313 return info->fw_version & 0x001000; in elantech_is_buttonpad()
322 struct input_dev *dev = psmouse->dev; in elantech_report_absolute_v1()
323 struct elantech_data *etd = psmouse->private; in elantech_report_absolute_v1()
324 unsigned char *packet = psmouse->packet; in elantech_report_absolute_v1()
327 if (etd->info.fw_version < 0x020000) { in elantech_report_absolute_v1()
342 if (etd->info.jumpy_cursor) { in elantech_report_absolute_v1()
344 etd->single_finger_reports = 0; in elantech_report_absolute_v1()
345 } else if (etd->single_finger_reports < 2) { in elantech_report_absolute_v1()
347 etd->single_finger_reports++; in elantech_report_absolute_v1()
363 etd->y_max - (((packet[1] & 0x03) << 8) | packet[3])); in elantech_report_absolute_v1()
372 if (etd->info.fw_version < 0x020000 && in elantech_report_absolute_v1()
373 (etd->info.capabilities[0] & ETP_CAP_HAS_ROCKER)) { in elantech_report_absolute_v1()
384 unsigned int x, unsigned int y) in elantech_set_slot() argument
389 input_report_abs(dev, ABS_MT_POSITION_X, x); in elantech_set_slot()
394 /* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */
410 struct elantech_data *etd = psmouse->private; in elantech_report_absolute_v2()
411 struct input_dev *dev = psmouse->dev; in elantech_report_absolute_v2()
412 unsigned char *packet = psmouse->packet; in elantech_report_absolute_v2()
438 y1 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); in elantech_report_absolute_v2()
453 y1 = etd->y_max - in elantech_report_absolute_v2()
461 y2 = etd->y_max - in elantech_report_absolute_v2()
481 if (etd->info.reports_pressure) { in elantech_report_absolute_v2()
500 * x and y are written in two's complement spread in elantech_report_trackpoint()
507 struct elantech_data *etd = psmouse->private; in elantech_report_trackpoint()
508 struct input_dev *tp_dev = etd->tp_dev; in elantech_report_trackpoint()
509 unsigned char *packet = psmouse->packet; in elantech_report_trackpoint()
510 int x, y; in elantech_report_trackpoint() local
523 * occasionally. Discard packets outside of [-127, 127] range in elantech_report_trackpoint()
533 x = packet[4] - (int)((packet[1]^0x80) << 1); in elantech_report_trackpoint()
534 y = (int)((packet[2]^0x80) << 1) - packet[5]; in elantech_report_trackpoint()
538 input_report_rel(tp_dev, REL_X, x); in elantech_report_trackpoint()
547 if (etd->info.debug == 1) in elantech_report_trackpoint()
561 struct input_dev *dev = psmouse->dev; in elantech_report_absolute_v3()
562 struct elantech_data *etd = psmouse->private; in elantech_report_absolute_v3()
563 unsigned char *packet = psmouse->packet; in elantech_report_absolute_v3()
582 y1 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); in elantech_report_absolute_v3()
591 etd->mt[0].x = ((packet[1] & 0x0f) << 8) | packet[2]; in elantech_report_absolute_v3()
596 etd->mt[0].y = etd->y_max - in elantech_report_absolute_v3()
605 x1 = etd->mt[0].x; in elantech_report_absolute_v3()
606 y1 = etd->mt[0].y; in elantech_report_absolute_v3()
608 y2 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); in elantech_report_absolute_v3()
626 if (elantech_is_buttonpad(&etd->info)) in elantech_report_absolute_v3()
639 struct input_dev *dev = psmouse->dev; in elantech_input_sync_v4()
640 struct elantech_data *etd = psmouse->private; in elantech_input_sync_v4()
641 unsigned char *packet = psmouse->packet; in elantech_input_sync_v4()
644 if (elantech_is_buttonpad(&etd->info)) in elantech_input_sync_v4()
655 struct input_dev *dev = psmouse->dev; in process_packet_status_v4()
656 unsigned char *packet = psmouse->packet; in process_packet_status_v4()
674 struct input_dev *dev = psmouse->dev; in process_packet_head_v4()
675 struct elantech_data *etd = psmouse->private; in process_packet_head_v4()
676 unsigned char *packet = psmouse->packet; in process_packet_head_v4()
680 id = ((packet[3] & 0xe0) >> 5) - 1; in process_packet_head_v4()
684 etd->mt[id].x = ((packet[1] & 0x0f) << 8) | packet[2]; in process_packet_head_v4()
685 etd->mt[id].y = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); in process_packet_head_v4()
692 input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x); in process_packet_head_v4()
693 input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y); in process_packet_head_v4()
695 input_report_abs(dev, ABS_MT_TOUCH_MAJOR, traces * etd->width); in process_packet_head_v4()
704 struct input_dev *dev = psmouse->dev; in process_packet_motion_v4()
705 struct elantech_data *etd = psmouse->private; in process_packet_motion_v4()
706 unsigned char *packet = psmouse->packet; in process_packet_motion_v4()
710 id = ((packet[0] & 0xe0) >> 5) - 1; in process_packet_motion_v4()
714 sid = ((packet[3] & 0xe0) >> 5) - 1; in process_packet_motion_v4()
717 * Motion packets give us the delta of x, y values of specific fingers, in process_packet_motion_v4()
726 etd->mt[id].x += delta_x1 * weight; in process_packet_motion_v4()
727 etd->mt[id].y -= delta_y1 * weight; in process_packet_motion_v4()
729 input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x); in process_packet_motion_v4()
730 input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y); in process_packet_motion_v4()
733 etd->mt[sid].x += delta_x2 * weight; in process_packet_motion_v4()
734 etd->mt[sid].y -= delta_y2 * weight; in process_packet_motion_v4()
736 input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[sid].x); in process_packet_motion_v4()
737 input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[sid].y); in process_packet_motion_v4()
768 struct elantech_data *etd = psmouse->private; in elantech_packet_check_v1()
769 unsigned char *packet = psmouse->packet; in elantech_packet_check_v1()
773 if (etd->info.fw_version < 0x020000) { in elantech_packet_check_v1()
785 return etd->parity[packet[1]] == p1 && in elantech_packet_check_v1()
786 etd->parity[packet[2]] == p2 && in elantech_packet_check_v1()
787 etd->parity[packet[3]] == p3; in elantech_packet_check_v1()
799 unsigned char *packet = psmouse->packet; in elantech_debounce_check_v2()
806 struct elantech_data *etd = psmouse->private; in elantech_packet_check_v2()
807 unsigned char *packet = psmouse->packet; in elantech_packet_check_v2()
818 if (etd->info.reports_pressure) in elantech_packet_check_v2()
838 struct elantech_data *etd = psmouse->private; in elantech_packet_check_v3()
842 unsigned char *packet = psmouse->packet; in elantech_packet_check_v3()
855 if (etd->info.crc_enabled) { in elantech_packet_check_v3()
876 struct elantech_data *etd = psmouse->private; in elantech_packet_check_v4()
877 unsigned char *packet = psmouse->packet; in elantech_packet_check_v4()
882 if (etd->tp_dev && (packet[3] & 0x0f) == 0x06) in elantech_packet_check_v4()
886 ic_version = (etd->info.fw_version & 0x0f0000) >> 16; in elantech_packet_check_v4()
895 if (etd->info.crc_enabled) in elantech_packet_check_v4()
897 else if (ic_version == 7 && etd->info.samples[1] == 0x2A) in elantech_packet_check_v4()
925 struct elantech_data *etd = psmouse->private; in elantech_process_byte()
928 if (psmouse->pktcnt < psmouse->pktsize) in elantech_process_byte()
931 if (etd->info.debug > 1) in elantech_process_byte()
934 switch (etd->info.hw_version) { in elantech_process_byte()
936 if (etd->info.paritycheck && !elantech_packet_check_v1(psmouse)) in elantech_process_byte()
947 if (etd->info.paritycheck && !elantech_packet_check_v2(psmouse)) in elantech_process_byte()
1003 struct elantech_data *etd = psmouse->private; in elantech_set_rate_restore_reg_07()
1005 etd->original_set_rate(psmouse, rate); in elantech_set_rate_restore_reg_07()
1006 if (elantech_write_reg(psmouse, 0x07, etd->reg_07)) in elantech_set_rate_restore_reg_07()
1015 struct elantech_data *etd = psmouse->private; in elantech_set_absolute_mode()
1020 switch (etd->info.hw_version) { in elantech_set_absolute_mode()
1022 etd->reg_10 = 0x16; in elantech_set_absolute_mode()
1023 etd->reg_11 = 0x8f; in elantech_set_absolute_mode()
1024 if (elantech_write_reg(psmouse, 0x10, etd->reg_10) || in elantech_set_absolute_mode()
1025 elantech_write_reg(psmouse, 0x11, etd->reg_11)) { in elantech_set_absolute_mode()
1026 rc = -1; in elantech_set_absolute_mode()
1032 etd->reg_10 = 0x54; in elantech_set_absolute_mode()
1033 etd->reg_11 = 0x88; /* 0x8a */ in elantech_set_absolute_mode()
1034 etd->reg_21 = 0x60; /* 0x00 */ in elantech_set_absolute_mode()
1035 if (elantech_write_reg(psmouse, 0x10, etd->reg_10) || in elantech_set_absolute_mode()
1036 elantech_write_reg(psmouse, 0x11, etd->reg_11) || in elantech_set_absolute_mode()
1037 elantech_write_reg(psmouse, 0x21, etd->reg_21)) { in elantech_set_absolute_mode()
1038 rc = -1; in elantech_set_absolute_mode()
1043 if (etd->info.set_hw_resolution) in elantech_set_absolute_mode()
1044 etd->reg_10 = 0x0b; in elantech_set_absolute_mode()
1046 etd->reg_10 = 0x01; in elantech_set_absolute_mode()
1048 if (elantech_write_reg(psmouse, 0x10, etd->reg_10)) in elantech_set_absolute_mode()
1049 rc = -1; in elantech_set_absolute_mode()
1054 etd->reg_07 = 0x01; in elantech_set_absolute_mode()
1055 if (elantech_write_reg(psmouse, 0x07, etd->reg_07)) in elantech_set_absolute_mode()
1056 rc = -1; in elantech_set_absolute_mode()
1072 tries--; in elantech_set_absolute_mode()
1080 } else if (etd->info.hw_version == 1 && in elantech_set_absolute_mode()
1084 rc = -1; in elantech_set_absolute_mode()
1097 * we also have to convert dpi to dots/mm (*10/254 to avoid floating point)
1112 return -1; in elantech_get_resolution_v4()
1123 struct input_dev *dev = psmouse->dev; in elantech_set_buttonpad_prop()
1124 struct elantech_data *etd = psmouse->private; in elantech_set_buttonpad_prop()
1126 if (elantech_is_buttonpad(&etd->info)) { in elantech_set_buttonpad_prop()
1127 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); in elantech_set_buttonpad_prop()
1128 __clear_bit(BTN_RIGHT, dev->keybit); in elantech_set_buttonpad_prop()
1167 struct input_dev *dev = psmouse->dev; in elantech_set_input_params()
1168 struct elantech_data *etd = psmouse->private; in elantech_set_input_params()
1169 struct elantech_device_info *info = &etd->info; in elantech_set_input_params()
1170 unsigned int x_min = info->x_min, y_min = info->y_min, in elantech_set_input_params()
1171 x_max = info->x_max, y_max = info->y_max, in elantech_set_input_params()
1172 width = info->width; in elantech_set_input_params()
1174 __set_bit(INPUT_PROP_POINTER, dev->propbit); in elantech_set_input_params()
1175 __set_bit(EV_KEY, dev->evbit); in elantech_set_input_params()
1176 __set_bit(EV_ABS, dev->evbit); in elantech_set_input_params()
1177 __clear_bit(EV_REL, dev->evbit); in elantech_set_input_params()
1179 __set_bit(BTN_LEFT, dev->keybit); in elantech_set_input_params()
1180 if (info->has_middle_button) in elantech_set_input_params()
1181 __set_bit(BTN_MIDDLE, dev->keybit); in elantech_set_input_params()
1182 __set_bit(BTN_RIGHT, dev->keybit); in elantech_set_input_params()
1184 __set_bit(BTN_TOUCH, dev->keybit); in elantech_set_input_params()
1185 __set_bit(BTN_TOOL_FINGER, dev->keybit); in elantech_set_input_params()
1186 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); in elantech_set_input_params()
1187 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); in elantech_set_input_params()
1189 switch (info->hw_version) { in elantech_set_input_params()
1192 if (info->fw_version < 0x020000 && in elantech_set_input_params()
1193 (info->capabilities[0] & ETP_CAP_HAS_ROCKER)) { in elantech_set_input_params()
1194 __set_bit(BTN_FORWARD, dev->keybit); in elantech_set_input_params()
1195 __set_bit(BTN_BACK, dev->keybit); in elantech_set_input_params()
1202 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); in elantech_set_input_params()
1203 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); in elantech_set_input_params()
1206 if (info->hw_version == 3) in elantech_set_input_params()
1210 if (info->reports_pressure) { in elantech_set_input_params()
1223 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); in elantech_set_input_params()
1224 /* For X to recognize me as touchpad. */ in elantech_set_input_params()
1243 * convert to surface unit as Protocol-B requires. in elantech_set_input_params()
1250 input_abs_set_res(dev, ABS_X, info->x_res); in elantech_set_input_params()
1251 input_abs_set_res(dev, ABS_Y, info->y_res); in elantech_set_input_params()
1252 if (info->hw_version > 1) { in elantech_set_input_params()
1253 input_abs_set_res(dev, ABS_MT_POSITION_X, info->x_res); in elantech_set_input_params()
1254 input_abs_set_res(dev, ABS_MT_POSITION_Y, info->y_res); in elantech_set_input_params()
1257 etd->y_max = y_max; in elantech_set_input_params()
1258 etd->width = width; in elantech_set_input_params()
1274 struct elantech_data *etd = psmouse->private; in elantech_show_int_attr()
1276 unsigned char *reg = (unsigned char *) etd + attr->field_offset; in elantech_show_int_attr()
1279 if (attr->reg) in elantech_show_int_attr()
1280 rc = elantech_read_reg(psmouse, attr->reg, reg); in elantech_show_int_attr()
1282 return sprintf(buf, "0x%02x\n", (attr->reg && rc) ? -1 : *reg); in elantech_show_int_attr()
1291 struct elantech_data *etd = psmouse->private; in elantech_set_int_attr()
1293 unsigned char *reg = (unsigned char *) etd + attr->field_offset; in elantech_set_int_attr()
1302 if (etd->info.hw_version == 1) { in elantech_set_int_attr()
1303 if (attr->reg == 0x10) in elantech_set_int_attr()
1306 else if (attr->reg == 0x11) in elantech_set_int_attr()
1311 if (!attr->reg || elantech_write_reg(psmouse, attr->reg, value) == 0) in elantech_set_int_attr()
1404 struct ps2dev *ps2dev = &psmouse->ps2dev; in elantech_detect()
1415 return -1; in elantech_detect()
1425 "unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n", in elantech_detect()
1427 return -1; in elantech_detect()
1432 * value to avoid mis-detection. Logitech mice are known to respond in elantech_detect()
1437 return -1; in elantech_detect()
1441 "Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n", in elantech_detect()
1447 return -1; in elantech_detect()
1451 psmouse->vendor = "Elantech"; in elantech_detect()
1452 psmouse->name = "Touchpad"; in elantech_detect()
1463 struct elantech_data *etd = psmouse->private; in elantech_disconnect()
1471 if (etd->tp_dev) in elantech_disconnect()
1472 input_unregister_device(etd->tp_dev); in elantech_disconnect()
1473 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, in elantech_disconnect()
1475 kfree(psmouse->private); in elantech_disconnect()
1476 psmouse->private = NULL; in elantech_disconnect()
1506 return -1; in elantech_reconnect()
1509 err = ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE); in elantech_reconnect()
1512 psmouse->ps2dev.serio->phys, err); in elantech_reconnect()
1514 err = ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); in elantech_reconnect()
1517 psmouse->ps2dev.serio->phys, err); in elantech_reconnect()
1523 return -1; in elantech_reconnect()
1627 * stack out-of-bound accesses. in elantech_change_report_id()
1635 return -EIO; in elantech_change_report_id()
1646 info->ic_version = (info->fw_version & 0x0f0000) >> 16; in elantech_set_properties()
1649 if (info->fw_version < 0x020030 || info->fw_version == 0x020600) in elantech_set_properties()
1650 info->hw_version = 1; in elantech_set_properties()
1652 switch (info->ic_version) { in elantech_set_properties()
1655 info->hw_version = 2; in elantech_set_properties()
1658 info->hw_version = 3; in elantech_set_properties()
1661 info->hw_version = 4; in elantech_set_properties()
1664 return -1; in elantech_set_properties()
1669 info->pattern = 0x00; in elantech_set_properties()
1670 if (info->ic_version == 0x0f && (info->fw_version & 0xff) <= 0x02) in elantech_set_properties()
1671 info->pattern = info->fw_version & 0xff; in elantech_set_properties()
1674 info->send_cmd = info->hw_version >= 3 ? elantech_send_cmd : in elantech_set_properties()
1678 info->paritycheck = 1; in elantech_set_properties()
1685 info->jumpy_cursor = in elantech_set_properties()
1686 (info->fw_version == 0x020022 || info->fw_version == 0x020600); in elantech_set_properties()
1688 if (info->hw_version > 1) { in elantech_set_properties()
1690 info->debug = 1; in elantech_set_properties()
1692 if (info->fw_version >= 0x020800) in elantech_set_properties()
1693 info->reports_pressure = true; in elantech_set_properties()
1700 info->crc_enabled = (info->fw_version & 0x4000) == 0x4000 || in elantech_set_properties()
1704 info->set_hw_resolution = !dmi_check_system(no_hw_res_dmi_table); in elantech_set_properties()
1723 return -EINVAL; in elantech_query_info()
1725 info->fw_version = (param[0] << 16) | (param[1] << 8) | param[2]; in elantech_query_info()
1729 return -EINVAL; in elantech_query_info()
1732 "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n", in elantech_query_info()
1733 info->hw_version, param[0], param[1], param[2]); in elantech_query_info()
1735 if (info->send_cmd(psmouse, ETP_CAPABILITIES_QUERY, in elantech_query_info()
1736 info->capabilities)) { in elantech_query_info()
1738 return -EINVAL; in elantech_query_info()
1741 "Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n", in elantech_query_info()
1742 info->capabilities[0], info->capabilities[1], in elantech_query_info()
1743 info->capabilities[2]); in elantech_query_info()
1745 if (info->hw_version != 1) { in elantech_query_info()
1746 if (info->send_cmd(psmouse, ETP_SAMPLE_QUERY, info->samples)) { in elantech_query_info()
1748 return -EINVAL; in elantech_query_info()
1751 "Elan sample query result %02x, %02x, %02x\n", in elantech_query_info()
1752 info->samples[0], in elantech_query_info()
1753 info->samples[1], in elantech_query_info()
1754 info->samples[2]); in elantech_query_info()
1757 if (info->pattern > 0x00 && info->ic_version == 0xf) { in elantech_query_info()
1758 if (info->send_cmd(psmouse, ETP_ICBODY_QUERY, ic_body)) { in elantech_query_info()
1760 return -EINVAL; in elantech_query_info()
1762 info->ic_version = be16_to_cpup((__be16 *)ic_body); in elantech_query_info()
1764 "Elan ic body: %#04x, current fw version: %#02x\n", in elantech_query_info()
1765 info->ic_version, ic_body[2]); in elantech_query_info()
1768 info->product_id = be16_to_cpup((__be16 *)info->samples); in elantech_query_info()
1769 if (info->pattern == 0x00) in elantech_query_info()
1770 info->product_id &= 0xff; in elantech_query_info()
1772 if (info->samples[1] == 0x74 && info->hw_version == 0x03) { in elantech_query_info()
1780 return -ENODEV; in elantech_query_info()
1784 info->has_trackpoint = (info->capabilities[0] & 0x80) == 0x80; in elantech_query_info()
1786 if (info->has_trackpoint && info->ic_version == 0x0011 && in elantech_query_info()
1787 (info->product_id == 0x08 || info->product_id == 0x09 || in elantech_query_info()
1788 info->product_id == 0x0d || info->product_id == 0x0e)) { in elantech_query_info()
1799 return -ENODEV; in elantech_query_info()
1803 info->x_res = 31; in elantech_query_info()
1804 info->y_res = 31; in elantech_query_info()
1805 if (info->hw_version == 4) { in elantech_query_info()
1807 &info->x_res, in elantech_query_info()
1808 &info->y_res, in elantech_query_info()
1809 &info->bus)) { in elantech_query_info()
1816 switch (info->hw_version) { in elantech_query_info()
1818 info->x_min = ETP_XMIN_V1; in elantech_query_info()
1819 info->y_min = ETP_YMIN_V1; in elantech_query_info()
1820 info->x_max = ETP_XMAX_V1; in elantech_query_info()
1821 info->y_max = ETP_YMAX_V1; in elantech_query_info()
1825 if (info->fw_version == 0x020800 || in elantech_query_info()
1826 info->fw_version == 0x020b00 || in elantech_query_info()
1827 info->fw_version == 0x020030) { in elantech_query_info()
1828 info->x_min = ETP_XMIN_V2; in elantech_query_info()
1829 info->y_min = ETP_YMIN_V2; in elantech_query_info()
1830 info->x_max = ETP_XMAX_V2; in elantech_query_info()
1831 info->y_max = ETP_YMAX_V2; in elantech_query_info()
1836 i = (info->fw_version > 0x020800 && in elantech_query_info()
1837 info->fw_version < 0x020900) ? 1 : 2; in elantech_query_info()
1839 if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) in elantech_query_info()
1840 return -EINVAL; in elantech_query_info()
1844 if (((info->fw_version >> 16) == 0x14) && fixed_dpi) { in elantech_query_info()
1845 if (info->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) in elantech_query_info()
1846 return -EINVAL; in elantech_query_info()
1848 info->x_max = (info->capabilities[1] - i) * param[1] / 2; in elantech_query_info()
1849 info->y_max = (info->capabilities[2] - i) * param[2] / 2; in elantech_query_info()
1850 } else if (info->fw_version == 0x040216) { in elantech_query_info()
1851 info->x_max = 819; in elantech_query_info()
1852 info->y_max = 405; in elantech_query_info()
1853 } else if (info->fw_version == 0x040219 || info->fw_version == 0x040215) { in elantech_query_info()
1854 info->x_max = 900; in elantech_query_info()
1855 info->y_max = 500; in elantech_query_info()
1857 info->x_max = (info->capabilities[1] - i) * 64; in elantech_query_info()
1858 info->y_max = (info->capabilities[2] - i) * 64; in elantech_query_info()
1864 if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) in elantech_query_info()
1865 return -EINVAL; in elantech_query_info()
1867 info->x_max = (0x0f & param[0]) << 8 | param[1]; in elantech_query_info()
1868 info->y_max = (0xf0 & param[0]) << 4 | param[2]; in elantech_query_info()
1872 if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) in elantech_query_info()
1873 return -EINVAL; in elantech_query_info()
1875 info->x_max = (0x0f & param[0]) << 8 | param[1]; in elantech_query_info()
1876 info->y_max = (0xf0 & param[0]) << 4 | param[2]; in elantech_query_info()
1877 traces = info->capabilities[1]; in elantech_query_info()
1878 if ((traces < 2) || (traces > info->x_max)) in elantech_query_info()
1879 return -EINVAL; in elantech_query_info()
1881 info->width = info->x_max / (traces - 1); in elantech_query_info()
1884 info->x_traces = traces; in elantech_query_info()
1887 traces = info->capabilities[2]; in elantech_query_info()
1888 if ((traces >= 2) && (traces <= info->y_max)) in elantech_query_info()
1889 info->y_traces = traces; in elantech_query_info()
1895 info->has_middle_button = dmi_check_system(elantech_dmi_has_middle_button) || in elantech_query_info()
1896 (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) && in elantech_query_info()
1910 ELANTECH_SMBUS_NOT_SET = -1,
1939 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-x", in elantech_create_smbus()
1940 info->x_max + 1); in elantech_create_smbus()
1941 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-y", in elantech_create_smbus()
1942 info->y_max + 1); in elantech_create_smbus()
1943 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-x", in elantech_create_smbus()
1944 info->x_min); in elantech_create_smbus()
1945 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-y", in elantech_create_smbus()
1946 info->y_min); in elantech_create_smbus()
1947 if (info->x_res) in elantech_create_smbus()
1948 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-x-mm", in elantech_create_smbus()
1949 (info->x_max + 1) / info->x_res); in elantech_create_smbus()
1950 if (info->y_res) in elantech_create_smbus()
1951 i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-y-mm", in elantech_create_smbus()
1952 (info->y_max + 1) / info->y_res); in elantech_create_smbus()
1954 if (info->has_trackpoint) in elantech_create_smbus()
1957 if (info->has_middle_button) in elantech_create_smbus()
1958 i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,middle-button"); in elantech_create_smbus()
1960 if (info->x_traces) in elantech_create_smbus()
1962 info->x_traces); in elantech_create_smbus()
1963 if (info->y_traces) in elantech_create_smbus()
1965 info->y_traces); in elantech_create_smbus()
1979 * elantech_setup_smbus - called once the PS/2 devices are enumerated
1989 return -ENXIO; in elantech_setup_smbus()
1997 if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) || in elantech_setup_smbus()
1999 return -ENXIO; in elantech_setup_smbus()
2006 if (error == -EAGAIN) in elantech_setup_smbus()
2020 if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) in elantech_use_host_notify()
2023 switch (info->bus) { in elantech_use_host_notify()
2037 info->bus); in elantech_use_host_notify()
2055 error = -ENXIO; in elantech_init_smbus()
2074 int error = -EINVAL; in elantech_setup_ps2()
2077 psmouse->private = etd = kzalloc(sizeof(*etd), GFP_KERNEL); in elantech_setup_ps2()
2079 return -ENOMEM; in elantech_setup_ps2()
2081 etd->info = *info; in elantech_setup_ps2()
2083 etd->parity[0] = 1; in elantech_setup_ps2()
2085 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1; in elantech_setup_ps2()
2093 if (info->fw_version == 0x381f17) { in elantech_setup_ps2()
2094 etd->original_set_rate = psmouse->set_rate; in elantech_setup_ps2()
2095 psmouse->set_rate = elantech_set_rate_restore_reg_07; in elantech_setup_ps2()
2103 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, in elantech_setup_ps2()
2112 if (info->has_trackpoint) { in elantech_setup_ps2()
2116 error = -ENOMEM; in elantech_setup_ps2()
2120 etd->tp_dev = tp_dev; in elantech_setup_ps2()
2121 snprintf(etd->tp_phys, sizeof(etd->tp_phys), "%s/input1", in elantech_setup_ps2()
2122 psmouse->ps2dev.serio->phys); in elantech_setup_ps2()
2123 tp_dev->phys = etd->tp_phys; in elantech_setup_ps2()
2124 tp_dev->name = "ETPS/2 Elantech TrackPoint"; in elantech_setup_ps2()
2125 tp_dev->id.bustype = BUS_I8042; in elantech_setup_ps2()
2126 tp_dev->id.vendor = 0x0002; in elantech_setup_ps2()
2127 tp_dev->id.product = PSMOUSE_ELANTECH; in elantech_setup_ps2()
2128 tp_dev->id.version = 0x0000; in elantech_setup_ps2()
2129 tp_dev->dev.parent = &psmouse->ps2dev.serio->dev; in elantech_setup_ps2()
2130 tp_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); in elantech_setup_ps2()
2131 tp_dev->relbit[BIT_WORD(REL_X)] = in elantech_setup_ps2()
2133 tp_dev->keybit[BIT_WORD(BTN_LEFT)] = in elantech_setup_ps2()
2137 __set_bit(INPUT_PROP_POINTER, tp_dev->propbit); in elantech_setup_ps2()
2138 __set_bit(INPUT_PROP_POINTING_STICK, tp_dev->propbit); in elantech_setup_ps2()
2140 error = input_register_device(etd->tp_dev); in elantech_setup_ps2()
2145 psmouse->protocol_handler = elantech_process_byte; in elantech_setup_ps2()
2146 psmouse->disconnect = elantech_disconnect; in elantech_setup_ps2()
2147 psmouse->reconnect = elantech_reconnect; in elantech_setup_ps2()
2148 psmouse->fast_reconnect = NULL; in elantech_setup_ps2()
2149 psmouse->pktsize = info->hw_version > 1 ? 6 : 4; in elantech_setup_ps2()
2155 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, in elantech_setup_ps2()