HID: autoload hid-multitouch as needed
PATCH v2 1/1 HID: autoload hid-multitouch as needed
From: Benjamin Tissoires <[email protected]>
When the generic hid parsing of the report descriptors in hid-core detects that the device contains the field ContactID, the device should be handled by hid-multitouch, and hid-core should release it. This patch implements a temporary fix for hid-core to automatically call the loading of hid-multitouch. A better solution would involve userspace.
The code is inspired from what is done in the bttv module.
---
Hi guys,
I finally managed to find some time to resend this patch.
Cheers,
Benjamin
drivers/hid/hid-core.c | 33 ++++++++++++++++++++++++++++++++- include/linux/hid.h | 8 ++++++++ 2 files changed, 40 insertions(+), 1 deletions(-)
drivers/hid/hid-core.c +32 -1
@@ -1210,6 +1210,31 @@ static struct bin_attribute dev_bin_attr_report_desc = { .size = HID_MAX_DESCRIPTOR_SIZE, }; +#if defined(CONFIG_MODULES ) && defined(MODULE ) +/* Loading of hid_multitouch. This is done from the kernel until we come up +* with a more robust solution. */ +static void hid_request_hid_mt_module_async (struct work_struct *work) +{ +request_module ("hid-multitouch" ); +} + +static void hid_request_hid_mt_module (struct hid_device *dev) +{ + dev->request_hid_mt_module =1 ; +INIT_WORK (&dev->request_hid_mt_module_wk, + hid_request_hid_mt_module_async); +schedule_work (&dev->request_hid_mt_module_wk); +} + +static void hid_flush_request_modules (struct hid_device *dev) +{ +flush_work_sync (&dev->request_hid_mt_module_wk); +} +#else +#define hid_request_hid_mt_module (dev) +#define hid_flush_request_modules (dev) +#endif /* CONFIG_MODULES */ +int hid_connect (struct hid_device *hdev,unsigned int connect_mask) {static const char *types[] = {"Device" ,"Pointer" ,"Mouse" ,"Device" ,
@@ -1235,7 +1260,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) connect_mask & HID_CONNECT_HIDINPUT_FORCE)) hdev->claimed |= HID_CLAIMED_INPUT;if (hdev->quirks &HID_QUIRK_MULTITOUCH ) { -/* this device should be handled by hid-multitouch, skip it */ +/* this device should be handled by hid-multitouch, request +* for hid-multitouch to be loaded and leave the device to it */ +hid_request_hid_mt_module (hdev);return -ENODEV ; }
@@ -2107,6 +2134,8 @@ struct hid_device *hid_allocate_device(void)INIT_LIST_HEAD (&hdev->debug_list);sema_init (&hdev->driver_lock,1 ); + hdev->request_hid_mt_module =0 ; +return hdev; err:put_device (&hdev->dev);
@@ -2121,6 +2150,8 @@ static void hid_remove_device(struct hid_device *hdev)hid_debug_unregister (hdev); hdev->status &= ~HID_STAT_ADDED ; } +if (hdev->request_hid_mt_module) +hid_flush_request_modules (hdev); }/**
include/linux/hid.h +8 -0
@@ -538,6 +538,14 @@ struct hid_device { /* device report descriptor */struct dentry *debug_events;struct list_head debug_list;wait_queue_head_t debug_wait; + +/* This is a temporary fix to make hid-multitouch loadable from +* the kernel before we come up with more robust solution +* (with userspace involvement). +* In case we detect a multitouch device through the parsing of +* hid-core, we request for hid-multitouch to be loaded. */ +struct work_struct request_hid_mt_module_wk; +bool request_hid_mt_module; };static inline void *hid_get_drvdata (struct hid_device *hdev)
Signature · 1 line
1.7.7.6
Hi Benjamin,
Quoted 7 lines
When the generic hid parsing of the report descriptors in hid-core detects that the device contains the field ContactID, the device should be handled by hid-multitouch, and hid-core should release it. This patch implements a temporary fix for hid-core to automatically call the loading of hid-multitouch. A better solution would involve userspace.
Quoted 8 lines
The code is inspired from what is done in the bttv module.
Signed-off-by Benjamin Tissoires <[email protected]>---
Hi guys,
I finally managed to find some time to resend this patch.
Great, please find some comments inline.
Quoted 15 lines
drivers/hid/hid-core.c | 33 ++++++++++++++++++++++++++++++++- include/linux/hid.h | 8 ++++++++ 2 files changed, 40 insertions(+), 1 deletions(-)drivers/hid/hid-core.c +3
-0@@ -1210,6 +1210,31 @@ static struct bin_attribute dev_bin_attr_report_desc = { .size = HID_MAX_DESCRIPTOR_SIZE, }; +#if defined(CONFIG_MODULES ) && defined(MODULE ) +/* Loading of hid_multitouch. This is done from the kernel until we come up +* with a more robust solution. */
drivers/hid/hid-core.c static struct bin_attribute dev_bin_attr_report_desc = { · line 1225
Quoted 10 lines
drivers/hid/hid-core.c +10
-0+static void hid_request_hid_mt_module_async (struct work_struct *work) +{ +request_module ("hid-multitouch" ); +} + +static void hid_request_hid_mt_module (struct hid_device *dev) +{ + dev->request_hid_mt_module =1 ; +INIT_WORK (&dev->request_hid_mt_module_wk, + hid_request_hid_mt_module_async);
This init would probably be better off as a static declaration; after all, we do not need one workqueue per hid device.
Quoted 27 lines
drivers/hid/hid-core.c +15
-1+schedule_work (&dev->request_hid_mt_module_wk); +} + +static void hid_flush_request_modules (struct hid_device *dev) +{ +flush_work_sync (&dev->request_hid_mt_module_wk); +} +#else +#define hid_request_hid_mt_module (dev) +#define hid_flush_request_modules (dev) +#endif /* CONFIG_MODULES */ +int hid_connect (struct hid_device *hdev,unsigned int connect_mask) {static const char *types[] = {"Device" ,"Pointer" ,"Mouse" ,"Device" ,@@ -1235,7 +1260,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) connect_mask & HID_CONNECT_HIDINPUT_FORCE)) hdev->claimed |= HID_CLAIMED_INPUT;if (hdev->quirks &HID_QUIRK_MULTITOUCH ) { -/* this device should be handled by hid-multitouch, skip it */ +/* this device should be handled by hid-multitouch, request +* for hid-multitouch to be loaded and leave the device to it */ +hid_request_hid_mt_module (hdev);return -ENODEV ; }
drivers/hid/hid-core.c struct hid_device *hid_allocate_device(void) · line 2138
Quoted 5 lines
drivers/hid/hid-core.c +2
-0@@ -2107,6 +2134,8 @@ struct hid_device *hid_allocate_device(void)INIT_LIST_HEAD (&hdev->debug_list);sema_init (&hdev->driver_lock,1 ); + hdev->request_hid_mt_module =0 ; +
Allocated using kzalloc, so no need.
drivers/hid/hid-core.c static void hid_remove_device(struct hid_device *hdev) · line 2154
Quoted 9 lines
drivers/hid/hid-core.c +2
-0return hdev; err:put_device (&hdev->dev);@@ -2121,6 +2150,8 @@ static void hid_remove_device(struct hid_device *hdev)hid_debug_unregister (hdev); hdev->status &= ~HID_STAT_ADDED ; } +if (hdev->request_hid_mt_module) +hid_flush_request_modules (hdev);
I would put the test inside the flush function instead, to restrict the use of the bare variables.
Quoted 9 lines
drivers/hid/hid-core.c +0
-0}/** include/linux/hid.h +0
-0@@ -538,6 +538,14 @@ struct hid_device { /* device report descriptor */struct dentry *debug_events;
include/linux/hid.h struct hid_device { /* device report descriptor */ · line 548
Quoted 10 lines
include/linux/hid.h +8
-0struct list_head debug_list;wait_queue_head_t debug_wait; + +/* This is a temporary fix to make hid-multitouch loadable from +* the kernel before we come up with more robust solution +* (with userspace involvement). +* In case we detect a multitouch device through the parsing of +* hid-core, we request for hid-multitouch to be loaded. */ +struct work_struct request_hid_mt_module_wk; +bool request_hid_mt_module;
This increases memory per hid device, which is not so nice. A static declaration in the core module ought to suffice. Probably needs additional locking as well.
Quoted 6 lines
include/linux/hid.h +0
-0};static inline void *hid_get_drvdata (struct hid_device *hdev)Signature · 1 line
1.7.7.6
Thanks,
Henrik
Hi Henrik,
I'll do the requested changes: no need to comment ;-)
Cheers,
Benjamin
Quoted 123 lines · Henrik Rydberg
Hi Benjamin,
Quoted 7 lines
When the generic hid parsing of the report descriptors in hid-core detects that the device contains the field ContactID, the device should be handled by hid-multitouch, and hid-core should release it. This patch implements a temporary fix for hid-core to automatically call the loading of hid-multitouch. A better solution would involve userspace.
Quoted 8 lines
The code is inspired from what is done in the bttv module.
Signed-off-by Benjamin Tissoires <[email protected]>---
Hi guys,
I finally managed to find some time to resend this patch.
Great, please find some comments inline.
Quoted 15 lines
drivers/hid/hid-core.c | 33 ++++++++++++++++++++++++++++++++-
include/linux/hid.h| 8 ++++++++2 files changed, 40 insertions(+), 1 deletions(-)drivers/hid/hid-core.c +3
-0@@ -1210,6 +1210,31 @@ static struct bin_attribute dev_bin_attr_report_desc = { .size = HID_MAX_DESCRIPTOR_SIZE, }; +#if defined(CONFIG_MODULES ) && defined(MODULE ) +/* Loading of hid_multitouch. This is done from the kernel until we come up +* with a more robust solution. */ drivers/hid/hid-core.c static struct bin_attribute dev_bin_attr_report_desc = { · line 1225
Quoted 10 lines
drivers/hid/hid-core.c +10
-0+static void hid_request_hid_mt_module_async (struct work_struct *work) +{ + request_module("hid-multitouch"); +} + +static void hid_request_hid_mt_module (struct hid_device *dev) +{ + dev->request_hid_mt_module = 1; + INIT_WORK(&dev->request_hid_mt_module_wk, + hid_request_hid_mt_module_async);This init would probably be better off as a static declaration; after all, we do not need one workqueue per hid device.
Quoted 27 lines
drivers/hid/hid-core.c +15
-1+ schedule_work(&dev->request_hid_mt_module_wk); +} + +static void hid_flush_request_modules (struct hid_device *dev) +{ + flush_work_sync(&dev->request_hid_mt_module_wk); +} +#else +#define hid_request_hid_mt_module (dev) +#define hid_flush_request_modules (dev) +#endif /* CONFIG_MODULES */ + int hid_connect(struct hid_device *hdev, unsigned int connect_mask) { static const char *types[] = { "Device", "Pointer", "Mouse", "Device",@@ -1235,7 +1260,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) connect_mask & HID_CONNECT_HIDINPUT_FORCE)) hdev->claimed |= HID_CLAIMED_INPUT; if (hdev->quirks & HID_QUIRK_MULTITOUCH) { - /* this device should be handled by hid-multitouch, skip it */ + /* this device should be handled by hid-multitouch, request + * for hid-multitouch to be loaded and leave the device to it */ + hid_request_hid_mt_module(hdev); return -ENODEV; }drivers/hid/hid-core.c struct hid_device *hid_allocate_device(void) · line 2138
Quoted 5 lines
drivers/hid/hid-core.c +2
-0@@ -2107,6 +2134,8 @@ struct hid_device *hid_allocate_device(void) INIT_LIST_HEAD(&hdev->debug_list); sema_init(&hdev->driver_lock, 1); + hdev->request_hid_mt_module = 0; +Allocated using kzalloc, so no need.
drivers/hid/hid-core.c static void hid_remove_device(struct hid_device *hdev) · line 2154
Quoted 9 lines
drivers/hid/hid-core.c +0
-0return hdev;err:
put_device(&hdev->dev);drivers/hid/hid-core.c +2
-0@@ -2121,6 +2150,8 @@ static void hid_remove_device(struct hid_device *hdev) hid_debug_unregister(hdev); hdev->status &= ~HID_STAT_ADDED; } + if (hdev->request_hid_mt_module) + hid_flush_request_modules(hdev);I would put the test inside the flush function instead, to restrict the use of the bare variables.
Quoted 9 lines
drivers/hid/hid-core.c +0
-0} /**include/linux/hid.h +0
-0@@ -538,6 +538,14 @@ struct hid_device { /* device report descriptor */ struct dentry *debug_events;include/linux/hid.h struct hid_device { /* device report descriptor */ · line 548
Quoted 10 lines
include/linux/hid.h +8
-0struct list_head debug_list; wait_queue_head_t debug_wait; + + /* This is a temporary fix to make hid-multitouch loadable from + * the kernel before we come up with more robust solution + * (with userspace involvement). + * In case we detect a multitouch device through the parsing of + * hid-core, we request for hid-multitouch to be loaded. */ + struct work_struct request_hid_mt_module_wk; + bool request_hid_mt_module;This increases memory per hid device, which is not so nice. A static declaration in the core module ought to suffice. Probably needs additional locking as well.
Quoted 2 lines
include/linux/hid.h +0
-0};
Quoted 7 lines
Quoted 4 lines
include/linux/hid.h +0
-1static inline void *hid_get_drvdata(struct hid_device *hdev) --1.7.7.6
Thanks,
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html