aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorKarsten Merker <merker@debian.org>2015-12-17 20:02:53 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-12-17 20:11:55 -0500
commitad48cf5e9597147bb2bb526a6d379ee88970dec8 (patch)
tree14daf797095a3df07c0ea13f8d244cc6e8735b72 /drivers/input
parent5d655b35466835c6bb8774122db95ecb4e18888d (diff)
Input: goodix - add axis swapping and axis inversion support
Implement support for the following device-tree and ACPI 5.1 DSD properties in the goodix touchscreen driver: - touchscreen-inverted-x: X axis is inverted (boolean) - touchscreen-inverted-y: Y axis is inverted (boolean) - touchscreen-swapped-x-y: X and Y axis are swapped (boolean) These are necessary on tablets which have a display in portrait format while the touchscreen is in landscape format, such as e.g. the MSI Primo 81. Signed-off-by: Karsten Merker <merker@debian.org> Tested-by: Bastien Nocera <hadess@hadess.net> Tested-by: Irina Tirdea <irina.tirdea@intel.com> (with ACPI DSD properties) Tested-by: Aleksei Mamlin <mamlinav@gmail.com> (with device-tree properties) Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/goodix.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 0acefe49540d..b5e910a44cdf 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -2,6 +2,7 @@
2 * Driver for Goodix Touchscreens 2 * Driver for Goodix Touchscreens
3 * 3 *
4 * Copyright (c) 2014 Red Hat Inc. 4 * Copyright (c) 2014 Red Hat Inc.
5 * Copyright (c) 2015 K. Merker <merker@debian.org>
5 * 6 *
6 * This code is based on gt9xx.c authored by andrew@goodix.com: 7 * This code is based on gt9xx.c authored by andrew@goodix.com:
7 * 8 *
@@ -35,6 +36,9 @@ struct goodix_ts_data {
35 struct input_dev *input_dev; 36 struct input_dev *input_dev;
36 int abs_x_max; 37 int abs_x_max;
37 int abs_y_max; 38 int abs_y_max;
39 bool swapped_x_y;
40 bool inverted_x;
41 bool inverted_y;
38 unsigned int max_touch_num; 42 unsigned int max_touch_num;
39 unsigned int int_trigger_type; 43 unsigned int int_trigger_type;
40 bool rotated_screen; 44 bool rotated_screen;
@@ -235,6 +239,14 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
235 input_y = ts->abs_y_max - input_y; 239 input_y = ts->abs_y_max - input_y;
236 } 240 }
237 241
242 /* Inversions have to happen before axis swapping */
243 if (ts->inverted_x)
244 input_x = ts->abs_x_max - input_x;
245 if (ts->inverted_y)
246 input_y = ts->abs_y_max - input_y;
247 if (ts->swapped_x_y)
248 swap(input_x, input_y);
249
238 input_mt_slot(ts->input_dev, id); 250 input_mt_slot(ts->input_dev, id);
239 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); 251 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
240 input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x); 252 input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x);
@@ -486,6 +498,8 @@ static void goodix_read_config(struct goodix_ts_data *ts)
486 error); 498 error);
487 ts->abs_x_max = GOODIX_MAX_WIDTH; 499 ts->abs_x_max = GOODIX_MAX_WIDTH;
488 ts->abs_y_max = GOODIX_MAX_HEIGHT; 500 ts->abs_y_max = GOODIX_MAX_HEIGHT;
501 if (ts->swapped_x_y)
502 swap(ts->abs_x_max, ts->abs_y_max);
489 ts->int_trigger_type = GOODIX_INT_TRIGGER; 503 ts->int_trigger_type = GOODIX_INT_TRIGGER;
490 ts->max_touch_num = GOODIX_MAX_CONTACTS; 504 ts->max_touch_num = GOODIX_MAX_CONTACTS;
491 return; 505 return;
@@ -493,6 +507,8 @@ static void goodix_read_config(struct goodix_ts_data *ts)
493 507
494 ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); 508 ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]);
495 ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); 509 ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]);
510 if (ts->swapped_x_y)
511 swap(ts->abs_x_max, ts->abs_y_max);
496 ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; 512 ts->int_trigger_type = config[TRIGGER_LOC] & 0x03;
497 ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f; 513 ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f;
498 if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) { 514 if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) {
@@ -500,6 +516,8 @@ static void goodix_read_config(struct goodix_ts_data *ts)
500 "Invalid config, using defaults\n"); 516 "Invalid config, using defaults\n");
501 ts->abs_x_max = GOODIX_MAX_WIDTH; 517 ts->abs_x_max = GOODIX_MAX_WIDTH;
502 ts->abs_y_max = GOODIX_MAX_HEIGHT; 518 ts->abs_y_max = GOODIX_MAX_HEIGHT;
519 if (ts->swapped_x_y)
520 swap(ts->abs_x_max, ts->abs_y_max);
503 ts->max_touch_num = GOODIX_MAX_CONTACTS; 521 ts->max_touch_num = GOODIX_MAX_CONTACTS;
504 } 522 }
505 523
@@ -622,6 +640,13 @@ static int goodix_configure_dev(struct goodix_ts_data *ts)
622{ 640{
623 int error; 641 int error;
624 642
643 ts->swapped_x_y = device_property_read_bool(&ts->client->dev,
644 "touchscreen-swapped-x-y");
645 ts->inverted_x = device_property_read_bool(&ts->client->dev,
646 "touchscreen-inverted-x");
647 ts->inverted_y = device_property_read_bool(&ts->client->dev,
648 "touchscreen-inverted-y");
649
625 goodix_read_config(ts); 650 goodix_read_config(ts);
626 651
627 error = goodix_request_input_dev(ts); 652 error = goodix_request_input_dev(ts);