From patchwork Tue Aug 1 09:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 129217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2599940vqg; Tue, 1 Aug 2023 04:26:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlELD2wR/vGCN1O0zb5y5jC5YPVpZo96fWpRyjnoIDgtXV9kbT0I3uZSSCUDwfcMVStDXC41 X-Received: by 2002:a05:6512:34c9:b0:4fb:8b2a:5e09 with SMTP id w9-20020a05651234c900b004fb8b2a5e09mr1690284lfr.43.1690889182967; Tue, 01 Aug 2023 04:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690889182; cv=none; d=google.com; s=arc-20160816; b=d5sziqECafCIeCEwdbxFZ2i5PemBklni2/YoOPM5n5tfcs/TY4y6aKnRPdJtGPA+nO ok1pYVPYak6n3xiivWunjOYkCW+2DzBHqQ8CgvVQG7mG/qsUlR89h6SkE7R0KA8GmNsI hOyK/2vNx5QdOO2nsehB2z0HdU32TsvT1ub7eUNYxX5Q/x/fzJRIYhkwMAwEvH5HovdR 1ajDIqCWzchQ6cKQrRP2YR/jKCYMX78DDlKgHo31i4xt5s8JDNO0hxKwUcVSIzJqCoTH HRnygXSfLGWQmWCmACgc3dLvOkmHQWuw7XdhFPKsuJuhp6b/ZnEKTXNJOEkTP80RDYrU 0I2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=TvNVC6Qo2ylC2c8TOOuPUJ8zxH5NPrXXo3KYwouBnE8=; fh=1n+sdiVRyEN7d9lVHrNTPZy55Go4Dk13q4g+RqENsD4=; b=BsRNnv+/EqQW50FMZzpq4l92tIsX6Qb/mcP6SXzW12Wld95bdM0CaPyPRYQ4x3QInh K1k1WkT5Jqux0jLIyPeKNwG5ntshmhAB58uQeFBD/CMX4AV/SOR3jE3ThBrpumxGfO7M H2ypUjNaFhMSc5p/p6E3E8mQaa8e9s6TqWa9GntrqKtCZW3RorU1SRbRSz+5ruddS7+X j/DWD1CpuYxNLrQd57mEOsBkBx9FVvnhow27LLebKwxQqpRbw3kLHgd9z7NY0/2kKKSU CUG31y9ZhA32qMogsgbqPojnPwj3VNhvw+a0cVbBlHgDmR6PcuYhLF1CkDTBElB3zf3s Xp6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=LE8CRj6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la14-20020a170906ad8e00b0099bd1d002e4si9029371ejb.846.2023.08.01.04.25.59; Tue, 01 Aug 2023 04:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=LE8CRj6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjHAJ3z (ORCPT + 99 others); Tue, 1 Aug 2023 05:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231449AbjHAJ3j (ORCPT ); Tue, 1 Aug 2023 05:29:39 -0400 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AA3630D1; Tue, 1 Aug 2023 02:28:22 -0700 (PDT) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id D333C409EE; Tue, 1 Aug 2023 14:09:32 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1690880973; bh=U1j/diLakc7eeJJZQaw8z9VtEXUjEbLYHFb9kbts2CU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LE8CRj6NMfZFcjIoDFpvmBf4LI2D559t92MvQL+hKSSbpmzMOCvgFOhMANvYDkRCz 4sn+GF1SzJG3m+bNLm7G/rxexrhcUIX4ia9+y5YG7rvCN3WIEjK/xpw1dGHhzyfSLY jqkHtfAfWas4WeFVvo8UpwQi3+mz9zS3hSv2A/Kp1BWMza7t66I2RAZscv5f4zpRA7 c2UwgVZmZzSTTE6I9RliWHQ64EoON5Z1UrsjBhQ+Lhii6HKmZgZYzjBde2Qo8o5mRw X71wkcIqKfXGhBFevrOZAYBAEVdbdZJOHGbUbjNFa9d6GoUFDPtEzmlDtC1+Gf9Y6v sMcENCOejEqsg== From: Nikita Travkin Date: Tue, 01 Aug 2023 14:09:25 +0500 Subject: [PATCH v4 1/2] dt-bindings: input: zinitix: Document touch-keys support MIME-Version: 1.0 Message-Id: <20230801-zinitix-tkey-v4-1-b85526c5a474@trvn.ru> References: <20230801-zinitix-tkey-v4-0-b85526c5a474@trvn.ru> In-Reply-To: <20230801-zinitix-tkey-v4-0-b85526c5a474@trvn.ru> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Srba , Linus Walleij Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nikita Travkin , Rob Herring X-Developer-Signature: v=1; a=openpgp-sha256; l=1461; i=nikita@trvn.ru; h=from:subject:message-id; bh=U1j/diLakc7eeJJZQaw8z9VtEXUjEbLYHFb9kbts2CU=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBkyMvLhj0qHLaiJDPiczKJDfYPM5k47g/XHQZ3V uk96kon7ZqJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZMjLywAKCRBDHOzuKBm/ dc8+D/9fxHBKflNDuHCnv1v7HUrFlycVR5DG8Pzf1kHdkjJ/md0OFLT9mGoJql9W/KsW8vNkvdF 9YoZTqkQSb6k6kJgUClEfyrzaeuPFi2raiGEopNgE96BWfizcMZFuGl5j4qBMjazcQF05O7V9Se S4KDeZLkd7IlCSbq8uq78+pNoZ3U/WEHfiRAB+Bsc00X/9KdfipZR9eiEFMF0AuWmS43iUMX8a/ EUsbt5gt2s6yzAXLZz671KUTN9OjHVFC/hR59HrV9lVs3U1TWpQGqHns0we4RgDdo8TeT7ZD1Ey JJQI7jMA22Q4VCiQjlbe4Xuwg9YFK8Q1RPWb5dwRD6gAD/E64EqqDRjEnBpXBsUu7m/Sw/v4WJH SB7pmce6I/00qIKXavR3vj4BlhoJJeWtL5dAPeFldD5o0R0STj6woPR/wUhJHSb1nhz+KBGVJj5 +W/oRq6h7lgh8CAIPAWmnvK0r4issE9/QndK6V1Vp+d6+2iMiJRLBxLh6nauawGZmETjij6HTJx ww2cUbWreVYK5YVl+33MALUpTCia9aE0XOS5VXje7eaZNlwD/WNV5CsDF9Xr8OXxFxASuqDHOnV 11QsZZd2bmxWDOaFljO0knJuCHCb+s1Xo8zhpRqtVzjmbIvJSLDItx/xhQSnMk9LWYOLhtv68p0 bJrzE7cUfGBa8ew== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773025815670120786 X-GMAIL-MSGID: 1773025815670120786 In some configurations the touch controller can support the touch-keys. Document the linux,keycodes property that enables those keys and specifies the keycodes that should be used to report the key events. Reviewed-by: Rob Herring Signed-off-by: Nikita Travkin --- .../devicetree/bindings/input/touchscreen/zinitix,bt400.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml index b1507463a03e..3f663ce3e44e 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml @@ -16,6 +16,7 @@ maintainers: allOf: - $ref: touchscreen.yaml# + - $ref: ../input.yaml# properties: $nodename: @@ -79,6 +80,15 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 enum: [1, 2] + linux,keycodes: + description: + This property specifies an array of keycodes assigned to the + touch-keys that can be present in some touchscreen configurations. + If the touch-keys are enabled, controller firmware will assign some + touch sense lines to those keys. + minItems: 1 + maxItems: 8 + touchscreen-size-x: true touchscreen-size-y: true touchscreen-fuzz-x: true From patchwork Tue Aug 1 09:09:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 129132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2567151vqg; Tue, 1 Aug 2023 03:16:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlERCFNjOqezkUyz9QJZBsU9TvjF03C0/g9CwVB+1RqUyWrrquNiXzb/vBoiXqedXbFUlfXu X-Received: by 2002:a17:903:24f:b0:1bb:94ed:20a with SMTP id j15-20020a170903024f00b001bb94ed020amr12871223plh.24.1690884971944; Tue, 01 Aug 2023 03:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690884971; cv=none; d=google.com; s=arc-20160816; b=z06SQfDW+reBTuUbhTDKLuHGDRPOgqteYoT85qxRg+6lDWMeF0FjkRDicgwOjTNSe1 C6VzBO+2t++Yxs2RjOTuet3oifMmbbiaT+EXNKzpKLATI1qgfp7jIeFcttbGNRummHN1 R8RTjvOx0YzpCT6xDtxMwnZfTV3sM9Zj+d53lDNyfFRopOy8/2cKDafrg69Ie5z1Uxva h/Td0EsPz+xSuBGuHAkQEKwK07hIdFofuwagjA3M+j6XsWvo50BwcoNOM0Qas6qMvzPX gvcw5lQjk8I6bNnmEgMPD2E8Ignk0HFtXwJ9zklLz6SOERFUzJkTartIVyumAd5/x2my +hyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DdladXmucq1uQxck3pQm8myz2bWBWKaYkFNCbNvhDm4=; fh=uf3zMPly93TrSHGJADmwM2QTUDuS2mRItjiYrFTKP98=; b=he2zILS2Uro7ZzqcJWHSisXefyEd4Kf/fx2aA7LKpTIO4iECd8P/ZUOE5ytqgUaiB5 hMAP8D33oQgtChqxeLP1VwG9dfL43srGg+DBQm4+vNAVPBhgmwydJHUH/T4CSqPqh0OV 98D/+EHKIJatcke76uGTs8Rzs4ytsgcqYiSHe5mSiOQ7lY3AWCcPe1crawRp+0M7uHm9 ll+2GFFTw4XQ85mZp4KqlRc60zWr6PH+SeOxip8o8nY0nENFUoq/Pz7F3Y1tQv+qasb9 qZt5XatTJaqwDpuKjbbzDEqyKOxANIrWynvfk5UiIQ63FTDh8mQAe8kJfZL6JeeiT9Yv kuaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=hX1plOZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a170902a3c600b001b9ce7a85cbsi8819571plb.281.2023.08.01.03.15.58; Tue, 01 Aug 2023 03:16:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=hX1plOZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232926AbjHAJYn (ORCPT + 99 others); Tue, 1 Aug 2023 05:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbjHAJYS (ORCPT ); Tue, 1 Aug 2023 05:24:18 -0400 X-Greylist: delayed 762 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 01 Aug 2023 02:23:23 PDT Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC3EE103; Tue, 1 Aug 2023 02:23:23 -0700 (PDT) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 7836342404; Tue, 1 Aug 2023 14:09:33 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1690880973; bh=yNGffE2xORf7vTs2Y1W53hQMQRyrUgd9ZhG7sX37y4A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hX1plOZNoNSYJ5Tes9r9w+Q/U6cB5DeuWOBj6NBaonWMsBKdPxBjBPNnspPmNgs+x e5UtyXZClheTyYeO+gdrQX5tYyArOesq4lX2fw6Inc6GvneEMAisUuwylNh1C0ckNt fwZPIiN2bBe5WjN1MnWpJgpOIwGxyjSpUmJGAsKF+Y/uNXXIgDROE3nrQYDlAeoHtm yDEaaA2Fmj7ogEpEsdLrtukiaXgImjv08QDZCv9Jmk1RgfmBkUJJbm82s9mmVWI32x 7FN0e+Bk+D0SoZNCH4cCQKh7odpO8jBIPM8qm2RGN9pm0bpjAd+En3a2DjC5cBIHNk P9zisnV7Z9uvA== From: Nikita Travkin Date: Tue, 01 Aug 2023 14:09:26 +0500 Subject: [PATCH v4 2/2] input: zinitix: Add touchkey support MIME-Version: 1.0 Message-Id: <20230801-zinitix-tkey-v4-2-b85526c5a474@trvn.ru> References: <20230801-zinitix-tkey-v4-0-b85526c5a474@trvn.ru> In-Reply-To: <20230801-zinitix-tkey-v4-0-b85526c5a474@trvn.ru> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Srba , Linus Walleij Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nikita Travkin X-Developer-Signature: v=1; a=openpgp-sha256; l=5056; i=nikita@trvn.ru; h=from:subject:message-id; bh=yNGffE2xORf7vTs2Y1W53hQMQRyrUgd9ZhG7sX37y4A=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBkyMvLM2Nf8SA/czU3HoTxrDPUJ/IPRby80sAm+ rJumybz3nSJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZMjLywAKCRBDHOzuKBm/ den8D/4khojf1r+/C8XgSbDvRhAGeqR63FHudPA1/rFI9dJOFGxCHsRRwOUn/E5a0WsltefurHX nZ7+wZ01WHndrfUZSHF2WiogfRhvupwPK+8IfQl6igrmOeKovmtVNFQRmd0ZAnzCPYVSdwHmiqD 6KfOaDngQte2j4mOG0/JvE5BwxWMA4oUPyAge5X6+CQ2NunhjgtcsNFjgClgRxZYdcNbJZxRMS4 rUkybAPiiteX1VY2D6qtn9j20azMKI9rJhnIag0qlGs32szer8+Smd4FV+AW47u3Ac00cWcp29u s75Ctqf/8sf1C8zja9KsY4RcGDP6Pzx02dR+binCR2LY1Lg0uNQ46n1Mtsn+EnD1XhoGF7b8Ves VHk18/uJA1mwrVsfOu/9PqIiNOyeoizoRlSSVCeRsWh1fV+A6uXpDJliQNTx+bD6YJvEk3KbUFT 7EH5ky/dbcZrLt9uZGSA9KBE5ONIxdvej9bGigt2IpCgd8ifZMcIrhewnL+cknT0QUMmXfmIXhX T2Trqsil4o9IDJDESMNh4bV+UlrWfslFtU3iKOoUDRDKp4Wx/JtlDLxdPjxOkIbULOguvoHp0r+ gEP4P3290bb0mGMmMFxd28ZrbEm9QB8cz0Ixu7Kuuwh6/Yvh5OKzW+zhsFesRCkF1jMvdcOqn+z dNH/XLZEht3ZWrA== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773021399950503409 X-GMAIL-MSGID: 1773021399950503409 Zinitix touch controllers can use some of the sense lines for virtual keys (like those found on many phones). Add support for those keys. Reviewed-by: Linus Walleij Signed-off-by: Nikita Travkin --- drivers/input/touchscreen/zinitix.c | 61 +++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index 1b4807ba4624..75390d67689e 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -119,6 +119,7 @@ #define DEFAULT_TOUCH_POINT_MODE 2 #define MAX_SUPPORTED_FINGER_NUM 5 +#define MAX_SUPPORTED_BUTTON_NUM 8 #define CHIP_ON_DELAY 15 // ms #define FIRMWARE_ON_DELAY 40 // ms @@ -146,6 +147,8 @@ struct bt541_ts_data { struct touchscreen_properties prop; struct regulator_bulk_data supplies[2]; u32 zinitix_mode; + u32 keycodes[MAX_SUPPORTED_BUTTON_NUM]; + int num_keycodes; }; static int zinitix_read_data(struct i2c_client *client, @@ -195,6 +198,7 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) struct i2c_client *client = bt541->client; int i; int error; + u16 int_flags = 0; error = zinitix_write_cmd(client, ZINITIX_SWRESET_CMD); if (error) { @@ -225,6 +229,11 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) if (error) return error; + error = zinitix_write_u16(client, ZINITIX_BUTTON_SUPPORTED_NUM, + bt541->num_keycodes); + if (error) + return error; + error = zinitix_write_u16(client, ZINITIX_INITIAL_TOUCH_MODE, bt541->zinitix_mode); if (error) @@ -235,9 +244,12 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) if (error) return error; - error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, - BIT_PT_CNT_CHANGE | BIT_DOWN | BIT_MOVE | - BIT_UP); + int_flags = BIT_PT_CNT_CHANGE | BIT_DOWN | BIT_MOVE | BIT_UP; + + if (bt541->num_keycodes) + int_flags |= BIT_ICON_EVENT; + + error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, int_flags); if (error) return error; @@ -350,6 +362,15 @@ static void zinitix_report_finger(struct bt541_ts_data *bt541, int slot, } } +static void zinitix_report_keys(struct bt541_ts_data *bt541, u16 icon_events) +{ + int i; + + for (i = 0; i < bt541->num_keycodes; i++) + input_report_key(bt541->input_dev, + bt541->keycodes[i], !!(icon_events & BIT(i))); +} + static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) { struct bt541_ts_data *bt541 = bt541_handler; @@ -358,6 +379,7 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) unsigned long finger_mask; int error; int i; + __le16 icon_events = 0; memset(&touch_event, 0, sizeof(struct touch_event)); @@ -368,6 +390,17 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) goto out; } + if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) { + error = zinitix_read_data(bt541->client, ZINITIX_ICON_STATUS_REG, + &icon_events, sizeof(icon_events)); + if (error) { + dev_err(&client->dev, "Failed to read icon events\n"); + goto out; + } + + zinitix_report_keys(bt541, le16_to_cpu(icon_events)); + } + finger_mask = touch_event.finger_mask; for_each_set_bit(i, &finger_mask, MAX_SUPPORTED_FINGER_NUM) { const struct point_coord *p = &touch_event.point_coord[i]; @@ -453,6 +486,7 @@ static int zinitix_init_input_dev(struct bt541_ts_data *bt541) { struct input_dev *input_dev; int error; + int i; input_dev = devm_input_allocate_device(&bt541->client->dev); if (!input_dev) { @@ -470,6 +504,14 @@ static int zinitix_init_input_dev(struct bt541_ts_data *bt541) input_dev->open = zinitix_input_open; input_dev->close = zinitix_input_close; + if (bt541->num_keycodes) { + input_dev->keycode = bt541->keycodes; + input_dev->keycodemax = bt541->num_keycodes; + input_dev->keycodesize = sizeof(bt541->keycodes[0]); + for (i = 0; i < bt541->num_keycodes; i++) + input_set_capability(input_dev, EV_KEY, bt541->keycodes[i]); + } + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); @@ -534,6 +576,19 @@ static int zinitix_ts_probe(struct i2c_client *client) return error; } + bt541->num_keycodes = of_property_read_variable_u32_array( + client->dev.of_node, "linux,keycodes", + bt541->keycodes, 0, + ARRAY_SIZE(bt541->keycodes)); + if (bt541->num_keycodes == -EINVAL) { + bt541->num_keycodes = 0; + } else if (bt541->num_keycodes < 0) { + dev_err(&client->dev, + "Unable to parse \"linux,keycodes\" property: %d\n", + bt541->num_keycodes); + return bt541->num_keycodes; + } + error = zinitix_init_input_dev(bt541); if (error) { dev_err(&client->dev,