Attachment 'elantech.c.patch'
Download 1 --- https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/input/mouse/elantech.c?h=linux-3.13.y
2 +++ https://github.com/HuayraLinux/elantech-marble-dkms/raw/master/src/elantech.c
3 @@ -480,6 +480,25 @@
4 input_sync(dev);
5 }
6
7 +static void elantech_report_relative_v3(struct psmouse *psmouse)
8 +{
9 + struct input_dev *dev = psmouse->dev;
10 + unsigned char *packet = psmouse->packet;
11 + int rel_x=0,rel_y=0;
12 +
13 + input_report_rel(dev, REL_WHEEL, -(signed char)packet[3]);
14 +
15 + rel_x = (int) packet[1] - (int) ((packet[0] << 4) & 0x100);
16 + rel_y = (int) ((packet[0] << 3) & 0x100) - (int) packet[2];
17 +
18 + input_report_key(dev, BTN_LEFT, packet[0] & 1);
19 + input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1);
20 + input_report_rel(dev, REL_X, rel_x);
21 + input_report_rel(dev, REL_Y, rel_y);
22 +
23 + input_sync(dev);
24 +}
25 +
26 static void elantech_input_sync_v4(struct psmouse *psmouse)
27 {
28 struct input_dev *dev = psmouse->dev;
29 @@ -775,8 +794,9 @@
30 break;
31
32 case 3:
33 - packet_type = elantech_packet_check_v3(psmouse);
34 + //packet_type = elantech_packet_check_v3(psmouse);
35 /* ignore debounce */
36 + /*
37 if (packet_type == PACKET_DEBOUNCE)
38 return PSMOUSE_FULL_PACKET;
39
40 @@ -784,6 +804,8 @@
41 return PSMOUSE_BAD_DATA;
42
43 elantech_report_absolute_v3(psmouse, packet_type);
44 + */
45 + elantech_report_relative_v3(psmouse);
46 break;
47
48 case 4:
49 @@ -799,14 +821,15 @@
50 }
51
52 /*
53 - * Put the touchpad into absolute mode
54 + * Put the touchpad into absolute/relative mode
55 */
56 -static int elantech_set_absolute_mode(struct psmouse *psmouse)
57 +static int elantech_set_mode(struct psmouse *psmouse)
58 {
59 struct elantech_data *etd = psmouse->private;
60 unsigned char val;
61 int tries = ETP_READ_BACK_TRIES;
62 int rc = 0;
63 + unsigned char param[3];
64
65 switch (etd->hw_version) {
66 case 1:
67 @@ -831,11 +854,27 @@
68 break;
69
70 case 3:
71 - etd->reg_10 = 0x0b;
72 + /*disable set abs mode, only using rel mode*/
73 + /*etd->reg_10 = 0x0b;
74 if (elantech_write_reg(psmouse, 0x10, etd->reg_10))
75 rc = -1;
76 + break;*/
77 + param[0]=0xc8;
78 + param[1]=0x64;
79 + param[2]=0x50;
80 +
81 + if(elantech_ps2_command(psmouse, ¶m[0], PSMOUSE_CMD_SETRATE)||
82 + elantech_ps2_command(psmouse, ¶m[1], PSMOUSE_CMD_SETRATE)||
83 + elantech_ps2_command(psmouse, ¶m[2], PSMOUSE_CMD_SETRATE)||
84 + elantech_ps2_command(psmouse, param, PSMOUSE_CMD_GETID))
85 + {
86 + rc = -1;
87 + }
88
89 - break;
90 + psmouse->set_rate(psmouse,0x64);
91 + psmouse->set_resolution(psmouse,200);
92 +
93 + return rc;
94
95 case 4:
96 etd->reg_07 = 0x01;
97 @@ -1037,16 +1076,23 @@
98
99 __set_bit(INPUT_PROP_POINTER, dev->propbit);
100 __set_bit(EV_KEY, dev->evbit);
101 - __set_bit(EV_ABS, dev->evbit);
102 - __clear_bit(EV_REL, dev->evbit);
103
104 __set_bit(BTN_LEFT, dev->keybit);
105 __set_bit(BTN_RIGHT, dev->keybit);
106 -
107 - __set_bit(BTN_TOUCH, dev->keybit);
108 - __set_bit(BTN_TOOL_FINGER, dev->keybit);
109 - __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
110 - __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
111 +
112 + if (etd->hw_version != 3) {
113 + __set_bit(EV_ABS, dev->evbit);
114 + __clear_bit(EV_REL, dev->evbit);
115 + __set_bit(BTN_TOUCH, dev->keybit);
116 + __set_bit(BTN_TOOL_FINGER, dev->keybit);
117 + __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
118 + __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
119 + } else {
120 + __set_bit(EV_REL, dev->evbit);
121 + __set_bit(REL_X, dev->relbit);
122 + __set_bit(REL_Y, dev->relbit);
123 + __set_bit(REL_WHEEL, dev->relbit);
124 + }
125
126 switch (etd->hw_version) {
127 case 1:
128 @@ -1063,8 +1109,20 @@
129 case 2:
130 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
131 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
132 - /* fall through */
133 + input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
134 + input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0);
135 + if (etd->reports_pressure) {
136 + input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2,
137 + ETP_PMAX_V2, 0, 0);
138 + input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2,
139 + ETP_WMAX_V2, 0, 0);
140 + }
141 + input_mt_init_slots(dev, 2, 0);
142 + input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
143 + input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
144 + break;
145 case 3:
146 + /*
147 if (etd->hw_version == 3)
148 elantech_set_buttonpad_prop(psmouse);
149 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
150 @@ -1078,6 +1136,7 @@
151 input_mt_init_slots(dev, 2, 0);
152 input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
153 input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
154 + */
155 break;
156
157 case 4:
158 @@ -1321,7 +1380,8 @@
159 if (elantech_detect(psmouse, 0))
160 return -1;
161
162 - if (elantech_set_absolute_mode(psmouse)) {
163 +
164 + if (elantech_set_mode(psmouse)) {
165 psmouse_err(psmouse,
166 "failed to put touchpad back into absolute mode.\n");
167 return -1;
168 @@ -1438,7 +1498,7 @@
169 etd->capabilities[0], etd->capabilities[1],
170 etd->capabilities[2]);
171
172 - if (elantech_set_absolute_mode(psmouse)) {
173 + if (elantech_set_mode(psmouse)) {
174 psmouse_err(psmouse,
175 "failed to put touchpad into absolute mode.\n");
176 goto init_fail;
177 @@ -1461,8 +1521,8 @@
178 psmouse->protocol_handler = elantech_process_byte;
179 psmouse->disconnect = elantech_disconnect;
180 psmouse->reconnect = elantech_reconnect;
181 - psmouse->pktsize = etd->hw_version > 1 ? 6 : 4;
182 -
183 + //psmouse->pktsize = etd->hw_version > 1 ? 6 : 4;
184 + psmouse->pktsize = 4;
185 return 0;
186
187 init_fail:
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.