From 16da0dabcace21df64e38e88e71c4ca96854372d Mon Sep 17 00:00:00 2001 From: codewalker Date: Fri, 7 Apr 2017 14:27:53 +0900 Subject: [PATCH] ODROID: Enable invert touch screen. Change-Id: I5d3c0ae8f1a4c3d864064f431f4b6f854980bfa3 --- drivers/hid/hid-multitouch.c | 16 +++++++- drivers/input/touchscreen/dwav-usb-mt.c | 50 ++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 14a9a89cc2ee..df4f421f2886 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -607,6 +607,8 @@ static int mt_compute_slot(struct mt_device *td, struct input_dev *input) return input_mt_get_slot_by_key(input, td->curdata.contactid); } +extern bool touch_invert_x; +extern bool touch_invert_y; /* * this function is called when a whole contact has been processed, * so that it can assign it to a slot and store the data there @@ -647,8 +649,18 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) int major = max(s->w, s->h) >> 1; int minor = min(s->w, s->h) >> 1; - input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x); - input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y); + if (touch_invert_x) + input_event(input, EV_ABS, ABS_MT_POSITION_X, + input->absinfo[0].maximum - s->x); + else + input_event(input, EV_ABS, ABS_MT_POSITION_X, + s->x); + if (touch_invert_y) + input_event(input, EV_ABS, ABS_MT_POSITION_Y, + input->absinfo[1].maximum - s->y); + else + input_event(input, EV_ABS, ABS_MT_POSITION_Y, + s->y); input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx); input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); input_event(input, EV_ABS, ABS_MT_DISTANCE, diff --git a/drivers/input/touchscreen/dwav-usb-mt.c b/drivers/input/touchscreen/dwav-usb-mt.c index fc2c0ba28ecb..89d903020dff 100644 --- a/drivers/input/touchscreen/dwav-usb-mt.c +++ b/drivers/input/touchscreen/dwav-usb-mt.c @@ -123,6 +123,42 @@ struct dwav_usb_mt { struct finger_t *finger; }; +bool touch_invert_x; +/*-------------------------------------------------------------------------*/ +static int __init touch_invert_x_para_setup(char *s) +{ + touch_invert_x = false; + if (!strncmp(s, "true", 4)) + touch_invert_x = true; + else if (!strncmp(s, "false", 5)) + touch_invert_x = false; + else { + pr_err("%s - wrong touch_invert_x parameter", __func__); + touch_invert_x = true; + } + + return 0; +} +__setup("touch_invert_x=", touch_invert_x_para_setup); + +bool touch_invert_y; +/*-------------------------------------------------------------------------*/ +static int __init touch_invert_y_para_setup(char *s) +{ + touch_invert_y = false; + if (!strncmp(s, "true", 4)) + touch_invert_y = true; + else if (!strncmp(s, "false", 5)) + touch_invert_y = false; + else { + pr_err("%s - wrong touch_invert_y parameter", __func__); + touch_invert_y = true; + } + + return 0; +} +__setup("touch_invert_y=", touch_invert_y_para_setup); + /*-------------------------------------------------------------------------*/ static void dwav_usb_mt_report(struct dwav_usb_mt *dwav_usb_mt) { @@ -147,10 +183,20 @@ static void dwav_usb_mt_report(struct dwav_usb_mt *dwav_usb_mt) if (dwav_usb_mt->finger[id].status != TS_EVENT_RELEASE) { input_mt_report_slot_state(dwav_usb_mt->input, MT_TOOL_FINGER, true); - input_report_abs(dwav_usb_mt->input, + if (touch_invert_x) + input_report_abs(dwav_usb_mt->input, + ABS_MT_POSITION_X, + max_x - dwav_usb_mt->finger[id].x); + else + input_report_abs(dwav_usb_mt->input, ABS_MT_POSITION_X, dwav_usb_mt->finger[id].x); - input_report_abs(dwav_usb_mt->input, + if (touch_invert_y) + input_report_abs(dwav_usb_mt->input, + ABS_MT_POSITION_Y, + max_y - dwav_usb_mt->finger[id].y); + else + input_report_abs(dwav_usb_mt->input, ABS_MT_POSITION_Y, dwav_usb_mt->finger[id].y); input_report_abs(dwav_usb_mt->input,