1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
6 * User-space I/O driver support for HID subsystem
7 * Copyright (c) 2012 David Herrmann
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
18 * Public header for user-space communication. We try to keep every structure
19 * aligned but to be safe we also use __attribute__((__packed__)). Therefore,
20 * the communication should be ABI compatible even between architectures.
23 #include <linux/input.h>
24 #include <linux/types.h>
25 #include <linux/hid.h>
27 enum uhid_event_type {
35 __UHID_LEGACY_OUTPUT_EV,
38 UHID_GET_REPORT_REPLY,
42 UHID_SET_REPORT_REPLY,
45 struct uhid_create2_req {
55 __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE];
56 } __attribute__((__packed__));
59 UHID_DEV_NUMBERED_FEATURE_REPORTS = (1ULL << 0),
60 UHID_DEV_NUMBERED_OUTPUT_REPORTS = (1ULL << 1),
61 UHID_DEV_NUMBERED_INPUT_REPORTS = (1ULL << 2),
64 struct uhid_start_req {
68 #define UHID_DATA_MAX 4096
70 enum uhid_report_type {
76 struct uhid_input2_req {
78 __u8 data[UHID_DATA_MAX];
79 } __attribute__((__packed__));
81 struct uhid_output_req {
82 __u8 data[UHID_DATA_MAX];
85 } __attribute__((__packed__));
87 struct uhid_get_report_req {
91 } __attribute__((__packed__));
93 struct uhid_get_report_reply_req {
97 __u8 data[UHID_DATA_MAX];
98 } __attribute__((__packed__));
100 struct uhid_set_report_req {
105 __u8 data[UHID_DATA_MAX];
106 } __attribute__((__packed__));
108 struct uhid_set_report_reply_req {
111 } __attribute__((__packed__));
115 * All these commands and requests are obsolete. You should avoid using them in
116 * new code. We support them for backwards-compatibility, but you might not get
117 * access to new feature in case you use them.
120 enum uhid_legacy_event_type {
121 UHID_CREATE = __UHID_LEGACY_CREATE,
122 UHID_OUTPUT_EV = __UHID_LEGACY_OUTPUT_EV,
123 UHID_INPUT = __UHID_LEGACY_INPUT,
124 UHID_FEATURE = UHID_GET_REPORT,
125 UHID_FEATURE_ANSWER = UHID_GET_REPORT_REPLY,
128 /* Obsolete! Use UHID_CREATE2. */
129 struct uhid_create_req {
133 __u8 __user *rd_data;
141 } __attribute__((__packed__));
143 /* Obsolete! Use UHID_INPUT2. */
144 struct uhid_input_req {
145 __u8 data[UHID_DATA_MAX];
147 } __attribute__((__packed__));
149 /* Obsolete! Kernel uses UHID_OUTPUT exclusively now. */
150 struct uhid_output_ev_req {
154 } __attribute__((__packed__));
156 /* Obsolete! Kernel uses ABI compatible UHID_GET_REPORT. */
157 struct uhid_feature_req {
161 } __attribute__((__packed__));
163 /* Obsolete! Use ABI compatible UHID_GET_REPORT_REPLY. */
164 struct uhid_feature_answer_req {
168 __u8 data[UHID_DATA_MAX];
169 } __attribute__((__packed__));
173 * All UHID events from and to the kernel are encoded as "struct uhid_event".
174 * The "type" field contains a UHID_* type identifier. All payload depends on
175 * that type and can be accessed via ev->u.XYZ accordingly.
176 * If user-space writes short events, they're extended with 0s by the kernel. If
177 * the kernel writes short events, user-space shall extend them with 0s.
184 struct uhid_create_req create;
185 struct uhid_input_req input;
186 struct uhid_output_req output;
187 struct uhid_output_ev_req output_ev;
188 struct uhid_feature_req feature;
189 struct uhid_get_report_req get_report;
190 struct uhid_feature_answer_req feature_answer;
191 struct uhid_get_report_reply_req get_report_reply;
192 struct uhid_create2_req create2;
193 struct uhid_input2_req input2;
194 struct uhid_set_report_req set_report;
195 struct uhid_set_report_reply_req set_report_reply;
196 struct uhid_start_req start;
198 } __attribute__((__packed__));
200 #endif /* __UHID_H_ */