aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c')
-rw-r--r--drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c106
1 files changed, 37 insertions, 69 deletions
diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
index 277491a877e..299f5181019 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)
@@ -891,7 +879,7 @@ static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata)
891 * the rmi4 Physical Device Table and enumerate any rmi4 functions that 879 * the rmi4 Physical Device Table and enumerate any rmi4 functions that
892 * have data sources associated with them. 880 * have data sources associated with them.
893 */ 881 */
894static int __devinit synaptics_rmi4_probe 882static int synaptics_rmi4_probe
895 (struct i2c_client *client, const struct i2c_device_id *dev_id) 883 (struct i2c_client *client, const struct i2c_device_id *dev_id)
896{ 884{
897 int retval; 885 int retval;
@@ -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,
@@ -1032,7 +1022,7 @@ err_input:
1032 * This function uses to remove the i2c-client 1022 * This function uses to remove the i2c-client
1033 * touchscreen driver and returns integer. 1023 * touchscreen driver and returns integer.
1034 */ 1024 */
1035static int __devexit synaptics_rmi4_remove(struct i2c_client *client) 1025static int synaptics_rmi4_remove(struct i2c_client *client)
1036{ 1026{
1037 struct synaptics_rmi4_data *rmi4_data = i2c_get_clientdata(client); 1027 struct synaptics_rmi4_data *rmi4_data = i2c_get_clientdata(client);
1038 const struct synaptics_rmi4_platform_data *pdata = rmi4_data->board; 1028 const struct synaptics_rmi4_platform_data *pdata = rmi4_data->board;
@@ -1140,33 +1130,11 @@ static struct i2c_driver synaptics_rmi4_driver = {
1140#endif 1130#endif
1141 }, 1131 },
1142 .probe = synaptics_rmi4_probe, 1132 .probe = synaptics_rmi4_probe,
1143 .remove = __devexit_p(synaptics_rmi4_remove), 1133 .remove = synaptics_rmi4_remove,
1144 .id_table = synaptics_rmi4_id_table, 1134 .id_table = synaptics_rmi4_id_table,
1145}; 1135};
1146/**
1147 * synaptics_rmi4_init() - Initialize the touchscreen driver
1148 *
1149 * This function uses to initializes the synaptics
1150 * touchscreen driver and returns integer.
1151 */
1152static int __init synaptics_rmi4_init(void)
1153{
1154 return i2c_add_driver(&synaptics_rmi4_driver);
1155}
1156/**
1157 * synaptics_rmi4_exit() - De-initialize the touchscreen driver
1158 *
1159 * This function uses to de-initialize the synaptics
1160 * touchscreen driver and returns none.
1161 */
1162static void __exit synaptics_rmi4_exit(void)
1163{
1164 i2c_del_driver(&synaptics_rmi4_driver);
1165}
1166
1167 1136
1168module_init(synaptics_rmi4_init); 1137module_i2c_driver(synaptics_rmi4_driver);
1169module_exit(synaptics_rmi4_exit);
1170 1138
1171MODULE_LICENSE("GPL v2"); 1139MODULE_LICENSE("GPL v2");
1172MODULE_AUTHOR("naveen.gaddipati@stericsson.com, js.ha@stericsson.com"); 1140MODULE_AUTHOR("naveen.gaddipati@stericsson.com, js.ha@stericsson.com");