blob: 3fa484921010398b4614c8d53454b84342f0ace0 [file] [log] [blame]
David Herrmann487e27e2012-06-10 15:16:14 +02001#ifndef __UHID_H_
2#define __UHID_H_
3
4/*
5 * User-space I/O driver support for HID subsystem
6 * Copyright (c) 2012 David Herrmann
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16/*
17 * Public header for user-space communication. We try to keep every structure
18 * aligned but to be safe we also use __attribute__((__packed__)). Therefore,
19 * the communication should be ABI compatible even between architectures.
20 */
21
22#include <linux/input.h>
23#include <linux/types.h>
24
25enum uhid_event_type {
David Herrmann9b9a3792012-06-10 15:16:18 +020026 UHID_CREATE,
27 UHID_DESTROY,
David Herrmannba5c3132012-06-10 15:16:21 +020028 UHID_START,
29 UHID_STOP,
David Herrmann8fbb8772012-06-10 15:16:22 +020030 UHID_OPEN,
31 UHID_CLOSE,
David Herrmann9db7c632012-06-10 15:16:23 +020032 UHID_OUTPUT_EV,
David Herrmann5f807222012-06-10 15:16:19 +020033 UHID_INPUT,
David Herrmann487e27e2012-06-10 15:16:14 +020034};
35
David Herrmann9b9a3792012-06-10 15:16:18 +020036struct uhid_create_req {
37 __u8 name[128];
38 __u8 phys[64];
39 __u8 uniq[64];
40 __u8 __user *rd_data;
41 __u16 rd_size;
42
43 __u16 bus;
44 __u32 vendor;
45 __u32 product;
46 __u32 version;
47 __u32 country;
48} __attribute__((__packed__));
49
David Herrmann5f807222012-06-10 15:16:19 +020050#define UHID_DATA_MAX 4096
51
52struct uhid_input_req {
53 __u8 data[UHID_DATA_MAX];
54 __u16 size;
55} __attribute__((__packed__));
56
David Herrmann9db7c632012-06-10 15:16:23 +020057struct uhid_output_ev_req {
58 __u16 type;
59 __u16 code;
60 __s32 value;
61} __attribute__((__packed__));
62
David Herrmann487e27e2012-06-10 15:16:14 +020063struct uhid_event {
64 __u32 type;
David Herrmann9b9a3792012-06-10 15:16:18 +020065
66 union {
67 struct uhid_create_req create;
David Herrmann5f807222012-06-10 15:16:19 +020068 struct uhid_input_req input;
David Herrmann9db7c632012-06-10 15:16:23 +020069 struct uhid_output_ev_req output_ev;
David Herrmann9b9a3792012-06-10 15:16:18 +020070 } u;
David Herrmann487e27e2012-06-10 15:16:14 +020071} __attribute__((__packed__));
72
73#endif /* __UHID_H_ */