From patchwork Tue Jun 20 16:08:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 9799911 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 D3F3760329 for ; Tue, 20 Jun 2017 16:09:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC6CF20008 for ; Tue, 20 Jun 2017 16:09:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0C88200DF; Tue, 20 Jun 2017 16:09:22 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 DABD420008 for ; Tue, 20 Jun 2017 16:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbdFTQJV (ORCPT ); Tue, 20 Jun 2017 12:09:21 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:47085 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbdFTQJU (ORCPT ); Tue, 20 Jun 2017 12:09:20 -0400 Received: from mfilter6-d.gandi.net (mfilter6-d.gandi.net [217.70.178.135]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id C6538A81B1; Tue, 20 Jun 2017 18:09:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter6-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter6-d.gandi.net (mfilter6-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id SD6edud5WrRl; Tue, 20 Jun 2017 18:09:17 +0200 (CEST) X-Originating-IP: 83.155.44.161 Received: from classic.redhat.com (mon69-7-83-155-44-161.fbx.proxad.net [83.155.44.161]) (Authenticated sender: hadess@hadess.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 037DCA8186; Tue, 20 Jun 2017 18:09:15 +0200 (CEST) From: Bastien Nocera To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , "Sergei A. Trusov" Subject: [PATCH v3] Input: goodix: Add support for capacitive home button Date: Tue, 20 Jun 2017 18:08:35 +0200 Message-Id: <20170620160835.13904-1-hadess@hadess.net> X-Mailer: git-send-email 2.13.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 From: "Sergei A. Trusov" 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 first byte set, while only the lower 4 bits (0-3) are used to indicate the number of touches. Report a KEY_LEFTMETA press when this happens. Note that the hardware might support more than one button, in which case the "id" byte of coor_data would identify the button in question. This is not implemented as we don't have access to hardware with multiple buttons. Signed-off-by: Sergei A. Trusov Acked-by: Bastien Nocera --- Changes from v2: - commit message fixes - use BIT(4) instead of 0x10 drivers/input/touchscreen/goodix.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 240b16f3ee97..903137d9cf7d 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -267,6 +267,12 @@ static void goodix_process_events(struct goodix_ts_data *ts) if (touch_num < 0) return; + /* + * Bit 4 of the first byte reports the status of the capacitive + * Windows/Home button. + */ + input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & BIT(4))); + for (i = 0; i < touch_num; i++) goodix_ts_report_touch(ts, &point_data[1 + GOODIX_CONTACT_SIZE * i]); @@ -612,6 +618,9 @@ 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; + /* Capacitive Windows/Home button on some devices */ + input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA); + error = input_register_device(ts->input_dev); if (error) { dev_err(&ts->client->dev,