usb/hid: The HID Simple Driver Interface 0.4.1 (core)
PATCH 1/1 usb/hid: The HID Simple Driver Interface 0.4.1 (core)
Changelogs (since 0.4.0):
1. Make hidinput_disconnect_core() be more robust, it can not break anything even failed to allocate device struct.
2. Thanks new input device driver API, we need not the extra code for support force-feed device yet, so say bye to CONFIG_HID_SIMPLE_FF.
This is one patch of The HID Simple Driver patches, for convenience, you can find them all in that mail:
[PATCH] usb/hid: The HID Simple Driver Patches 0.4.1 (all-in-one)
The code base is 2.6.19.
Is this ready to merge? or What still is problem in them? Thanks.
drivers/usb/input/hid-core.c +200 -7
@@ -26,6 +26,7 @@#include <asm/byteorder.h> #include <linux/input.h> #include <linux/wait.h> +#include <linux/mutex.h> #undef DEBUG#undef DEBUG_DATA
@@ -33,6 +34,7 @@#include <linux/usb.h> #include "hid.h" +#include "hid-simple.h" #include <linux/hiddev.h> /*
@@ -46,6 +48,15 @@static char *hid_types[] = {"Device" ,"Pointer" ,"Mouse" ,"Device" ,"Joystick" ,"Gamepad" ,"Keyboard" ,"Keypad" ,"Multi-Axis Controller" }; + +/* +* The global data structure for simple device driver interface. +*/ +static DEFINE_MUTEX (matched_devices_lock); +static DEFINE_MUTEX (simple_drivers_lock); +static struct list_head matched_devices_list; +static struct list_head simple_drivers_list; +/* * Module parameters. */
@@ -818,8 +829,13 @@ static __inline__ int search(__s32 *arrastatic void hid_process_event (struct hid_device *hid,struct hid_field *field,struct hid_usage *usage,__s32 value,int interrupt) {hid_dump_input (usage, value); -if (hid->claimed &HID_CLAIMED_INPUT ) -hidinput_hid_event (hid, field, usage, value); +if (hid->claimed &HID_CLAIMED_INPUT ) { +if (!hidinput_simple_event_filter (hid, field, usage, value)) +return ; +hidinput_hid_event (hid, field, usage, value); +hidinput_simple_event_post (hid, field, usage, value); + } +if (hid->claimed &HID_CLAIMED_HIDDEV && interrupt)hiddev_hid_event (hid, field, usage, value); }
@@ -2097,8 +2113,32 @@ static void hid_disconnect(struct usb_indel_timer_sync (&hid->io_retry);flush_scheduled_work (); -if (hid->claimed &HID_CLAIMED_INPUT ) +if (hid->claimed &HID_CLAIMED_INPUT ) { +struct list_head *node; +struct matched_device *matched =NULL ; +struct hidinput_simple_driver *simple = hid->simple; + +mutex_lock (&matched_devices_lock); +list_for_each (node, &matched_devices_list) { + matched = list_entry(node, struct matched_device, node); +if (matched->intf == intf) { +list_del (&matched->node); +break ; + } + matched =NULL ; + } +mutex_unlock (&matched_devices_lock); +/* disconnect simple device driver if need */ +if (matched && simple) { +hidinput_simple_driver_disconnect (hid, matched); +module_put (simple->owner); + } +if (matched) { + matched->intf =NULL ; +kfree (matched); + }hidinput_disconnect (hid); + }if (hid->claimed &HID_CLAIMED_HIDDEV )hiddev_disconnect (hid);
@@ -2111,6 +2151,139 @@ static void hid_disconnect(struct usb_inhid_free_device (hid); } +#ifdef CONFIG_HID_SIMPLE +static int hidinput_simple_driver_bind_one (struct hidinput_simple_driver *simple, +struct hid_device *hid, +struct matched_device *matched, +int reload) +{ +int ret; + +if (!try_module_get (simple->owner)) +return -ENODEV ; +/* +* If the simple driver register itself after device insert, +* we must send hotplug message to userspace again, elsewise, +* we will break down some applications. +*/ +if (reload &&hidinput_disconnect_core (hid)) { +module_put (simple->owner); +return -ENODEV ; + } + ret =hidinput_simple_driver_connect (simple, hid, matched); + +if (reload) +hidinput_reconnect_core (hid);/* To activate this input_dev */ +if (!ret) +printk (KERN_INFO "The simple driver \'%s\' attach" +" to the device \'%s\'\n" , simple->name, hid->name); +else +module_put (simple->owner); +return 0 ; +} + +/* Only be called in hid_probe(), so we just use the hid of matched->intf. */ +static void hidinput_simple_driver_bind_foreach_simple ( +struct matched_device *matched) +{ +struct hidinput_simple_driver *simple; +struct list_head *node; +struct hid_device *hid; + +if (!matched || !matched->intf)/* should not get here */ +return ; + hid =usb_get_intfdata (matched->intf); +if (!hid || hid->simple) +return ; + +mutex_lock (&simple_drivers_lock); +list_for_each (node, &simple_drivers_list) { + simple = list_entry(node, struct hidinput_simple_driver, node); +if (usb_match_id (matched->intf, simple->id_table)) { +if (!hidinput_simple_driver_bind_one (simple, hid, matched,0 )) +break ; + } + } +mutex_unlock (&simple_drivers_lock); +} + +static void hidinput_simple_driver_bind_foreach_matched ( +struct hidinput_simple_driver *simple) +{ +struct list_head *node=NULL ; +struct matched_device *matched; +struct hid_device *hid=NULL ; + +if (!simple) +return ; + +mutex_lock (&matched_devices_lock); +list_for_each (node, &matched_devices_list) { + matched = list_entry(node, struct matched_device, node); + hid =usb_get_intfdata (matched->intf); +if (!hid || hid->simple) +continue ; +if (!usb_match_id (matched->intf, simple->id_table)) +continue ; +if (!hidinput_simple_driver_bind_one (simple, hid, matched,1 )) +break ; + } +mutex_unlock (&matched_devices_lock); +} + +static void hidinput_simple_driver_bind_foreach (void ) +{ +struct hidinput_simple_driver *simple; +struct matched_device *matched =NULL ; +struct list_head *matched_node =NULL , *simple_node =NULL ; +struct hid_device *hid =NULL ; + +mutex_lock (&matched_devices_lock); +list_for_each (matched_node, &matched_devices_list) { + matched = list_entry(matched_node, struct matched_device, node); + hid =usb_get_intfdata (matched->intf); +if (!hid || hid->simple) +continue ; +mutex_lock (&simple_drivers_lock); +list_for_each (simple_node, &simple_drivers_list) { + simple = list_entry(simple_node, struct hidinput_simple_driver, node); +if (!usb_match_id (matched->intf, simple->id_table)) +continue ; +hidinput_simple_driver_bind_one (simple, hid, matched,1 ); + } +mutex_unlock (&simple_drivers_lock); + } +mutex_unlock (&matched_devices_lock); +} + +int hidinput_register_simple_driver (struct hidinput_simple_driver *simple) +{ +if (!simple || !simple->name) +return -EINVAL ; + +hidinput_simple_driver_init (simple); +hidinput_simple_driver_bind_foreach_matched (simple); + +mutex_lock (&simple_drivers_lock); +list_add (&simple->node, &simple_drivers_list); +mutex_unlock (&simple_drivers_lock); + +return 0 ; +} +EXPORT_SYMBOL_GPL (hidinput_register_simple_driver); + +void hidinput_unregister_simple_driver (struct hidinput_simple_driver *simple) +{ +hidinput_simple_driver_clear (simple); +mutex_lock (&simple_drivers_lock); +list_del (&simple->node); +mutex_unlock (&simple_drivers_lock); +/* to active simple device driver that it is waiting */ +hidinput_simple_driver_bind_foreach (); +} +EXPORT_SYMBOL_GPL (hidinput_unregister_simple_driver); +#endif +static int hid_probe (struct usb_interface *intf,const struct usb_device_id *id) {struct hid_device *hid;
@@ -2127,15 +2300,25 @@ static int hid_probe(struct usb_interfachid_init_reports (hid);hid_dump_device (hid); -if (!hidinput_connect (hid)) +usb_set_intfdata (intf, hid); + +if (!hidinput_connect (hid)) { +struct matched_device *matched; + matched =kmalloc (sizeof (struct matched_device ),GFP_KERNEL ); +if (matched) { + matched->intf = intf; +mutex_lock (&matched_devices_lock); +list_add (&matched->node, &matched_devices_list); +mutex_unlock (&matched_devices_lock); +hidinput_simple_driver_bind_foreach_simple (matched); + } hid->claimed |=HID_CLAIMED_INPUT ; + }if (!hiddev_connect (hid)) hid->claimed |=HID_CLAIMED_HIDDEV ; -usb_set_intfdata (intf, hid); -if (!hid->claimed) { -printk ("HID device not claimed by input or hiddev\n" ); +printk (KERN_INFO "HID device not claimed by input or hiddev\n" );hid_disconnect (intf);return -ENODEV ; }
@@ -2234,6 +2417,8 @@ static int __init hid_init(void) retval =hiddev_init ();if (retval) goto hiddev_init_fail; +INIT_LIST_HEAD (&matched_devices_list); +INIT_LIST_HEAD (&simple_drivers_list); retval =usb_register (&hid_driver);if (retval) goto usb_register_fail;
@@ -2248,7 +2433,15 @@ hiddev_init_fail: static void __exit hid_exit(void) { +struct list_head *node, *tmp; +struct matched_device *matched; +usb_deregister (&hid_driver); +list_for_each_safe (node, tmp, &matched_devices_list) { + matched = list_entry(node, struct matched_device, node); +list_del (&matched->node); +kfree (matched); + }hiddev_exit (); }
drivers/usb/input/hid.h +14 -1
@@ -33,7 +33,7 @@#include <linux/list.h> #include <linux/timer.h> #include <linux/workqueue.h> - +#include <linux/mutex.h> /* * USB HID (Human Interface Device) interface class code */
@@ -390,8 +390,15 @@ struct hid_input {struct list_head list;struct hid_report *report;struct input_dev *input; +unsigned long input_lock;/* To protect accessing input_dev from +* hid-input processing. But it not +* necessary for accessing this input_dev +* instance from input subsystem. */ +void *private; }; +struct hidinput_simple_driver ; +struct hid_device {/* device report descriptor */ __u8 *rdesc;unsigned rsize;
@@ -450,6 +457,8 @@ struct hid_device { /* device repochar phys[64 ];/* Device physical location */ char uniq[64 ];/* Device unique identifier (serial #) */ +struct hidinput_simple_driver *simple; +#ifdef CONFIG_USB_HIDINPUT_POWERBOOK unsigned long pb_pressed_fn[NBITS (KEY_MAX )];unsigned long pb_pressed_numlock[NBITS (KEY_MAX )];
@@ -504,12 +513,16 @@ extern void hidinput_hid_event(struct hiextern void hidinput_report_event (struct hid_device *hid,struct hid_report *report);extern int hidinput_connect (struct hid_device *);extern void hidinput_disconnect (struct hid_device *); +extern void hidinput_reconnect_core (struct hid_device *); +extern int hidinput_disconnect_core (struct hid_device *);#else #define IS_INPUT_APPLICATION (a) (0)static inline void hidinput_hid_event (struct hid_device *hid,struct hid_field *field,struct hid_usage *usage,__s32 value) { }static inline void hidinput_report_event (struct hid_device *hid,struct hid_report *report) { }static inline int hidinput_connect (struct hid_device *hid) {return -ENODEV ; }static inline void hidinput_disconnect (struct hid_device *hid) { } +static inline void hidinput_reconnect_core (struct hid_device *hid) { } +static inline int hidinput_disconnect_core (struct hid_device *hid) {return -ENODEV ; }#endif int hid_open (struct hid_device *);
drivers/usb/input/hid-input.c +147 -40
357 lines not on this page · raw message
drivers/usb/input/hid-simple.c +326 -0
326 lines not on this page · raw message
drivers/usb/input/hid-simple.h +221 -0
221 lines not on this page · raw message
drivers/usb/input/Kconfig +17 -0
@@ -348,3 +348,20 @@ config USB_APPLETOUCH To compile this driver as a module, choose M here: the module will be called appletouch. + +config HID_SIMPLE + bool "HID simple driver interface" + depends on USB_HIDINPUT + help + This simple interface let the writing HID driver more easier. Moreover, + this allow you write force-feedback driver without touch HID input + implementation code. Also, it can be used as input filter. + +config HID_SIMPLE_MSNEK4K + tristate "Microsoft Natural Ergonomic Keyboard 4000 Driver" + depends on HID_SIMPLE + help + Microsoft Natural Ergonomic Keyboard 4000 extend keys support. These + may not work without change user space configration, e.g, XKB + configuration in X. +
drivers/usb/input/Makefile +4 -0
@@ -29,6 +29,9 @@ endif ifeq ($(CONFIG_HID_FF),y) usbhid-objs += hid-ff.o endif +ifeq ($(CONFIG_HID_SIMPLE),y) + usbhid-objs += hid-simple.o +endif obj-$(CONFIG_USB_AIPTEK) += aiptek.o obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
@@ -48,6 +51,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o obj-$(CONFIG_USB_YEALINK) += yealink.o obj-$(CONFIG_USB_XPAD) += xpad.o obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o +obj-$(CONFIG_HID_SIMPLE_MSNEK4K) += usbnek4k.o ifeq ($(CONFIG_USB_DEBUG),y) EXTRA_CFLAGS += -DDEBUG
Quoted 6 lines · Li Yu
1. Make
hidinput_disconnect_core()be more robust, it can not break anything even failed to allocate device struct.
2. Thanks new input device driver API, we need not the extra code for support force-feed device yet, so say bye toCONFIG_HID_SIMPLE_FF.
Is this ready to merge? or What still is problem in them? Thanks.
Hi,
actually, I have prepared patches to split the USBHID code in two parts - generic HID, which could be hooked by transport-specific HID layers (USB, Bluetooth).
I did not send them to lkml/linux-usb, as they are quite big (mainly because a lot of code is being moved around). I am currently trying to setup a git repository on kernel.org, hopefully kernel.org people will react, so that the patches could be easily put into git repository and be available for rewiew and easy merge. After that, they are planned to be merged either into Greg's or Andrew's tree. I can send them to you if you want.
Do you think that you could wait a little bit more, after the split has been done? (it's currently planned approximately after 2.6.20-rc1). It seems to me that your patches will apply almost cleanly on top of the split patches (you will have to change the pathnames, of course).
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Hi,
Quoted 23 lines · Jiri Kosina
Quoted 6 lines · Li Yu
1. Make
hidinput_disconnect_core()be more robust, it can not break anything even failed to allocate device struct.
2. Thanks new input device driver API, we need not the extra code for support force-feed device yet, so say bye toCONFIG_HID_SIMPLE_FF.
Is this ready to merge? or What still is problem in them? Thanks.Hi,
actually, I have prepared patches to split the USBHID code in two parts - generic HID, which could be hooked by transport-specific HID layers (USB, Bluetooth).
I did not send them to lkml/linux-usb, as they are quite big (mainly because a lot of code is being moved around). I am currently trying to setup a git repository on kernel.org, hopefully kernel.org people will react, so that the patches could be easily put into git repository and be available for rewiew and easy merge. After that, they are planned to be merged either into Greg's or Andrew's tree. I can send them to you if you want.
Quoted 5 lines
Do you think that you could wait a little bit more, after the split has been done? (it's currently planned approximately after 2.6.20-rc1). It seems to me that your patches will apply almost cleanly on top of the split patches (you will have to change the pathnames, of course).
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
Jiri, I have not looked at your patches yet (I need to do that) but what I was hoping to do (or have someone to do ;) ) is to provide ability to define HID transport drivers (we would have USB transport and bluetooth transport) and then say:
device = hid_create_device(&my_transport);
device->event = my_event_handler;
....
hid_start_device(device);
hid-create_device would parse all reports and create "standard" hid device. Then you have a chance to override and tweak it as you see fit.
This way we could have several small drivers implementing quirks to the generic HID driver. Most of the code is still in hid core module but every individual driver is complete USB (or bluetooth) driver, has its own device table and is loaded via standard driver code bust matching/hotplug modalias mechanism.
Btw, I saw you moving it into drivers/hid, would not drivers/input/hid/ suit better?
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 38 lines
Quoted 21 lines
Quoted 6 lines
1. Make
hidinput_disconnect_core()be more robust, it can not break anything even failed to allocate device struct.
2. Thanks new input device driver API, we need not the extra code for support force-feed device yet, so say bye toCONFIG_HID_SIMPLE_FF.
Is this ready to merge? or What still is problem in them? Thanks.Hi,
actually, I have prepared patches to split the USBHID code in two parts - generic HID, which could be hooked by transport-specific HID layers (USB, Bluetooth).
I did not send them to lkml/linux-usb, as they are quite big (mainly because a lot of code is being moved around). I am currently trying to setup a git repository on kernel.org, hopefully kernel.org people will react, so that the patches could be easily put into git repository and be available for rewiew and easy merge. After that, they are planned to be merged either into Greg's or Andrew's tree. I can send them to you if you want.
Quoted 5 lines
Do you think that you could wait a little bit more, after the split has been done? (it's currently planned approximately after 2.6.20-rc1). It seems to me that your patches will apply almost cleanly on top of the split patches (you will have to change the pathnames, of course).
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
Jiri, I have not looked at your patches yet (I need to do that) but what I was hoping to do (or have someone to do ;) ) is to provide ability to define HID transport drivers (we would have USB transport and bluetooth transport) and then say:
Quoted 8 lines
device = hid_create_device(&my_transport); device->event = my_event_handler; .... hid_start_device(device);hid-create_device would parse all reports and create "standard" hid device. Then you have a chance to override and tweak it as you see fit.
I actually prefer that we go the way hid_{register|unregister}_device and have a hid_alloc_device(descriptor) to actually create the new HID device and allocate its descriptor tables.
The transport actually doesn't care on how you interpret or tweak the events. This is not its job. It is a simple plain stupid transport. Every additional driver that you put on top of the HID parser will look at the VID/PID and then decide which input event to send or what to do. So from my understanding the generic one should work just fine, but in case we need some special handling you can load an extra driver to handle this. And this could be done as HID driver. One driver could be the new hidraw driver to allow raw access to the HID reports.
Quoted 5 lines
This way we could have several small drivers implementing quirks to the generic HID driver. Most of the code is still in hid core module but every individual driver is complete USB (or bluetooth) driver, has its own device table and is loaded via standard driver code bust matching/hotplug modalias mechanism.
Again. The driver doesn't have to know if it is Bluetooth or USB that the reports are send over. For example a company can make the same keyboard and one version is using Bluetooth and the other USB. You don't wanna have two different drivers for it. You only need one driver that knows how to speak HID.
Quoted 2 lines
Btw, I saw you moving it into
drivers/hid, would notdrivers/input/hid/suit better?
This would stick HID to the input subsystem and from my understanding the HID parser can even work without input. The input subsystem is only one user of it. In case of hidraw access you don't need the input subsystem at all.
Regards
Marcel
Hi Marcel,
Quoted 53 lines · Marcel Holtmann
Hi Dmitry,
Quoted 38 lines
Quoted 21 lines
Quoted 6 lines
1. Make
hidinput_disconnect_core()be more robust, it can not break anything even failed to allocate device struct.
2. Thanks new input device driver API, we need not the extra code for support force-feed device yet, so say bye toCONFIG_HID_SIMPLE_FF.
Is this ready to merge? or What still is problem in them? Thanks.Hi,
actually, I have prepared patches to split the USBHID code in two parts - generic HID, which could be hooked by transport-specific HID layers (USB, Bluetooth).
I did not send them to lkml/linux-usb, as they are quite big (mainly because a lot of code is being moved around). I am currently trying to setup a git repository on kernel.org, hopefully kernel.org people will react, so that the patches could be easily put into git repository and be available for rewiew and easy merge. After that, they are planned to be merged either into Greg's or Andrew's tree. I can send them to you if you want.
Quoted 5 lines
Do you think that you could wait a little bit more, after the split has been done? (it's currently planned approximately after 2.6.20-rc1). It seems to me that your patches will apply almost cleanly on top of the split patches (you will have to change the pathnames, of course).
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
Jiri, I have not looked at your patches yet (I need to do that) but what I was hoping to do (or have someone to do ;) ) is to provide ability to define HID transport drivers (we would have USB transport and bluetooth transport) and then say:
Quoted 8 lines
device = hid_create_device(&my_transport); device->event = my_event_handler; .... hid_start_device(device);hid-create_device would parse all reports and create "standard" hid device. Then you have a chance to override and tweak it as you see fit.
I actually prefer that we go the way hid_{register|unregister}_device and have a
hid_alloc_device(descriptor)to actually create the new HID device and allocate its descriptor tables.
Quoted 8 lines
The transport actually doesn't care on how you interpret or tweak the events. This is not its job. It is a simple plain stupid transport. Every additional driver that you put on top of the HID parser will look at the VID/PID and then decide which input event to send or what to do. So from my understanding the generic one should work just fine, but in case we need some special handling you can load an extra driver to handle this. And this could be done as HID driver. One driver could be the new hidraw driver to allow raw access to the HID reports.
Well, it seems we have 2 different kinds of HID drivers. Hidraw is an alternate interface driver - it provides different interface to HID device and therefore can be implemented as "extra" driver. Li Yu's "simple" drivers extend existing input interfaces. I do not think you'd want to have /dev/input/event0 implementing partially incorrect keyboard support (for a particular keyboard) and /dev/input/event1 (the one cretaed by a simple drver if impleented as extra interface) implementing better support.
Quoted 7 lines
Quoted 6 lines
This way we could have several small drivers implementing quirks to the generic HID driver. Most of the code is still in hid core module but every individual driver is complete USB (or bluetooth) driver, has its own device table and is loaded via standard driver code bust matching/hotplug modalias mechanism.
Quoted 6 lines
Again. The driver doesn't have to know if it is Bluetooth or USB that the reports are send over. For example a company can make the same keyboard and one version is using Bluetooth and the other USB. You don't wanna have two different drivers for it. You only need one driver that knows how to speak HID.
But you need to know when to attach your driver. How would pure HID driver know that? USB driver can do that via manufacturer/product IDs. And we have all that infrastructure of loading proper modules. Or do you want to create a hid bus?
Quoted 8 lines
Quoted 2 lines
Btw, I saw you moving it into
drivers/hid, would notdrivers/input/hid/suit better?This would stick HID to the input subsystem and from my understanding the HID parser can even work without input. The input subsystem is only one user of it. In case of hidraw access you don't need the input subsystem at all.
OK.
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 33 lines
Quoted 24 lines
Quoted 11 lines
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
Jiri, I have not looked at your patches yet (I need to do that) but what I was hoping to do (or have someone to do ;) ) is to provide ability to define HID transport drivers (we would have USB transport and bluetooth transport) and then say:
Quoted 8 lines
device = hid_create_device(&my_transport); device->event = my_event_handler; .... hid_start_device(device);hid-create_device would parse all reports and create "standard" hid device. Then you have a chance to override and tweak it as you see fit.
I actually prefer that we go the way hid_{register|unregister}_device and have a
hid_alloc_device(descriptor)to actually create the new HID device and allocate its descriptor tables.Quoted 8 lines
The transport actually doesn't care on how you interpret or tweak the events. This is not its job. It is a simple plain stupid transport. Every additional driver that you put on top of the HID parser will look at the VID/PID and then decide which input event to send or what to do. So from my understanding the generic one should work just fine, but in case we need some special handling you can load an extra driver to handle this. And this could be done as HID driver. One driver could be the new hidraw driver to allow raw access to the HID reports.
Quoted 8 lines
Well, it seems we have 2 different kinds of HID drivers. Hidraw is an alternate interface driver - it provides different interface to HID device and therefore can be implemented as "extra" driver. Li Yu's "simple" drivers extend existing input interfaces. I do not think you'd want to have
/dev/input/event0implementing partially incorrect keyboard support (for a particular keyboard) and/dev/input/event1(the one cretaed by a simple drver if impleented as extra interface) implementing better support.
I think for every HID report id, you should be able to attach a special driver that handles the reports of this id.
Quoted 13 lines
Quoted 6 lines
Quoted 5 lines
This way we could have several small drivers implementing quirks to the generic HID driver. Most of the code is still in hid core module but every individual driver is complete USB (or bluetooth) driver, has its own device table and is loaded via standard driver code bust matching/hotplug modalias mechanism.
Quoted 6 lines
Again. The driver doesn't have to know if it is Bluetooth or USB that the reports are send over. For example a company can make the same keyboard and one version is using Bluetooth and the other USB. You don't wanna have two different drivers for it. You only need one driver that knows how to speak HID.
Quoted 4 lines
But you need to know when to attach your driver. How would pure HID driver know that? USB driver can do that via manufacturer/product IDs. And we have all that infrastructure of loading proper modules. Or do you want to create a hid bus?
Actually creating a HID bus is not a bad idea. And even Bluetooth provides the VID/PID values for every device. So the transports only have to give these to the HID parser. Then every driver on top of the common HID layer can do whatever they think is best and they don't have to care about the actual transport. Actually the report descriptor is a good example which both (USB and Bluetooth) have in common, but they are retrieved totally different. The driver on-top of HID doesn't need to have to deal with that.
However separating out the transports and creating a common HID layer should be done sooner than later. Once we have done that, we can talk about the HID simple driver or device specific drivers on top of the common HID layer.
Regards
Marcel
Quoted 5 lines · Marcel Holtmann
Quoted 5 lines
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
I guess that this paragraph wasn't for me, but rather for the author of the HID Simple Driver proposal, am I right?
Quoted 1 line
Quoted 1 line
Jiri, I have not looked at your patches yet (I need to do that) but
Please do, when you will have time. Any comments are very welcome, before I start actually heading for the merge.
Quoted 8 lines
The transport actually doesn't care on how you interpret or tweak the events. This is not its job. It is a simple plain stupid transport. Every additional driver that you put on top of the HID parser will look at the VID/PID and then decide which input event to send or what to do. So from my understanding the generic one should work just fine, but in case we need some special handling you can load an extra driver to handle this. And this could be done as HID driver. One driver could be the new hidraw driver to allow raw access to the HID reports.
Yes, the hidraw driver is one of the things that I am planning to develop on top of the generic HID layer, after the HID split gets merged.
The current patches mainly take the contents of drivers/usb/input, and separate the code to transport-specific and the rest, which is then put into drivers/hid (of course some code changes are needed) and USB-specific HID code is then hooked into this new HID layer.
I have tried to verify that hooking bluetooth, in the state in which it currently is (plus the patches which are not in mainline, also because of non-existence of common HID code), would stay relatively easy task, hopefully.
This split is quite painful, as there are many things happening in USB all the time, so the best way seem to be just to perform big split (with needed changes) at once, and then develop other things on top of it (like hidraw).
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 10 lines · Jiri Kosina
Quoted 5 lines · Marcel Holtmann
Quoted 5 lines
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
I guess that this paragraph wasn't for me, but rather for the author of the HID Simple Driver proposal, am I right?
Yes, mainly for him but also for you because we need to be able to do what Li Yu is trying to do and be able to tweak HID interfaces.
...
Quoted 4 lines
This split is quite painful, as there are many things happening in USB all the time, so the best way seem to be just to perform big split (with needed changes) at once, and then develop other things on top of it (like hidraw).
Is there any reason why we can't mecanically move everything into drivers/hid right now? Then Greg could simply forward all patches he gets for HID your way and you won't have hard time merging your work with others...
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 19 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
I guess that this paragraph wasn't for me, but rather for the author of the HID Simple Driver proposal, am I right?
Yes, mainly for him but also for you because we need to be able to do what Li Yu is trying to do and be able to tweak HID interfaces.
...
Quoted 4 lines
This split is quite painful, as there are many things happening in USB all the time, so the best way seem to be just to perform big split (with needed changes) at once, and then develop other things on top of it (like hidraw).
Quoted 4 lines
Is there any reason why we can't mecanically move everything into
drivers/hidright now? Then Greg could simply forward all patches he gets for HID your way and you won't have hard time merging your work with others...
I fully agree. Lets move and split the transports now and start the work on top of it. My only concern is to have a clean Git tree to the full history of HID changes stay intact and will trackable. Some quirk decisions and other stuff is not obvious and I assume will never be when it comes to broken HID devices.
So do you have pending HID patches. If yes, please sync them with Linus and Jiri can setup a clean tree for the move.
Regards
Marcel
Quoted 26 lines · Marcel Holtmann
Hi Dmitry,
Quoted 19 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
I guess that this paragraph wasn't for me, but rather for the author of the HID Simple Driver proposal, am I right?
Yes, mainly for him but also for you because we need to be able to do what Li Yu is trying to do and be able to tweak HID interfaces.
...
Quoted 4 lines
This split is quite painful, as there are many things happening in USB all the time, so the best way seem to be just to perform big split (with needed changes) at once, and then develop other things on top of it (like hidraw).
Quoted 4 lines
Is there any reason why we can't mecanically move everything into
drivers/hidright now? Then Greg could simply forward all patches he gets for HID your way and you won't have hard time merging your work with others...
Quoted 8 lines
I fully agree. Lets move and split the transports now and start the work on top of it. My only concern is to have a clean Git tree to the full history of HID changes stay intact and will trackable. Some quirk decisions and other stuff is not obvious and I assume will never be when it comes to broken HID devices.
So do you have pending HID patches. If yes, please sync them with Linus and Jiri can setup a clean tree for the move.
I have no pending HID patches in my queue right now. Jiri, feel free to respin your patches against Linus's tree and send them to me now. I can handle the git stuff and send them to Linus.
thanks,
greg k-h
Quoted 4 lines · Dmitry Torokhov
Quoted 2 lines
I guess that this paragraph wasn't for me, but rather for the author of the HID Simple Driver proposal, am I right?
Yes, mainly for him but also for you because we need to be able to do what Li Yu is trying to do and be able to tweak HID interfaces.
I see. Will look at Li Yu's code to lear better what the Simple Driver Interface idea is about. Thanks.
Quoted 8 lines
Quoted 4 lines
This split is quite painful, as there are many things happening in USB all the time, so the best way seem to be just to perform big split (with needed changes) at once, and then develop other things on top of it (like hidraw).
Is there any reason why we can't mecanically move everything into
drivers/hidright now? Then Greg could simply forward all patches he gets for HID your way and you won't have hard time merging your work with others...
That definitely would be a possible solution.
In fact, the patches for the split I sent to you and a few other people two weeks ago or so, do exactly this - in some sense "mechanical" split of the generic parts laying currently in USB hid, from the USB-specific ones, and moving them around (sure, some changes are done, like introducing data structures specific to usbhid, etc., but no rocket science yet).
This would be nice to merge, if noone has any major objections, and do other development on top of that.
I am currently trying to set up an account and git tree for this at kernel.org ... request sent, waiting for reply :)
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Hi Jiri,
Quoted 4 lines
This would be nice to merge, if noone has any major objections, and do other development on top of that.
I am currently trying to set up an account and git tree for this at kernel.org ... request sent, waiting for reply :)
I can setup a tree for the merge. You simply have to create the patches with cg-mkpatch and then I can apply them.
Regards
Marcel
Quoted 6 lines · Jiri Kosina
Quoted 4 lines · Dmitry Torokhov
Is there any reason why we can't mecanically move everything into
drivers/hidright now? Then Greg could simply forward all patches he gets for HID your way and you won't have hard time merging your work with others...
Quoted 8 lines
That definitely would be a possible solution.
In fact, the patches for the split I sent to you and a few other people two weeks ago or so, do exactly this - in some sense "mechanical" split of the generic parts laying currently in USB hid, from the USB-specific ones, and moving them around (sure, some changes are done, like introducing data structures specific to usbhid, etc., but no rocket science yet).
If Greg is OK with that I would start with truly mechanical merge (no now data structures, just move the files around) and merge this ASAP, before we hit -rc1 or -rc2 at the latest. Then you can start puling up your changesin the separate git tree.
Quoted 5 lines
This would be nice to merge, if noone has any major objections, and do other development on top of that.
I am currently trying to set up an account and git tree for this at kernel.org ... request sent, waiting for reply :)
Take up Marcel on his suggestion ;) I could set up a tree too but I am afraid I won't have enought time at the moment.
Signature · 1 line
Dmitry
Quoted 4 lines · Dmitry Torokhov
If Greg is OK with that I would start with truly mechanical merge (no now data structures, just move the files around) and merge this ASAP, before we hit -rc1 or -rc2 at the latest. Then you can start puling up your changesin the separate git tree.
The first of the 8 patches which currently exist just moves things around physically. Just that is not enough, unfortunately, some tweaking is needed anyway (static functions, new headers, Kconfig changes, etc), so I think it might maybe be better to take the bunch of all 8 patches initially as a whole, as they really don't do too intrusive changes to the code, and could stay in tree for some testing (though I of course tested them to some extent) together.
Quoted 2 lines
Take up Marcel on his suggestion ;) I could set up a tree too but I am afraid I won't have enought time at the moment.
:) Thanks
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 4 lines · Jiri Kosina
Do you think that you could wait a little bit more, after the split has been done? (it's currently planned approximately after 2.6.20-rc1). It seems to me that your patches will apply almost cleanly on top of the split patches (you will have to change the pathnames, of course).
Of course, I interest to wait this. If they have other weakless, tell me too.
I also think the HID split plan is a great idea.
Quoted 5 lines · Dmitry
I still have the same objection - the "simple'" code will have to be compiled into the driver instead of being a separate module and eventyally will lead to a monster-size HID module. We have this issue with psmouse to a degree but with HID the growth potential is much bigger IMO.
As you guess;), I do not agree with your words very much. We can image, there
are many devices use some HID base layer, however they even do not merge into
mainstream kernel source tree for some reasons. and in fact, I do not like the
mainstream kernel source tree include every drivers. For such devices out of core,
we should have such feature that let developer write such driver quickly. I think
it allows many monster-size driver modules is a better means than all-in-one.But we
need resolve /dev/input/event? switching problem in principle first, else we still
encounter same problem when new hidraw come.
Good luck.
-Li Yu
www.co-create.com.cn