diff mbox series

[2/2] Disable touchpad on firmware level while not in use

Message ID 20250211133950.422232-2-wse@tuxedocomputers.com
State New
Headers show
Series [1/2] Add functions for HID drivers to react on first open and last close call | expand

Commit Message

Werner Sembach Feb. 11, 2025, 1:39 p.m. UTC
Using the new on_hid_hw_open and on_hid_hw_close functions to disable the
touchpad on firmware level while not being in use.

This safes some battery and triggers touchpad-disabled-leds hardwired to
the touchpads firmware, that exist for example on some TongFang barebones.

For a lengthy discussion with all the details see
https://gitlab.freedesktop.org/libinput/libinput/-/issues/558

Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
---
 drivers/hid/hid-multitouch.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Werner Sembach March 4, 2025, 12:14 p.m. UTC | #1
Hi,

Am 11.02.25 um 14:39 schrieb Werner Sembach:
> Using the new on_hid_hw_open and on_hid_hw_close functions to disable the
> touchpad on firmware level while not being in use.
>
> This safes some battery and triggers touchpad-disabled-leds hardwired to
> the touchpads firmware, that exist for example on some TongFang barebones.
>
> For a lengthy discussion with all the details see
> https://gitlab.freedesktop.org/libinput/libinput/-/issues/558

Any comments if this is a good idea or not?

Best regards,

Werner

> Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
> ---
>   drivers/hid/hid-multitouch.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 82900857bfd87..7289c04f47f17 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -1884,6 +1884,16 @@ static void mt_remove(struct hid_device *hdev)
>   	hid_hw_stop(hdev);
>   }
>   
> +static void mt_on_hid_hw_open(struct hid_device *hdev)
> +{
> +	mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
> +}
> +
> +static void mt_on_hid_hw_close(struct hid_device *hdev)
> +{
> +	mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE);
> +}
> +
>   /*
>    * This list contains only:
>    * - VID/PID of products not working with the default multitouch handling
> @@ -2351,5 +2361,7 @@ static struct hid_driver mt_driver = {
>   	.suspend = pm_ptr(mt_suspend),
>   	.reset_resume = pm_ptr(mt_reset_resume),
>   	.resume = pm_ptr(mt_resume),
> +	.on_hid_hw_open = mt_on_hid_hw_open,
> +	.on_hid_hw_close = mt_on_hid_hw_close,
>   };
>   module_hid_driver(mt_driver);
Jiri Kosina April 24, 2025, 9:20 a.m. UTC | #2
On Tue, 4 Mar 2025, Werner Sembach wrote:

> > Using the new on_hid_hw_open and on_hid_hw_close functions to disable the
> > touchpad on firmware level while not being in use.
> >
> > This safes some battery and triggers touchpad-disabled-leds hardwired to
> > the touchpads firmware, that exist for example on some TongFang barebones.
> >
> > For a lengthy discussion with all the details see
> > https://gitlab.freedesktop.org/libinput/libinput/-/issues/558
> 
> Any comments if this is a good idea or not?

Sorry for the delay.

To me this looks like generally a good idea; Benjamin, any comments on the 
hid-mt part?

BTW you'd need to adjust the Subject line of the patches to conform to the 
subsystem style (i.e. HID: core: ....)

Thanks,
Werner Sembach April 24, 2025, 10:58 a.m. UTC | #3
Am 24.04.25 um 11:20 schrieb Jiri Kosina:
> On Tue, 4 Mar 2025, Werner Sembach wrote:
>
>>> Using the new on_hid_hw_open and on_hid_hw_close functions to disable the
>>> touchpad on firmware level while not being in use.
>>>
>>> This safes some battery and triggers touchpad-disabled-leds hardwired to
>>> the touchpads firmware, that exist for example on some TongFang barebones.
>>>
>>> For a lengthy discussion with all the details see
>>> https://gitlab.freedesktop.org/libinput/libinput/-/issues/558
>> Any comments if this is a good idea or not?
> Sorry for the delay.
np
>
> To me this looks like generally a good idea; Benjamin, any comments on the
> hid-mt part?
>
> BTW you'd need to adjust the Subject line of the patches to conform to the
> subsystem style (i.e. HID: core: ....)

sorry an oversight when rewriting the commit log from local testing branch to 
upstream ready

will do in v2 after Benjamins reply

Thanks for looking at this,

Werner

>
> Thanks,
>
diff mbox series

Patch

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 82900857bfd87..7289c04f47f17 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1884,6 +1884,16 @@  static void mt_remove(struct hid_device *hdev)
 	hid_hw_stop(hdev);
 }
 
+static void mt_on_hid_hw_open(struct hid_device *hdev)
+{
+	mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
+}
+
+static void mt_on_hid_hw_close(struct hid_device *hdev)
+{
+	mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE);
+}
+
 /*
  * This list contains only:
  * - VID/PID of products not working with the default multitouch handling
@@ -2351,5 +2361,7 @@  static struct hid_driver mt_driver = {
 	.suspend = pm_ptr(mt_suspend),
 	.reset_resume = pm_ptr(mt_reset_resume),
 	.resume = pm_ptr(mt_resume),
+	.on_hid_hw_open = mt_on_hid_hw_open,
+	.on_hid_hw_close = mt_on_hid_hw_close,
 };
 module_hid_driver(mt_driver);