[PATCH v5 7/10] HID: multitouch: allow specifying if a device is direct in a class

Benjamin Tissoires bentiss at kernel.org
Fri Sep 27 15:59:00 UTC 2024


On Aug 17 2024, Aditya Garg wrote:
> From: Kerem Karabay <kekrby at gmail.com>
> 
> Currently the driver determines the device type based on the
> application, but this value is not reliable on Apple Touch Bars, where
> the application is HID_DG_TOUCHPAD even though the devices are direct,
> so allow setting it in classes.
> 
> Signed-off-by: Kerem Karabay <kekrby at gmail.com>
> Signed-off-by: Aditya Garg <gargaditya08 at live.com>

So that one commit breaks the HID selftests.

For a reproducer:

./tools/testing/selftests/hid/vmtest.sh -- \
  "pip3 install hid-tools attrs pyroute2; \
   pytest -v tools/testing/selftests/hid/tests/ --udevd -k Topseed"

In summary: Topseed devices are weird, and I guess this patch makes them
weirder. Please ensure you do not regress on any known devices (so by
removing '-k Topseed' once this is fixed).

Cheers,
Benjamin

> ---
>  drivers/hid/hid-multitouch.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 60b675cd1..2948fbcbc 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -146,6 +146,7 @@ struct mt_class {
>  	__s32 sn_height;	/* Signal/noise ratio for height events */
>  	__s32 sn_pressure;	/* Signal/noise ratio for pressure events */
>  	__u8 maxcontacts;
> +	bool is_direct;	/* true for touchscreens */
>  	bool is_indirect;	/* true for touchpads */
>  	bool export_all_inputs;	/* do not ignore mouse, keyboards, etc... */
>  };
> @@ -563,13 +564,13 @@ static struct mt_application *mt_allocate_application(struct mt_device *td,
>  	mt_application->application = application;
>  	INIT_LIST_HEAD(&mt_application->mt_usages);
>  
> -	if (application == HID_DG_TOUCHSCREEN)
> +	if (application == HID_DG_TOUCHSCREEN && !td->mtclass.is_indirect)
>  		mt_application->mt_flags |= INPUT_MT_DIRECT;
>  
>  	/*
>  	 * Model touchscreens providing buttons as touchpads.
>  	 */
> -	if (application == HID_DG_TOUCHPAD) {
> +	if (application == HID_DG_TOUCHPAD && !td->mtclass.is_direct) {
>  		mt_application->mt_flags |= INPUT_MT_POINTER;
>  		td->inputmode_value = MT_INPUTMODE_TOUCHPAD;
>  	}
> @@ -1317,6 +1318,9 @@ static int mt_touch_input_configured(struct hid_device *hdev,
>  	if (td->serial_maybe)
>  		mt_post_parse_default_settings(td, app);
>  
> +	if (cls->is_direct)
> +		app->mt_flags |= INPUT_MT_DIRECT;
> +
>  	if (cls->is_indirect)
>  		app->mt_flags |= INPUT_MT_POINTER;
>  
> -- 
> 2.43.0
> 


More information about the dri-devel mailing list