Bugzilla – Attachment 654999 Details for
Bug 883192
ElanTech Touchpad not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
[patch]
Patch for elantech.c
patch_elantech.c.patch (text/plain), 17.59 KB, created by
Forgotten User wm10pd-IdS
on 2015-11-06 14:48:47 UTC
(
hide
)
Description:
Patch for elantech.c
Filename:
MIME Type:
Creator:
Forgotten User wm10pd-IdS
Created:
2015-11-06 14:48:47 UTC
Size:
17.59 KB
patch
obsolete
>--- psmouse-Leap_default/elantech.c 2015-10-29 07:43:42.000000000 +0100 >+++ psmouse-elantech-v7right/src/elantech.c 2013-07-15 07:45:52.000000000 +0200 >@@ -11,14 +11,12 @@ > */ > > #include <linux/delay.h> >-#include <linux/dmi.h> > #include <linux/slab.h> > #include <linux/module.h> > #include <linux/input.h> > #include <linux/input/mt.h> > #include <linux/serio.h> > #include <linux/libps2.h> >-#include <asm/unaligned.h> > #include "psmouse.h" > #include "elantech.h" > >@@ -315,7 +313,7 @@ static void elantech_report_semi_mt_data > unsigned int x2, unsigned int y2) > { > elantech_set_slot(dev, 0, num_fingers != 0, x1, y1); >- elantech_set_slot(dev, 1, num_fingers >= 2, x2, y2); >+ elantech_set_slot(dev, 1, num_fingers == 2, x2, y2); > } > > /* >@@ -404,60 +402,6 @@ static void elantech_report_absolute_v2( > input_sync(dev); > } > >-static void elantech_report_trackpoint(struct psmouse *psmouse, >- int packet_type) >-{ >- /* >- * byte 0: 0 0 sx sy 0 M R L >- * byte 1:~sx 0 0 0 0 0 0 0 >- * byte 2:~sy 0 0 0 0 0 0 0 >- * byte 3: 0 0 ~sy ~sx 0 1 1 0 >- * byte 4: x7 x6 x5 x4 x3 x2 x1 x0 >- * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 >- * >- * x and y are written in two's complement spread >- * over 9 bits with sx/sy the relative top bit and >- * x7..x0 and y7..y0 the lower bits. >- * The sign of y is opposite to what the input driver >- * expects for a relative movement >- */ >- >- struct elantech_data *etd = psmouse->private; >- struct input_dev *tp_dev = etd->tp_dev; >- unsigned char *packet = psmouse->packet; >- int x, y; >- u32 t; >- >- t = get_unaligned_le32(&packet[0]); >- >- switch (t & ~7U) { >- case 0x06000030U: >- case 0x16008020U: >- case 0x26800010U: >- case 0x36808000U: >- x = packet[4] - (int)((packet[1]^0x80) << 1); >- y = (int)((packet[2]^0x80) << 1) - packet[5]; >- >- input_report_key(tp_dev, BTN_LEFT, packet[0] & 0x01); >- input_report_key(tp_dev, BTN_RIGHT, packet[0] & 0x02); >- input_report_key(tp_dev, BTN_MIDDLE, packet[0] & 0x04); >- >- input_report_rel(tp_dev, REL_X, x); >- input_report_rel(tp_dev, REL_Y, y); >- >- input_sync(tp_dev); >- >- break; >- >- default: >- /* Dump unexpected packet sequences if debug=1 (default) */ >- if (etd->debug == 1) >- elantech_packet_dump(psmouse); >- >- break; >- } >-} >- > /* > * Interpret complete data packets and report absolute mode input events for > * hardware version 3. (12 byte packets for two fingers) >@@ -528,15 +472,8 @@ static void elantech_report_absolute_v3( > input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); > input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); > input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); >- >- /* For clickpads map both buttons to BTN_LEFT */ >- if (etd->fw_version & 0x001000) { >- input_report_key(dev, BTN_LEFT, packet[0] & 0x03); >- } else { >- input_report_key(dev, BTN_LEFT, packet[0] & 0x01); >- input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); >- } >- >+ input_report_key(dev, BTN_LEFT, packet[0] & 0x01); >+ input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); > input_report_abs(dev, ABS_PRESSURE, pres); > input_report_abs(dev, ABS_TOOL_WIDTH, width); > >@@ -546,18 +483,10 @@ static void elantech_report_absolute_v3( > static void elantech_input_sync_v4(struct psmouse *psmouse) > { > struct input_dev *dev = psmouse->dev; >- struct elantech_data *etd = psmouse->private; > unsigned char *packet = psmouse->packet; > >- /* For clickpads map both buttons to BTN_LEFT */ >- if (etd->fw_version & 0x001000) { >- input_report_key(dev, BTN_LEFT, packet[0] & 0x03); >- } else { >- input_report_key(dev, BTN_LEFT, packet[0] & 0x01); >- input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); >- input_report_key(dev, BTN_MIDDLE, packet[0] & 0x04); >- } >- >+ input_report_key(dev, BTN_LEFT, packet[0] & 0x01); >+ input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); > input_mt_report_pointer_emulation(dev, true); > input_sync(dev); > } >@@ -744,7 +673,6 @@ static int elantech_packet_check_v2(stru > */ > static int elantech_packet_check_v3(struct psmouse *psmouse) > { >- struct elantech_data *etd = psmouse->private; > const u8 debounce_packet[] = { 0xc4, 0xff, 0xff, 0x02, 0xff, 0xff }; > unsigned char *packet = psmouse->packet; > >@@ -755,64 +683,28 @@ static int elantech_packet_check_v3(stru > if (!memcmp(packet, debounce_packet, sizeof(debounce_packet))) > return PACKET_DEBOUNCE; > >- /* >- * If the hardware flag 'crc_enabled' is set the packets have >- * different signatures. >- */ >- if (etd->crc_enabled) { >- if ((packet[3] & 0x09) == 0x08) >- return PACKET_V3_HEAD; >- >- if ((packet[3] & 0x09) == 0x09) >- return PACKET_V3_TAIL; >- } else { >- if ((packet[0] & 0x0c) == 0x04 && (packet[3] & 0xcf) == 0x02) >- return PACKET_V3_HEAD; >+ if ((packet[0] & 0x0c) == 0x04 && (packet[3] & 0xcf) == 0x02) >+ return PACKET_V3_HEAD; > >- if ((packet[0] & 0x0c) == 0x0c && (packet[3] & 0xce) == 0x0c) >- return PACKET_V3_TAIL; >- if ((packet[3] & 0x0f) == 0x06) >- return PACKET_TRACKPOINT; >- } >+ if ((packet[0] & 0x0c) == 0x0c && (packet[3] & 0xce) == 0x0c) >+ return PACKET_V3_TAIL; > > return PACKET_UNKNOWN; > } > > static int elantech_packet_check_v4(struct psmouse *psmouse) > { >- struct elantech_data *etd = psmouse->private; > unsigned char *packet = psmouse->packet; > unsigned char packet_type = packet[3] & 0x03; >- bool sanity_check; >- >- if (etd->tp_dev && (packet[3] & 0x0f) == 0x06) >- return PACKET_TRACKPOINT; >- >- /* >- * Sanity check based on the constant bits of a packet. >- * The constant bits change depending on the value of >- * the hardware flag 'crc_enabled' but are the same for >- * every packet, regardless of the type. >- */ >- if (etd->crc_enabled) >- sanity_check = ((packet[3] & 0x08) == 0x00); >- else >- sanity_check = ((packet[0] & 0x0c) == 0x04 && >- (packet[3] & 0x1c) == 0x10); >- >- if (!sanity_check) >- return PACKET_UNKNOWN; >- >- switch (packet_type) { >- case 0: >- return PACKET_V4_STATUS; > >- case 1: >+ if (packet_type == 0x01) > return PACKET_V4_HEAD; > >- case 2: >+ if (packet_type == 0x02) > return PACKET_V4_MOTION; >- } >+ >+ if (packet_type == 0x00) >+ return PACKET_V4_STATUS; > > return PACKET_UNKNOWN; > } >@@ -852,40 +744,22 @@ static psmouse_ret_t elantech_process_by > > case 3: > packet_type = elantech_packet_check_v3(psmouse); >- switch (packet_type) { >- case PACKET_UNKNOWN: >- return PSMOUSE_BAD_DATA; >- >- case PACKET_DEBOUNCE: >- /* ignore debounce */ >- break; >- >- case PACKET_TRACKPOINT: >- elantech_report_trackpoint(psmouse, packet_type); >- break; >+ /* ignore debounce */ >+ if (packet_type == PACKET_DEBOUNCE) >+ return PSMOUSE_FULL_PACKET; > >- default: >- elantech_report_absolute_v3(psmouse, packet_type); >- break; >- } >+ if (packet_type == PACKET_UNKNOWN) >+ return PSMOUSE_BAD_DATA; > >+ elantech_report_absolute_v3(psmouse, packet_type); > break; > > case 4: > packet_type = elantech_packet_check_v4(psmouse); >- switch (packet_type) { >- case PACKET_UNKNOWN: >+ if (packet_type == PACKET_UNKNOWN) > return PSMOUSE_BAD_DATA; > >- case PACKET_TRACKPOINT: >- elantech_report_trackpoint(psmouse, packet_type); >- break; >- >- default: >- elantech_report_absolute_v4(psmouse, packet_type); >- break; >- } >- >+ elantech_report_absolute_v4(psmouse, packet_type); > break; > } > >@@ -893,21 +767,6 @@ static psmouse_ret_t elantech_process_by > } > > /* >- * This writes the reg_07 value again to the hardware at the end of every >- * set_rate call because the register loses its value. reg_07 allows setting >- * absolute mode on v4 hardware >- */ >-static void elantech_set_rate_restore_reg_07(struct psmouse *psmouse, >- unsigned int rate) >-{ >- struct elantech_data *etd = psmouse->private; >- >- etd->original_set_rate(psmouse, rate); >- if (elantech_write_reg(psmouse, 0x07, etd->reg_07)) >- psmouse_err(psmouse, "restoring reg_07 failed\n"); >-} >- >-/* > * Put the touchpad into absolute mode > */ > static int elantech_set_absolute_mode(struct psmouse *psmouse) >@@ -940,11 +799,7 @@ static int elantech_set_absolute_mode(st > break; > > case 3: >- if (etd->set_hw_resolution) >- etd->reg_10 = 0x0b; >- else >- etd->reg_10 = 0x01; >- >+ etd->reg_10 = 0x0b; > if (elantech_write_reg(psmouse, 0x10, etd->reg_10)) > rc = -1; > >@@ -1098,68 +953,6 @@ static int elantech_get_resolution_v4(st > } > > /* >- * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in >- * fw_version for this is based on the following fw_version & caps table: >- * >- * Laptop-model: fw_version: caps: buttons: >- * Acer S3 0x461f00 10, 13, 0e clickpad >- * Acer S7-392 0x581f01 50, 17, 0d clickpad >- * Acer V5-131 0x461f02 01, 16, 0c clickpad >- * Acer V5-551 0x461f00 ? clickpad >- * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons >- * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons >- * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons >- * Asus TP500LN 0x381f17 10, 14, 0e clickpad >- * Asus X750JN 0x381f17 10, 14, 0e clickpad >- * Asus UX31 0x361f00 20, 15, 0e clickpad >- * Asus UX32VD 0x361f02 00, 15, 0e clickpad >- * Avatar AVIU-145A2 0x361f00 ? clickpad >- * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons >- * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons >- * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) >- * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons >- * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) >- * Lenovo L530 0x350f02 b9, 15, 0c 2 hw buttons (*) >- * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons >- * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad >- * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad >- * Samsung NP900X3E-A02 0x575f03 ? clickpad >- * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad >- * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons >- * Samsung RF710 0x450f00 ? 2 hw buttons >- * System76 Pangolin 0x250f01 ? 2 hw buttons >- * (*) + 3 trackpoint buttons >- * (**) + 0 trackpoint buttons >- * Note: Lenovo L430 and Lenovo L430 have the same fw_version/caps >- */ >-static void elantech_set_buttonpad_prop(struct psmouse *psmouse) >-{ >- struct input_dev *dev = psmouse->dev; >- struct elantech_data *etd = psmouse->private; >- >- if (etd->fw_version & 0x001000) { >- __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); >- __clear_bit(BTN_RIGHT, dev->keybit); >- } >-} >- >-/* >- * Some hw_version 4 models do have a middle button >- */ >-static const struct dmi_system_id elantech_dmi_has_middle_button[] = { >-#if defined(CONFIG_DMI) && defined(CONFIG_X86) >- { >- /* Fujitsu H730 has a middle button */ >- .matches = { >- DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), >- DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"), >- }, >- }, >-#endif >- { } >-}; >- >-/* > * Set the appropriate event bits for the input subsystem > */ > static int elantech_set_input_params(struct psmouse *psmouse) >@@ -1178,8 +971,6 @@ static int elantech_set_input_params(str > __clear_bit(EV_REL, dev->evbit); > > __set_bit(BTN_LEFT, dev->keybit); >- if (dmi_check_system(elantech_dmi_has_middle_button)) >- __set_bit(BTN_MIDDLE, dev->keybit); > __set_bit(BTN_RIGHT, dev->keybit); > > __set_bit(BTN_TOUCH, dev->keybit); >@@ -1204,8 +995,6 @@ static int elantech_set_input_params(str > __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); > /* fall through */ > case 3: >- if (etd->hw_version == 3) >- elantech_set_buttonpad_prop(psmouse); > input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); > input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); > if (etd->reports_pressure) { >@@ -1227,7 +1016,9 @@ static int elantech_set_input_params(str > */ > psmouse_warn(psmouse, "couldn't query resolution data.\n"); > } >- elantech_set_buttonpad_prop(psmouse); >+ /* v4 is clickpad, with only one button. */ >+ __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); >+ //__clear_bit(BTN_RIGHT, dev->keybit); > __set_bit(BTN_TOOL_QUADTAP, dev->keybit); > /* For X to recognize me as touchpad. */ > input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); >@@ -1341,7 +1132,6 @@ ELANTECH_INT_ATTR(reg_25, 0x25); > ELANTECH_INT_ATTR(reg_26, 0x26); > ELANTECH_INT_ATTR(debug, 0); > ELANTECH_INT_ATTR(paritycheck, 0); >-ELANTECH_INT_ATTR(crc_enabled, 0); > > static struct attribute *elantech_attrs[] = { > &psmouse_attr_reg_07.dattr.attr, >@@ -1356,7 +1146,6 @@ static struct attribute *elantech_attrs[ > &psmouse_attr_reg_26.dattr.attr, > &psmouse_attr_debug.dattr.attr, > &psmouse_attr_paritycheck.dattr.attr, >- &psmouse_attr_crc_enabled.dattr.attr, > NULL > }; > >@@ -1375,14 +1164,6 @@ static bool elantech_is_signature_valid( > if (param[1] == 0) > return true; > >- /* >- * Some hw_version >= 4 models have a revision higher then 20. Meaning >- * that param[2] may be 10 or 20, skip the rates check for these. >- */ >- if ((param[0] & 0x0f) >= 0x06 && (param[1] & 0xaf) == 0x0f && >- param[2] < 40) >- return true; >- > for (i = 0; i < ARRAY_SIZE(rates); i++) > if (param[2] == rates[i]) > return false; >@@ -1454,10 +1235,6 @@ int elantech_detect(struct psmouse *psmo > */ > static void elantech_disconnect(struct psmouse *psmouse) > { >- struct elantech_data *etd = psmouse->private; >- >- if (etd->tp_dev) >- input_unregister_device(etd->tp_dev); > sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, > &elantech_attr_group); > kfree(psmouse->private); >@@ -1484,53 +1261,6 @@ static int elantech_reconnect(struct psm > } > > /* >- * Some hw_version 4 models do not work with crc_disabled >- */ >-static const struct dmi_system_id elantech_dmi_force_crc_enabled[] = { >-#if defined(CONFIG_DMI) && defined(CONFIG_X86) >- { >- /* Fujitsu H730 does not work with crc_enabled == 0 */ >- .matches = { >- DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), >- DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"), >- }, >- }, >- { >- /* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ >- .matches = { >- DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), >- DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E554"), >- }, >- }, >- { >- /* Fujitsu LIFEBOOK E544 does not work with crc_enabled == 0 */ >- .matches = { >- DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), >- DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E544"), >- }, >- }, >-#endif >- { } >-}; >- >-/* >- * Some hw_version 3 models go into error state when we try to set >- * bit 3 and/or bit 1 of r10. >- */ >-static const struct dmi_system_id no_hw_res_dmi_table[] = { >-#if defined(CONFIG_DMI) && defined(CONFIG_X86) >- { >- /* Gigabyte U2442 */ >- .matches = { >- DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), >- DMI_MATCH(DMI_PRODUCT_NAME, "U2442"), >- }, >- }, >-#endif >- { } >-}; >- >-/* > * determine hardware version and set some properties according to it. > */ > static int elantech_set_properties(struct elantech_data *etd) >@@ -1552,11 +1282,6 @@ static int elantech_set_properties(struc > break; > case 6: > case 7: >- case 8: >- case 9: >- case 10: >- case 13: >- case 14: > etd->hw_version = 4; > break; > default: >@@ -1587,16 +1312,6 @@ static int elantech_set_properties(struc > etd->reports_pressure = true; > } > >- /* >- * The signatures of v3 and v4 packets change depending on the >- * value of this hardware flag. >- */ >- etd->crc_enabled = (etd->fw_version & 0x4000) == 0x4000 || >- dmi_check_system(elantech_dmi_force_crc_enabled); >- >- /* Enable real hardware resolution on hw_version 3 ? */ >- etd->set_hw_resolution = !dmi_check_system(no_hw_res_dmi_table); >- > return 0; > } > >@@ -1606,10 +1321,8 @@ static int elantech_set_properties(struc > int elantech_init(struct psmouse *psmouse) > { > struct elantech_data *etd; >- int i; >- int error = -EINVAL; >+ int i, error; > unsigned char param[3]; >- struct input_dev *tp_dev; > > psmouse->private = etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL); > if (!etd) >@@ -1654,11 +1367,6 @@ int elantech_init(struct psmouse *psmous > goto init_fail; > } > >- if (etd->fw_version == 0x381f17) { >- etd->original_set_rate = psmouse->set_rate; >- psmouse->set_rate = elantech_set_rate_restore_reg_07; >- } >- > if (elantech_set_input_params(psmouse)) { > psmouse_err(psmouse, "failed to query touchpad range.\n"); > goto init_fail; >@@ -1673,53 +1381,14 @@ int elantech_init(struct psmouse *psmous > goto init_fail; > } > >- /* The MSB indicates the presence of the trackpoint */ >- if ((etd->capabilities[0] & 0x80) == 0x80) { >- tp_dev = input_allocate_device(); >- >- if (!tp_dev) { >- error = -ENOMEM; >- goto init_fail_tp_alloc; >- } >- >- etd->tp_dev = tp_dev; >- snprintf(etd->tp_phys, sizeof(etd->tp_phys), "%s/input1", >- psmouse->ps2dev.serio->phys); >- tp_dev->phys = etd->tp_phys; >- tp_dev->name = "Elantech PS/2 TrackPoint"; >- tp_dev->id.bustype = BUS_I8042; >- tp_dev->id.vendor = 0x0002; >- tp_dev->id.product = PSMOUSE_ELANTECH; >- tp_dev->id.version = 0x0000; >- tp_dev->dev.parent = &psmouse->ps2dev.serio->dev; >- tp_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); >- tp_dev->relbit[BIT_WORD(REL_X)] = >- BIT_MASK(REL_X) | BIT_MASK(REL_Y); >- tp_dev->keybit[BIT_WORD(BTN_LEFT)] = >- BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | >- BIT_MASK(BTN_RIGHT); >- >- __set_bit(INPUT_PROP_POINTER, tp_dev->propbit); >- __set_bit(INPUT_PROP_POINTING_STICK, tp_dev->propbit); >- >- error = input_register_device(etd->tp_dev); >- if (error < 0) >- goto init_fail_tp_reg; >- } >- > psmouse->protocol_handler = elantech_process_byte; > psmouse->disconnect = elantech_disconnect; > psmouse->reconnect = elantech_reconnect; > psmouse->pktsize = etd->hw_version > 1 ? 6 : 4; > > return 0; >- init_fail_tp_reg: >- input_free_device(tp_dev); >- init_fail_tp_alloc: >- sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, >- &elantech_attr_group); >+ > init_fail: >- psmouse_reset(psmouse); > kfree(etd); >- return error; >+ return -1; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 883192
:
595041
|
600177
|
654990
| 654999 |
655000
|
655015
|
655018
|
660360