88f3771
From 2a99775c336303d2efc43eab4f24b34722a28faa Mon Sep 17 00:00:00 2001
88f3771
From: "Sergei A. Trusov" <sergei.a.trusov@ya.ru>
88f3771
Date: Tue, 20 Jun 2017 18:08:35 +0200
88f3771
Subject: [PATCH 11/16] Input: goodix: Add support for capacitive home button
88f3771
88f3771
On some x86 tablets with a Goodix touchscreen, the Windows logo on the
88f3771
front is a capacitive home button. Touching this button results in a touch
88f3771
with bit 4 of the first byte set, while only the lower 4 bits (0-3) are
88f3771
used to indicate the number of touches.
88f3771
88f3771
Report a KEY_LEFTMETA press when this happens.
88f3771
88f3771
Note that the hardware might support more than one button, in which
88f3771
case the "id" byte of coor_data would identify the button in question.
88f3771
This is not implemented as we don't have access to hardware with
88f3771
multiple buttons.
88f3771
88f3771
Signed-off-by: Sergei A. Trusov <sergei.a.trusov@ya.ru>
88f3771
Acked-by: Bastien Nocera <hadess@hadess.net>
88f3771
---
88f3771
 drivers/input/touchscreen/goodix.c | 9 +++++++++
88f3771
 1 file changed, 9 insertions(+)
88f3771
88f3771
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
88f3771
index 240b16f3ee97..903137d9cf7d 100644
88f3771
--- a/drivers/input/touchscreen/goodix.c
88f3771
+++ b/drivers/input/touchscreen/goodix.c
88f3771
@@ -267,6 +267,12 @@ static void goodix_process_events(struct goodix_ts_data *ts)
88f3771
 	if (touch_num < 0)
88f3771
 		return;
88f3771
 
88f3771
+	/*
88f3771
+	 * Bit 4 of the first byte reports the status of the capacitive
88f3771
+	 * Windows/Home button.
88f3771
+	 */
88f3771
+	input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & BIT(4)));
88f3771
+
88f3771
 	for (i = 0; i < touch_num; i++)
88f3771
 		goodix_ts_report_touch(ts,
88f3771
 				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
88f3771
@@ -612,6 +618,9 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
88f3771
 	ts->input_dev->id.product = ts->id;
88f3771
 	ts->input_dev->id.version = ts->version;
88f3771
 
88f3771
+	/* Capacitive Windows/Home button on some devices */
88f3771
+	input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA);
88f3771
+
88f3771
 	error = input_register_device(ts->input_dev);
88f3771
 	if (error) {
88f3771
 		dev_err(&ts->client->dev,
88f3771
-- 
88f3771
2.13.0
88f3771