
liyu at ccoss
Jan 4, 2006, 6:59 PM
Views: 1376
Permalink
|
|
[PATCH] HID device simple driver interface.
|
|
===================== HID device simple driver interface ===================== Goal: ---------------- Let us write HID device driver more easier. Basic idea: --------------- Under current HID device driver development technique, We need write one new interrupt handler to report event to input subsystem as long as one new HID device come. However, the most of them have only some extended keys, I think it seem break a fly on the wheel, which write one new interrupt handler for this reason, My idea is reuse the interrupt handler in hid-core.c. so we write driver for new simple HID device will be more easier, and need not touch hid core. In essence, this interface just are some hooks in HID core. Limitation: ---------------- The driver use this simple interface only can work with one device at same time. In most time, this just is not a problem. if you are going to make your driver can work with a bundle of devices at same time, the I am sorry, this simple interface can not help you, and I am afraid that driver is not one simple driver. Of course, any improvement on this patch is welcome :) Testing: -------------- Tested on i386. Usage: --------------- Although this simple driver have not direct relation with device driver core, but I still make its interface like it on purpose. The simple device has five methods: 1. int (*connect)(struct hid_device *); 2. void (*disconnect)(struct hid_device *); When you simple device is connect with one real HID device, we will call connect() method. To return 0 flag it complete its job successfully. Any other value is looked as one error. When the HID device that your simple device connect with is down, or you unregister this simple device, we will call disconnect() method. 3. void (*setup_usage)(struct hid_field *, struct hid_usage *); 4. void (*clear_usage)(struct hid_field *, struct hid_usage *); The setup_usage() method is like hidinput_configure_usage() in hid_input.c. You also can setup input_dev here. In most time, I think you should be fill the pointer slot for this method, elsewise the event() method do not work for you at all. The clear_usage() method is used to clear side-effect that came from setup_usage() method, if they are there. Of course, you can do same job in disconnect() method, but this method let your life more simpler. 5. void (*event)(const struct hid_device *, const struct hid_field *, const struct hid_usage *, const __s32, const struct pt_regs *regs); Its behavior is same with hidinput_hid_event() exactly. Note again, if you do not correctly configure usage in setup_usage(), this method do not work as you want. All these method are optional, but if they are all NULL pointers, what are you want *-) Other information ............................ I am sorry that these patches are included in attachment, my mail client alway transform TAB to eight spaces. The attatchment include: 1. HID device simple driver interface 2. One sample use this interface. 3. Microsoft Natural Ergonomic Keyboard 4000 Driver use this interface. Happy new year.
|