aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2006-12-08 12:40:53 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-08 13:43:12 -0500
commit229695e51efc4ed5e04ab471c82591d0f432909d (patch)
tree9e333780589010c61224f185a4a83323305e7d8d /include
parentdde5845a529ff753364a6d1aea61180946270bfa (diff)
[PATCH] Generic HID layer - API
- fixed generic API (added neccessary EXPORT_SYMBOL, fixed hid.h to provide correct prototypes) - extended hid_device with open/close/event function pointers to driver-specific functions - added driver specific driver_data to hid_device Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/hid.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index ee567ae6fec1..0473b45b73b8 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -403,11 +403,17 @@ struct hid_device { /* device report descriptor */
403 unsigned collection_size; /* Number of allocated hid_collections */ 403 unsigned collection_size; /* Number of allocated hid_collections */
404 unsigned maxcollection; /* Number of parsed collections */ 404 unsigned maxcollection; /* Number of parsed collections */
405 unsigned maxapplication; /* Number of applications */ 405 unsigned maxapplication; /* Number of applications */
406 unsigned short bus; /* BUS ID */
407 unsigned short vendor; /* Vendor ID */
408 unsigned short product; /* Product ID */
406 unsigned version; /* HID version */ 409 unsigned version; /* HID version */
407 unsigned country; /* HID country */ 410 unsigned country; /* HID country */
408 struct hid_report_enum report_enum[HID_REPORT_TYPES]; 411 struct hid_report_enum report_enum[HID_REPORT_TYPES];
409 412
410 struct usb_device *dev; /* USB device */ 413 struct usb_device *dev; /* device */
414
415 /* USB specific fields */
416
411 struct usb_interface *intf; /* USB interface */ 417 struct usb_interface *intf; /* USB interface */
412 int ifnum; /* USB interface number */ 418 int ifnum; /* USB interface number */
413 419
@@ -454,6 +460,13 @@ struct hid_device { /* device report descriptor */
454 char phys[64]; /* Device physical location */ 460 char phys[64]; /* Device physical location */
455 char uniq[64]; /* Device unique identifier (serial #) */ 461 char uniq[64]; /* Device unique identifier (serial #) */
456 462
463 void *driver_data;
464
465 /* device-specific function pointers */
466 int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int);
467 int (*hidinput_open) (struct input_dev *);
468 void (*hidinput_close) (struct input_dev *);
469
457#ifdef CONFIG_USB_HIDINPUT_POWERBOOK 470#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
458 unsigned long pb_pressed_fn[NBITS(KEY_MAX)]; 471 unsigned long pb_pressed_fn[NBITS(KEY_MAX)];
459 unsigned long pb_pressed_numlock[NBITS(KEY_MAX)]; 472 unsigned long pb_pressed_numlock[NBITS(KEY_MAX)];
@@ -502,17 +515,15 @@ struct hid_descriptor {
502/* Applications from HID Usage Tables 4/8/99 Version 1.1 */ 515/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
503/* We ignore a few input applications that are not widely used */ 516/* We ignore a few input applications that are not widely used */
504#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001)) 517#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
518#else
519#define IS_INPUT_APPLICATION(a) (0)
520#endif
521
522/* HID core API */
505extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 523extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
506extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); 524extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
507extern int hidinput_connect(struct hid_device *); 525extern int hidinput_connect(struct hid_device *);
508extern void hidinput_disconnect(struct hid_device *); 526extern void hidinput_disconnect(struct hid_device *);
509#else
510#define IS_INPUT_APPLICATION(a) (0)
511static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { }
512static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { }
513static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; }
514static inline void hidinput_disconnect(struct hid_device *hid) { }
515#endif
516 527
517int hid_set_field(struct hid_field *, unsigned, __s32); 528int hid_set_field(struct hid_field *, unsigned, __s32);
518int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 529int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
@@ -536,5 +547,14 @@ static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; }
536#else 547#else
537static inline int hid_ff_init(struct hid_device *hid) { return -1; } 548static inline int hid_ff_init(struct hid_device *hid) { return -1; }
538#endif 549#endif
550#ifdef DEBUG
551#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \
552 __FILE__ , ## arg)
553#else
554#define dbg(format, arg...) do {} while (0)
555#endif
556
557#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
558 __FILE__ , ## arg)
539#endif 559#endif
540 560