Input: stmfts - restore touch after system resume with the device open
Subsystems (3)
PATCH 1/1 Input: stmfts - restore touch after system resume with the device open
stmfts_resume() only calls stmfts_power_on(), which re-initialises the controller and deliberately leaves it in SLEEP_IN, assuming nobody uses the touchscreen yet. That assumption does not hold for a system resume:
userspace keeps the evdev node open, runtime PM still considers the device active and stmfts_input_open() never runs again, so the controller stays asleep with scanning off. On FTS5 the controller interrupt enable command is part of the runtime resume sequence, so the result is a completely dead touchscreen until the input device is reopened.
Factor the scan enable part of stmfts_input_open() into stmfts_start_scan() and, when the input device is open, replay the runtime resume sequence and re-enable scanning from stmfts_resume().
--- drivers/input/touchscreen/stmfts.c | 53 +++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-)
drivers/input/touchscreen/stmfts.c +43 -10
@@ -563,30 +563,23 @@ static int stmfts5_set_scan(struct stmfts_data *sdata, bool enable) err =i2c_master_send (sdata->client, scan_mode_cmd,sizeof (scan_mode_cmd));if (err !=sizeof (scan_mode_cmd))return err <0 ? err : -EIO ;return 0 ; } -static int stmfts_input_open (struct input_dev *dev) +static int stmfts_start_scan (struct stmfts_data *sdata) { -struct stmfts_data *sdata =input_get_drvdata (dev);int err; - err =pm_runtime_resume_and_get (&sdata->client->dev); -if (err) -return err; - err = sdata->ops->set_scan (sdata, true); -if (err) { -pm_runtime_put_sync (&sdata->client->dev); +if (err)return err; - } scoped_guard(mutex, &sdata->mutex) { sdata->running = true;if (sdata->hover_enabled && sdata->ops->set_hover) { err = sdata->ops->set_hover (sdata, true);if (err) dev_warn(&sdata->client->dev,
@@ -601,16 +594,32 @@ static int stmfts_input_open(struct input_dev *dev)/* I can still use only the touch screen */ dev_warn (&sdata->client->dev,"failed to enable touchkey\n" ); }return 0 ; } +static int stmfts_input_open (struct input_dev *dev) +{ +struct stmfts_data *sdata =input_get_drvdata (dev); +int err; + + err =pm_runtime_resume_and_get (&sdata->client->dev); +if (err) +return err; + + err =stmfts_start_scan (sdata); +if (err) +pm_runtime_put_sync (&sdata->client->dev); + +return err; +} +static void stmfts_input_close (struct input_dev *dev) {struct stmfts_data *sdata =input_get_drvdata (dev);int err; err = sdata->ops->set_scan (sdata, false);if (err) dev_warn(&sdata->client->dev,
@@ -1163,18 +1172,42 @@ static int stmfts_suspend(struct device *dev)stmfts_power_off (sdata);return 0 ; }static int stmfts_resume (struct device *dev) {struct stmfts_data *sdata =dev_get_drvdata (dev); +int err; + + err =stmfts_power_on (sdata); +if (err) +return err; + +/* +* stmfts_power_on() leaves the controller in sleep mode. If the +* input device is open, runtime PM still considers the device +* active and will not wake it up again, so redo the runtime +* resume sequence and re-enable scanning here. +*/ +guard (mutex)(&sdata->input->mutex); + +if (!input_device_enabled (sdata->input)) +return 0 ; + + err =stmfts_runtime_resume (dev); +if (err) +return err; -return stmfts_power_on (sdata); + err =stmfts_start_scan (sdata); +if (err) +return err; + +return 0 ; }static const struct dev_pm_ops stmfts_pm_ops = { SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)RUNTIME_PM_OPS (stmfts_runtime_suspend, stmfts_runtime_resume,NULL ) };static const struct stmfts_chip_ops stmfts4_ops = {
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20261123-stmfts-suspend-7878d8ee5c74
Best regards,
Signature · 1 line
David Heidelberg <[email protected]>
Quoted 12 lines · On Mon, Nov 23, 2026 at 05:13:41PM +0100, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
stmfts_resume()only callsstmfts_power_on(), which re-initialises the controller and deliberately leaves it inSLEEP_IN, assuming nobody uses the touchscreen yet. That assumption does not hold for a system resume:
userspace keeps the evdev node open, runtime PM still considers the device active andstmfts_input_open()never runs again, so the controller stays asleep with scanning off. On FTS5 the controller interrupt enable command is part of the runtime resume sequence, so the result is a completely dead touchscreen until the input device is reopened.
Quoted 6 lines
Factor the scan enable part of
stmfts_input_open()intostmfts_start_scan()and, when the input device is open, replay the runtime resume sequence and re-enable scanning fromstmfts_resume().Fixes 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")Signed-off-by David Heidelberg <[email protected]>
Applied, thank you.
Signature · 1 line
Dmitry