Skip to content

Commit

Permalink
HID: uhid: forward output request to user-space
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 18, 2012
1 parent e719147 commit f80e136
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/hid/uhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ static void uhid_hid_close(struct hid_device *hid)
static int uhid_hid_input(struct input_dev *input, unsigned int type,
unsigned int code, int value)
{
struct hid_device *hid = input_get_drvdata(input);
struct uhid_device *uhid = hid->driver_data;
unsigned long flags;
struct uhid_event *ev;

ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
if (!ev)
return -ENOMEM;

ev->type = UHID_OUTPUT_EV;
ev->u.output_ev.type = type;
ev->u.output_ev.code = code;
ev->u.output_ev.value = value;

spin_lock_irqsave(&uhid->qlock, flags);
uhid_queue(uhid, ev);
spin_unlock_irqrestore(&uhid->qlock, flags);

return 0;
}

Expand Down
8 changes: 8 additions & 0 deletions include/linux/uhid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum uhid_event_type {
UHID_STOP,
UHID_OPEN,
UHID_CLOSE,
UHID_OUTPUT_EV,
UHID_INPUT,
};

Expand All @@ -53,12 +54,19 @@ struct uhid_input_req {
__u16 size;
} __attribute__((__packed__));

struct uhid_output_ev_req {
__u16 type;
__u16 code;
__s32 value;
} __attribute__((__packed__));

struct uhid_event {
__u32 type;

union {
struct uhid_create_req create;
struct uhid_input_req input;
struct uhid_output_ev_req output_ev;
} u;
} __attribute__((__packed__));

Expand Down

0 comments on commit f80e136

Please sign in to comment.