diff options
-rw-r--r-- | Documentation/input/multi-touch-protocol.txt | 118 | ||||
-rw-r--r-- | drivers/input/input-mt.c | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 463 | ||||
-rw-r--r-- | include/linux/input.h | 8 |
4 files changed, 339 insertions, 252 deletions
diff --git a/Documentation/input/multi-touch-protocol.txt b/Documentation/input/multi-touch-protocol.txt index 543101c5bf26..2c179613f81b 100644 --- a/Documentation/input/multi-touch-protocol.txt +++ b/Documentation/input/multi-touch-protocol.txt | |||
@@ -162,26 +162,48 @@ are divided into categories, to allow for partial implementation. The | |||
162 | minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which | 162 | minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which |
163 | allows for multiple contacts to be tracked. If the device supports it, the | 163 | allows for multiple contacts to be tracked. If the device supports it, the |
164 | ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size | 164 | ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size |
165 | of the contact area and approaching contact, respectively. | 165 | of the contact area and approaching tool, respectively. |
166 | 166 | ||
167 | The TOUCH and WIDTH parameters have a geometrical interpretation; imagine | 167 | The TOUCH and WIDTH parameters have a geometrical interpretation; imagine |
168 | looking through a window at someone gently holding a finger against the | 168 | looking through a window at someone gently holding a finger against the |
169 | glass. You will see two regions, one inner region consisting of the part | 169 | glass. You will see two regions, one inner region consisting of the part |
170 | of the finger actually touching the glass, and one outer region formed by | 170 | of the finger actually touching the glass, and one outer region formed by |
171 | the perimeter of the finger. The diameter of the inner region is the | 171 | the perimeter of the finger. The center of the touching region (a) is |
172 | ABS_MT_TOUCH_MAJOR, the diameter of the outer region is | 172 | ABS_MT_POSITION_X/Y and the center of the approaching finger (b) is |
173 | ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger harder | 173 | ABS_MT_TOOL_X/Y. The touch diameter is ABS_MT_TOUCH_MAJOR and the finger |
174 | against the glass. The inner region will increase, and in general, the | 174 | diameter is ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger |
175 | ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller than | 175 | harder against the glass. The touch region will increase, and in general, |
176 | unity, is related to the contact pressure. For pressure-based devices, | 176 | the ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller |
177 | than unity, is related to the contact pressure. For pressure-based devices, | ||
177 | ABS_MT_PRESSURE may be used to provide the pressure on the contact area | 178 | ABS_MT_PRESSURE may be used to provide the pressure on the contact area |
178 | instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to | 179 | instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to |
179 | indicate the distance between the contact and the surface. | 180 | indicate the distance between the contact and the surface. |
180 | 181 | ||
181 | In addition to the MAJOR parameters, the oval shape of the contact can be | 182 | |
182 | described by adding the MINOR parameters, such that MAJOR and MINOR are the | 183 | Linux MT Win8 |
183 | major and minor axis of an ellipse. Finally, the orientation of the oval | 184 | __________ _______________________ |
184 | shape can be describe with the ORIENTATION parameter. | 185 | / \ | | |
186 | / \ | | | ||
187 | / ____ \ | | | ||
188 | / / \ \ | | | ||
189 | \ \ a \ \ | a | | ||
190 | \ \____/ \ | | | ||
191 | \ \ | | | ||
192 | \ b \ | b | | ||
193 | \ \ | | | ||
194 | \ \ | | | ||
195 | \ \ | | | ||
196 | \ / | | | ||
197 | \ / | | | ||
198 | \ / | | | ||
199 | \__________/ |_______________________| | ||
200 | |||
201 | |||
202 | In addition to the MAJOR parameters, the oval shape of the touch and finger | ||
203 | regions can be described by adding the MINOR parameters, such that MAJOR | ||
204 | and MINOR are the major and minor axis of an ellipse. The orientation of | ||
205 | the touch ellipse can be described with the ORIENTATION parameter, and the | ||
206 | direction of the finger ellipse is given by the vector (a - b). | ||
185 | 207 | ||
186 | For type A devices, further specification of the touch shape is possible | 208 | For type A devices, further specification of the touch shape is possible |
187 | via ABS_MT_BLOB_ID. | 209 | via ABS_MT_BLOB_ID. |
@@ -224,7 +246,7 @@ tool. Omit if circular [4]. | |||
224 | The above four values can be used to derive additional information about | 246 | The above four values can be used to derive additional information about |
225 | the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates | 247 | the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates |
226 | the notion of pressure. The fingers of the hand and the palm all have | 248 | the notion of pressure. The fingers of the hand and the palm all have |
227 | different characteristic widths [1]. | 249 | different characteristic widths. |
228 | 250 | ||
229 | ABS_MT_PRESSURE | 251 | ABS_MT_PRESSURE |
230 | 252 | ||
@@ -240,17 +262,24 @@ the contact is hovering above the surface. | |||
240 | 262 | ||
241 | ABS_MT_ORIENTATION | 263 | ABS_MT_ORIENTATION |
242 | 264 | ||
243 | The orientation of the ellipse. The value should describe a signed quarter | 265 | The orientation of the touching ellipse. The value should describe a signed |
244 | of a revolution clockwise around the touch center. The signed value range | 266 | quarter of a revolution clockwise around the touch center. The signed value |
245 | is arbitrary, but zero should be returned for a finger aligned along the Y | 267 | range is arbitrary, but zero should be returned for an ellipse aligned with |
246 | axis of the surface, a negative value when finger is turned to the left, and | 268 | the Y axis of the surface, a negative value when the ellipse is turned to |
247 | a positive value when finger turned to the right. When completely aligned with | 269 | the left, and a positive value when the ellipse is turned to the |
248 | the X axis, the range max should be returned. Orientation can be omitted | 270 | right. When completely aligned with the X axis, the range max should be |
249 | if the touching object is circular, or if the information is not available | 271 | returned. |
250 | in the kernel driver. Partial orientation support is possible if the device | 272 | |
251 | can distinguish between the two axis, but not (uniquely) any values in | 273 | Touch ellipsis are symmetrical by default. For devices capable of true 360 |
252 | between. In such cases, the range of ABS_MT_ORIENTATION should be [0, 1] | 274 | degree orientation, the reported orientation must exceed the range max to |
253 | [4]. | 275 | indicate more than a quarter of a revolution. For an upside-down finger, |
276 | range max * 2 should be returned. | ||
277 | |||
278 | Orientation can be omitted if the touch area is circular, or if the | ||
279 | information is not available in the kernel driver. Partial orientation | ||
280 | support is possible if the device can distinguish between the two axis, but | ||
281 | not (uniquely) any values in between. In such cases, the range of | ||
282 | ABS_MT_ORIENTATION should be [0, 1] [4]. | ||
254 | 283 | ||
255 | ABS_MT_POSITION_X | 284 | ABS_MT_POSITION_X |
256 | 285 | ||
@@ -260,6 +289,23 @@ ABS_MT_POSITION_Y | |||
260 | 289 | ||
261 | The surface Y coordinate of the center of the touching ellipse. | 290 | The surface Y coordinate of the center of the touching ellipse. |
262 | 291 | ||
292 | ABS_MT_TOOL_X | ||
293 | |||
294 | The surface X coordinate of the center of the approaching tool. Omit if | ||
295 | the device cannot distinguish between the intended touch point and the | ||
296 | tool itself. | ||
297 | |||
298 | ABS_MT_TOOL_Y | ||
299 | |||
300 | The surface Y coordinate of the center of the approaching tool. Omit if the | ||
301 | device cannot distinguish between the intended touch point and the tool | ||
302 | itself. | ||
303 | |||
304 | The four position values can be used to separate the position of the touch | ||
305 | from the position of the tool. If both positions are present, the major | ||
306 | tool axis points towards the touch point [1]. Otherwise, the tool axes are | ||
307 | aligned with the touch axes. | ||
308 | |||
263 | ABS_MT_TOOL_TYPE | 309 | ABS_MT_TOOL_TYPE |
264 | 310 | ||
265 | The type of approaching tool. A lot of kernel drivers cannot distinguish | 311 | The type of approaching tool. A lot of kernel drivers cannot distinguish |
@@ -305,6 +351,28 @@ The range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that | |||
305 | the device can distinguish between a finger along the Y axis (0) and a | 351 | the device can distinguish between a finger along the Y axis (0) and a |
306 | finger along the X axis (1). | 352 | finger along the X axis (1). |
307 | 353 | ||
354 | For win8 devices with both T and C coordinates, the position mapping is | ||
355 | |||
356 | ABS_MT_POSITION_X := T_X | ||
357 | ABS_MT_POSITION_Y := T_Y | ||
358 | ABS_MT_TOOL_X := C_X | ||
359 | ABS_MT_TOOL_X := C_Y | ||
360 | |||
361 | Unfortunately, there is not enough information to specify both the touching | ||
362 | ellipse and the tool ellipse, so one has to resort to approximations. One | ||
363 | simple scheme, which is compatible with earlier usage, is: | ||
364 | |||
365 | ABS_MT_TOUCH_MAJOR := min(X, Y) | ||
366 | ABS_MT_TOUCH_MINOR := <not used> | ||
367 | ABS_MT_ORIENTATION := <not used> | ||
368 | ABS_MT_WIDTH_MAJOR := min(X, Y) + distance(T, C) | ||
369 | ABS_MT_WIDTH_MINOR := min(X, Y) | ||
370 | |||
371 | Rationale: We have no information about the orientation of the touching | ||
372 | ellipse, so approximate it with an inscribed circle instead. The tool | ||
373 | ellipse should align with the the vector (T - C), so the diameter must | ||
374 | increase with distance(T, C). Finally, assume that the touch diameter is | ||
375 | equal to the tool thickness, and we arrive at the formulas above. | ||
308 | 376 | ||
309 | Finger Tracking | 377 | Finger Tracking |
310 | --------------- | 378 | --------------- |
@@ -338,9 +406,7 @@ subsequent events of the same type refer to different fingers. | |||
338 | For example usage of the type A protocol, see the bcm5974 driver. For | 406 | For example usage of the type A protocol, see the bcm5974 driver. For |
339 | example usage of the type B protocol, see the hid-egalax driver. | 407 | example usage of the type B protocol, see the hid-egalax driver. |
340 | 408 | ||
341 | [1] With the extension ABS_MT_APPROACH_X and ABS_MT_APPROACH_Y, the | 409 | [1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt. |
342 | difference between the contact position and the approaching tool position | ||
343 | could be used to derive tilt. | ||
344 | [2] The list can of course be extended. | 410 | [2] The list can of course be extended. |
345 | [3] The mtdev project: http://bitmath.org/code/mtdev/. | 411 | [3] The mtdev project: http://bitmath.org/code/mtdev/. |
346 | [4] See the section on event computation. | 412 | [4] See the section on event computation. |
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index f658086fbbe0..70a16c7da8cc 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(input_mt_report_finger_count); | |||
135 | */ | 135 | */ |
136 | void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) | 136 | void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) |
137 | { | 137 | { |
138 | struct input_mt_slot *oldest = 0; | 138 | struct input_mt_slot *oldest = NULL; |
139 | int oldid = dev->trkid; | 139 | int oldid = dev->trkid; |
140 | int count = 0; | 140 | int count = 0; |
141 | int i; | 141 | int i; |
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 25fd0561a17d..4623cc69fc60 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #define MXT_FW_NAME "maxtouch.fw" | 36 | #define MXT_FW_NAME "maxtouch.fw" |
37 | 37 | ||
38 | /* Registers */ | 38 | /* Registers */ |
39 | #define MXT_INFO 0x00 | ||
39 | #define MXT_FAMILY_ID 0x00 | 40 | #define MXT_FAMILY_ID 0x00 |
40 | #define MXT_VARIANT_ID 0x01 | 41 | #define MXT_VARIANT_ID 0x01 |
41 | #define MXT_VERSION 0x02 | 42 | #define MXT_VERSION 0x02 |
@@ -194,6 +195,7 @@ | |||
194 | #define MXT_BOOT_STATUS_MASK 0x3f | 195 | #define MXT_BOOT_STATUS_MASK 0x3f |
195 | 196 | ||
196 | /* Touch status */ | 197 | /* Touch status */ |
198 | #define MXT_UNGRIP (1 << 0) | ||
197 | #define MXT_SUPPRESS (1 << 1) | 199 | #define MXT_SUPPRESS (1 << 1) |
198 | #define MXT_AMP (1 << 2) | 200 | #define MXT_AMP (1 << 2) |
199 | #define MXT_VECTOR (1 << 3) | 201 | #define MXT_VECTOR (1 << 3) |
@@ -210,8 +212,6 @@ | |||
210 | /* Touchscreen absolute values */ | 212 | /* Touchscreen absolute values */ |
211 | #define MXT_MAX_AREA 0xff | 213 | #define MXT_MAX_AREA 0xff |
212 | 214 | ||
213 | #define MXT_MAX_FINGER 10 | ||
214 | |||
215 | struct mxt_info { | 215 | struct mxt_info { |
216 | u8 family_id; | 216 | u8 family_id; |
217 | u8 variant_id; | 217 | u8 variant_id; |
@@ -225,44 +225,37 @@ struct mxt_info { | |||
225 | struct mxt_object { | 225 | struct mxt_object { |
226 | u8 type; | 226 | u8 type; |
227 | u16 start_address; | 227 | u16 start_address; |
228 | u8 size; | 228 | u8 size; /* Size of each instance - 1 */ |
229 | u8 instances; | 229 | u8 instances; /* Number of instances - 1 */ |
230 | u8 num_report_ids; | 230 | u8 num_report_ids; |
231 | 231 | } __packed; | |
232 | /* to map object and message */ | ||
233 | u8 max_reportid; | ||
234 | }; | ||
235 | 232 | ||
236 | struct mxt_message { | 233 | struct mxt_message { |
237 | u8 reportid; | 234 | u8 reportid; |
238 | u8 message[7]; | 235 | u8 message[7]; |
239 | }; | 236 | }; |
240 | 237 | ||
241 | struct mxt_finger { | ||
242 | int status; | ||
243 | int x; | ||
244 | int y; | ||
245 | int area; | ||
246 | int pressure; | ||
247 | }; | ||
248 | |||
249 | /* Each client has this additional data */ | 238 | /* Each client has this additional data */ |
250 | struct mxt_data { | 239 | struct mxt_data { |
251 | struct i2c_client *client; | 240 | struct i2c_client *client; |
252 | struct input_dev *input_dev; | 241 | struct input_dev *input_dev; |
242 | char phys[64]; /* device physical location */ | ||
253 | const struct mxt_platform_data *pdata; | 243 | const struct mxt_platform_data *pdata; |
254 | struct mxt_object *object_table; | 244 | struct mxt_object *object_table; |
255 | struct mxt_info info; | 245 | struct mxt_info info; |
256 | struct mxt_finger finger[MXT_MAX_FINGER]; | ||
257 | unsigned int irq; | 246 | unsigned int irq; |
258 | unsigned int max_x; | 247 | unsigned int max_x; |
259 | unsigned int max_y; | 248 | unsigned int max_y; |
249 | |||
250 | /* Cached parameters from object table */ | ||
251 | u8 T6_reportid; | ||
252 | u8 T9_reportid_min; | ||
253 | u8 T9_reportid_max; | ||
260 | }; | 254 | }; |
261 | 255 | ||
262 | static bool mxt_object_readable(unsigned int type) | 256 | static bool mxt_object_readable(unsigned int type) |
263 | { | 257 | { |
264 | switch (type) { | 258 | switch (type) { |
265 | case MXT_GEN_MESSAGE_T5: | ||
266 | case MXT_GEN_COMMAND_T6: | 259 | case MXT_GEN_COMMAND_T6: |
267 | case MXT_GEN_POWER_T7: | 260 | case MXT_GEN_POWER_T7: |
268 | case MXT_GEN_ACQUIRE_T8: | 261 | case MXT_GEN_ACQUIRE_T8: |
@@ -396,6 +389,7 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
396 | { | 389 | { |
397 | struct i2c_msg xfer[2]; | 390 | struct i2c_msg xfer[2]; |
398 | u8 buf[2]; | 391 | u8 buf[2]; |
392 | int ret; | ||
399 | 393 | ||
400 | buf[0] = reg & 0xff; | 394 | buf[0] = reg & 0xff; |
401 | buf[1] = (reg >> 8) & 0xff; | 395 | buf[1] = (reg >> 8) & 0xff; |
@@ -412,12 +406,17 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
412 | xfer[1].len = len; | 406 | xfer[1].len = len; |
413 | xfer[1].buf = val; | 407 | xfer[1].buf = val; |
414 | 408 | ||
415 | if (i2c_transfer(client->adapter, xfer, 2) != 2) { | 409 | ret = i2c_transfer(client->adapter, xfer, 2); |
416 | dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); | 410 | if (ret == 2) { |
417 | return -EIO; | 411 | ret = 0; |
412 | } else { | ||
413 | if (ret >= 0) | ||
414 | ret = -EIO; | ||
415 | dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", | ||
416 | __func__, ret); | ||
418 | } | 417 | } |
419 | 418 | ||
420 | return 0; | 419 | return ret; |
421 | } | 420 | } |
422 | 421 | ||
423 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | 422 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) |
@@ -425,27 +424,39 @@ static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | |||
425 | return __mxt_read_reg(client, reg, 1, val); | 424 | return __mxt_read_reg(client, reg, 1, val); |
426 | } | 425 | } |
427 | 426 | ||
428 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) | 427 | static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, |
428 | const void *val) | ||
429 | { | 429 | { |
430 | u8 buf[3]; | 430 | u8 *buf; |
431 | size_t count; | ||
432 | int ret; | ||
433 | |||
434 | count = len + 2; | ||
435 | buf = kmalloc(count, GFP_KERNEL); | ||
436 | if (!buf) | ||
437 | return -ENOMEM; | ||
431 | 438 | ||
432 | buf[0] = reg & 0xff; | 439 | buf[0] = reg & 0xff; |
433 | buf[1] = (reg >> 8) & 0xff; | 440 | buf[1] = (reg >> 8) & 0xff; |
434 | buf[2] = val; | 441 | memcpy(&buf[2], val, len); |
435 | 442 | ||
436 | if (i2c_master_send(client, buf, 3) != 3) { | 443 | ret = i2c_master_send(client, buf, count); |
437 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | 444 | if (ret == count) { |
438 | return -EIO; | 445 | ret = 0; |
446 | } else { | ||
447 | if (ret >= 0) | ||
448 | ret = -EIO; | ||
449 | dev_err(&client->dev, "%s: i2c send failed (%d)\n", | ||
450 | __func__, ret); | ||
439 | } | 451 | } |
440 | 452 | ||
441 | return 0; | 453 | kfree(buf); |
454 | return ret; | ||
442 | } | 455 | } |
443 | 456 | ||
444 | static int mxt_read_object_table(struct i2c_client *client, | 457 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) |
445 | u16 reg, u8 *object_buf) | ||
446 | { | 458 | { |
447 | return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE, | 459 | return __mxt_write_reg(client, reg, 1, &val); |
448 | object_buf); | ||
449 | } | 460 | } |
450 | 461 | ||
451 | static struct mxt_object * | 462 | static struct mxt_object * |
@@ -479,20 +490,6 @@ static int mxt_read_message(struct mxt_data *data, | |||
479 | sizeof(struct mxt_message), message); | 490 | sizeof(struct mxt_message), message); |
480 | } | 491 | } |
481 | 492 | ||
482 | static int mxt_read_object(struct mxt_data *data, | ||
483 | u8 type, u8 offset, u8 *val) | ||
484 | { | ||
485 | struct mxt_object *object; | ||
486 | u16 reg; | ||
487 | |||
488 | object = mxt_get_object(data, type); | ||
489 | if (!object) | ||
490 | return -EINVAL; | ||
491 | |||
492 | reg = object->start_address; | ||
493 | return __mxt_read_reg(data->client, reg + offset, 1, val); | ||
494 | } | ||
495 | |||
496 | static int mxt_write_object(struct mxt_data *data, | 493 | static int mxt_write_object(struct mxt_data *data, |
497 | u8 type, u8 offset, u8 val) | 494 | u8 type, u8 offset, u8 val) |
498 | { | 495 | { |
@@ -507,75 +504,17 @@ static int mxt_write_object(struct mxt_data *data, | |||
507 | return mxt_write_reg(data->client, reg + offset, val); | 504 | return mxt_write_reg(data->client, reg + offset, val); |
508 | } | 505 | } |
509 | 506 | ||
510 | static void mxt_input_report(struct mxt_data *data, int single_id) | ||
511 | { | ||
512 | struct mxt_finger *finger = data->finger; | ||
513 | struct input_dev *input_dev = data->input_dev; | ||
514 | int status = finger[single_id].status; | ||
515 | int finger_num = 0; | ||
516 | int id; | ||
517 | |||
518 | for (id = 0; id < MXT_MAX_FINGER; id++) { | ||
519 | if (!finger[id].status) | ||
520 | continue; | ||
521 | |||
522 | input_mt_slot(input_dev, id); | ||
523 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, | ||
524 | finger[id].status != MXT_RELEASE); | ||
525 | |||
526 | if (finger[id].status != MXT_RELEASE) { | ||
527 | finger_num++; | ||
528 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
529 | finger[id].area); | ||
530 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
531 | finger[id].x); | ||
532 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
533 | finger[id].y); | ||
534 | input_report_abs(input_dev, ABS_MT_PRESSURE, | ||
535 | finger[id].pressure); | ||
536 | } else { | ||
537 | finger[id].status = 0; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); | ||
542 | |||
543 | if (status != MXT_RELEASE) { | ||
544 | input_report_abs(input_dev, ABS_X, finger[single_id].x); | ||
545 | input_report_abs(input_dev, ABS_Y, finger[single_id].y); | ||
546 | input_report_abs(input_dev, | ||
547 | ABS_PRESSURE, finger[single_id].pressure); | ||
548 | } | ||
549 | |||
550 | input_sync(input_dev); | ||
551 | } | ||
552 | |||
553 | static void mxt_input_touchevent(struct mxt_data *data, | 507 | static void mxt_input_touchevent(struct mxt_data *data, |
554 | struct mxt_message *message, int id) | 508 | struct mxt_message *message, int id) |
555 | { | 509 | { |
556 | struct mxt_finger *finger = data->finger; | ||
557 | struct device *dev = &data->client->dev; | 510 | struct device *dev = &data->client->dev; |
558 | u8 status = message->message[0]; | 511 | u8 status = message->message[0]; |
512 | struct input_dev *input_dev = data->input_dev; | ||
559 | int x; | 513 | int x; |
560 | int y; | 514 | int y; |
561 | int area; | 515 | int area; |
562 | int pressure; | 516 | int pressure; |
563 | 517 | ||
564 | /* Check the touch is present on the screen */ | ||
565 | if (!(status & MXT_DETECT)) { | ||
566 | if (status & MXT_RELEASE) { | ||
567 | dev_dbg(dev, "[%d] released\n", id); | ||
568 | |||
569 | finger[id].status = MXT_RELEASE; | ||
570 | mxt_input_report(data, id); | ||
571 | } | ||
572 | return; | ||
573 | } | ||
574 | |||
575 | /* Check only AMP detection */ | ||
576 | if (!(status & (MXT_PRESS | MXT_MOVE))) | ||
577 | return; | ||
578 | |||
579 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); | 518 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); |
580 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); | 519 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); |
581 | if (data->max_x < 1024) | 520 | if (data->max_x < 1024) |
@@ -586,30 +525,50 @@ static void mxt_input_touchevent(struct mxt_data *data, | |||
586 | area = message->message[4]; | 525 | area = message->message[4]; |
587 | pressure = message->message[5]; | 526 | pressure = message->message[5]; |
588 | 527 | ||
589 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | 528 | dev_dbg(dev, |
590 | status & MXT_MOVE ? "moved" : "pressed", | 529 | "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u\n", |
591 | x, y, area); | 530 | id, |
531 | (status & MXT_DETECT) ? 'D' : '.', | ||
532 | (status & MXT_PRESS) ? 'P' : '.', | ||
533 | (status & MXT_RELEASE) ? 'R' : '.', | ||
534 | (status & MXT_MOVE) ? 'M' : '.', | ||
535 | (status & MXT_VECTOR) ? 'V' : '.', | ||
536 | (status & MXT_AMP) ? 'A' : '.', | ||
537 | (status & MXT_SUPPRESS) ? 'S' : '.', | ||
538 | (status & MXT_UNGRIP) ? 'U' : '.', | ||
539 | x, y, area, pressure); | ||
540 | |||
541 | input_mt_slot(input_dev, id); | ||
542 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, | ||
543 | status & MXT_DETECT); | ||
544 | |||
545 | if (status & MXT_DETECT) { | ||
546 | input_report_abs(input_dev, ABS_MT_POSITION_X, x); | ||
547 | input_report_abs(input_dev, ABS_MT_POSITION_Y, y); | ||
548 | input_report_abs(input_dev, ABS_MT_PRESSURE, pressure); | ||
549 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area); | ||
550 | } | ||
551 | } | ||
592 | 552 | ||
593 | finger[id].status = status & MXT_MOVE ? | 553 | static unsigned mxt_extract_T6_csum(const u8 *csum) |
594 | MXT_MOVE : MXT_PRESS; | 554 | { |
595 | finger[id].x = x; | 555 | return csum[0] | (csum[1] << 8) | (csum[2] << 16); |
596 | finger[id].y = y; | 556 | } |
597 | finger[id].area = area; | ||
598 | finger[id].pressure = pressure; | ||
599 | 557 | ||
600 | mxt_input_report(data, id); | 558 | static bool mxt_is_T9_message(struct mxt_data *data, struct mxt_message *msg) |
559 | { | ||
560 | u8 id = msg->reportid; | ||
561 | return (id >= data->T9_reportid_min && id <= data->T9_reportid_max); | ||
601 | } | 562 | } |
602 | 563 | ||
603 | static irqreturn_t mxt_interrupt(int irq, void *dev_id) | 564 | static irqreturn_t mxt_interrupt(int irq, void *dev_id) |
604 | { | 565 | { |
605 | struct mxt_data *data = dev_id; | 566 | struct mxt_data *data = dev_id; |
606 | struct mxt_message message; | 567 | struct mxt_message message; |
607 | struct mxt_object *object; | 568 | const u8 *payload = &message.message[0]; |
608 | struct device *dev = &data->client->dev; | 569 | struct device *dev = &data->client->dev; |
609 | int id; | ||
610 | u8 reportid; | 570 | u8 reportid; |
611 | u8 max_reportid; | 571 | bool update_input = false; |
612 | u8 min_reportid; | ||
613 | 572 | ||
614 | do { | 573 | do { |
615 | if (mxt_read_message(data, &message)) { | 574 | if (mxt_read_message(data, &message)) { |
@@ -619,21 +578,25 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) | |||
619 | 578 | ||
620 | reportid = message.reportid; | 579 | reportid = message.reportid; |
621 | 580 | ||
622 | /* whether reportid is thing of MXT_TOUCH_MULTI_T9 */ | 581 | if (reportid == data->T6_reportid) { |
623 | object = mxt_get_object(data, MXT_TOUCH_MULTI_T9); | 582 | u8 status = payload[0]; |
624 | if (!object) | 583 | unsigned csum = mxt_extract_T6_csum(&payload[1]); |
625 | goto end; | 584 | dev_dbg(dev, "Status: %02x Config Checksum: %06x\n", |
626 | 585 | status, csum); | |
627 | max_reportid = object->max_reportid; | 586 | } else if (mxt_is_T9_message(data, &message)) { |
628 | min_reportid = max_reportid - object->num_report_ids + 1; | 587 | int id = reportid - data->T9_reportid_min; |
629 | id = reportid - min_reportid; | ||
630 | |||
631 | if (reportid >= min_reportid && reportid <= max_reportid) | ||
632 | mxt_input_touchevent(data, &message, id); | 588 | mxt_input_touchevent(data, &message, id); |
633 | else | 589 | update_input = true; |
590 | } else { | ||
634 | mxt_dump_message(dev, &message); | 591 | mxt_dump_message(dev, &message); |
592 | } | ||
635 | } while (reportid != 0xff); | 593 | } while (reportid != 0xff); |
636 | 594 | ||
595 | if (update_input) { | ||
596 | input_mt_report_pointer_emulation(data->input_dev, false); | ||
597 | input_sync(data->input_dev); | ||
598 | } | ||
599 | |||
637 | end: | 600 | end: |
638 | return IRQ_HANDLED; | 601 | return IRQ_HANDLED; |
639 | } | 602 | } |
@@ -644,7 +607,8 @@ static int mxt_check_reg_init(struct mxt_data *data) | |||
644 | struct mxt_object *object; | 607 | struct mxt_object *object; |
645 | struct device *dev = &data->client->dev; | 608 | struct device *dev = &data->client->dev; |
646 | int index = 0; | 609 | int index = 0; |
647 | int i, j, config_offset; | 610 | int i, size; |
611 | int ret; | ||
648 | 612 | ||
649 | if (!pdata->config) { | 613 | if (!pdata->config) { |
650 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); | 614 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); |
@@ -657,18 +621,17 @@ static int mxt_check_reg_init(struct mxt_data *data) | |||
657 | if (!mxt_object_writable(object->type)) | 621 | if (!mxt_object_writable(object->type)) |
658 | continue; | 622 | continue; |
659 | 623 | ||
660 | for (j = 0; | 624 | size = (object->size + 1) * (object->instances + 1); |
661 | j < (object->size + 1) * (object->instances + 1); | 625 | if (index + size > pdata->config_length) { |
662 | j++) { | 626 | dev_err(dev, "Not enough config data!\n"); |
663 | config_offset = index + j; | 627 | return -EINVAL; |
664 | if (config_offset > pdata->config_length) { | ||
665 | dev_err(dev, "Not enough config data!\n"); | ||
666 | return -EINVAL; | ||
667 | } | ||
668 | mxt_write_object(data, object->type, j, | ||
669 | pdata->config[config_offset]); | ||
670 | } | 628 | } |
671 | index += (object->size + 1) * (object->instances + 1); | 629 | |
630 | ret = __mxt_write_reg(data->client, object->start_address, | ||
631 | size, &pdata->config[index]); | ||
632 | if (ret) | ||
633 | return ret; | ||
634 | index += size; | ||
672 | } | 635 | } |
673 | 636 | ||
674 | return 0; | 637 | return 0; |
@@ -749,68 +712,76 @@ static int mxt_get_info(struct mxt_data *data) | |||
749 | struct i2c_client *client = data->client; | 712 | struct i2c_client *client = data->client; |
750 | struct mxt_info *info = &data->info; | 713 | struct mxt_info *info = &data->info; |
751 | int error; | 714 | int error; |
752 | u8 val; | ||
753 | 715 | ||
754 | error = mxt_read_reg(client, MXT_FAMILY_ID, &val); | 716 | /* Read 7-byte info block starting at address 0 */ |
717 | error = __mxt_read_reg(client, MXT_INFO, sizeof(*info), info); | ||
755 | if (error) | 718 | if (error) |
756 | return error; | 719 | return error; |
757 | info->family_id = val; | ||
758 | |||
759 | error = mxt_read_reg(client, MXT_VARIANT_ID, &val); | ||
760 | if (error) | ||
761 | return error; | ||
762 | info->variant_id = val; | ||
763 | |||
764 | error = mxt_read_reg(client, MXT_VERSION, &val); | ||
765 | if (error) | ||
766 | return error; | ||
767 | info->version = val; | ||
768 | |||
769 | error = mxt_read_reg(client, MXT_BUILD, &val); | ||
770 | if (error) | ||
771 | return error; | ||
772 | info->build = val; | ||
773 | |||
774 | error = mxt_read_reg(client, MXT_OBJECT_NUM, &val); | ||
775 | if (error) | ||
776 | return error; | ||
777 | info->object_num = val; | ||
778 | 720 | ||
779 | return 0; | 721 | return 0; |
780 | } | 722 | } |
781 | 723 | ||
782 | static int mxt_get_object_table(struct mxt_data *data) | 724 | static int mxt_get_object_table(struct mxt_data *data) |
783 | { | 725 | { |
726 | struct i2c_client *client = data->client; | ||
727 | size_t table_size; | ||
784 | int error; | 728 | int error; |
785 | int i; | 729 | int i; |
786 | u16 reg; | 730 | u8 reportid; |
787 | u8 reportid = 0; | 731 | |
788 | u8 buf[MXT_OBJECT_SIZE]; | 732 | table_size = data->info.object_num * sizeof(struct mxt_object); |
733 | error = __mxt_read_reg(client, MXT_OBJECT_START, table_size, | ||
734 | data->object_table); | ||
735 | if (error) | ||
736 | return error; | ||
789 | 737 | ||
738 | /* Valid Report IDs start counting from 1 */ | ||
739 | reportid = 1; | ||
790 | for (i = 0; i < data->info.object_num; i++) { | 740 | for (i = 0; i < data->info.object_num; i++) { |
791 | struct mxt_object *object = data->object_table + i; | 741 | struct mxt_object *object = data->object_table + i; |
742 | u8 min_id, max_id; | ||
792 | 743 | ||
793 | reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i; | 744 | le16_to_cpus(&object->start_address); |
794 | error = mxt_read_object_table(data->client, reg, buf); | ||
795 | if (error) | ||
796 | return error; | ||
797 | |||
798 | object->type = buf[0]; | ||
799 | object->start_address = (buf[2] << 8) | buf[1]; | ||
800 | object->size = buf[3]; | ||
801 | object->instances = buf[4]; | ||
802 | object->num_report_ids = buf[5]; | ||
803 | 745 | ||
804 | if (object->num_report_ids) { | 746 | if (object->num_report_ids) { |
747 | min_id = reportid; | ||
805 | reportid += object->num_report_ids * | 748 | reportid += object->num_report_ids * |
806 | (object->instances + 1); | 749 | (object->instances + 1); |
807 | object->max_reportid = reportid; | 750 | max_id = reportid - 1; |
751 | } else { | ||
752 | min_id = 0; | ||
753 | max_id = 0; | ||
754 | } | ||
755 | |||
756 | dev_dbg(&data->client->dev, | ||
757 | "Type %2d Start %3d Size %3d Instances %2d ReportIDs %3u : %3u\n", | ||
758 | object->type, object->start_address, object->size + 1, | ||
759 | object->instances + 1, min_id, max_id); | ||
760 | |||
761 | switch (object->type) { | ||
762 | case MXT_GEN_COMMAND_T6: | ||
763 | data->T6_reportid = min_id; | ||
764 | break; | ||
765 | case MXT_TOUCH_MULTI_T9: | ||
766 | data->T9_reportid_min = min_id; | ||
767 | data->T9_reportid_max = max_id; | ||
768 | break; | ||
808 | } | 769 | } |
809 | } | 770 | } |
810 | 771 | ||
811 | return 0; | 772 | return 0; |
812 | } | 773 | } |
813 | 774 | ||
775 | static void mxt_free_object_table(struct mxt_data *data) | ||
776 | { | ||
777 | kfree(data->object_table); | ||
778 | data->object_table = NULL; | ||
779 | data->T6_reportid = 0; | ||
780 | data->T9_reportid_min = 0; | ||
781 | data->T9_reportid_max = 0; | ||
782 | |||
783 | } | ||
784 | |||
814 | static int mxt_initialize(struct mxt_data *data) | 785 | static int mxt_initialize(struct mxt_data *data) |
815 | { | 786 | { |
816 | struct i2c_client *client = data->client; | 787 | struct i2c_client *client = data->client; |
@@ -833,12 +804,12 @@ static int mxt_initialize(struct mxt_data *data) | |||
833 | /* Get object table information */ | 804 | /* Get object table information */ |
834 | error = mxt_get_object_table(data); | 805 | error = mxt_get_object_table(data); |
835 | if (error) | 806 | if (error) |
836 | return error; | 807 | goto err_free_object_table; |
837 | 808 | ||
838 | /* Check register init values */ | 809 | /* Check register init values */ |
839 | error = mxt_check_reg_init(data); | 810 | error = mxt_check_reg_init(data); |
840 | if (error) | 811 | if (error) |
841 | return error; | 812 | goto err_free_object_table; |
842 | 813 | ||
843 | mxt_handle_pdata(data); | 814 | mxt_handle_pdata(data); |
844 | 815 | ||
@@ -856,25 +827,29 @@ static int mxt_initialize(struct mxt_data *data) | |||
856 | /* Update matrix size at info struct */ | 827 | /* Update matrix size at info struct */ |
857 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); | 828 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); |
858 | if (error) | 829 | if (error) |
859 | return error; | 830 | goto err_free_object_table; |
860 | info->matrix_xsize = val; | 831 | info->matrix_xsize = val; |
861 | 832 | ||
862 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); | 833 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); |
863 | if (error) | 834 | if (error) |
864 | return error; | 835 | goto err_free_object_table; |
865 | info->matrix_ysize = val; | 836 | info->matrix_ysize = val; |
866 | 837 | ||
867 | dev_info(&client->dev, | 838 | dev_info(&client->dev, |
868 | "Family ID: %d Variant ID: %d Version: %d Build: %d\n", | 839 | "Family ID: %u Variant ID: %u Major.Minor.Build: %u.%u.%02X\n", |
869 | info->family_id, info->variant_id, info->version, | 840 | info->family_id, info->variant_id, info->version >> 4, |
870 | info->build); | 841 | info->version & 0xf, info->build); |
871 | 842 | ||
872 | dev_info(&client->dev, | 843 | dev_info(&client->dev, |
873 | "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", | 844 | "Matrix X Size: %u Matrix Y Size: %u Object Num: %u\n", |
874 | info->matrix_xsize, info->matrix_ysize, | 845 | info->matrix_xsize, info->matrix_ysize, |
875 | info->object_num); | 846 | info->object_num); |
876 | 847 | ||
877 | return 0; | 848 | return 0; |
849 | |||
850 | err_free_object_table: | ||
851 | mxt_free_object_table(data); | ||
852 | return error; | ||
878 | } | 853 | } |
879 | 854 | ||
880 | static void mxt_calc_resolution(struct mxt_data *data) | 855 | static void mxt_calc_resolution(struct mxt_data *data) |
@@ -891,6 +866,44 @@ static void mxt_calc_resolution(struct mxt_data *data) | |||
891 | } | 866 | } |
892 | } | 867 | } |
893 | 868 | ||
869 | /* Firmware Version is returned as Major.Minor.Build */ | ||
870 | static ssize_t mxt_fw_version_show(struct device *dev, | ||
871 | struct device_attribute *attr, char *buf) | ||
872 | { | ||
873 | struct mxt_data *data = dev_get_drvdata(dev); | ||
874 | struct mxt_info *info = &data->info; | ||
875 | return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n", | ||
876 | info->version >> 4, info->version & 0xf, info->build); | ||
877 | } | ||
878 | |||
879 | /* Hardware Version is returned as FamilyID.VariantID */ | ||
880 | static ssize_t mxt_hw_version_show(struct device *dev, | ||
881 | struct device_attribute *attr, char *buf) | ||
882 | { | ||
883 | struct mxt_data *data = dev_get_drvdata(dev); | ||
884 | struct mxt_info *info = &data->info; | ||
885 | return scnprintf(buf, PAGE_SIZE, "%u.%u\n", | ||
886 | info->family_id, info->variant_id); | ||
887 | } | ||
888 | |||
889 | static ssize_t mxt_show_instance(char *buf, int count, | ||
890 | struct mxt_object *object, int instance, | ||
891 | const u8 *val) | ||
892 | { | ||
893 | int i; | ||
894 | |||
895 | if (object->instances > 0) | ||
896 | count += scnprintf(buf + count, PAGE_SIZE - count, | ||
897 | "Instance %u\n", instance); | ||
898 | |||
899 | for (i = 0; i < object->size + 1; i++) | ||
900 | count += scnprintf(buf + count, PAGE_SIZE - count, | ||
901 | "\t[%2u]: %02x (%d)\n", i, val[i], val[i]); | ||
902 | count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); | ||
903 | |||
904 | return count; | ||
905 | } | ||
906 | |||
894 | static ssize_t mxt_object_show(struct device *dev, | 907 | static ssize_t mxt_object_show(struct device *dev, |
895 | struct device_attribute *attr, char *buf) | 908 | struct device_attribute *attr, char *buf) |
896 | { | 909 | { |
@@ -899,43 +912,38 @@ static ssize_t mxt_object_show(struct device *dev, | |||
899 | int count = 0; | 912 | int count = 0; |
900 | int i, j; | 913 | int i, j; |
901 | int error; | 914 | int error; |
902 | u8 val; | 915 | u8 *obuf; |
903 | 916 | ||
917 | /* Pre-allocate buffer large enough to hold max sized object. */ | ||
918 | obuf = kmalloc(256, GFP_KERNEL); | ||
919 | if (!obuf) | ||
920 | return -ENOMEM; | ||
921 | |||
922 | error = 0; | ||
904 | for (i = 0; i < data->info.object_num; i++) { | 923 | for (i = 0; i < data->info.object_num; i++) { |
905 | object = data->object_table + i; | 924 | object = data->object_table + i; |
906 | 925 | ||
907 | count += snprintf(buf + count, PAGE_SIZE - count, | 926 | if (!mxt_object_readable(object->type)) |
908 | "Object[%d] (Type %d)\n", | ||
909 | i + 1, object->type); | ||
910 | if (count >= PAGE_SIZE) | ||
911 | return PAGE_SIZE - 1; | ||
912 | |||
913 | if (!mxt_object_readable(object->type)) { | ||
914 | count += snprintf(buf + count, PAGE_SIZE - count, | ||
915 | "\n"); | ||
916 | if (count >= PAGE_SIZE) | ||
917 | return PAGE_SIZE - 1; | ||
918 | continue; | 927 | continue; |
919 | } | ||
920 | 928 | ||
921 | for (j = 0; j < object->size + 1; j++) { | 929 | count += scnprintf(buf + count, PAGE_SIZE - count, |
922 | error = mxt_read_object(data, | 930 | "T%u:\n", object->type); |
923 | object->type, j, &val); | 931 | |
932 | for (j = 0; j < object->instances + 1; j++) { | ||
933 | u16 size = object->size + 1; | ||
934 | u16 addr = object->start_address + j * size; | ||
935 | |||
936 | error = __mxt_read_reg(data->client, addr, size, obuf); | ||
924 | if (error) | 937 | if (error) |
925 | return error; | 938 | goto done; |
926 | 939 | ||
927 | count += snprintf(buf + count, PAGE_SIZE - count, | 940 | count = mxt_show_instance(buf, count, object, j, obuf); |
928 | "\t[%2d]: %02x (%d)\n", j, val, val); | ||
929 | if (count >= PAGE_SIZE) | ||
930 | return PAGE_SIZE - 1; | ||
931 | } | 941 | } |
932 | |||
933 | count += snprintf(buf + count, PAGE_SIZE - count, "\n"); | ||
934 | if (count >= PAGE_SIZE) | ||
935 | return PAGE_SIZE - 1; | ||
936 | } | 942 | } |
937 | 943 | ||
938 | return count; | 944 | done: |
945 | kfree(obuf); | ||
946 | return error ?: count; | ||
939 | } | 947 | } |
940 | 948 | ||
941 | static int mxt_load_fw(struct device *dev, const char *fn) | 949 | static int mxt_load_fw(struct device *dev, const char *fn) |
@@ -1028,8 +1036,7 @@ static ssize_t mxt_update_fw_store(struct device *dev, | |||
1028 | /* Wait for reset */ | 1036 | /* Wait for reset */ |
1029 | msleep(MXT_FWRESET_TIME); | 1037 | msleep(MXT_FWRESET_TIME); |
1030 | 1038 | ||
1031 | kfree(data->object_table); | 1039 | mxt_free_object_table(data); |
1032 | data->object_table = NULL; | ||
1033 | 1040 | ||
1034 | mxt_initialize(data); | 1041 | mxt_initialize(data); |
1035 | } | 1042 | } |
@@ -1043,10 +1050,14 @@ static ssize_t mxt_update_fw_store(struct device *dev, | |||
1043 | return count; | 1050 | return count; |
1044 | } | 1051 | } |
1045 | 1052 | ||
1053 | static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL); | ||
1054 | static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL); | ||
1046 | static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); | 1055 | static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); |
1047 | static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); | 1056 | static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); |
1048 | 1057 | ||
1049 | static struct attribute *mxt_attrs[] = { | 1058 | static struct attribute *mxt_attrs[] = { |
1059 | &dev_attr_fw_version.attr, | ||
1060 | &dev_attr_hw_version.attr, | ||
1050 | &dev_attr_object.attr, | 1061 | &dev_attr_object.attr, |
1051 | &dev_attr_update_fw.attr, | 1062 | &dev_attr_update_fw.attr, |
1052 | NULL | 1063 | NULL |
@@ -1093,6 +1104,7 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1093 | struct mxt_data *data; | 1104 | struct mxt_data *data; |
1094 | struct input_dev *input_dev; | 1105 | struct input_dev *input_dev; |
1095 | int error; | 1106 | int error; |
1107 | unsigned int num_mt_slots; | ||
1096 | 1108 | ||
1097 | if (!pdata) | 1109 | if (!pdata) |
1098 | return -EINVAL; | 1110 | return -EINVAL; |
@@ -1106,6 +1118,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1106 | } | 1118 | } |
1107 | 1119 | ||
1108 | input_dev->name = "Atmel maXTouch Touchscreen"; | 1120 | input_dev->name = "Atmel maXTouch Touchscreen"; |
1121 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", | ||
1122 | client->adapter->nr, client->addr); | ||
1123 | input_dev->phys = data->phys; | ||
1124 | |||
1109 | input_dev->id.bustype = BUS_I2C; | 1125 | input_dev->id.bustype = BUS_I2C; |
1110 | input_dev->dev.parent = &client->dev; | 1126 | input_dev->dev.parent = &client->dev; |
1111 | input_dev->open = mxt_input_open; | 1127 | input_dev->open = mxt_input_open; |
@@ -1118,6 +1134,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1118 | 1134 | ||
1119 | mxt_calc_resolution(data); | 1135 | mxt_calc_resolution(data); |
1120 | 1136 | ||
1137 | error = mxt_initialize(data); | ||
1138 | if (error) | ||
1139 | goto err_free_mem; | ||
1140 | |||
1121 | __set_bit(EV_ABS, input_dev->evbit); | 1141 | __set_bit(EV_ABS, input_dev->evbit); |
1122 | __set_bit(EV_KEY, input_dev->evbit); | 1142 | __set_bit(EV_KEY, input_dev->evbit); |
1123 | __set_bit(BTN_TOUCH, input_dev->keybit); | 1143 | __set_bit(BTN_TOUCH, input_dev->keybit); |
@@ -1131,7 +1151,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1131 | 0, 255, 0, 0); | 1151 | 0, 255, 0, 0); |
1132 | 1152 | ||
1133 | /* For multi touch */ | 1153 | /* For multi touch */ |
1134 | input_mt_init_slots(input_dev, MXT_MAX_FINGER); | 1154 | num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1; |
1155 | error = input_mt_init_slots(input_dev, num_mt_slots); | ||
1156 | if (error) | ||
1157 | goto err_free_object; | ||
1135 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1158 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
1136 | 0, MXT_MAX_AREA, 0, 0); | 1159 | 0, MXT_MAX_AREA, 0, 0); |
1137 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1160 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
@@ -1144,13 +1167,9 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1144 | input_set_drvdata(input_dev, data); | 1167 | input_set_drvdata(input_dev, data); |
1145 | i2c_set_clientdata(client, data); | 1168 | i2c_set_clientdata(client, data); |
1146 | 1169 | ||
1147 | error = mxt_initialize(data); | ||
1148 | if (error) | ||
1149 | goto err_free_object; | ||
1150 | |||
1151 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, | 1170 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, |
1152 | pdata->irqflags | IRQF_ONESHOT, | 1171 | pdata->irqflags | IRQF_ONESHOT, |
1153 | client->dev.driver->name, data); | 1172 | client->name, data); |
1154 | if (error) { | 1173 | if (error) { |
1155 | dev_err(&client->dev, "Failed to register interrupt\n"); | 1174 | dev_err(&client->dev, "Failed to register interrupt\n"); |
1156 | goto err_free_object; | 1175 | goto err_free_object; |
diff --git a/include/linux/input.h b/include/linux/input.h index 2740d080ec6b..725dcd0f63a4 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -807,18 +807,20 @@ struct input_keymap_entry { | |||
807 | #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ | 807 | #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ |
808 | #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ | 808 | #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ |
809 | #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ | 809 | #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ |
810 | #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ | 810 | #define ABS_MT_POSITION_X 0x35 /* Center X touch position */ |
811 | #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ | 811 | #define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ |
812 | #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ | 812 | #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ |
813 | #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ | 813 | #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ |
814 | #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ | 814 | #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ |
815 | #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ | 815 | #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ |
816 | #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ | 816 | #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ |
817 | #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ | ||
818 | #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ | ||
817 | 819 | ||
818 | #ifdef __KERNEL__ | 820 | #ifdef __KERNEL__ |
819 | /* Implementation details, userspace should not care about these */ | 821 | /* Implementation details, userspace should not care about these */ |
820 | #define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR | 822 | #define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR |
821 | #define ABS_MT_LAST ABS_MT_DISTANCE | 823 | #define ABS_MT_LAST ABS_MT_TOOL_Y |
822 | #endif | 824 | #endif |
823 | 825 | ||
824 | #define ABS_MAX 0x3f | 826 | #define ABS_MAX 0x3f |