blob: 1e3b09c191cd50648fd4bd31425a6adaa7c0bd7b [file] [log] [blame]
David Herrmannace3d862012-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>
Petri Gynther45226432014-03-24 13:50:01 -070024#include <linux/hid.h>
David Herrmannace3d862012-06-10 15:16:14 +020025
26enum uhid_event_type {
David Herrmannd365c6c2012-06-10 15:16:18 +020027 UHID_CREATE,
28 UHID_DESTROY,
David Herrmannec4b7de2012-06-10 15:16:21 +020029 UHID_START,
30 UHID_STOP,
David Herrmanne7191472012-06-10 15:16:22 +020031 UHID_OPEN,
32 UHID_CLOSE,
David Herrmann3b3baa82012-06-10 15:16:24 +020033 UHID_OUTPUT,
David Herrmannbdb829e2013-07-15 19:10:15 +020034 UHID_OUTPUT_EV, /* obsolete! */
David Herrmann5e87a362012-06-10 15:16:19 +020035 UHID_INPUT,
David Herrmannfcfcf0d2012-06-10 15:16:25 +020036 UHID_FEATURE,
37 UHID_FEATURE_ANSWER,
Petri Gynther45226432014-03-24 13:50:01 -070038 UHID_CREATE2,
39 UHID_INPUT2,
David Herrmannace3d862012-06-10 15:16:14 +020040};
41
David Herrmannd365c6c2012-06-10 15:16:18 +020042struct uhid_create_req {
43 __u8 name[128];
44 __u8 phys[64];
45 __u8 uniq[64];
46 __u8 __user *rd_data;
47 __u16 rd_size;
48
49 __u16 bus;
50 __u32 vendor;
51 __u32 product;
52 __u32 version;
53 __u32 country;
54} __attribute__((__packed__));
55
Petri Gynther45226432014-03-24 13:50:01 -070056struct uhid_create2_req {
57 __u8 name[128];
58 __u8 phys[64];
59 __u8 uniq[64];
60 __u16 rd_size;
61 __u16 bus;
62 __u32 vendor;
63 __u32 product;
64 __u32 version;
65 __u32 country;
66 __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE];
67} __attribute__((__packed__));
68
David Herrmann5e87a362012-06-10 15:16:19 +020069#define UHID_DATA_MAX 4096
70
David Herrmann3b3baa82012-06-10 15:16:24 +020071enum uhid_report_type {
72 UHID_FEATURE_REPORT,
73 UHID_OUTPUT_REPORT,
74 UHID_INPUT_REPORT,
75};
76
David Herrmann5e87a362012-06-10 15:16:19 +020077struct uhid_input_req {
78 __u8 data[UHID_DATA_MAX];
79 __u16 size;
80} __attribute__((__packed__));
81
Petri Gynther45226432014-03-24 13:50:01 -070082struct uhid_input2_req {
83 __u16 size;
84 __u8 data[UHID_DATA_MAX];
85} __attribute__((__packed__));
86
David Herrmann3b3baa82012-06-10 15:16:24 +020087struct uhid_output_req {
88 __u8 data[UHID_DATA_MAX];
89 __u16 size;
90 __u8 rtype;
91} __attribute__((__packed__));
92
David Herrmannbdb829e2013-07-15 19:10:15 +020093/* Obsolete! Newer kernels will no longer send these events but instead convert
94 * it into raw output reports via UHID_OUTPUT. */
David Herrmannf80e1362012-06-10 15:16:23 +020095struct uhid_output_ev_req {
96 __u16 type;
97 __u16 code;
98 __s32 value;
99} __attribute__((__packed__));
100
David Herrmannfcfcf0d2012-06-10 15:16:25 +0200101struct uhid_feature_req {
102 __u32 id;
103 __u8 rnum;
104 __u8 rtype;
105} __attribute__((__packed__));
106
107struct uhid_feature_answer_req {
108 __u32 id;
109 __u16 err;
110 __u16 size;
111 __u8 data[UHID_DATA_MAX];
David Herrmannfee5dfe2012-12-17 13:20:43 +0100112} __attribute__((__packed__));
David Herrmannfcfcf0d2012-06-10 15:16:25 +0200113
David Herrmannace3d862012-06-10 15:16:14 +0200114struct uhid_event {
115 __u32 type;
David Herrmannd365c6c2012-06-10 15:16:18 +0200116
117 union {
118 struct uhid_create_req create;
David Herrmann5e87a362012-06-10 15:16:19 +0200119 struct uhid_input_req input;
David Herrmann3b3baa82012-06-10 15:16:24 +0200120 struct uhid_output_req output;
David Herrmannf80e1362012-06-10 15:16:23 +0200121 struct uhid_output_ev_req output_ev;
David Herrmannfcfcf0d2012-06-10 15:16:25 +0200122 struct uhid_feature_req feature;
123 struct uhid_feature_answer_req feature_answer;
Petri Gynther45226432014-03-24 13:50:01 -0700124 struct uhid_create2_req create2;
125 struct uhid_input2_req input2;
David Herrmannd365c6c2012-06-10 15:16:18 +0200126 } u;
David Herrmannace3d862012-06-10 15:16:14 +0200127} __attribute__((__packed__));
128
129#endif /* __UHID_H_ */