From patchwork Wed Jul 17 13:55:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 813288 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28E3C1802DA; Wed, 17 Jul 2024 13:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.87.146.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721224562; cv=none; b=Ld26mrjzfxCG7JiwONrzLEwpqxdhDdC7jsbbYqq6FcX5LAHEWS7n7rqV4SV8xTlAWqeRVcY6JLvyvDPNfj6IP61v15wQ2cpDaB/sNnC9MAiUaBhS8P8EGiY/YzFO7A1pHkxc/Aod6pAkqRDWTGUXGyUj8Iz13SDYww6k1xNpOWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721224562; c=relaxed/simple; bh=bmIgxc0PzdJDo8ZRzTqn8JeYF2n5fgLK8q0l12myA9A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nJC1oT3B2lgcdzZmZnYv2R37gxq4nXbwUvNIiF3S76/oYKFoAht9S8sclEbpgDGbUG7qCCps+zdgWvTRnj/dovVM6bi7StmFUdgprnju44Tq7yCcR/3m2GfFAAQIKtjTLJFz+wv56XHIHXMzhIOjkNndxoHor1dLUuYddCaOA5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru; spf=pass smtp.mailfrom=trvn.ru; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b=cYIHzjHQ; arc=none smtp.client-ip=194.87.146.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trvn.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b="cYIHzjHQ" 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 B9B45403F4; Wed, 17 Jul 2024 18:55:44 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1721224545; bh=bmIgxc0PzdJDo8ZRzTqn8JeYF2n5fgLK8q0l12myA9A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cYIHzjHQV7CBHagqdBR3sm699Tg0u27LnoYgRWx2Ot9iLkl9q3CaE/Gmx4cPmA7N6 joo6QeX3G7iY7c8DpMAsZobbBQ94YwDCkkdL6vyNliMMooFlZCT+H2nSrUMzwdc/Zi CM3YNb90aU35fyILeYerGqJBfLjaFFV0R7ZJdX5rVYxkiV7zVb2W/3lpmvcG1v+SME GHBzW4KOPUkuaURxW5D9IWmI/TNeE9RlTuZrI8Q9vrP43JEc4a1FZdtUildeXu6ubI +xTr0ZeiGlhLl8oWnZlNtbp+UjuEau7JxyXpPwf1zgwC1whsw+N1uxyRLIwWjlsFQk e3nO42Obi8otQ== From: Nikita Travkin Date: Wed, 17 Jul 2024 18:55:33 +0500 Subject: [PATCH v5 1/2] dt-bindings: input: zinitix: Document touch-keys support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240717-zinitix-tkey-v5-1-52ea4cd4bd50@trvn.ru> References: <20240717-zinitix-tkey-v5-0-52ea4cd4bd50@trvn.ru> In-Reply-To: <20240717-zinitix-tkey-v5-0-52ea4cd4bd50@trvn.ru> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Srba , Linus Walleij , Rob Herring , Krzysztof Kozlowski 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=1461; i=nikita@trvn.ru; h=from:subject:message-id; bh=bmIgxc0PzdJDo8ZRzTqn8JeYF2n5fgLK8q0l12myA9A=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBml81dHjEAfCI3XnrhUSe8s0YNX8R/sQ0JhiLgi SArsSoo6bGJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZpfNXQAKCRBDHOzuKBm/ deDZD/9QMcV+Ppzf0xMsZS3V5LJMgoYMmYZ8J6acMpNDpYmvCqvMzqAA+vdHq0eMHK3fVtLh9hE 7pdB0935ETiu1xK31P5QOSsse8acU1/P6Jdq7yO+11w26GTEHgXAzRYIKSJyBSDRT1VQ/IBYFN/ R9ym/77u6quaTHbdgJLUHbeB1NSyPIcm0hgk35qJZaCYC3a6Dxoxe47WAbM7wUqq3XOnLwZKHuB dYm6X2s/u3MkO8mxgJHOaidepHO7I/QQ7UNzMQukXAggs7EndBgqIYRnJHorVEs7uLJxt203mHu SO/zfIlyF8DjUwQZx1bbUEhLEAZk/fwffXVrkyf7XssZK9YIcwlp6v364gz+AWpTN+qeabCR60H bV3K/TLpD245v9YJkT8Mfd9Vl9ZTmY9dlg9fv5NI1p3zcgGVC8v+s/+QZeRHrjsBuNnm10Z2jQU UDXxA6UfpGSWWtnh4Q85MbIR4C+ddut7KVI96c63v23G9oaofj8xERDpby5I3BiHp7a/Y20zpM4 77uc1w5QXFXyKeEvI1k9iAs6iTghLOtRT/bMBIBlo3obqjbYUh1at8uPGv7duAf3gd+KsljCEHv k6FjWHibLkDZTfzQrKLWMZlHIYohc54qYRogjEBqrVHUIYnXMLH2i4NVHyo4/xLc6C4El1TrcmN Gm7AtnnpUrIcbHA== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 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 Wed Jul 17 13:55:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 813061 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28DE9180053; Wed, 17 Jul 2024 13:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.87.146.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721224562; cv=none; b=DQ9t9/1WI6FKtBZwoLiU6ep8ti9SlOb5wIhzn0tiJsevHmNEuahjCZUKxeroLs1zNQbTXjZ5Fd3FyArl46fmSxEenAcUuel89AV/44Xber0gUzX2nYgIPX8JJ7MUKTIKV91JEvu75y1mD/JampYBn7hqIhBTPnflozXvQOvBVTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721224562; c=relaxed/simple; bh=t6zNy31B64DMsjtCyfWmRr63vBv9RmhXGUzzvZfhK3k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D1NTeAQRV1QEbmighSt4AkhnkwiIWynBAWAT/1ASrK0yN5DU+Nqs9pbtwBQa8htUJhcApOq2D85gaqAhKJrM2p1f6ofidhKWZI+ToG8RAMALV2HwPMCMBVUWPntbzAE466oo7VsHjaNqz63vxLv4M6WLCo78udnj5BLd0VjWNyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru; spf=pass smtp.mailfrom=trvn.ru; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b=W0Uia3v4; arc=none smtp.client-ip=194.87.146.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=trvn.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trvn.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trvn.ru header.i=@trvn.ru header.b="W0Uia3v4" 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 99D5A427AB; Wed, 17 Jul 2024 18:55:48 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1721224549; bh=t6zNy31B64DMsjtCyfWmRr63vBv9RmhXGUzzvZfhK3k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=W0Uia3v4cNYqDP0OVrcgjszuWL6h6pCvTtBMCltanwNmgEWyW3wr7jqLXtTW4KfTi RqTJlbnz8iGmqI3u/GijAj86aRe2Eg13sm0dVD6mAfrEoXaGDgm1KjX6eMHyVOvqR3 s7f8gp4eLeq3M57yn7EkEqXb9bRss1gzKsM+4B5GkL5H3WYounfSkjurz9w813z13v SIPHz9rSN2jZRgXzbgGrR3ftIkI2x6lIF6KsnCDPnN9EmtlS1K/zP8GP763JrjCZ0+ E8sVRIAN3mNaLhe91bH0cMIaL3k+V5TktEr9r6v/ieDu+74MvThmgACXAeqvpvmZoY RJDSdAm7PXFPQ== From: Nikita Travkin Date: Wed, 17 Jul 2024 18:55:34 +0500 Subject: [PATCH v5 2/2] input: zinitix: Add touchkey support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240717-zinitix-tkey-v5-2-52ea4cd4bd50@trvn.ru> References: <20240717-zinitix-tkey-v5-0-52ea4cd4bd50@trvn.ru> In-Reply-To: <20240717-zinitix-tkey-v5-0-52ea4cd4bd50@trvn.ru> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Srba , Linus Walleij , Rob Herring , Krzysztof Kozlowski 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=5266; i=nikita@trvn.ru; h=from:subject:message-id; bh=t6zNy31B64DMsjtCyfWmRr63vBv9RmhXGUzzvZfhK3k=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBml81dMatw8vJZHUXQB87T4OPu5FkSHEPE19K0t Ob+2mqTpkOJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZpfNXQAKCRBDHOzuKBm/ dWIvD/4hJCrUcoGESEsJa/BAmnOINsP8q3C0pPvBN47RVu8P3C8vN92+LJIgO2iXaFzUZST+9CZ lBczJY+jtHAbNgnCm58MMgxEOHdo2IMD949qm1potydOIy+8ywOBA4/ww8brd6NSrGJPu3BpQ5J dMIAVKG4niFpeYJR3BxmiER4+MHPbZZzfNITDpNttA30ZHxA5iqf7J45qACkOXmokrLwsNq+kF7 XbJB0pwc4V6H+ky1dr+efzPWtvPvbj+AZXENIaZsPetc7E6ayDDiz4XsnOL/s9xELBXcPAejavG wNMnTeg0F+FsArnTB/vIG/Ws95DZu/IMtGVaaynFJPx6Wj8vfKxGPBtlZO2Y1B6UeFEKdLQA9Z8 Ce3JV4e6FGCR06SiwpmKLqJRNd2pdJMatBKMOqM3h7MyaRBHtb2sbkmIl2M5HneeOtqbv9D15Nc WeQQ9TQZMSTSCofjEJ+EKJcnEa9FI6eeEj5pGORR5VMU1oPkHrbrLjs5pUCf3CH0GMZB+SSHUjz va1kNUPFNAwdKLL3MdWHbYjvwP70Bmf3drUMC4rmhUsDti4yijdsbpLuY8fijsX0rwpf54rhHGc Uez9XctyDIJd/6DBC6XK1ktszS44iUQLWHo7j02pRaCvyaLx8fgoAcHx3jP7MC7otlVkz97on15 agOiDxSZqPfk9rg== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 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 | 63 +++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index 1b4807ba4624..1df93c96f6bf 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -119,6 +120,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 +148,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 +199,7 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) struct i2c_client *client = bt541->client; int i; int error; + u16 int_flags; error = zinitix_write_cmd(client, ZINITIX_SWRESET_CMD); if (error) { @@ -225,6 +230,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 +245,11 @@ 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,12 +362,22 @@ 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; struct i2c_client *client = bt541->client; struct touch_event touch_event; unsigned long finger_mask; + __le16 icon_events; int error; int i; @@ -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,21 @@ static int zinitix_ts_probe(struct i2c_client *client) return error; } + bt541->num_keycodes = device_property_count_u32(&client->dev, "linux,keycodes"); + if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) { + dev_err(&client->dev, "too many keys defined (%d)\n", bt541->num_keycodes); + return -EINVAL; + } + + error = device_property_read_u32_array(&client->dev, "linux,keycodes", + bt541->keycodes, + bt541->num_keycodes); + if (error) { + dev_err(&client->dev, + "Unable to parse \"linux,keycodes\" property: %d\n", error); + return error; + } + error = zinitix_init_input_dev(bt541); if (error) { dev_err(&client->dev,