================================== HID device simple driver interface ================================== This patch include the header file for this API. Signed-off-by: Yu Li diff -Naurp linux-2.6.17.6/drivers/usb/input.orig/hid-simple.h linux-2.6.17.6/drivers/usb/input/hid-simple.h --- linux-2.6.17.6/drivers/usb/input.orig/hid-simple.h 1970-01-01 08:00:00.000000000 +0800 +++ linux-2.6.17.6/drivers/usb/input/hid-simple.h 2006-07-26 09:42:36.000000000 +0800 @@ -0,0 +1,106 @@ +/* + * NOTE: + * For use me , you must include hid.h in your source first. + */ +#ifndef __HID_SIMPLE_H +#define __HID_SIMPLE_H + +/* list_*_entry like interface */ +/* FIXME: Would you like move them to include/linux/list.h ? */ +#define list_for_each_continue(pos, head) \ + for ((pos) = (pos)->next; \ + prefetch((pos)->next), (pos) != (head); \ + (pos) = (pos)->next) +#define list_prepare(pos, head) ((pos) ? : head) + +#include +/***** The private section for simple device implement only *****/ + +/* + * matched_device record one device which hid-subsystem handle, it may + * be one simple device can not handle. + * + * The element of matched_device list is inserted at hidinput_connect(), + * and is removed at hidinput_disconnect(). + */ +struct matched_device { + struct usb_interface *intf; + struct list_head node; +}; + +/* + * raw_simple_driver record one device which hid simple device handle. + * It used as one member of hid_simple_driver. + */ + +struct raw_simple_device { + struct usb_interface *intf; + struct list_head node; +}; + + +/* simple device internal flags */ +#define HIDINPUT_SIMPLE_SETUP_USAGE 0x1 /* the reverse is to call clear_usage */ + +#define hidinput_simple_driver_setup_usage(hid) \ +do {\ + if (hid->simple) {\ + hid->simple->flags |= HIDINPUT_SIMPLE_SETUP_USAGE; \ + hidinput_simple_driver_configure_usage(hid); \ + }\ +} while (0) + +#define hidinput_simple_driver_clear_usage(hid) \ +do {\ + if (hid->simple) {\ + hid->simple->flags &= (~HIDINPUT_SIMPLE_SETUP_USAGE); \ + hidinput_simple_driver_configure_usage(hid); \ + }\ +} while (0) + +/* Note again here, you must include hid.h in your source first. */ + +struct hidinput_simple_driver; +void hidinput_simple_driver_configure_usage(struct hid_device *hid); +int hidinput_simple_driver_init(struct hidinput_simple_driver *simple); +int hidinput_simple_driver_push(struct hidinput_simple_driver *simple, + struct matched_device *dev); +void hidinput_simple_driver_pop(struct hidinput_simple_driver *simple, + struct matched_device *dev); +void hidinput_simple_driver_clear(struct hidinput_simple_driver *simple); +int hidinput_simple_driver_connect(struct hidinput_simple_driver *simple, + struct hid_device *hid); +void hidinput_simple_driver_disconnect(struct hid_device *hid); + + +/***** The private section end. *****/ + + +/***** The public interface for simple device driver *****/ +struct hidinput_simple_driver { +/* private */ + struct list_head node; /* link with simple_drivers_list */ + struct list_head raw_devices; + int flags; +/* public */ + char *name; + int (*connect)(struct hid_device *, struct hid_input *); + void (*setup_usage)(struct hid_field *, struct hid_usage *); + int (*pre_event)(const struct hid_device *, const struct hid_field *, + const struct hid_usage *, const __s32, + const struct pt_regs *regs); + int (*post_event)(const struct hid_device *, const struct hid_field *, + const struct hid_usage *, const __s32, + const struct pt_regs *regs); + void (*clear_usage)(struct hid_field *, struct hid_usage *); + void (*disconnect)(struct hid_device *, struct hid_input *); + void *private; + struct usb_device_id *id_table; +}; + + +int hidinput_register_simple_driver(struct hidinput_simple_driver *device); +void hidinput_unregister_simple_driver(struct hidinput_simple_driver *device); + +/********************* The public section end ***********/ +#endif /* __HID_SIMPLE_H */