diff options
Diffstat (limited to 'drivers/input/touchscreen/atmel_mxt_ts.c')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 136 |
1 files changed, 65 insertions, 71 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7a9197a19f67..75493ca8e784 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -100,33 +100,16 @@ | |||
100 | 100 | ||
101 | /* MXT_TOUCH_MULTI_T9 field */ | 101 | /* MXT_TOUCH_MULTI_T9 field */ |
102 | #define MXT_TOUCH_CTRL 0 | 102 | #define MXT_TOUCH_CTRL 0 |
103 | #define MXT_TOUCH_XORIGIN 1 | 103 | #define MXT_T9_ORIENT 9 |
104 | #define MXT_TOUCH_YORIGIN 2 | 104 | #define MXT_T9_RANGE 18 |
105 | #define MXT_TOUCH_XSIZE 3 | 105 | |
106 | #define MXT_TOUCH_YSIZE 4 | 106 | struct t9_range { |
107 | #define MXT_TOUCH_BLEN 6 | 107 | u16 x; |
108 | #define MXT_TOUCH_TCHTHR 7 | 108 | u16 y; |
109 | #define MXT_TOUCH_TCHDI 8 | 109 | } __packed; |
110 | #define MXT_TOUCH_ORIENT 9 | 110 | |
111 | #define MXT_TOUCH_MOVHYSTI 11 | 111 | /* Touch orient bits */ |
112 | #define MXT_TOUCH_MOVHYSTN 12 | 112 | #define MXT_XY_SWITCH (1 << 0) |
113 | #define MXT_TOUCH_NUMTOUCH 14 | ||
114 | #define MXT_TOUCH_MRGHYST 15 | ||
115 | #define MXT_TOUCH_MRGTHR 16 | ||
116 | #define MXT_TOUCH_AMPHYST 17 | ||
117 | #define MXT_TOUCH_XRANGE_LSB 18 | ||
118 | #define MXT_TOUCH_XRANGE_MSB 19 | ||
119 | #define MXT_TOUCH_YRANGE_LSB 20 | ||
120 | #define MXT_TOUCH_YRANGE_MSB 21 | ||
121 | #define MXT_TOUCH_XLOCLIP 22 | ||
122 | #define MXT_TOUCH_XHICLIP 23 | ||
123 | #define MXT_TOUCH_YLOCLIP 24 | ||
124 | #define MXT_TOUCH_YHICLIP 25 | ||
125 | #define MXT_TOUCH_XEDGECTRL 26 | ||
126 | #define MXT_TOUCH_XEDGEDIST 27 | ||
127 | #define MXT_TOUCH_YEDGECTRL 28 | ||
128 | #define MXT_TOUCH_YEDGEDIST 29 | ||
129 | #define MXT_TOUCH_JUMPLIMIT 30 | ||
130 | 113 | ||
131 | /* MXT_PROCI_GRIPFACE_T20 field */ | 114 | /* MXT_PROCI_GRIPFACE_T20 field */ |
132 | #define MXT_GRIPFACE_CTRL 0 | 115 | #define MXT_GRIPFACE_CTRL 0 |
@@ -211,11 +194,6 @@ | |||
211 | #define MXT_PRESS (1 << 6) | 194 | #define MXT_PRESS (1 << 6) |
212 | #define MXT_DETECT (1 << 7) | 195 | #define MXT_DETECT (1 << 7) |
213 | 196 | ||
214 | /* Touch orient bits */ | ||
215 | #define MXT_XY_SWITCH (1 << 0) | ||
216 | #define MXT_X_INVERT (1 << 1) | ||
217 | #define MXT_Y_INVERT (1 << 2) | ||
218 | |||
219 | /* Touchscreen absolute values */ | 197 | /* Touchscreen absolute values */ |
220 | #define MXT_MAX_AREA 0xff | 198 | #define MXT_MAX_AREA 0xff |
221 | 199 | ||
@@ -580,11 +558,6 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
580 | return ret; | 558 | return ret; |
581 | } | 559 | } |
582 | 560 | ||
583 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | ||
584 | { | ||
585 | return __mxt_read_reg(client, reg, 1, val); | ||
586 | } | ||
587 | |||
588 | static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, | 561 | static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, |
589 | const void *val) | 562 | const void *val) |
590 | { | 563 | { |
@@ -1029,12 +1002,59 @@ static void mxt_free_object_table(struct mxt_data *data) | |||
1029 | data->T19_reportid = 0; | 1002 | data->T19_reportid = 0; |
1030 | } | 1003 | } |
1031 | 1004 | ||
1005 | static int mxt_read_t9_resolution(struct mxt_data *data) | ||
1006 | { | ||
1007 | struct i2c_client *client = data->client; | ||
1008 | int error; | ||
1009 | struct t9_range range; | ||
1010 | unsigned char orient; | ||
1011 | struct mxt_object *object; | ||
1012 | |||
1013 | object = mxt_get_object(data, MXT_TOUCH_MULTI_T9); | ||
1014 | if (!object) | ||
1015 | return -EINVAL; | ||
1016 | |||
1017 | error = __mxt_read_reg(client, | ||
1018 | object->start_address + MXT_T9_RANGE, | ||
1019 | sizeof(range), &range); | ||
1020 | if (error) | ||
1021 | return error; | ||
1022 | |||
1023 | le16_to_cpus(&range.x); | ||
1024 | le16_to_cpus(&range.y); | ||
1025 | |||
1026 | error = __mxt_read_reg(client, | ||
1027 | object->start_address + MXT_T9_ORIENT, | ||
1028 | 1, &orient); | ||
1029 | if (error) | ||
1030 | return error; | ||
1031 | |||
1032 | /* Handle default values */ | ||
1033 | if (range.x == 0) | ||
1034 | range.x = 1023; | ||
1035 | |||
1036 | if (range.y == 0) | ||
1037 | range.y = 1023; | ||
1038 | |||
1039 | if (orient & MXT_XY_SWITCH) { | ||
1040 | data->max_x = range.y; | ||
1041 | data->max_y = range.x; | ||
1042 | } else { | ||
1043 | data->max_x = range.x; | ||
1044 | data->max_y = range.y; | ||
1045 | } | ||
1046 | |||
1047 | dev_dbg(&client->dev, | ||
1048 | "Touchscreen size X%uY%u\n", data->max_x, data->max_y); | ||
1049 | |||
1050 | return 0; | ||
1051 | } | ||
1052 | |||
1032 | static int mxt_initialize(struct mxt_data *data) | 1053 | static int mxt_initialize(struct mxt_data *data) |
1033 | { | 1054 | { |
1034 | struct i2c_client *client = data->client; | 1055 | struct i2c_client *client = data->client; |
1035 | struct mxt_info *info = &data->info; | 1056 | struct mxt_info *info = &data->info; |
1036 | int error; | 1057 | int error; |
1037 | u8 val; | ||
1038 | 1058 | ||
1039 | error = mxt_get_info(data); | 1059 | error = mxt_get_info(data); |
1040 | if (error) | 1060 | if (error) |
@@ -1063,26 +1083,16 @@ static int mxt_initialize(struct mxt_data *data) | |||
1063 | goto err_free_object_table; | 1083 | goto err_free_object_table; |
1064 | } | 1084 | } |
1065 | 1085 | ||
1066 | /* Update matrix size at info struct */ | 1086 | error = mxt_read_t9_resolution(data); |
1067 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); | 1087 | if (error) { |
1068 | if (error) | 1088 | dev_err(&client->dev, "Failed to initialize T9 resolution\n"); |
1069 | goto err_free_object_table; | ||
1070 | info->matrix_xsize = val; | ||
1071 | |||
1072 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); | ||
1073 | if (error) | ||
1074 | goto err_free_object_table; | 1089 | goto err_free_object_table; |
1075 | info->matrix_ysize = val; | 1090 | } |
1076 | |||
1077 | dev_info(&client->dev, | ||
1078 | "Family: %u Variant: %u Firmware V%u.%u.%02X\n", | ||
1079 | info->family_id, info->variant_id, info->version >> 4, | ||
1080 | info->version & 0xf, info->build); | ||
1081 | 1091 | ||
1082 | dev_info(&client->dev, | 1092 | dev_info(&client->dev, |
1083 | "Matrix X Size: %u Matrix Y Size: %u Objects: %u\n", | 1093 | "Family: %u Variant: %u Firmware V%u.%u.%02X Objects: %u\n", |
1084 | info->matrix_xsize, info->matrix_ysize, | 1094 | info->family_id, info->variant_id, info->version >> 4, |
1085 | info->object_num); | 1095 | info->version & 0xf, info->build, info->object_num); |
1086 | 1096 | ||
1087 | return 0; | 1097 | return 0; |
1088 | 1098 | ||
@@ -1091,20 +1101,6 @@ err_free_object_table: | |||
1091 | return error; | 1101 | return error; |
1092 | } | 1102 | } |
1093 | 1103 | ||
1094 | static void mxt_calc_resolution(struct mxt_data *data) | ||
1095 | { | ||
1096 | unsigned int max_x = data->pdata->x_size - 1; | ||
1097 | unsigned int max_y = data->pdata->y_size - 1; | ||
1098 | |||
1099 | if (data->pdata->orient & MXT_XY_SWITCH) { | ||
1100 | data->max_x = max_y; | ||
1101 | data->max_y = max_x; | ||
1102 | } else { | ||
1103 | data->max_x = max_x; | ||
1104 | data->max_y = max_y; | ||
1105 | } | ||
1106 | } | ||
1107 | |||
1108 | /* Firmware Version is returned as Major.Minor.Build */ | 1104 | /* Firmware Version is returned as Major.Minor.Build */ |
1109 | static ssize_t mxt_fw_version_show(struct device *dev, | 1105 | static ssize_t mxt_fw_version_show(struct device *dev, |
1110 | struct device_attribute *attr, char *buf) | 1106 | struct device_attribute *attr, char *buf) |
@@ -1430,8 +1426,6 @@ static int mxt_probe(struct i2c_client *client, | |||
1430 | init_completion(&data->reset_completion); | 1426 | init_completion(&data->reset_completion); |
1431 | init_completion(&data->crc_completion); | 1427 | init_completion(&data->crc_completion); |
1432 | 1428 | ||
1433 | mxt_calc_resolution(data); | ||
1434 | |||
1435 | error = mxt_initialize(data); | 1429 | error = mxt_initialize(data); |
1436 | if (error) | 1430 | if (error) |
1437 | goto err_free_mem; | 1431 | goto err_free_mem; |