Input: hynitron-cst816x: axes, gesture keys and panel power
Subsystems (3)
v2 cover Input: hynitron-cst816x: axes, gesture keys and panel power
This series improves the hynitron-cst816x touchscreen driver. It makes the driver respect the common touchscreen axis properties, which are now documented in the binding as well, it keeps gesture keys from getting stuck, and it lets the controller follow the panel it is mounted on.
The gesture key is reported with the controller's touch flag as its value, so the key stays pressed once the controller stops reporting the gesture code. The controller has no lift event to offer, so the keys are now released on the first report carrying no gesture code, or 40 ms after the last one that carried a code, whichever comes first.
Boards which mount the controller on the panel feed it from the panel's rail, so the reset and the interrupt now wait for the panel to be prepared, which the common 'panel' phandle asks for.
Changes since v1:
- the binding allows touchscreen-min-x/y, touchscreen-size-x/y and touchscreen-fuzz-x/y as well, which touchscreen_parse_properties() already honours; the 240x240 default is unchanged
- the binding allows the 'panel' phandle, and patch 5 is new: it follows the panel's power sequence
- the binding commit message carries a justification (Conor Dooley)
- keycodes above KEY_MAX are rejected, which keeps the gesture key lookup inside the input core's key bitmap (Sashiko AI review)
- the timed release is skipped when the interrupt handler re-armed the timer while the timer callback waited for the lock (Sashiko AI review)
- the Sashiko AI review also asked about additionalProperties next to a $ref, which stays, as this binding allows a subset of touchscreen.yaml (writing-schema.rst)
Daniel Golle (5):
dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel
Input: hynitron-cst816x: respect touchscreen DT properties
Input: hynitron-cst816x: release gesture keys
Input: hynitron-cst816x: time out gesture key release
Input: hynitron-cst816x: power sequence with the panel
.../input/touchscreen/hynitron,cst816x.yaml | 16 ++ drivers/input/touchscreen/Kconfig | 2 + drivers/input/touchscreen/hynitron-cst816x.c | 182 +++++++++++++++--- 3 files changed, 171 insertions(+), 29 deletions(-)
base-commit: 6474fa070f2b8013b4b87350b775b8c3be6e8aac
Signature · 1 line
2.55.0
PATCH v2 1/5 dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel
The chip hands out coordinates in its own frame and knows nothing of the panel it is glued to, so how it is oriented against that panel, which coordinate range the assembly reports and how noisy it is are properties of the board. Reference touchscreen.yaml so that a board can state them with the common axis properties. Allow the 'panel' phandle as well, since these controllers are mounted on the panel and fed from its rail, which asks for the two to be power sequenced together.
---
v2:
- allow touchscreen-min-x/y, touchscreen-size-x/y and touchscreen-fuzz-x/y as well (Sashiko AI review)
- allow the 'panel' phandle
- justify the change in the commit message (Conor Dooley)
.../input/touchscreen/hynitron,cst816x.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +16 -0
@@ -36,6 +36,18 @@ properties: - description: Slide right gesture - description: Long press gesture + panel: true + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + required: - compatible - reg
@@ -43,6 +55,9 @@ required: additionalProperties: false +allOf: + - $ref: touchscreen.yaml# + examples: - | #include <dt-bindings/gpio/gpio.h>
@@ -59,6 +74,7 @@ examples: reset-gpios = <&gpio 17 GPIO_ACTIVE_LOW>; linux,keycodes = <KEY_UP>, <KEY_DOWN>, <KEY_LEFT>, <KEY_RIGHT>, <BTN_TOOL_TRIPLETAP>; + touchscreen-swapped-x-y; }; };
Signature · 1 line
2.55.0
PATCH v2 2/5 Input: hynitron-cst816x: respect touchscreen DT properties
In reply to Daniel GolleParse common touchscreen properties and use touchscreen_report_pos() instead of reporting raw absolute position.
This makes the driver respect the touchscreen-min-x/y, touchscreen-size-x/y, touchscreen-fuzz-x/y, touchscreen-inverted-x/y and touchscreen-swapped-x-y properties.
---
v2:
- name all the properties the parser honours, no functional change
drivers/input/touchscreen/hynitron-cst816x.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/input/touchscreen/hynitron-cst816x.c +5 -2
@@ -11,6 +11,7 @@#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/input.h> +#include <linux/input/touchscreen.h> #include <linux/unaligned.h> #include <linux/interrupt.h> #include <linux/module.h>
@@ -31,6 +32,7 @@ struct cst816x_priv {struct input_dev *input;unsigned int keycode[CST816X_NUM_KEYS ];unsigned int keycodemax; +struct touchscreen_properties prop; };static int cst816x_parse_keycodes (struct device *dev,struct cst816x_priv *priv)
@@ -142,6 +144,7 @@ static int cst816x_register_input(struct cst816x_priv *priv)input_set_abs_params (priv->input,ABS_X ,0 ,240 ,0 ,0 );input_set_abs_params (priv->input,ABS_Y ,0 ,240 ,0 ,0 );input_set_capability (priv->input,EV_KEY ,BTN_TOUCH ); +touchscreen_parse_properties (priv->input, false, &priv->prop); priv->input->keycode = priv->keycode; priv->input->keycodesize =sizeof (priv->keycode[0 ]);
@@ -173,8 +176,8 @@ static irqreturn_t cst816x_irq_cb(int irq, void *cookie)if (!cst816x_process_touch (priv, &tch))return IRQ_HANDLED ; -input_report_abs (priv->input,ABS_X , tch.abs_x); -input_report_abs (priv->input,ABS_Y , tch.abs_y); +touchscreen_report_pos (priv->input, &priv->prop, + tch.abs_x, tch.abs_y, false);if (tch.gest) input_report_key(priv->input,
Signature · 1 line
2.55.0
PATCH v2 3/5 Input: hynitron-cst816x: release gesture keys
In reply to Daniel GolleThe gesture key is reported with the value of the touch flag, so it stays pressed once the controller stops reporting the gesture code while the finger is still down. Report the press on its own and release the keys the input core still holds down on the first report that carries no gesture code. Keycodes above KEY_MAX are rejected, as that release looks the key state up in the input core's key bitmap.
---
v2:
- reject keycodes above KEY_MAX and publish keycodemax only once the whole array validates (Sashiko AI review)
drivers/input/touchscreen/hynitron-cst816x.c | 67 ++++++++++++++------ 1 file changed, 46 insertions(+), 21 deletions(-)
drivers/input/touchscreen/hynitron-cst816x.c +46 -21
@@ -39,28 +39,40 @@ static int cst816x_parse_keycodes(struct device *dev, struct cst816x_priv *priv) {int count;int error; +int i; -if (device_property_present (dev,"linux,keycodes" )) { - count =device_property_count_u32 (dev,"linux,keycodes" ); -if (count <0 ) { - error = count; -dev_err (dev,"failed to count keys: %d\n" , error); -return error; - }else if (count >ARRAY_SIZE (priv->keycode)) { -dev_err (dev,"too many keys defined: %d\n" , count); -return -EINVAL ; - } - priv->keycodemax = count; - - error =device_property_read_u32_array (dev,"linux,keycodes" , - priv->keycode, - priv->keycodemax); -if (error) { -dev_err (dev,"failed to read keycodes: %d\n" , error); -return error; - } +if (!device_property_present (dev,"linux,keycodes" )) +return 0 ; + + count =device_property_count_u32 (dev,"linux,keycodes" ); +if (count <0 ) { + error = count; +dev_err (dev,"failed to count keys: %d\n" , error); +return error; + } + +if (count >ARRAY_SIZE (priv->keycode)) { +dev_err (dev,"too many keys defined: %d\n" , count); +return -EINVAL ; + } + + error =device_property_read_u32_array (dev,"linux,keycodes" , + priv->keycode, count); +if (error) { +dev_err (dev,"failed to read keycodes: %d\n" , error); +return error; } +for (i =0 ; i < count; i++) { +if (priv->keycode[i] <=KEY_MAX ) +continue ; + +dev_err (dev,"keycode %u out of range\n" , priv->keycode[i]); +return -EINVAL ; + } + + priv->keycodemax = count; +return 0 ; }
@@ -168,6 +180,18 @@ static void cst816x_reset(struct cst816x_priv *priv)msleep (100 ); } +static void cst816x_release_keys (struct cst816x_priv *priv) +{ +unsigned int i; + +for (i =0 ; i < priv->keycodemax; i++) { +if (!test_bit (priv->keycode[i], priv->input->key)) +continue ; + +input_report_key (priv->input, priv->keycode[i],0 ); + } +} +static irqreturn_t cst816x_irq_cb (int irq,void *cookie) {struct cst816x_priv *priv = cookie;
@@ -181,8 +205,9 @@ static irqreturn_t cst816x_irq_cb(int irq, void *cookie)if (tch.gest)input_report_key (priv->input, - priv->keycode[cst816x_gest_idx (tch.gest)], - tch.active); + priv->keycode[cst816x_gest_idx (tch.gest)],1 ); +else +cst816x_release_keys (priv);input_report_key (priv->input,BTN_TOUCH , tch.active);
Signature · 1 line
2.55.0
PATCH v2 4/5 Input: hynitron-cst816x: time out gesture key release
In reply to Daniel GolleThe controller reports a gesture code once and can then stay quiet until the next touch, which leaves the gesture key pressed for as long as the panel is left alone. Release the gesture keys 40 ms after the last report that carried a gesture code, so that the release comes from whichever happens first, the timeout or a report without a gesture code. The 40 ms matches TSC200X_PENUP_TIME_MS, chosen there for the same want of a lift event from the controller, and has to stay above the interval between consecutive reports of a held gesture.
---
v2:
- skip the release when the interrupt handler re-armed the timer while the timer callback waited for the lock (Sashiko AI review)
drivers/input/touchscreen/hynitron-cst816x.c | 52 ++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-)
drivers/input/touchscreen/hynitron-cst816x.c +49 -3
@@ -15,9 +15,12 @@#include <linux/unaligned.h> #include <linux/interrupt.h> #include <linux/module.h> +#include <linux/spinlock.h> +#include <linux/timer.h> #define CST816X_RD_REG 0x01#define CST816X_NUM_KEYS 5 +#define CST816X_GEST_HOLD_MS 40struct cst816x_touch {u8 gest;
@@ -32,6 +35,9 @@ struct cst816x_priv {struct input_dev *input;unsigned int keycode[CST816X_NUM_KEYS ];unsigned int keycodemax; +struct timer_list release_timer; +/* lock keeps the timeout out of the middle of a report */ +spinlock_t lock;struct touchscreen_properties prop; };
@@ -180,8 +186,9 @@ static void cst816x_reset(struct cst816x_priv *priv)msleep (100 ); } -static void cst816x_release_keys (struct cst816x_priv *priv) +static bool cst816x_release_keys (struct cst816x_priv *priv) { +bool released = false;unsigned int i;for (i =0 ; i < priv->keycodemax; i++) {
@@ -189,33 +196,66 @@ static void cst816x_release_keys(struct cst816x_priv *priv)continue ;input_report_key (priv->input, priv->keycode[i],0 ); + released = true; } + +return released; +} + +static void cst816x_release_timeout (struct timer_list *t) +{ +struct cst816x_priv *priv =timer_container_of (priv, t, release_timer); +unsigned long flags; + +spin_lock_irqsave (&priv->lock, flags); + +/* a re-arm while this waited for the lock supersedes the timeout */ +if (!timer_pending (&priv->release_timer) &&cst816x_release_keys (priv)) +input_sync (priv->input); + +spin_unlock_irqrestore (&priv->lock, flags); }static irqreturn_t cst816x_irq_cb (int irq,void *cookie) {struct cst816x_priv *priv = cookie;struct cst816x_touch tch; +unsigned long flags;if (!cst816x_process_touch (priv, &tch))return IRQ_HANDLED ; +spin_lock_irqsave (&priv->lock, flags); +touchscreen_report_pos (priv->input, &priv->prop, tch.abs_x, tch.abs_y, false); -if (tch.gest) +if (tch.gest) {input_report_key (priv->input, priv->keycode[cst816x_gest_idx (tch.gest)],1 ); -else +mod_timer (&priv->release_timer, + jiffies +msecs_to_jiffies (CST816X_GEST_HOLD_MS )); + }else { +timer_delete (&priv->release_timer);cst816x_release_keys (priv); + }input_report_key (priv->input,BTN_TOUCH , tch.active);input_sync (priv->input); +spin_unlock_irqrestore (&priv->lock, flags); +return IRQ_HANDLED ; } +static void cst816x_timer_stop (void *data) +{ +struct cst816x_priv *priv = data; + +timer_delete_sync (&priv->release_timer); +} +static int cst816x_probe (struct i2c_client *client) {struct device *dev = &client->dev;
@@ -227,6 +267,8 @@ static int cst816x_probe(struct i2c_client *client)return -ENOMEM ; priv->client = client; +spin_lock_init (&priv->lock); +timer_setup (&priv->release_timer, cst816x_release_timeout,0 ); priv->reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (priv->reset))
@@ -244,6 +286,10 @@ static int cst816x_probe(struct i2c_client *client)if (error)return dev_err_probe (dev, error,"input register failed\n" ); + error =devm_add_action_or_reset (dev, cst816x_timer_stop, priv); +if (error) +return error; + error =devm_request_threaded_irq (dev, client->irq,NULL , cst816x_irq_cb,IRQF_ONESHOT ,dev_driver_string (dev), priv);
Signature · 1 line
2.55.0
PATCH v2 5/5 Input: hynitron-cst816x: power sequence with the panel
In reply to Daniel GolleBoards which mount the controller on the panel feed it from the panel's rail, where a reset and the first interrupts are only meaningful once the panel is powered. Register as a DRM panel follower when the device tree points at a panel, so that the reset stays asserted and the interrupt masked until the panel is prepared, and a pressed key is released before the panel goes down again.
---
v2: new patch
drivers/input/touchscreen/Kconfig | 2 + drivers/input/touchscreen/hynitron-cst816x.c | 60 ++++++++++++++++++-- 2 files changed, 57 insertions(+), 5 deletions(-)
drivers/input/touchscreen/Kconfig +2 -0
@@ -478,6 +478,8 @@ config TOUCHSCREEN_HYNITRON_CSTXXX config TOUCHSCREEN_HYNITRON_CST816X tristate "Hynitron CST816x touchscreen" depends on I2C + # We call into panel code, so if DRM=m, this can't be 'y' + depends on DRM || !DRM help Say Y here if you have a touchscreen using a Hynitron CST816x series touchscreen controller.
drivers/input/touchscreen/hynitron-cst816x.c +55 -5
94 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 4/5] Input: hynitron-cst816x: time out gesture key release
In reply to Daniel GolleThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] timers: use timer_shutdown_sync() for devres teardown path --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] timers: use timer_shutdown_sync() for devres teardown path
--
commit f56704648dd845b470f4641ef231af0c72507d76
Author: Daniel Golle <[email protected]>
Input: hynitron-cst816x: time out gesture key release
This commit introduces a timer to release the gesture keys 40 ms after the last report containing a gesture code. This prevents the gesture key from remaining pressed indefinitely if the panel stops reporting after the initial gesture event.
Quoted 3 lines
drivers/input/touchscreen/hynitron-cst816x.c +0
-0
[ ... ]
drivers/input/touchscreen/hynitron-cst816x.c static void cst816x_release_keys(struct cst816x_priv *priv) · line 256
Quoted 5 lines
drivers/input/touchscreen/hynitron-cst816x.c +5
-0+static void cst816x_timer_stop (void *data) +{ +struct cst816x_priv *priv = data; + +timer_delete_sync (&priv->release_timer);
[Severity: Low]
Does this devres teardown path need to use timer_shutdown_sync() instead of timer_delete_sync()?
Using timer_delete_sync() in a final teardown path is deprecated. The timer subsystem introduced timer_shutdown_sync() to permanently disable timers during teardown.
Because devres executes actions in last-in, first-out order, the interrupt is already freed and synchronized before the timer is stopped. A re-arm race is structurally impossible here, making this an API compliance regression rather than a use-after-free bug.
Quoted 3 lines
drivers/input/touchscreen/hynitron-cst816x.c +2
-0+} +static int cst816x_probe (struct i2c_client *client)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v2 5/5] Input: hynitron-cst816x: power sequence with the panel
In reply to Daniel GolleThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] kconfig: built-in driver links to module due to incomplete DRM_PANEL dependency --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] kconfig: built-in driver links to module due to incomplete DRM_PANEL dependency --
commit 334717615b8688937194889ec9606ffff8c712fd
Author: Daniel Golle <[email protected]>
Input: hynitron-cst816x: power sequence with the panel
Boards which mount the controller on the panel feed it from the panel's rail, where a reset and the first interrupts are only meaningful once the panel is powered. Register as a DRM panel follower when the device tree points at a panel, so that the reset stays asserted and the interrupt masked until the panel is prepared, and a pressed key is released before the panel goes down again.
drivers/input/touchscreen/Kconfig config TOUCHSCREEN_HYNITRON_CSTXXX · line 482
Quoted 10 lines
drivers/input/touchscreen/Kconfig +2
-0@@ -478,6 +478,8 @@ config TOUCHSCREEN_HYNITRON_CSTXXX config TOUCHSCREEN_HYNITRON_CST816X tristate "Hynitron CST816x touchscreen" depends on I2C + # We call into panel code, so if DRM=m, this can't be 'y' + depends on DRM || !DRM
[Severity: Low]
Does this allow a configuration where the driver is built-in but links to a module?
The driver relies on devm_drm_panel_add_follower() from the drm_panel framework. If DRM=y but DRM_PANEL=m, and TOUCHSCREEN_HYNITRON_CST816X=y, the built-in touchscreen driver will have an unresolved external reference to devm_drm_panel_add_follower() in drm_panel.ko, causing a build linking failure.
Should this dependency be tied directly to DRM_PANEL instead, such as depends on DRM_PANEL || !DRM_PANEL?
Quoted 3 lines
drivers/input/touchscreen/Kconfig +0
-0help Say Y here if you have a touchscreen using a Hynitron CST816x series touchscreen controller.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v2 1/5] dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel
In reply to Daniel GolleQuoted 24 lines · Daniel Golle
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +12
-0@@ -36,6 +36,18 @@ properties: - description: Slide right gesture - description: Long press gesture + panel: true + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + required: - compatible - reg
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml required: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +0
-0@@ -43,6 +55,9 @@ required: additionalProperties: false
So just use unevaluatedProperties instead of listing almost entire contents of touchscreen.yaml.
Re: [PATCH v2 1/5] dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 lines · Daniel Golle
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +12
-0@@ -36,6 +36,18 @@ properties: - description: Slide right gesture - description: Long press gesture + panel: true + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + required: - compatible - reg@@ -43,6 +55,9 @@ required:
Quoted 5 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml required: · line 56
Quoted 1 line
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +0
-0additionalProperties: falseSo just use unevaluatedProperties instead of listing almost entire contents of
touchscreen.yaml.
"almost" is the keyword here. If it is acceptable to include properties the driver doesn't (and will never) parse, I'll do that instead.
Re: [PATCH v2 1/5] dt-bindings: input: touchscreen: hynitron,cst816x: axes and panel
Quoted 27 lines · Daniel Golle
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 lines · Daniel Golle
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +12
-0@@ -36,6 +36,18 @@ properties: - description: Slide right gesture - description: Long press gesture + panel: true + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + required: - compatible - reg@@ -43,6 +55,9 @@ required:
Quoted 8 lines
Quoted 5 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml required: · line 56
Quoted 1 line
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml +0
-0additionalProperties: falseSo just use unevaluatedProperties instead of listing almost entire contents of
touchscreen.yaml."almost" is the keyword here. If it is acceptable to include properties the driver doesn't (and will never) parse, I'll do that instead.
And if you add them to the driver, you would be changing the binding? We ask instead to post complete binding (see also writing-bindings).
Best regards,
Krzysztof
Re: [PATCH v2 2/5] Input: hynitron-cst816x: respect touchscreen DT properties
In reply to Daniel GolleQuoted 11 lines · Daniel Golle
Parse common touchscreen properties and use
touchscreen_report_pos()instead of reporting raw absolute position.This makes the driver respect the touchscreen-min-x/y, touchscreen-size-x/y, touchscreen-fuzz-x/y, touchscreen-inverted-x/y and touchscreen-swapped-x-y properties.
Signed-off-by Daniel Golle <[email protected]>---
v2:
- name all the properties the parser honours, no functional change
Tested on Raspberry Pi 4B with CST816S panel, with and without touchscreen-swapped-x-y. Reported coordinates are valid.
Best regards,
Oleh Kuzhylnyi
Re: [PATCH v2 3/5] Input: hynitron-cst816x: release gesture keys
In reply to Daniel GolleQuoted 18 lines · Daniel Golle
The gesture key is reported with the value of the touch flag, so it stays pressed once the controller stops reporting the gesture code while the finger is still down. Report the press on its own and release the keys the input core still holds down on the first report that carries no gesture code. Keycodes above
KEY_MAXare rejected, as that release looks the key state up in the input core's key bitmap.Fixes c87a819bec86 ("Input: add driver for Hynitron CST816x series")Signed-off-by Daniel Golle <[email protected]>---
v2:
- reject keycodes aboveKEY_MAXand publish keycodemax only once the whole array validates (Sashiko AI review)static
irqreturn_tcst816x_irq_cb(int irq, void *cookie){drivers/input/touchscreen/hynitron-cst816x.c +0
-0struct cst816x_priv *priv = cookie;
drivers/input/touchscreen/hynitron-cst816x.c static irqreturn_t cst816x_irq_cb(int irq, void *cookie) · line 208
Quoted 6 lines
drivers/input/touchscreen/hynitron-cst816x.c +1
-2@@ -181,8 +205,9 @@ static irqreturn_t cst816x_irq_cb(int irq, void *cookie)if (tch.gest)input_report_key (priv->input, - priv->keycode[cst816x_gest_idx (tch.gest)], - tch.active); + priv->keycode[cst816x_gest_idx (tch.gest)],1 );
Tested on CST816S setup, found out a subtle issue: cst816x_gest_idx() maps unhandled single-click (0x05) and long-press (0x0C) gestures to index 4.
Input subsystem ignores SINGLE_TOUCH (code 0x5) events with tch.active == 0 (t: 0).
Instead, reporting index 4 (single-click 0x05 minus 1) with tch.active == 1 falls into BTN_TOOL_TRIPLETAP linux,keycodes element.
As a result every single touch accompanied by BTN_TOOL_TRIPLETAP:
Event: time 1791148663.331439, type 3 (EV_ABS), code 0 (ABS_X), value 117
Event: time 1791148663.331439, type 3 (EV_ABS), code 1 (ABS_Y), value 124
Event: time 1791148663.331439, type 1 (EV_KEY), code 334 (BTN_TOOL_TRIPLETAP), value 0
Event: time 1791148663.331439, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1791148663.331439, -------------- SYN_REPORT ------------
Event: time 1791148663.397477, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1791148663.397477, -------------- SYN_REPORT ------------
Event: time 1791148663.409413, type 1 (EV_KEY), code 334 (BTN_TOOL_TRIPLETAP), value 1
Event: time 1791148663.409413, -------------- SYN_REPORT ------------
Interrupts:
cst816x 1-0015: x: 127, y: 124, t: 0, g: 0x5 // Finger down (index 4, tch.active == 1) cst816x 1-0015: x: 117, y: 124, t: 1, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 1, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 0, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 0, g: 0x5 // Finged up (index 4, tch.active == 1)
I suggest either gate the gesture branch on tch.active so a finger-up single-click never fires a key, or fix cst816x_gest_idx() to map 0x5/0xC to their own valid slots so they stop aliasing the TRIPLETAP keycode.
Best regards,
Oleh Kuzhylnyi
Quoted 5 lines
drivers/input/touchscreen/hynitron-cst816x.c +2
-0+else +cst816x_release_keys (priv);input_report_key (priv->input,BTN_TOUCH , tch.active);
Re: [PATCH v2 3/5] Input: hynitron-cst816x: release gesture keys
In reply to Daniel GolleHi!
Thank you for testing, and for reporting the issue.
Quoted 3 lines
I suggest either gate the gesture branch on tch.active so a finger-up single-click never fires a key, or fix
cst816x_gest_idx()to map 0x5/0xC to their own valid slots so they stop aliasing the TRIPLETAP keycode.
v3 takes the second route. cst816x_gest_idx() returned CST816X_NUM_KEYS - 1 for every code its switch did not name, so single click, 0x05, shared the long-press slot. Reporting the key with a fixed value of 1 is what made that alias visible as the BTN_TOOL_TRIPLETAP pair in your log.
The lookup now yields a keycode instead of an index:
static unsigned int cst816x_gest_keycode(struct cst816x_priv *priv,
u8 gest)
{
switch (gest) {
case 0x01: /* Slide up gesture */
case 0x02: /* Slide down gesture */
case 0x03: /* Slide left gesture */
case 0x04: /* Slide right gesture */
return priv->keycode[gest - 1];
case 0x0c: /* Long press gesture */
return priv->keycode[CST816X_NUM_KEYS - 1];
default:
return KEY_RESERVED;
}
}A code the driver does not map is handled like a report that carries no gesture code at all: it releases whatever the input core still holds down, rather than pressing a key that belongs to another gesture. Single click reports nothing of its own, so a tap is described by BTN_TOUCH alone.
I left the gate on tch.active out, because your trace shows the gesture codes arriving with t: 0 on both the finger-down and the finger-up report, and that t is tch.active. Slide gestures reach the driver the same way, at lift, so the gate would silence the keys this series is meant to report, not only the single click.
If a key for single click is wanted, that is a linux,keycodes extension in the binding and can follow on its own.
v3 with that change follows. A retest on your CST816S would be most welcome.