diff options
| author | David Herrmann <dh.herrmann@googlemail.com> | 2012-06-10 09:16:23 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2012-06-18 07:42:02 -0400 |
| commit | f80e13601c51a836b2aac583b8a3b4327c0c27ce (patch) | |
| tree | e8aec7e0ce0523153a53404cb97454b74c702dc1 | |
| parent | e7191474a5459e6ba7039fadca6a32f3a5731909 (diff) | |
HID: uhid: forward output request to user-space
If the hid-driver wants to send standardized data to the device it uses a
linux input_event. We forward this to the user-space transport-level
driver so they can perform the requested action on the device.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| -rw-r--r-- | drivers/hid/uhid.c | 18 | ||||
| -rw-r--r-- | include/linux/uhid.h | 8 |
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 0226ba3f5307..4dd693e1c8b8 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c | |||
| @@ -112,6 +112,24 @@ static void uhid_hid_close(struct hid_device *hid) | |||
| 112 | static int uhid_hid_input(struct input_dev *input, unsigned int type, | 112 | static int uhid_hid_input(struct input_dev *input, unsigned int type, |
| 113 | unsigned int code, int value) | 113 | unsigned int code, int value) |
| 114 | { | 114 | { |
| 115 | struct hid_device *hid = input_get_drvdata(input); | ||
| 116 | struct uhid_device *uhid = hid->driver_data; | ||
| 117 | unsigned long flags; | ||
| 118 | struct uhid_event *ev; | ||
| 119 | |||
| 120 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); | ||
| 121 | if (!ev) | ||
| 122 | return -ENOMEM; | ||
| 123 | |||
| 124 | ev->type = UHID_OUTPUT_EV; | ||
| 125 | ev->u.output_ev.type = type; | ||
| 126 | ev->u.output_ev.code = code; | ||
| 127 | ev->u.output_ev.value = value; | ||
| 128 | |||
| 129 | spin_lock_irqsave(&uhid->qlock, flags); | ||
| 130 | uhid_queue(uhid, ev); | ||
| 131 | spin_unlock_irqrestore(&uhid->qlock, flags); | ||
| 132 | |||
| 115 | return 0; | 133 | return 0; |
| 116 | } | 134 | } |
| 117 | 135 | ||
diff --git a/include/linux/uhid.h b/include/linux/uhid.h index 351650b7a0f6..3fa484921010 100644 --- a/include/linux/uhid.h +++ b/include/linux/uhid.h | |||
| @@ -29,6 +29,7 @@ enum uhid_event_type { | |||
| 29 | UHID_STOP, | 29 | UHID_STOP, |
| 30 | UHID_OPEN, | 30 | UHID_OPEN, |
| 31 | UHID_CLOSE, | 31 | UHID_CLOSE, |
| 32 | UHID_OUTPUT_EV, | ||
| 32 | UHID_INPUT, | 33 | UHID_INPUT, |
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| @@ -53,12 +54,19 @@ struct uhid_input_req { | |||
| 53 | __u16 size; | 54 | __u16 size; |
| 54 | } __attribute__((__packed__)); | 55 | } __attribute__((__packed__)); |
| 55 | 56 | ||
| 57 | struct uhid_output_ev_req { | ||
| 58 | __u16 type; | ||
| 59 | __u16 code; | ||
| 60 | __s32 value; | ||
| 61 | } __attribute__((__packed__)); | ||
| 62 | |||
| 56 | struct uhid_event { | 63 | struct uhid_event { |
| 57 | __u32 type; | 64 | __u32 type; |
| 58 | 65 | ||
| 59 | union { | 66 | union { |
| 60 | struct uhid_create_req create; | 67 | struct uhid_create_req create; |
| 61 | struct uhid_input_req input; | 68 | struct uhid_input_req input; |
| 69 | struct uhid_output_ev_req output_ev; | ||
| 62 | } u; | 70 | } u; |
| 63 | } __attribute__((__packed__)); | 71 | } __attribute__((__packed__)); |
| 64 | 72 | ||
