aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hid.h
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-05-16 05:49:15 -0400
committerJiri Kosina <jkosina@suse.cz>2008-10-14 17:50:48 -0400
commit85cdaf524b7ddab627e7d15405693f2511ef7505 (patch)
treea85fb7c801df07842301c27dc57cf2eb5092f6ed /include/linux/hid.h
parente8c84f9a5f06912c94c38961096c994da3890a2e (diff)
HID: make a bus from hid code
Make a bus from hid core. This is the first step for converting all the quirks and separate almost-drivers into real drivers attached to this bus. It's implemented to change behaviour in very tiny manner, so that no driver needs to be changed this time. Also add generic drivers for both usb and bt into usbhid or hidp respectively which will bind all non-blacklisted device. Those blacklisted will be either grabbed by special drivers or by nobody if they are broken at the very rude base. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'include/linux/hid.h')
-rw-r--r--include/linux/hid.h104
1 files changed, 96 insertions, 8 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index b7a17762a0b2..c4bea0eda85b 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -418,6 +418,8 @@ struct hid_control_fifo {
418#define HID_CLAIMED_HIDDEV 2 418#define HID_CLAIMED_HIDDEV 2
419#define HID_CLAIMED_HIDRAW 4 419#define HID_CLAIMED_HIDRAW 4
420 420
421#define HID_STAT_ADDED 1
422
421#define HID_CTRL_RUNNING 1 423#define HID_CTRL_RUNNING 1
422#define HID_OUT_RUNNING 2 424#define HID_OUT_RUNNING 2
423#define HID_IN_RUNNING 3 425#define HID_IN_RUNNING 3
@@ -432,22 +434,26 @@ struct hid_input {
432 struct input_dev *input; 434 struct input_dev *input;
433}; 435};
434 436
437struct hid_driver;
438
435struct hid_device { /* device report descriptor */ 439struct hid_device { /* device report descriptor */
436 __u8 *rdesc; 440 __u8 *rdesc;
437 unsigned rsize; 441 unsigned rsize;
438 struct hid_collection *collection; /* List of HID collections */ 442 struct hid_collection *collection; /* List of HID collections */
439 unsigned collection_size; /* Number of allocated hid_collections */ 443 unsigned collection_size; /* Number of allocated hid_collections */
440 unsigned maxcollection; /* Number of parsed collections */ 444 unsigned maxcollection; /* Number of parsed collections */
441 unsigned maxapplication; /* Number of applications */ 445 unsigned maxapplication; /* Number of applications */
442 unsigned short bus; /* BUS ID */ 446 __u16 bus; /* BUS ID */
443 unsigned short vendor; /* Vendor ID */ 447 __u32 vendor; /* Vendor ID */
444 unsigned short product; /* Product ID */ 448 __u32 product; /* Product ID */
445 unsigned version; /* HID version */ 449 __u32 version; /* HID version */
446 unsigned country; /* HID country */ 450 unsigned country; /* HID country */
447 struct hid_report_enum report_enum[HID_REPORT_TYPES]; 451 struct hid_report_enum report_enum[HID_REPORT_TYPES];
448 452
449 struct device *dev; /* device */ 453 struct device dev; /* device */
454 struct hid_driver *driver;
450 455
456 unsigned int status; /* see STAT flags above */
451 unsigned claimed; /* Claimed by hidinput, hiddev? */ 457 unsigned claimed; /* Claimed by hidinput, hiddev? */
452 unsigned quirks; /* Various quirks the device can pull on us */ 458 unsigned quirks; /* Various quirks the device can pull on us */
453 459
@@ -483,6 +489,16 @@ struct hid_device { /* device report descriptor */
483#endif 489#endif
484}; 490};
485 491
492static inline void *hid_get_drvdata(struct hid_device *hdev)
493{
494 return dev_get_drvdata(&hdev->dev);
495}
496
497static inline void hid_set_drvdata(struct hid_device *hdev, void *data)
498{
499 dev_set_drvdata(&hdev->dev, data);
500}
501
486#define HID_GLOBAL_STACK_SIZE 4 502#define HID_GLOBAL_STACK_SIZE 4
487#define HID_COLLECTION_STACK_SIZE 4 503#define HID_COLLECTION_STACK_SIZE 4
488 504
@@ -511,6 +527,61 @@ struct hid_descriptor {
511 struct hid_class_descriptor desc[1]; 527 struct hid_class_descriptor desc[1];
512} __attribute__ ((packed)); 528} __attribute__ ((packed));
513 529
530#define HID_DEVICE(b, ven, prod) \
531 .bus = (b), \
532 .vendor = (ven), .product = (prod)
533
534#define HID_USB_DEVICE(ven, prod) HID_DEVICE(BUS_USB, ven, prod)
535#define HID_BLUETOOTH_DEVICE(ven, prod) HID_DEVICE(BUS_BLUETOOTH, ven, prod)
536
537#define HID_REPORT_ID(rep) \
538 .report_type = (rep)
539#define HID_USAGE_ID(uhid, utype, ucode) \
540 .usage_hid = (uhid), .usage_type = (utype), .usage_code = (ucode)
541/* we don't want to catch types and codes equal to 0 */
542#define HID_TERMINATOR (HID_ANY_ID - 1)
543
544struct hid_report_id {
545 __u32 report_type;
546};
547struct hid_usage_id {
548 __u32 usage_hid;
549 __u32 usage_type;
550 __u32 usage_code;
551};
552
553/**
554 * struct hid_driver
555 * @name: driver name (e.g. "Footech_bar-wheel")
556 * @id_table: which devices is this driver for (must be non-NULL for probe
557 * to be called)
558 * @probe: new device inserted
559 * @remove: device removed (NULL if not a hot-plug capable driver)
560 * @report_table: on which reports to call raw_event (NULL means all)
561 * @raw_event: if report in report_table, this hook is called (NULL means nop)
562 * @usage_table: on which events to call event (NULL means all)
563 * @event: if usage in usage_table, this hook is called (NULL means nop)
564 *
565 * raw_event and event should return 0 on no action performed, 1 when no
566 * further processing should be done and negative on error
567 */
568struct hid_driver {
569 char *name;
570 const struct hid_device_id *id_table;
571
572 int (*probe)(struct hid_device *dev, const struct hid_device_id *id);
573 void (*remove)(struct hid_device *dev);
574
575 const struct hid_report_id *report_table;
576 int (*raw_event)(struct hid_device *hdev, struct hid_report *report,
577 u8 *data, int size);
578 const struct hid_usage_id *usage_table;
579 int (*event)(struct hid_device *hdev, struct hid_field *field,
580 struct hid_usage *usage, __s32 value);
581/* private: */
582 struct device_driver driver;
583};
584
514/* Applications from HID Usage Tables 4/8/99 Version 1.1 */ 585/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
515/* We ignore a few input applications that are not widely used */ 586/* We ignore a few input applications that are not widely used */
516#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || (a == 0x000d0002)) 587#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || (a == 0x000d0002))
@@ -521,6 +592,17 @@ struct hid_descriptor {
521extern int hid_debug; 592extern int hid_debug;
522#endif 593#endif
523 594
595extern int hid_add_device(struct hid_device *);
596extern void hid_destroy_device(struct hid_device *);
597
598extern int __must_check __hid_register_driver(struct hid_driver *,
599 struct module *, const char *mod_name);
600static inline int __must_check hid_register_driver(struct hid_driver *driver)
601{
602 return __hid_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
603}
604extern void hid_unregister_driver(struct hid_driver *);
605
524extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 606extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
525extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); 607extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
526extern int hidinput_connect(struct hid_device *); 608extern int hidinput_connect(struct hid_device *);
@@ -533,8 +615,14 @@ int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned lon
533int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 615int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
534int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32); 616int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
535void hid_output_report(struct hid_report *report, __u8 *data); 617void hid_output_report(struct hid_report *report, __u8 *data);
536void hid_free_device(struct hid_device *device); 618struct hid_device *hid_allocate_device(void);
537struct hid_device *hid_parse_report(__u8 *start, unsigned size); 619int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
620
621void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
622 int interrupt);
623
624extern int hid_generic_init(void);
625extern void hid_generic_exit(void);
538 626
539/* HID quirks API */ 627/* HID quirks API */
540u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); 628u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);