5 * User-space I/O driver support for HID subsystem
6 * Copyright (c) 2012 David Herrmann
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)
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.
22 #include <linux/input.h>
23 #include <linux/types.h>
24 #include <linux/hid.h>
26 enum uhid_event_type
{
34 __UHID_LEGACY_OUTPUT_EV
,
37 UHID_GET_REPORT_REPLY
,
41 UHID_SET_REPORT_REPLY
,
44 struct uhid_create2_req
{
54 __u8 rd_data
[HID_MAX_DESCRIPTOR_SIZE
];
55 } __attribute__((__packed__
));
58 UHID_DEV_NUMBERED_FEATURE_REPORTS
= (1ULL << 0),
59 UHID_DEV_NUMBERED_OUTPUT_REPORTS
= (1ULL << 1),
60 UHID_DEV_NUMBERED_INPUT_REPORTS
= (1ULL << 2),
63 struct uhid_start_req
{
67 #define UHID_DATA_MAX 4096
69 enum uhid_report_type
{
75 struct uhid_input2_req
{
77 __u8 data
[UHID_DATA_MAX
];
78 } __attribute__((__packed__
));
80 struct uhid_output_req
{
81 __u8 data
[UHID_DATA_MAX
];
84 } __attribute__((__packed__
));
86 struct uhid_get_report_req
{
90 } __attribute__((__packed__
));
92 struct uhid_get_report_reply_req
{
96 __u8 data
[UHID_DATA_MAX
];
97 } __attribute__((__packed__
));
99 struct uhid_set_report_req
{
104 __u8 data
[UHID_DATA_MAX
];
105 } __attribute__((__packed__
));
107 struct uhid_set_report_reply_req
{
110 } __attribute__((__packed__
));
114 * All these commands and requests are obsolete. You should avoid using them in
115 * new code. We support them for backwards-compatibility, but you might not get
116 * access to new feature in case you use them.
119 enum uhid_legacy_event_type
{
120 UHID_CREATE
= __UHID_LEGACY_CREATE
,
121 UHID_OUTPUT_EV
= __UHID_LEGACY_OUTPUT_EV
,
122 UHID_INPUT
= __UHID_LEGACY_INPUT
,
123 UHID_FEATURE
= UHID_GET_REPORT
,
124 UHID_FEATURE_ANSWER
= UHID_GET_REPORT_REPLY
,
127 /* Obsolete! Use UHID_CREATE2. */
128 struct uhid_create_req
{
132 __u8 __user
*rd_data
;
140 } __attribute__((__packed__
));
142 /* Obsolete! Use UHID_INPUT2. */
143 struct uhid_input_req
{
144 __u8 data
[UHID_DATA_MAX
];
146 } __attribute__((__packed__
));
148 /* Obsolete! Kernel uses UHID_OUTPUT exclusively now. */
149 struct uhid_output_ev_req
{
153 } __attribute__((__packed__
));
155 /* Obsolete! Kernel uses ABI compatible UHID_GET_REPORT. */
156 struct uhid_feature_req
{
160 } __attribute__((__packed__
));
162 /* Obsolete! Use ABI compatible UHID_GET_REPORT_REPLY. */
163 struct uhid_feature_answer_req
{
167 __u8 data
[UHID_DATA_MAX
];
168 } __attribute__((__packed__
));
172 * All UHID events from and to the kernel are encoded as "struct uhid_event".
173 * The "type" field contains a UHID_* type identifier. All payload depends on
174 * that type and can be accessed via ev->u.XYZ accordingly.
175 * If user-space writes short events, they're extended with 0s by the kernel. If
176 * the kernel writes short events, user-space shall extend them with 0s.
183 struct uhid_create_req create
;
184 struct uhid_input_req input
;
185 struct uhid_output_req output
;
186 struct uhid_output_ev_req output_ev
;
187 struct uhid_feature_req feature
;
188 struct uhid_get_report_req get_report
;
189 struct uhid_feature_answer_req feature_answer
;
190 struct uhid_get_report_reply_req get_report_reply
;
191 struct uhid_create2_req create2
;
192 struct uhid_input2_req input2
;
193 struct uhid_set_report_req set_report
;
194 struct uhid_set_report_reply_req set_report_reply
;
195 struct uhid_start_req start
;
197 } __attribute__((__packed__
));
199 #endif /* __UHID_H_ */