History

HID: uhid: keep legacy definitions at the bottom of uhid.h

Instead of inlining the legacy definitions into the main part of uhid.h, keep them at the bottom now. This way, the API is much easier to read and legacy requests can be looked up at a separate place.

David Herrmann committed 12 years ago

Commit 50598e71 parent fa71f321 file · +62 −39Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/uhid.h+62−39
@@ -24,37 +24,21 @@ · 23 unmodified lines
2424 #include <linux/hid.h>
2525
2626 enum uhid_event_type {
27− UHID_CREATE,
27+ __UHID_LEGACY_CREATE,
2828 UHID_DESTROY,
2929 UHID_START,
3030 UHID_STOP,
3131 UHID_OPEN,
3232 UHID_CLOSE,
3333 UHID_OUTPUT,
34− UHID_OUTPUT_EV, /* obsolete! */
35− UHID_INPUT,
36− UHID_FEATURE, /* obsolete! use UHID_GET_REPORT */
37− UHID_GET_REPORT = UHID_FEATURE,
38− UHID_FEATURE_ANSWER, /* obsolete! use UHID_GET_REPORT_REPLY */
39− UHID_GET_REPORT_REPLY = UHID_FEATURE_ANSWER,
34+ __UHID_LEGACY_OUTPUT_EV,
35+ __UHID_LEGACY_INPUT,
36+ UHID_GET_REPORT,
37+ UHID_GET_REPORT_REPLY,
4038 UHID_CREATE2,
4139 UHID_INPUT2,
4240 };
4341
44−struct uhid_create_req {
45− __u8 name[128];
46− __u8 phys[64];
47− __u8 uniq[64];
48− __u8 __user *rd_data;
49− __u16 rd_size;
50−
51− __u16 bus;
52− __u32 vendor;
53− __u32 product;
54− __u32 version;
55− __u32 country;
56−} __attribute__((__packed__));
57−
5842 struct uhid_create2_req {
5943 __u8 name[128];
6044 __u8 phys[64];
@@ -76,24 +60,67 @@ enum uhid_report_type { · 15 unmodified lines
7660 UHID_INPUT_REPORT,
7761 };
7862
79−struct uhid_input_req {
63+struct uhid_input2_req {
64+ __u16 size;
65+ __u8 data[UHID_DATA_MAX];
66+} __attribute__((__packed__));
67+
68+struct uhid_output_req {
8069 __u8 data[UHID_DATA_MAX];
8170 __u16 size;
71+ __u8 rtype;
8272 } __attribute__((__packed__));
8373
84−struct uhid_input2_req {
74+struct uhid_get_report_req {
75+ __u32 id;
76+ __u8 rnum;
77+ __u8 rtype;
78+} __attribute__((__packed__));
79+
80+struct uhid_get_report_reply_req {
81+ __u32 id;
82+ __u16 err;
8583 __u16 size;
8684 __u8 data[UHID_DATA_MAX];
8785 } __attribute__((__packed__));
8886
89−struct uhid_output_req {
87+/*
88+ * Compat Layer
89+ * All these commands and requests are obsolete. You should avoid using them in
90+ * new code. We support them for backwards-compatibility, but you might not get
91+ * access to new feature in case you use them.
92+ */
93+
94+enum uhid_legacy_event_type {
95+ UHID_CREATE = __UHID_LEGACY_CREATE,
96+ UHID_OUTPUT_EV = __UHID_LEGACY_OUTPUT_EV,
97+ UHID_INPUT = __UHID_LEGACY_INPUT,
98+ UHID_FEATURE = UHID_GET_REPORT,
99+ UHID_FEATURE_ANSWER = UHID_GET_REPORT_REPLY,
100+};
101+
102+/* Obsolete! Use UHID_CREATE2. */
103+struct uhid_create_req {
104+ __u8 name[128];
105+ __u8 phys[64];
106+ __u8 uniq[64];
107+ __u8 __user *rd_data;
108+ __u16 rd_size;
109+
110+ __u16 bus;
111+ __u32 vendor;
112+ __u32 product;
113+ __u32 version;
114+ __u32 country;
115+} __attribute__((__packed__));
116+
117+/* Obsolete! Use UHID_INPUT2. */
118+struct uhid_input_req {
90119 __u8 data[UHID_DATA_MAX];
91120 __u16 size;
92− __u8 rtype;
93121 } __attribute__((__packed__));
94122
95−/* Obsolete! Newer kernels will no longer send these events but instead convert
96− * it into raw output reports via UHID_OUTPUT. */
123+/* Obsolete! Kernel uses UHID_OUTPUT exclusively now. */
97124 struct uhid_output_ev_req {
98125 __u16 type;
99126 __u16 code;
@@ -107,12 +134,6 @@ struct uhid_feature_req { · 7 unmodified lines
107134 __u8 rtype;
108135 } __attribute__((__packed__));
109136
110−struct uhid_get_report_req {
111− __u32 id;
112− __u8 rnum;
113− __u8 rtype;
114−} __attribute__((__packed__));
115−
116137 /* Obsolete! Use ABI compatible UHID_GET_REPORT_REPLY. */
117138 struct uhid_feature_answer_req {
118139 __u32 id;
@@ -121,12 +142,14 @@ struct uhid_feature_answer_req { · 2 unmodified lines
121142 __u8 data[UHID_DATA_MAX];
122143 } __attribute__((__packed__));
123144
124−struct uhid_get_report_reply_req {
125− __u32 id;
126− __u16 err;
127− __u16 size;
128− __u8 data[UHID_DATA_MAX];
129−} __attribute__((__packed__));
145+/*
146+ * UHID Events
147+ * All UHID events from and to the kernel are encoded as "struct uhid_event".
148+ * The "type" field contains a UHID_* type identifier. All payload depends on
149+ * that type and can be accessed via ev->u.XYZ accordingly.
150+ * If user-space writes short events, they're extended with 0s by the kernel. If
151+ * the kernel writes short events, user-space shall extend them with 0s.
152+ */
130153
131154 struct uhid_event {
132155 __u32 type;