summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-05-18 14:14:22 +0200
committerKlaus Goger <klaus.goger@theobroma-systems.com>2017-05-24 11:35:10 +0200
commitd14e860044d9560793b478157ecb5d897db93ce5 (patch)
tree47f8a6048e040d6d481c348751b8886d4fb24078
parentf747e0672f16fcd02d63791b9da645f3554acde1 (diff)
Input: back-port silead.c: invert_x/y & swap_xy
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
-rw-r--r--drivers/input/touchscreen/silead.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index 580232769690..5a6cfe2c1667 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -57,11 +57,19 @@
#define SILEAD_POINT_X_MSB_OFF 0x03
#define SILEAD_TOUCH_ID_MASK 0xF0
+#define SILEAD_DP_X_MAX "touchscreen-size-x"
+#define SILEAD_DP_Y_MAX "touchscreen-size-y"
+#define SILEAD_DP_X_INVERT "touchscreen-inverted-x"
+#define SILEAD_DP_Y_INVERT "touchscreen-inverted-y"
+#define SILEAD_DP_XY_SWAP "touchscreen-swapped-x-y"
+
#define SILEAD_CMD_SLEEP_MIN 10000
#define SILEAD_CMD_SLEEP_MAX 20000
#define SILEAD_POWER_SLEEP 20
#define SILEAD_STARTUP_SLEEP 30
+#define SILEAD_MAX_X 4096
+#define SILEAD_MAX_Y 4096
#define SILEAD_MAX_FINGERS 10
enum silead_ts_power {
@@ -74,7 +82,12 @@ struct silead_ts_data {
struct gpio_desc *gpio_power;
struct input_dev *input;
char fw_name[64];
+ u32 x_max;
+ u32 y_max;
u32 max_fingers;
+ bool x_invert;
+ bool y_invert;
+ bool xy_swap;
u32 chip_id;
struct input_mt_pos pos[SILEAD_MAX_FINGERS];
int slots[SILEAD_MAX_FINGERS];
@@ -98,8 +111,17 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data)
return -ENOMEM;
}
- input_set_abs_params(data->input, ABS_MT_POSITION_X, 0, 4095, 0, 0);
- input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0, 4095, 0, 0);
+ if (!data->xy_swap) {
+ input_set_abs_params(data->input, ABS_MT_POSITION_X, 0,
+ data->x_max, 0, 0);
+ input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0,
+ data->y_max, 0, 0);
+ } else {
+ input_set_abs_params(data->input, ABS_MT_POSITION_X, 0,
+ data->y_max, 0, 0);
+ input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0,
+ data->x_max, 0, 0);
+ }
touchscreen_parse_properties(data->input, true);
input_mt_init_slots(data->input, data->max_fingers,
@@ -167,13 +189,25 @@ static void silead_ts_read_data(struct i2c_client *client)
input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0);
for (i = 0; i < touch_nr; i++) {
+ u16 x = data->pos[i].x;
+ u16 y = data->pos[i].y;
+
+ if (data->x_invert)
+ x = data->x_max - x;
+
+ if (data->y_invert)
+ y = data->y_max - y;
+
+ if (data->xy_swap)
+ swap(x, y);
+
input_mt_slot(input, data->slots[i]);
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
- input_report_abs(input, ABS_MT_POSITION_X, data->pos[i].x);
- input_report_abs(input, ABS_MT_POSITION_Y, data->pos[i].y);
+ input_report_abs(input, ABS_MT_POSITION_X, x);
+ input_report_abs(input, ABS_MT_POSITION_Y, y);
- dev_dbg(dev, "x=%d y=%d hw_id=%d sw_id=%d\n", data->pos[i].x,
- data->pos[i].y, data->id[i], data->slots[i]);
+ dev_dbg(dev, "x=%d y=%d hw_id=%d sw_id=%d\n", x, y,
+ data->id[i], data->slots[i]);
}
input_mt_sync_frame(input);
@@ -397,6 +431,24 @@ static void silead_ts_read_props(struct i2c_client *client)
"silead/%s", str);
else
dev_dbg(dev, "Firmware file name read error. Using default.");
+
+ error = device_property_read_u32(dev, SILEAD_DP_X_MAX, &data->x_max);
+ if (error) {
+ dev_dbg(dev, "Resolution X not configured %d\n", error);
+ data->x_max = SILEAD_MAX_X;
+ }
+ data->x_max--; /* Property contains size not max */
+
+ error = device_property_read_u32(dev, SILEAD_DP_Y_MAX, &data->y_max);
+ if (error) {
+ dev_dbg(dev, "Resolution Y not configured %d\n", error);
+ data->y_max = SILEAD_MAX_Y;
+ }
+ data->y_max--; /* Property contains size not max */
+
+ data->x_invert = device_property_read_bool(dev, SILEAD_DP_X_INVERT);
+ data->y_invert = device_property_read_bool(dev, SILEAD_DP_Y_INVERT);
+ data->xy_swap = device_property_read_bool(dev, SILEAD_DP_XY_SWAP);
}
#ifdef CONFIG_ACPI