diff options
-rw-r--r-- | drivers/input/touchscreen/goodix.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index ca196689f025..3ab7232ac1af 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c | |||
@@ -48,6 +48,7 @@ struct goodix_ts_data { | |||
48 | #define GOODIX_REG_VERSION 0x8140 | 48 | #define GOODIX_REG_VERSION 0x8140 |
49 | 49 | ||
50 | #define RESOLUTION_LOC 1 | 50 | #define RESOLUTION_LOC 1 |
51 | #define MAX_CONTACTS_LOC 5 | ||
51 | #define TRIGGER_LOC 6 | 52 | #define TRIGGER_LOC 6 |
52 | 53 | ||
53 | static const unsigned long goodix_irq_flags[] = { | 54 | static const unsigned long goodix_irq_flags[] = { |
@@ -99,7 +100,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) | |||
99 | } | 100 | } |
100 | 101 | ||
101 | touch_num = data[0] & 0x0f; | 102 | touch_num = data[0] & 0x0f; |
102 | if (touch_num > GOODIX_MAX_CONTACTS) | 103 | if (touch_num > ts->max_touch_num) |
103 | return -EPROTO; | 104 | return -EPROTO; |
104 | 105 | ||
105 | if (touch_num > 1) { | 106 | if (touch_num > 1) { |
@@ -141,7 +142,7 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) | |||
141 | */ | 142 | */ |
142 | static void goodix_process_events(struct goodix_ts_data *ts) | 143 | static void goodix_process_events(struct goodix_ts_data *ts) |
143 | { | 144 | { |
144 | u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; | 145 | u8 point_data[1 + GOODIX_CONTACT_SIZE * ts->max_touch_num]; |
145 | int touch_num; | 146 | int touch_num; |
146 | int i; | 147 | int i; |
147 | 148 | ||
@@ -202,21 +203,23 @@ static void goodix_read_config(struct goodix_ts_data *ts) | |||
202 | ts->abs_x_max = GOODIX_MAX_WIDTH; | 203 | ts->abs_x_max = GOODIX_MAX_WIDTH; |
203 | ts->abs_y_max = GOODIX_MAX_HEIGHT; | 204 | ts->abs_y_max = GOODIX_MAX_HEIGHT; |
204 | ts->int_trigger_type = GOODIX_INT_TRIGGER; | 205 | ts->int_trigger_type = GOODIX_INT_TRIGGER; |
206 | ts->max_touch_num = GOODIX_MAX_CONTACTS; | ||
205 | return; | 207 | return; |
206 | } | 208 | } |
207 | 209 | ||
208 | ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); | 210 | ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); |
209 | ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); | 211 | ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); |
210 | ts->int_trigger_type = (config[TRIGGER_LOC]) & 0x03; | 212 | ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; |
211 | if (!ts->abs_x_max || !ts->abs_y_max) { | 213 | ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f; |
214 | if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) { | ||
212 | dev_err(&ts->client->dev, | 215 | dev_err(&ts->client->dev, |
213 | "Invalid config, using defaults\n"); | 216 | "Invalid config, using defaults\n"); |
214 | ts->abs_x_max = GOODIX_MAX_WIDTH; | 217 | ts->abs_x_max = GOODIX_MAX_WIDTH; |
215 | ts->abs_y_max = GOODIX_MAX_HEIGHT; | 218 | ts->abs_y_max = GOODIX_MAX_HEIGHT; |
219 | ts->max_touch_num = GOODIX_MAX_CONTACTS; | ||
216 | } | 220 | } |
217 | } | 221 | } |
218 | 222 | ||
219 | |||
220 | /** | 223 | /** |
221 | * goodix_read_version - Read goodix touchscreen version | 224 | * goodix_read_version - Read goodix touchscreen version |
222 | * | 225 | * |
@@ -295,7 +298,7 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts) | |||
295 | input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); | 298 | input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); |
296 | input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); | 299 | input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); |
297 | 300 | ||
298 | input_mt_init_slots(ts->input_dev, GOODIX_MAX_CONTACTS, | 301 | input_mt_init_slots(ts->input_dev, ts->max_touch_num, |
299 | INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); | 302 | INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); |
300 | 303 | ||
301 | ts->input_dev->name = "Goodix Capacitive TouchScreen"; | 304 | ts->input_dev->name = "Goodix Capacitive TouchScreen"; |