diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/hid-debug.h | 6 | ||||
-rw-r--r-- | include/linux/hid.h | 100 |
2 files changed, 103 insertions, 3 deletions
diff --git a/include/linux/hid-debug.h b/include/linux/hid-debug.h index 53744fa1c8b7..8663f216c563 100644 --- a/include/linux/hid-debug.h +++ b/include/linux/hid-debug.h | |||
@@ -22,11 +22,12 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define HID_DEBUG_BUFSIZE 512 | ||
26 | |||
27 | #ifdef CONFIG_DEBUG_FS | 25 | #ifdef CONFIG_DEBUG_FS |
28 | 26 | ||
27 | #define HID_DEBUG_BUFSIZE 512 | ||
28 | |||
29 | void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); | 29 | void hid_dump_input(struct hid_device *, struct hid_usage *, __s32); |
30 | void hid_dump_report(struct hid_device *, int , u8 *, int); | ||
30 | void hid_dump_device(struct hid_device *, struct seq_file *); | 31 | void hid_dump_device(struct hid_device *, struct seq_file *); |
31 | void hid_dump_field(struct hid_field *, int, struct seq_file *); | 32 | void hid_dump_field(struct hid_field *, int, struct seq_file *); |
32 | char *hid_resolv_usage(unsigned, struct seq_file *); | 33 | char *hid_resolv_usage(unsigned, struct seq_file *); |
@@ -50,6 +51,7 @@ struct hid_debug_list { | |||
50 | #else | 51 | #else |
51 | 52 | ||
52 | #define hid_dump_input(a,b,c) do { } while (0) | 53 | #define hid_dump_input(a,b,c) do { } while (0) |
54 | #define hid_dump_report(a,b,c,d) do { } while (0) | ||
53 | #define hid_dump_device(a,b) do { } while (0) | 55 | #define hid_dump_device(a,b) do { } while (0) |
54 | #define hid_dump_field(a,b,c) do { } while (0) | 56 | #define hid_dump_field(a,b,c) do { } while (0) |
55 | #define hid_resolv_usage(a,b) do { } while (0) | 57 | #define hid_resolv_usage(a,b) do { } while (0) |
diff --git a/include/linux/hid.h b/include/linux/hid.h index e14b465b1146..31e7cb51b17d 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
@@ -456,7 +456,8 @@ struct hid_device { /* device report descriptor */ | |||
456 | unsigned country; /* HID country */ | 456 | unsigned country; /* HID country */ |
457 | struct hid_report_enum report_enum[HID_REPORT_TYPES]; | 457 | struct hid_report_enum report_enum[HID_REPORT_TYPES]; |
458 | 458 | ||
459 | struct semaphore driver_lock; /* protects the current driver */ | 459 | struct semaphore driver_lock; /* protects the current driver, except during input */ |
460 | struct semaphore driver_input_lock; /* protects the current driver */ | ||
460 | struct device dev; /* device */ | 461 | struct device dev; /* device */ |
461 | struct hid_driver *driver; | 462 | struct hid_driver *driver; |
462 | struct hid_ll_driver *ll_driver; | 463 | struct hid_ll_driver *ll_driver; |
@@ -477,6 +478,7 @@ struct hid_device { /* device report descriptor */ | |||
477 | unsigned int status; /* see STAT flags above */ | 478 | unsigned int status; /* see STAT flags above */ |
478 | unsigned claimed; /* Claimed by hidinput, hiddev? */ | 479 | unsigned claimed; /* Claimed by hidinput, hiddev? */ |
479 | unsigned quirks; /* Various quirks the device can pull on us */ | 480 | unsigned quirks; /* Various quirks the device can pull on us */ |
481 | bool io_started; /* Protected by driver_lock. If IO has started */ | ||
480 | 482 | ||
481 | struct list_head inputs; /* The list of inputs */ | 483 | struct list_head inputs; /* The list of inputs */ |
482 | void *hiddev; /* The hiddev structure */ | 484 | void *hiddev; /* The hiddev structure */ |
@@ -512,6 +514,7 @@ struct hid_device { /* device report descriptor */ | |||
512 | struct dentry *debug_rdesc; | 514 | struct dentry *debug_rdesc; |
513 | struct dentry *debug_events; | 515 | struct dentry *debug_events; |
514 | struct list_head debug_list; | 516 | struct list_head debug_list; |
517 | struct mutex debug_list_lock; | ||
515 | wait_queue_head_t debug_wait; | 518 | wait_queue_head_t debug_wait; |
516 | }; | 519 | }; |
517 | 520 | ||
@@ -599,6 +602,10 @@ struct hid_usage_id { | |||
599 | * @resume: invoked on resume if device was not reset (NULL means nop) | 602 | * @resume: invoked on resume if device was not reset (NULL means nop) |
600 | * @reset_resume: invoked on resume if device was reset (NULL means nop) | 603 | * @reset_resume: invoked on resume if device was reset (NULL means nop) |
601 | * | 604 | * |
605 | * probe should return -errno on error, or 0 on success. During probe, | ||
606 | * input will not be passed to raw_event unless hid_device_io_start is | ||
607 | * called. | ||
608 | * | ||
602 | * raw_event and event should return 0 on no action performed, 1 when no | 609 | * raw_event and event should return 0 on no action performed, 1 when no |
603 | * further processing should be done and negative on error | 610 | * further processing should be done and negative on error |
604 | * | 611 | * |
@@ -662,6 +669,9 @@ struct hid_driver { | |||
662 | * @hidinput_input_event: event input event (e.g. ff or leds) | 669 | * @hidinput_input_event: event input event (e.g. ff or leds) |
663 | * @parse: this method is called only once to parse the device data, | 670 | * @parse: this method is called only once to parse the device data, |
664 | * shouldn't allocate anything to not leak memory | 671 | * shouldn't allocate anything to not leak memory |
672 | * @request: send report request to device (e.g. feature report) | ||
673 | * @wait: wait for buffered io to complete (send/recv reports) | ||
674 | * @idle: send idle request to device | ||
665 | */ | 675 | */ |
666 | struct hid_ll_driver { | 676 | struct hid_ll_driver { |
667 | int (*start)(struct hid_device *hdev); | 677 | int (*start)(struct hid_device *hdev); |
@@ -676,6 +686,13 @@ struct hid_ll_driver { | |||
676 | unsigned int code, int value); | 686 | unsigned int code, int value); |
677 | 687 | ||
678 | int (*parse)(struct hid_device *hdev); | 688 | int (*parse)(struct hid_device *hdev); |
689 | |||
690 | void (*request)(struct hid_device *hdev, | ||
691 | struct hid_report *report, int reqtype); | ||
692 | |||
693 | int (*wait)(struct hid_device *hdev); | ||
694 | int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); | ||
695 | |||
679 | }; | 696 | }; |
680 | 697 | ||
681 | #define PM_HINT_FULLON 1<<5 | 698 | #define PM_HINT_FULLON 1<<5 |
@@ -738,6 +755,44 @@ const struct hid_device_id *hid_match_id(struct hid_device *hdev, | |||
738 | s32 hid_snto32(__u32 value, unsigned n); | 755 | s32 hid_snto32(__u32 value, unsigned n); |
739 | 756 | ||
740 | /** | 757 | /** |
758 | * hid_device_io_start - enable HID input during probe, remove | ||
759 | * | ||
760 | * @hid - the device | ||
761 | * | ||
762 | * This should only be called during probe or remove and only be | ||
763 | * called by the thread calling probe or remove. It will allow | ||
764 | * incoming packets to be delivered to the driver. | ||
765 | */ | ||
766 | static inline void hid_device_io_start(struct hid_device *hid) { | ||
767 | if (hid->io_started) { | ||
768 | dev_warn(&hid->dev, "io already started"); | ||
769 | return; | ||
770 | } | ||
771 | hid->io_started = true; | ||
772 | up(&hid->driver_input_lock); | ||
773 | } | ||
774 | |||
775 | /** | ||
776 | * hid_device_io_stop - disable HID input during probe, remove | ||
777 | * | ||
778 | * @hid - the device | ||
779 | * | ||
780 | * Should only be called after hid_device_io_start. It will prevent | ||
781 | * incoming packets from going to the driver for the duration of | ||
782 | * probe, remove. If called during probe, packets will still go to the | ||
783 | * driver after probe is complete. This function should only be called | ||
784 | * by the thread calling probe or remove. | ||
785 | */ | ||
786 | static inline void hid_device_io_stop(struct hid_device *hid) { | ||
787 | if (!hid->io_started) { | ||
788 | dev_warn(&hid->dev, "io already stopped"); | ||
789 | return; | ||
790 | } | ||
791 | hid->io_started = false; | ||
792 | down(&hid->driver_input_lock); | ||
793 | } | ||
794 | |||
795 | /** | ||
741 | * hid_map_usage - map usage input bits | 796 | * hid_map_usage - map usage input bits |
742 | * | 797 | * |
743 | * @hidinput: hidinput which we are interested in | 798 | * @hidinput: hidinput which we are interested in |
@@ -883,6 +938,49 @@ static inline int hid_hw_power(struct hid_device *hdev, int level) | |||
883 | return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0; | 938 | return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0; |
884 | } | 939 | } |
885 | 940 | ||
941 | |||
942 | /** | ||
943 | * hid_hw_request - send report request to device | ||
944 | * | ||
945 | * @hdev: hid device | ||
946 | * @report: report to send | ||
947 | * @reqtype: hid request type | ||
948 | */ | ||
949 | static inline void hid_hw_request(struct hid_device *hdev, | ||
950 | struct hid_report *report, int reqtype) | ||
951 | { | ||
952 | if (hdev->ll_driver->request) | ||
953 | hdev->ll_driver->request(hdev, report, reqtype); | ||
954 | } | ||
955 | |||
956 | /** | ||
957 | * hid_hw_idle - send idle request to device | ||
958 | * | ||
959 | * @hdev: hid device | ||
960 | * @report: report to control | ||
961 | * @idle: idle state | ||
962 | * @reqtype: hid request type | ||
963 | */ | ||
964 | static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle, | ||
965 | int reqtype) | ||
966 | { | ||
967 | if (hdev->ll_driver->idle) | ||
968 | return hdev->ll_driver->idle(hdev, report, idle, reqtype); | ||
969 | |||
970 | return 0; | ||
971 | } | ||
972 | |||
973 | /** | ||
974 | * hid_hw_wait - wait for buffered io to complete | ||
975 | * | ||
976 | * @hdev: hid device | ||
977 | */ | ||
978 | static inline void hid_hw_wait(struct hid_device *hdev) | ||
979 | { | ||
980 | if (hdev->ll_driver->wait) | ||
981 | hdev->ll_driver->wait(hdev); | ||
982 | } | ||
983 | |||
886 | int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, | 984 | int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
887 | int interrupt); | 985 | int interrupt); |
888 | 986 | ||