From patchwork Sat Jun 17 09:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sergei A. Trusov" X-Patchwork-Id: 9794039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F15D2602A7 for ; Sat, 17 Jun 2017 09:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D697E27861 for ; Sat, 17 Jun 2017 09:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7EE6284AF; Sat, 17 Jun 2017 09:49:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C56DF27861 for ; Sat, 17 Jun 2017 09:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718AbdFQJtD (ORCPT ); Sat, 17 Jun 2017 05:49:03 -0400 Received: from forward11o.cmail.yandex.net ([37.9.109.178]:58111 "EHLO forward11o.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752715AbdFQJtC (ORCPT ); Sat, 17 Jun 2017 05:49:02 -0400 X-Greylist: delayed 426 seconds by postgrey-1.27 at vger.kernel.org; Sat, 17 Jun 2017 05:49:02 EDT Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::25]) by forward11o.cmail.yandex.net (Yandex) with ESMTP id 7B81D22912; Sat, 17 Jun 2017 12:41:54 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 6303E13008C3; Sat, 17 Jun 2017 12:41:50 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id RC8iLnao3e-foSCAmFO; Sat, 17 Jun 2017 12:41:50 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1497692510; bh=x2fY0DaUgSZ7d5sEOjcFgt5ADX1ewDL/Nvd9+FvbMr4=; h=From:To:Cc:Subject:Date:Message-ID; b=LvpSUP7cW/79JecXCuzq16OH9FsiTodSL3k7ls1GjZRxfQ9qkJA3yx3tqJraqeB3j UjpsNM5Eug0mKkKZb07QN3H2WqQfhCjNUFEiYtVkCnaCLaFGM0EhyLfaLgAIusZbJA 0fC7W6wwtaHIX9xSRGaB0vTBDILaRzrCck5RlWLg= Authentication-Results: smtp1o.mail.yandex.net; dkim=pass header.i=@ya.ru X-Yandex-ForeignMX: FR X-Yandex-Suid-Status: 1 0,1 0,1 0,1 85683232,1 1027208208,1 0 From: "Sergei A. Trusov" To: Bastien Nocera , Dmitry Torokhov Cc: Hans de Goede , russianneuromancer@ya.ru, "Sergei A. Trusov" , linux-input@vger.kernel.org Subject: [PATCH] Input: goodix: Add support for capacitive home button found on some x86 tablets Date: Sat, 17 Jun 2017 19:42:20 +1000 Message-ID: <1725443.Vzhj3lzWjD@z12> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches. Detect this and report a KEY_LEFTMETA press when this happens. Note the hardware might support more than one button, the number of a button is reported by the 'id' byte of coor_data. Now we ignore button id. Signed-off-by: Sergei A. Trusov Acked-by: Hans de Goede Tested-by: Hans de Goede --- drivers/input/touchscreen/goodix.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 240b16f3ee97..a4c17c461792 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -76,6 +76,10 @@ struct goodix_ts_data { #define MAX_CONTACTS_LOC 5 #define TRIGGER_LOC 6 +#define GOODIX_TOUCH_NUM_MASK 0x0f +#define GOODIX_SOFTBUTTON_MASK 0x10 +#define GOODIX_SOFTBUTTON1 KEY_LEFTMETA + static const unsigned long goodix_irq_flags[] = { IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, @@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) if (!(data[0] & 0x80)) return -EAGAIN; - touch_num = data[0] & 0x0f; + touch_num = data[0] & GOODIX_TOUCH_NUM_MASK; if (touch_num > ts->max_touch_num) return -EPROTO; @@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) return error; } - return touch_num; + return data[0]; } static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) @@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) static void goodix_process_events(struct goodix_ts_data *ts) { u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; - int touch_num; + int touch_num, status; int i; - touch_num = goodix_ts_read_input_report(ts, point_data); - if (touch_num < 0) + status = goodix_ts_read_input_report(ts, point_data); + if (status < 0) return; + input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1, + !!(status & GOODIX_SOFTBUTTON_MASK)); + + touch_num = status & GOODIX_TOUCH_NUM_MASK; for (i = 0; i < touch_num; i++) goodix_ts_report_touch(ts, &point_data[1 + GOODIX_CONTACT_SIZE * i]); @@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts) ts->input_dev->id.product = ts->id; ts->input_dev->id.version = ts->version; + input_set_capability(ts->input_dev, EV_KEY, GOODIX_SOFTBUTTON1); + error = input_register_device(ts->input_dev); if (error) { dev_err(&ts->client->dev,