From c388533d33b7b4822f423effe87de7fe6d0a7ede Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 27 Mar 2023 12:14:55 +0900 Subject: [PATCH] ODROID-M1: Add flipped x, y axis. Change-Id: Iad87c8dcc3826414330087405d95f3053de8fb38 --- drivers/hid/hid-multitouch.c | 44 ++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index a78ce16d4782..ed7706f5ac9f 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -874,6 +874,36 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, return 0; } +#if defined(CONFIG_ARCH_ROCKCHIP_ODROID_COMMON) +bool touch_flip_x = false; +static int __init touch_flip_x_para_setup(char *s) +{ + if (!strncmp(s, "true", 4)) + touch_flip_x = true; + else { + pr_err("%s - wrong touch_flip_x parameter", __func__); + touch_flip_x = true; + } + + return 0; +} +__setup("touch_flip_x=", touch_flip_x_para_setup); + +bool touch_flip_y = false; +static int __init touch_flip_y_para_setup(char *s) +{ + if (!strncmp(s, "true", 4)) + touch_flip_y = true; + else { + pr_err("%s - wrong touch_flip_y parameter", __func__); + touch_flip_y = true; + } + + return 0; +} +__setup("touch_flip_y=", touch_flip_y_para_setup); +#endif + static int mt_compute_slot(struct mt_device *td, struct mt_application *app, struct mt_usages *slot, struct input_dev *input) @@ -1084,8 +1114,18 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, minor = minor >> 1; } - input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); - input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); +#if defined(CONFIG_ARCH_ROCKCHIP_ODROID_COMMON) + if (touch_flip_x) + input_event(input, EV_ABS, ABS_MT_POSITION_X, input->absinfo[0].maximum - *slot->x); + else +#endif + input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); +#if defined(CONFIG_ARCH_ROCKCHIP_ODROID_COMMON) + if (touch_flip_y) + input_event(input, EV_ABS, ABS_MT_POSITION_Y, input->absinfo[1].maximum - *slot->y); + else +#endif + input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state);