aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hid.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index ac2584fe65c5..986c0e7ea66a 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -655,7 +655,8 @@ extern void hidinput_disconnect(struct hid_device *);
655int hid_set_field(struct hid_field *, unsigned, __s32); 655int hid_set_field(struct hid_field *, unsigned, __s32);
656int hid_input_report(struct hid_device *, int type, u8 *, int, int); 656int hid_input_report(struct hid_device *, int type, u8 *, int, int);
657int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 657int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
658int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *); 658int hidinput_mapping_quirks(struct hid_usage *, struct hid_input *,
659 unsigned long **, int *);
659int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 660int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
660int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32); 661int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
661void hid_output_report(struct hid_report *report, __u8 *data); 662void hid_output_report(struct hid_report *report, __u8 *data);
@@ -663,6 +664,59 @@ struct hid_device *hid_allocate_device(void);
663int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size); 664int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
664 665
665/** 666/**
667 * hid_map_usage - map usage input bits
668 *
669 * @hidinput: hidinput which we are interested in
670 * @usage: usage to fill in
671 * @bit: pointer to input->{}bit (out parameter)
672 * @max: maximal valid usage->code to consider later (out parameter)
673 * @type: input event type (EV_KEY, EV_REL, ...)
674 * @c: code which corresponds to this usage and type
675 */
676static inline void hid_map_usage(struct hid_input *hidinput,
677 struct hid_usage *usage, unsigned long **bit, int *max,
678 __u8 type, __u16 c)
679{
680 struct input_dev *input = hidinput->input;
681
682 usage->type = type;
683 usage->code = c;
684
685 switch (type) {
686 case EV_ABS:
687 *bit = input->absbit;
688 *max = ABS_MAX;
689 break;
690 case EV_REL:
691 *bit = input->relbit;
692 *max = REL_MAX;
693 break;
694 case EV_KEY:
695 *bit = input->keybit;
696 *max = KEY_MAX;
697 break;
698 case EV_LED:
699 *bit = input->ledbit;
700 *max = LED_MAX;
701 break;
702 }
703}
704
705/**
706 * hid_map_usage_clear - map usage input bits and clear the input bit
707 *
708 * The same as hid_map_usage, except the @c bit is also cleared in supported
709 * bits (@bit).
710 */
711static inline void hid_map_usage_clear(struct hid_input *hidinput,
712 struct hid_usage *usage, unsigned long **bit, int *max,
713 __u8 type, __u16 c)
714{
715 hid_map_usage(hidinput, usage, bit, max, type, c);
716 clear_bit(c, *bit);
717}
718
719/**
666 * hid_parse - parse HW reports 720 * hid_parse - parse HW reports
667 * 721 *
668 * @hdev: hid device 722 * @hdev: hid device