aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-05-16 05:49:18 -0400
committerJiri Kosina <jkosina@suse.cz>2008-10-14 17:50:49 -0400
commit022e8c4d08b3b06361594b60412db0242035c4b4 (patch)
tree9a8c57a3054737fb142054d146bad99723cd3cfa /include
parent990436a7c9d0e5d395b83d79cfa32f89b8144e5b (diff)
HID: move usage input mapping to hid.h
This mapping are currently used on 2 placces and will be needed by more quirk drivers, so move them to hid.h to allow them to use it. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'include')
-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