diff options
author | Joonyoung Shim <jy0922.shim@samsung.com> | 2011-04-13 02:14:38 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-04-13 02:34:11 -0400 |
commit | 910d80513056589d3b12b3aad8598d19e0a0a5bd (patch) | |
tree | 7c00de43d7dc00fa28c932389c554ed7ea7a10f3 /drivers/input/touchscreen | |
parent | 4203306506ebe4eaaa84a2cbd7c1eb2fc0128faa (diff) |
Input: atmel_mxt_ts - support 12bit resolution
Atmel touchscreen chip can support 12bit resolution and this patch
modifies to get maximum x and y size from platform data.
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Acked-by: Iiro Valkonen <iiro.valkonen@atmel.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 4012436633b..a97905a17b7 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -196,9 +196,12 @@ | |||
196 | #define MXT_PRESS (1 << 6) | 196 | #define MXT_PRESS (1 << 6) |
197 | #define MXT_DETECT (1 << 7) | 197 | #define MXT_DETECT (1 << 7) |
198 | 198 | ||
199 | /* Touch orient bits */ | ||
200 | #define MXT_XY_SWITCH (1 << 0) | ||
201 | #define MXT_X_INVERT (1 << 1) | ||
202 | #define MXT_Y_INVERT (1 << 2) | ||
203 | |||
199 | /* Touchscreen absolute values */ | 204 | /* Touchscreen absolute values */ |
200 | #define MXT_MAX_XC 0x3ff | ||
201 | #define MXT_MAX_YC 0x3ff | ||
202 | #define MXT_MAX_AREA 0xff | 205 | #define MXT_MAX_AREA 0xff |
203 | 206 | ||
204 | #define MXT_MAX_FINGER 10 | 207 | #define MXT_MAX_FINGER 10 |
@@ -246,6 +249,8 @@ struct mxt_data { | |||
246 | struct mxt_info info; | 249 | struct mxt_info info; |
247 | struct mxt_finger finger[MXT_MAX_FINGER]; | 250 | struct mxt_finger finger[MXT_MAX_FINGER]; |
248 | unsigned int irq; | 251 | unsigned int irq; |
252 | unsigned int max_x; | ||
253 | unsigned int max_y; | ||
249 | }; | 254 | }; |
250 | 255 | ||
251 | static bool mxt_object_readable(unsigned int type) | 256 | static bool mxt_object_readable(unsigned int type) |
@@ -549,8 +554,13 @@ static void mxt_input_touchevent(struct mxt_data *data, | |||
549 | if (!(status & (MXT_PRESS | MXT_MOVE))) | 554 | if (!(status & (MXT_PRESS | MXT_MOVE))) |
550 | return; | 555 | return; |
551 | 556 | ||
552 | x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); | 557 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); |
553 | y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); | 558 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); |
559 | if (data->max_x < 1024) | ||
560 | x = x >> 2; | ||
561 | if (data->max_y < 1024) | ||
562 | y = y >> 2; | ||
563 | |||
554 | area = message->message[4]; | 564 | area = message->message[4]; |
555 | 565 | ||
556 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | 566 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, |
@@ -845,6 +855,20 @@ static int mxt_initialize(struct mxt_data *data) | |||
845 | return 0; | 855 | return 0; |
846 | } | 856 | } |
847 | 857 | ||
858 | static void mxt_calc_resolution(struct mxt_data *data) | ||
859 | { | ||
860 | unsigned int max_x = data->pdata->x_size - 1; | ||
861 | unsigned int max_y = data->pdata->y_size - 1; | ||
862 | |||
863 | if (data->pdata->orient & MXT_XY_SWITCH) { | ||
864 | data->max_x = max_y; | ||
865 | data->max_y = max_x; | ||
866 | } else { | ||
867 | data->max_x = max_x; | ||
868 | data->max_y = max_y; | ||
869 | } | ||
870 | } | ||
871 | |||
848 | static ssize_t mxt_object_show(struct device *dev, | 872 | static ssize_t mxt_object_show(struct device *dev, |
849 | struct device_attribute *attr, char *buf) | 873 | struct device_attribute *attr, char *buf) |
850 | { | 874 | { |
@@ -1052,31 +1076,32 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1052 | input_dev->open = mxt_input_open; | 1076 | input_dev->open = mxt_input_open; |
1053 | input_dev->close = mxt_input_close; | 1077 | input_dev->close = mxt_input_close; |
1054 | 1078 | ||
1079 | data->client = client; | ||
1080 | data->input_dev = input_dev; | ||
1081 | data->pdata = pdata; | ||
1082 | data->irq = client->irq; | ||
1083 | |||
1084 | mxt_calc_resolution(data); | ||
1085 | |||
1055 | __set_bit(EV_ABS, input_dev->evbit); | 1086 | __set_bit(EV_ABS, input_dev->evbit); |
1056 | __set_bit(EV_KEY, input_dev->evbit); | 1087 | __set_bit(EV_KEY, input_dev->evbit); |
1057 | __set_bit(BTN_TOUCH, input_dev->keybit); | 1088 | __set_bit(BTN_TOUCH, input_dev->keybit); |
1058 | 1089 | ||
1059 | /* For single touch */ | 1090 | /* For single touch */ |
1060 | input_set_abs_params(input_dev, ABS_X, | 1091 | input_set_abs_params(input_dev, ABS_X, |
1061 | 0, MXT_MAX_XC, 0, 0); | 1092 | 0, data->max_x, 0, 0); |
1062 | input_set_abs_params(input_dev, ABS_Y, | 1093 | input_set_abs_params(input_dev, ABS_Y, |
1063 | 0, MXT_MAX_YC, 0, 0); | 1094 | 0, data->max_y, 0, 0); |
1064 | 1095 | ||
1065 | /* For multi touch */ | 1096 | /* For multi touch */ |
1066 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1097 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
1067 | 0, MXT_MAX_AREA, 0, 0); | 1098 | 0, MXT_MAX_AREA, 0, 0); |
1068 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1099 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
1069 | 0, MXT_MAX_XC, 0, 0); | 1100 | 0, data->max_x, 0, 0); |
1070 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | 1101 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
1071 | 0, MXT_MAX_YC, 0, 0); | 1102 | 0, data->max_y, 0, 0); |
1072 | 1103 | ||
1073 | input_set_drvdata(input_dev, data); | 1104 | input_set_drvdata(input_dev, data); |
1074 | |||
1075 | data->client = client; | ||
1076 | data->input_dev = input_dev; | ||
1077 | data->pdata = pdata; | ||
1078 | data->irq = client->irq; | ||
1079 | |||
1080 | i2c_set_clientdata(client, data); | 1105 | i2c_set_clientdata(client, data); |
1081 | 1106 | ||
1082 | error = mxt_initialize(data); | 1107 | error = mxt_initialize(data); |