Input: elan_i2c_smbus - resend ENABLE_TP on wake from sleep (NOT TESTED, NEEDS TESTER!) (v2: typo fixes)
Subsystems (2)
RFC PATCH v2 1/1 Input: elan_i2c_smbus - resend ENABLE_TP on wake from sleep (NOT TESTED, NEEDS TESTER!) (v2: typo fixes)
From: "Raphaël Larocque" <[email protected]>
elan_smbus_sleep_control() sends ETP_SMBUS_SLEEP_CMD to put the controller to sleep, but does nothing on wake, leaving a long-standing XXX comment questioning whether ETP_SMBUS_ENABLE_TP should be re-sent.
elan_initialize() already treats sleep_control(client, false) as a genuine "wake device up" primitive (see the ASUS special-firmware branch and its accompanying dev_err() message), so this makes the non-ASUS/default path resend ETP_SMBUS_ENABLE_TP symmetrically with elan_smbus_initialize() instead of being a no-op.
---
RFC: I don't have the Elan SMBus protocol datasheet and consequently haven't been able to test this on any real hardware where the previous no-op path was actually relied upon. Sending this for testing by someone with access to affected devices before it is considered for merge. A bad SMBus write to a sleeping controller could leave it in a weird state on the wrong firmware revision if unlucky.
drivers/input/mouse/elan_i2c_smbus.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/input/mouse/elan_i2c_smbus.c +17 -2
@@ -93,10 +93,25 @@ static int elan_smbus_set_mode(struct i2c_client *client, u8 mode)static int elan_smbus_sleep_control (struct i2c_client *client,bool sleep) { +int error; +if (sleep)return i2c_smbus_write_byte (client,ETP_SMBUS_SLEEP_CMD ); -else -return 0 ;/* XXX should we send ETP_SMBUS_ENABLE_TP here? */ + +/* +* The controller stops touch reporting while asleep; resend +* ETP_SMBUS_ENABLE_TP on wake, mirroring what is done during +* elan_smbus_initialize(), so that reporting actually resumes. +*/ + error =i2c_smbus_write_byte (client,ETP_SMBUS_ENABLE_TP ); +if (error) { +dev_err (&client->dev, +"failed to re-enable touchpad after wake: %d\n" , + error); +return error; + } + +return 0 ; }static int elan_smbus_power_control (struct i2c_client *client,bool enable)
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] input: elan_i2c: ENABLE_TP command sent after set_mode() may clobber absolute mode --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] input: elan_i2c: ENABLE_TP command sent after set_mode() may clobber absolute mode --
commit 37faf4759d30c6532910d41f48a2708415776398
Author: Raphaël Larocque <[email protected]>
Input: elan_i2c_smbus - resend ENABLE_TP on wake from sleep (NOT TESTED, NEEDS TESTER!) (v2: typo fixes)
This commit updates elan_smbus_sleep_control() to resend the ETP_SMBUS_ENABLE_TP command when waking the controller from sleep.
Quoted 8 lines
drivers/input/mouse/elan_i2c_smbus.c +0
-0@@ -93,10 +93,25 @@ static int elan_smbus_set_mode(struct i2c_client *client, u8 mode)static int elan_smbus_sleep_control (struct i2c_client *client,bool sleep) {
[ ... ]
drivers/input/mouse/elan_i2c_smbus.c static int elan_smbus_set_mode(struct i2c_client *client, u8 mode) · line 106
Quoted 6 lines
drivers/input/mouse/elan_i2c_smbus.c +6
-0+/* +* The controller stops touch reporting while asleep; resend +* ETP_SMBUS_ENABLE_TP on wake, mirroring what is done during +* elan_smbus_initialize(), so that reporting actually resumes. +*/ + error =i2c_smbus_write_byte (client,ETP_SMBUS_ENABLE_TP );
[Severity: Medium]
Could this clobber the absolute mode configuration for non-ASUS devices?
Looking at __elan_initialize() in drivers/input/mouse/elan_i2c_core.c, non-ASUS devices first configure absolute mode via set_mode(), and then call sleep_control() to wake the device:
data->mode |= ETP_ENABLE_ABS;
error = data->ops->set_mode(client, data->mode);
if (error) {
...
}
if (!woken_up) {
error = data->ops->sleep_control(client, false);
...
}Since this patch now sends ETP_SMBUS_ENABLE_TP in sleep_control() on wake, it gets transmitted after set_mode() for these non-ASUS devices. Could sending this command after configuring absolute mode reset the hardware to its default relative mode, breaking absolute touch reporting?
Quoted 9 lines
drivers/input/mouse/elan_i2c_smbus.c +8
-0+if (error) { +dev_err (&client->dev, +"failed to re-enable touchpad after wake: %d\n" , + error); +return error; + } + +return 0 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Dmitry Torokhov
maintainerHi Raphaël,
Quoted 12 lines · R. Larocque
From: "Raphaël Larocque" <[email protected]>
elan_smbus_sleep_control()sendsETP_SMBUS_SLEEP_CMDto put the controller to sleep, but does nothing on wake, leaving a long-standing XXX comment questioning whetherETP_SMBUS_ENABLE_TPshould be re-sent.
elan_initialize()already treatssleep_control(client, false)as a genuine "wake device up" primitive (see the ASUS special-firmware branch and its accompanyingdev_err()message), so this makes the non-ASUS/default path resendETP_SMBUS_ENABLE_TPsymmetrically withelan_smbus_initialize()instead of being a no-op.
Quoted 8 lines
Signed-off-by Raphaël Larocque <[email protected]>---
RFC: I don't have the Elan SMBus protocol datasheet and consequently haven't been able to test this on any real hardware where the previous no-op path was actually relied upon. Sending this for testing by someone with access to affected devices before it is considered for merge. A bad SMBus write to a sleeping controller could leave it in a weird state on the wrong firmware revision if unlucky.
I do not have objections in principle, but this really needs testing on real hardware...
Thanks.
Signature · 1 line
Dmitry