From patchwork Wed Oct 13 11:23:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 12555665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 923CBC433EF for ; Wed, 13 Oct 2021 11:30:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7862160D07 for ; Wed, 13 Oct 2021 11:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbhJMLcS (ORCPT ); Wed, 13 Oct 2021 07:32:18 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.22]:10195 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbhJMLcR (ORCPT ); Wed, 13 Oct 2021 07:32:17 -0400 X-Greylist: delayed 356 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Oct 2021 07:32:17 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1634124254; s=strato-dkim-0002; d=gerhold.net; h=Message-Id:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=FCtuDE1u80YNiJ8AFJazorwhZZNNWexK1KT82oYrAqo=; b=K7QYoU2pdc3ZIgCJcgcd2ZmQdtrwZV2DEiLgSZayG2pheNDmKyfG3QvRAL3caZt94c Yuz2ISl205/cQMDPbfzThIw8qAGcAk6qAZ/ePnNyMkBmtmtsDOP2GCoCz1wh8Q6U6hvl eJDHEhYIbUO50duQ+4aOZGW/Qw2bOyrG2QB4UP2zLLtx9BS0vw1hjNGO/y2BYvpBSm6Q SMdDyyKSmYRvECdlEmDBOrGFIvtWwejP+f0E3320ADad4bOyqVJvQ8zjeuijdE/dahy1 BCGihumwFxfaG3JlzrO3fubtaSFMEIrdQ2RT10+gnwJq5M/M3LksyXBWARcklufj6dTl hmsw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXQ7UOGqRde+a0fiL2ZP6Q" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.33.8 AUTH) with ESMTPSA id 301038x9DBOD7gI (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 13 Oct 2021 13:24:13 +0200 (CEST) From: Stephan Gerhold To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Stephan Gerhold Subject: [PATCH 1/2] Input: tm2-touchkey - report scan codes Date: Wed, 13 Oct 2021 13:23:04 +0200 Message-Id: <20211013112305.41574-1-stephan@gerhold.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Report the index of pressed touch key as MSC_SCAN code to userspace so it is possible to identify which of the keys was pressed (not just the function that is currently assigned to the key). This is done similarly also in mcs_touchkey and mpr121_touchkey. Signed-off-by: Stephan Gerhold --- drivers/input/keyboard/tm2-touchkey.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index 6218b1c682ef..ce40ea2d940f 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -156,6 +156,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) goto out; } + input_event(touchkey->input_dev, EV_MSC, MSC_SCAN, index); + if (data & TM2_TOUCHKEY_BIT_PRESS_EV) { for (i = 0; i < touchkey->num_keycodes; i++) input_report_key(touchkey->input_dev, @@ -250,6 +252,7 @@ static int tm2_touchkey_probe(struct i2c_client *client, touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; touchkey->input_dev->id.bustype = BUS_I2C; + input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN); for (i = 0; i < touchkey->num_keycodes; i++) input_set_capability(touchkey->input_dev, EV_KEY, touchkey->keycodes[i]); From patchwork Wed Oct 13 11:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 12555667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89B70C433EF for ; Wed, 13 Oct 2021 11:30:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B79361027 for ; Wed, 13 Oct 2021 11:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbhJMLcY (ORCPT ); Wed, 13 Oct 2021 07:32:24 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:14552 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbhJMLcX (ORCPT ); Wed, 13 Oct 2021 07:32:23 -0400 X-Greylist: delayed 361 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Oct 2021 07:32:22 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1634124254; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=XptmbXlpM3h7fhYWz3DQbghIL528PDytMp77zNP76OI=; b=WCOoteKIXy95dacThsGwCAsqbWttBq1HyC8eAXNJJXBlm1M0lafb93B8DiL6wQ3GJM v09iQiOJ/6860Bc7lw4NzJYWs0KGDXnn+15cfMD1a1YgT0h1Irr08xfU8+nQD1aUPJoC inO+TEUcDkc+bm5vuIcJ2/0zajJn1/9patbQz3BIwK3e6k+qNiBSIssDK3gkc0fXJe4J AY4PfNTIhKIVjyBpjPXPQJ+eLTgchx6Cy6GBN+9tmiCS3CDYdLDFDP2kmWtN/TtaDy4s ndo+/mTtJwM88cTX7nQKoZ8hPKTjaU42AiNHBFwQQqvcfteoaIa1VN90UoMFml5XR3p5 rhOQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXQ7UOGqRde+a0fiL2ZP6Q" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.33.8 AUTH) with ESMTPSA id 301038x9DBOE7gJ (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 13 Oct 2021 13:24:14 +0200 (CEST) From: Stephan Gerhold To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Stephan Gerhold Subject: [PATCH 2/2] Input: tm2-touchkey - allow changing keycodes from userspace Date: Wed, 13 Oct 2021 13:23:05 +0200 Message-Id: <20211013112305.41574-2-stephan@gerhold.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013112305.41574-1-stephan@gerhold.net> References: <20211013112305.41574-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org At the moment the touch keys have key codes assigned from the device tree. In some cases, users might want to change the key code from userspace. There is existing functionality for this in the input core using the EVIOCSKEYCODE ioctl, which is integrated for example into udev. Make it possible to use this functionality for tm2-touchkey by simply making the input core aware of the array that holds the keycodes. Similar code also exists in mcs_touchkey and mpr121_touchkey. Signed-off-by: Stephan Gerhold --- drivers/input/keyboard/tm2-touchkey.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index ce40ea2d940f..632cd6c1c8d4 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -252,6 +252,10 @@ static int tm2_touchkey_probe(struct i2c_client *client, touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; touchkey->input_dev->id.bustype = BUS_I2C; + touchkey->input_dev->keycode = touchkey->keycodes; + touchkey->input_dev->keycodemax = touchkey->num_keycodes; + touchkey->input_dev->keycodesize = sizeof(touchkey->keycodes[0]); + input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN); for (i = 0; i < touchkey->num_keycodes; i++) input_set_capability(touchkey->input_dev, EV_KEY,