diff options
author | Alexandra Chin <Alexandra.Chin@tw.synaptics.com> | 2012-11-16 03:31:46 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-16 07:20:37 -0500 |
commit | a13ea24e20fc09c33e5bbd5ab35b24fd69437313 (patch) | |
tree | 9954fee551ed6c49244570bb6af9c9118266ba73 | |
parent | a369aa0eb7082da3d97c63f7d2265fddc84923d3 (diff) |
staging: ste_rmi4: Convert to Type-B support
Convert to MT-B because Synaptics touch devices are capable
of tracking identifiable fingers.
Signed-off-by: Alexandra Chin <alexandra.chin@tw.synaptics.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c index 37d19c696ea9..c71366d3deec 100644 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/input/mt.h> | ||
34 | #include "synaptics_i2c_rmi4.h" | 35 | #include "synaptics_i2c_rmi4.h" |
35 | 36 | ||
36 | /* TODO: for multiple device support will need a per-device mutex */ | 37 | /* TODO: for multiple device support will need a per-device mutex */ |
@@ -67,7 +68,6 @@ | |||
67 | #define PDT_START_SCAN_LOCATION (0x00E9) | 68 | #define PDT_START_SCAN_LOCATION (0x00E9) |
68 | #define PDT_END_SCAN_LOCATION (0x000A) | 69 | #define PDT_END_SCAN_LOCATION (0x000A) |
69 | #define PDT_ENTRY_SIZE (0x0006) | 70 | #define PDT_ENTRY_SIZE (0x0006) |
70 | #define RMI4_NUMBER_OF_MAX_FINGERS (8) | ||
71 | #define SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM (0x11) | 71 | #define SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM (0x11) |
72 | #define SYNAPTICS_RMI4_DEVICE_CONTROL_FUNC_NUM (0x01) | 72 | #define SYNAPTICS_RMI4_DEVICE_CONTROL_FUNC_NUM (0x01) |
73 | 73 | ||
@@ -164,6 +164,7 @@ struct synaptics_rmi4_device_info { | |||
164 | * @regulator: pointer to the regulator structure | 164 | * @regulator: pointer to the regulator structure |
165 | * @wait: wait queue structure variable | 165 | * @wait: wait queue structure variable |
166 | * @touch_stopped: flag to stop the thread function | 166 | * @touch_stopped: flag to stop the thread function |
167 | * @fingers_supported: maximum supported fingers | ||
167 | * | 168 | * |
168 | * This structure gives the device data information. | 169 | * This structure gives the device data information. |
169 | */ | 170 | */ |
@@ -184,6 +185,7 @@ struct synaptics_rmi4_data { | |||
184 | struct regulator *regulator; | 185 | struct regulator *regulator; |
185 | wait_queue_head_t wait; | 186 | wait_queue_head_t wait; |
186 | bool touch_stopped; | 187 | bool touch_stopped; |
188 | unsigned char fingers_supported; | ||
187 | }; | 189 | }; |
188 | 190 | ||
189 | /** | 191 | /** |
@@ -303,22 +305,21 @@ static int synpatics_rmi4_touchpad_report(struct synaptics_rmi4_data *pdata, | |||
303 | /* number of touch points - fingers down in this case */ | 305 | /* number of touch points - fingers down in this case */ |
304 | int touch_count = 0; | 306 | int touch_count = 0; |
305 | int finger; | 307 | int finger; |
306 | int fingers_supported; | ||
307 | int finger_registers; | 308 | int finger_registers; |
308 | int reg; | 309 | int reg; |
309 | int finger_shift; | 310 | int finger_shift; |
310 | int finger_status; | 311 | int finger_status; |
311 | int retval; | 312 | int retval; |
313 | int x, y; | ||
314 | int wx, wy; | ||
312 | unsigned short data_base_addr; | 315 | unsigned short data_base_addr; |
313 | unsigned short data_offset; | 316 | unsigned short data_offset; |
314 | unsigned char data_reg_blk_size; | 317 | unsigned char data_reg_blk_size; |
315 | unsigned char values[2]; | 318 | unsigned char values[2]; |
316 | unsigned char data[DATA_LEN]; | 319 | unsigned char data[DATA_LEN]; |
317 | int x[RMI4_NUMBER_OF_MAX_FINGERS]; | 320 | unsigned char fingers_supported = pdata->fingers_supported; |
318 | int y[RMI4_NUMBER_OF_MAX_FINGERS]; | ||
319 | int wx[RMI4_NUMBER_OF_MAX_FINGERS]; | ||
320 | int wy[RMI4_NUMBER_OF_MAX_FINGERS]; | ||
321 | struct i2c_client *client = pdata->i2c_client; | 321 | struct i2c_client *client = pdata->i2c_client; |
322 | struct input_dev *input_dev = pdata->input_dev; | ||
322 | 323 | ||
323 | /* get 2D sensor finger data */ | 324 | /* get 2D sensor finger data */ |
324 | /* | 325 | /* |
@@ -333,7 +334,6 @@ static int synpatics_rmi4_touchpad_report(struct synaptics_rmi4_data *pdata, | |||
333 | * 10 = finger present but data may not be accurate, | 334 | * 10 = finger present but data may not be accurate, |
334 | * 11 = reserved for product use. | 335 | * 11 = reserved for product use. |
335 | */ | 336 | */ |
336 | fingers_supported = rfi->num_of_data_points; | ||
337 | finger_registers = (fingers_supported + 3)/4; | 337 | finger_registers = (fingers_supported + 3)/4; |
338 | data_base_addr = rfi->fn_desc.data_base_addr; | 338 | data_base_addr = rfi->fn_desc.data_base_addr; |
339 | retval = synaptics_rmi4_i2c_block_read(pdata, data_base_addr, values, | 339 | retval = synaptics_rmi4_i2c_block_read(pdata, data_base_addr, values, |
@@ -358,7 +358,11 @@ static int synpatics_rmi4_touchpad_report(struct synaptics_rmi4_data *pdata, | |||
358 | * if finger status indicates a finger is present then | 358 | * if finger status indicates a finger is present then |
359 | * read the finger data and report it | 359 | * read the finger data and report it |
360 | */ | 360 | */ |
361 | if (finger_status == 1 || finger_status == 2) { | 361 | input_mt_slot(input_dev, finger); |
362 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, | ||
363 | finger_status != 0); | ||
364 | |||
365 | if (finger_status) { | ||
362 | /* Read the finger data */ | 366 | /* Read the finger data */ |
363 | data_offset = data_base_addr + | 367 | data_offset = data_base_addr + |
364 | ((finger * data_reg_blk_size) + | 368 | ((finger * data_reg_blk_size) + |
@@ -367,50 +371,33 @@ static int synpatics_rmi4_touchpad_report(struct synaptics_rmi4_data *pdata, | |||
367 | data_offset, data, | 371 | data_offset, data, |
368 | data_reg_blk_size); | 372 | data_reg_blk_size); |
369 | if (retval != data_reg_blk_size) { | 373 | if (retval != data_reg_blk_size) { |
370 | printk(KERN_ERR "%s:read data failed\n", | 374 | dev_err(&client->dev, "%s:read data failed\n", |
371 | __func__); | 375 | __func__); |
372 | return 0; | 376 | return 0; |
373 | } else { | ||
374 | x[touch_count] = | ||
375 | (data[0] << 4) | (data[2] & MASK_4BIT); | ||
376 | y[touch_count] = | ||
377 | (data[1] << 4) | | ||
378 | ((data[2] >> 4) & MASK_4BIT); | ||
379 | wy[touch_count] = | ||
380 | (data[3] >> 4) & MASK_4BIT; | ||
381 | wx[touch_count] = | ||
382 | (data[3] & MASK_4BIT); | ||
383 | |||
384 | if (pdata->board->x_flip) | ||
385 | x[touch_count] = | ||
386 | pdata->sensor_max_x - | ||
387 | x[touch_count]; | ||
388 | if (pdata->board->y_flip) | ||
389 | y[touch_count] = | ||
390 | pdata->sensor_max_y - | ||
391 | y[touch_count]; | ||
392 | } | 377 | } |
378 | x = (data[0] << 4) | (data[2] & MASK_4BIT); | ||
379 | y = (data[1] << 4) | ((data[2] >> 4) & MASK_4BIT); | ||
380 | wy = (data[3] >> 4) & MASK_4BIT; | ||
381 | wx = (data[3] & MASK_4BIT); | ||
382 | |||
383 | if (pdata->board->x_flip) | ||
384 | x = pdata->sensor_max_x - x; | ||
385 | if (pdata->board->y_flip) | ||
386 | y = pdata->sensor_max_y - y; | ||
387 | |||
388 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
389 | max(wx, wy)); | ||
390 | input_report_abs(input_dev, ABS_MT_POSITION_X, x); | ||
391 | input_report_abs(input_dev, ABS_MT_POSITION_Y, y); | ||
392 | |||
393 | /* number of active touch points */ | 393 | /* number of active touch points */ |
394 | touch_count++; | 394 | touch_count++; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | /* report to input subsystem */ | ||
399 | if (touch_count) { | ||
400 | for (finger = 0; finger < touch_count; finger++) { | ||
401 | input_report_abs(pdata->input_dev, ABS_MT_TOUCH_MAJOR, | ||
402 | max(wx[finger] , wy[finger])); | ||
403 | input_report_abs(pdata->input_dev, ABS_MT_POSITION_X, | ||
404 | x[finger]); | ||
405 | input_report_abs(pdata->input_dev, ABS_MT_POSITION_Y, | ||
406 | y[finger]); | ||
407 | input_mt_sync(pdata->input_dev); | ||
408 | } | ||
409 | } else | ||
410 | input_mt_sync(pdata->input_dev); | ||
411 | |||
412 | /* sync after groups of events */ | 398 | /* sync after groups of events */ |
413 | input_sync(pdata->input_dev); | 399 | input_mt_sync_frame(input_dev); |
400 | input_sync(input_dev); | ||
414 | /* return the number of touch points */ | 401 | /* return the number of touch points */ |
415 | return touch_count; | 402 | return touch_count; |
416 | } | 403 | } |
@@ -575,6 +562,7 @@ static int synpatics_rmi4_touchpad_detect(struct synaptics_rmi4_data *pdata, | |||
575 | if ((queries[1] & MASK_3BIT) == 5) | 562 | if ((queries[1] & MASK_3BIT) == 5) |
576 | rfi->num_of_data_points = 10; | 563 | rfi->num_of_data_points = 10; |
577 | } | 564 | } |
565 | pdata->fingers_supported = rfi->num_of_data_points; | ||
578 | /* Need to get interrupt info for handling interrupts */ | 566 | /* Need to get interrupt info for handling interrupts */ |
579 | rfi->index_to_intr_reg = (interruptcount + 7)/8; | 567 | rfi->index_to_intr_reg = (interruptcount + 7)/8; |
580 | if (rfi->index_to_intr_reg != 0) | 568 | if (rfi->index_to_intr_reg != 0) |
@@ -988,6 +976,8 @@ static int __devinit synaptics_rmi4_probe | |||
988 | rmi4_data->sensor_max_y, 0, 0); | 976 | rmi4_data->sensor_max_y, 0, 0); |
989 | input_set_abs_params(rmi4_data->input_dev, ABS_MT_TOUCH_MAJOR, 0, | 977 | input_set_abs_params(rmi4_data->input_dev, ABS_MT_TOUCH_MAJOR, 0, |
990 | MAX_TOUCH_MAJOR, 0, 0); | 978 | MAX_TOUCH_MAJOR, 0, 0); |
979 | input_mt_init_slots(rmi4_data->input_dev, | ||
980 | rmi4_data->fingers_supported, 0); | ||
991 | 981 | ||
992 | /* Clear interrupts */ | 982 | /* Clear interrupts */ |
993 | synaptics_rmi4_i2c_block_read(rmi4_data, | 983 | synaptics_rmi4_i2c_block_read(rmi4_data, |