History

Merge tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg Kroah-Hartman: "Here are the USB patches against your 3.7-rc1 tree. There are the usual UABI header file movements, and we finally are now able to remove the dbg() macro that is over 15 years old (that had to wait for after some other trees got merged into yours during the big 3.7-rc1 merge window.) Other than that, nothing major, just a number of bugfixes and new device ids. It turns out that almost all of the usb-serial drivers had bugs in how they were handling their internal data, leaking memory, hence all of those fixups. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (42 commits) USB: option: add more ZTE devices USB: option: blacklist net interface on ZTE devices usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP USB: io_ti: fix sysfs-attribute creation USB: iuu_phoenix: fix sysfs-attribute creation USB: spcp8x5: fix port-data memory leak USB: ssu100: fix port-data memory leak USB: ti_usb_3410_5052: fix port-data memory leak USB: oti6858: fix port-data memory leak USB: iuu_phoenix: fix port-data memory leak USB: kl5kusb105: fix port-data memory leak USB: io_ti: fix port-data memory leak USB: keyspan_pda: fix port-data memory leak USB: f81232: fix port-data memory leak USB: io_edgeport: fix port-data memory leak USB: kobil_sct: fix port-data memory leak USB: cypress_m8: fix port-data memory leak usb: acm: fix the computation of the number of data bits usb: Missing dma_mask in ehci-vt8500.c when probed from device-tree usb: Missing dma_mask in uhci-platform.c when probed from device-tree ...

Linus Torvalds committed 14 years ago

Commit 42bf3e22 parents fb06de0 4b35f1c51 files · +2333 −2221Browse files

Showing the changes to include/uapi/linux (11 of 51 files). Show all

Unified · Split

11 files
  1. include/uapi/linux/usb/Kbuild +10 −0
  2. include/uapi/linux/usb/audio.h +545 −0
  3. include/uapi/linux/usb/cdc.h +412 −0
  4. include/uapi/linux/usb/ch11.h +266 −0
  5. include/uapi/linux/usb/ch9.h +993 −0
  6. include/uapi/linux/usb/functionfs.h +169 −0
  7. include/uapi/linux/usb/g_printer.h +35 −0
  8. include/uapi/linux/usb/gadgetfs.h +88 −0
  9. include/uapi/linux/usb/midi.h +112 −0
  10. include/uapi/linux/usb/tmc.h +43 −0
  11. include/uapi/linux/usb/video.h +568 −0
include/uapi/linux/usb/Kbuild+10−0
@@ -1 +1,11 @@
11 # UAPI Header export list
2+header-y += audio.h
3+header-y += cdc.h
4+header-y += ch11.h
5+header-y += ch9.h
6+header-y += functionfs.h
7+header-y += g_printer.h
8+header-y += gadgetfs.h
9+header-y += midi.h
10+header-y += tmc.h
11+header-y += video.h
include/uapi/linux/usb/audio.h+545−0
@@ -0,0 +1,545 @@
1+/*
2+ * <linux/usb/audio.h> -- USB Audio definitions.
3+ *
4+ * Copyright (C) 2006 Thumtronics Pty Ltd.
5+ * Developed for Thumtronics by Grey Innovation
6+ * Ben Williamson <ben.williamson@greyinnovation.com>
7+ *
8+ * This software is distributed under the terms of the GNU General Public
9+ * License ("GPL") version 2, as published by the Free Software Foundation.
10+ *
11+ * This file holds USB constants and structures defined
12+ * by the USB Device Class Definition for Audio Devices.
13+ * Comments below reference relevant sections of that document:
14+ *
15+ * http://www.usb.org/developers/devclass_docs/audio10.pdf
16+ *
17+ * Types and defines in this file are either specific to version 1.0 of
18+ * this standard or common for newer versions.
19+ */
20+
21+#ifndef _UAPI__LINUX_USB_AUDIO_H
22+#define _UAPI__LINUX_USB_AUDIO_H
23+
24+#include <linux/types.h>
25+
26+/* bInterfaceProtocol values to denote the version of the standard used */
27+#define UAC_VERSION_1 0x00
28+#define UAC_VERSION_2 0x20
29+
30+/* A.2 Audio Interface Subclass Codes */
31+#define USB_SUBCLASS_AUDIOCONTROL 0x01
32+#define USB_SUBCLASS_AUDIOSTREAMING 0x02
33+#define USB_SUBCLASS_MIDISTREAMING 0x03
34+
35+/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
36+#define UAC_HEADER 0x01
37+#define UAC_INPUT_TERMINAL 0x02
38+#define UAC_OUTPUT_TERMINAL 0x03
39+#define UAC_MIXER_UNIT 0x04
40+#define UAC_SELECTOR_UNIT 0x05
41+#define UAC_FEATURE_UNIT 0x06
42+#define UAC1_PROCESSING_UNIT 0x07
43+#define UAC1_EXTENSION_UNIT 0x08
44+
45+/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
46+#define UAC_AS_GENERAL 0x01
47+#define UAC_FORMAT_TYPE 0x02
48+#define UAC_FORMAT_SPECIFIC 0x03
49+
50+/* A.7 Processing Unit Process Types */
51+#define UAC_PROCESS_UNDEFINED 0x00
52+#define UAC_PROCESS_UP_DOWNMIX 0x01
53+#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
54+#define UAC_PROCESS_STEREO_EXTENDER 0x03
55+#define UAC_PROCESS_REVERB 0x04
56+#define UAC_PROCESS_CHORUS 0x05
57+#define UAC_PROCESS_DYN_RANGE_COMP 0x06
58+
59+/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
60+#define UAC_EP_GENERAL 0x01
61+
62+/* A.9 Audio Class-Specific Request Codes */
63+#define UAC_SET_ 0x00
64+#define UAC_GET_ 0x80
65+
66+#define UAC__CUR 0x1
67+#define UAC__MIN 0x2
68+#define UAC__MAX 0x3
69+#define UAC__RES 0x4
70+#define UAC__MEM 0x5
71+
72+#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
73+#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
74+#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
75+#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
76+#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
77+#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
78+#define UAC_SET_RES (UAC_SET_ | UAC__RES)
79+#define UAC_GET_RES (UAC_GET_ | UAC__RES)
80+#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
81+#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
82+
83+#define UAC_GET_STAT 0xff
84+
85+/* A.10 Control Selector Codes */
86+
87+/* A.10.1 Terminal Control Selectors */
88+#define UAC_TERM_COPY_PROTECT 0x01
89+
90+/* A.10.2 Feature Unit Control Selectors */
91+#define UAC_FU_MUTE 0x01
92+#define UAC_FU_VOLUME 0x02
93+#define UAC_FU_BASS 0x03
94+#define UAC_FU_MID 0x04
95+#define UAC_FU_TREBLE 0x05
96+#define UAC_FU_GRAPHIC_EQUALIZER 0x06
97+#define UAC_FU_AUTOMATIC_GAIN 0x07
98+#define UAC_FU_DELAY 0x08
99+#define UAC_FU_BASS_BOOST 0x09
100+#define UAC_FU_LOUDNESS 0x0a
101+
102+#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
103+
104+/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
105+#define UAC_UD_ENABLE 0x01
106+#define UAC_UD_MODE_SELECT 0x02
107+
108+/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
109+#define UAC_DP_ENABLE 0x01
110+#define UAC_DP_MODE_SELECT 0x02
111+
112+/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
113+#define UAC_3D_ENABLE 0x01
114+#define UAC_3D_SPACE 0x02
115+
116+/* A.10.3.4 Reverberation Processing Unit Control Selectors */
117+#define UAC_REVERB_ENABLE 0x01
118+#define UAC_REVERB_LEVEL 0x02
119+#define UAC_REVERB_TIME 0x03
120+#define UAC_REVERB_FEEDBACK 0x04
121+
122+/* A.10.3.5 Chorus Processing Unit Control Selectors */
123+#define UAC_CHORUS_ENABLE 0x01
124+#define UAC_CHORUS_LEVEL 0x02
125+#define UAC_CHORUS_RATE 0x03
126+#define UAC_CHORUS_DEPTH 0x04
127+
128+/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
129+#define UAC_DCR_ENABLE 0x01
130+#define UAC_DCR_RATE 0x02
131+#define UAC_DCR_MAXAMPL 0x03
132+#define UAC_DCR_THRESHOLD 0x04
133+#define UAC_DCR_ATTACK_TIME 0x05
134+#define UAC_DCR_RELEASE_TIME 0x06
135+
136+/* A.10.4 Extension Unit Control Selectors */
137+#define UAC_XU_ENABLE 0x01
138+
139+/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
140+#define UAC_MS_HEADER 0x01
141+#define UAC_MIDI_IN_JACK 0x02
142+#define UAC_MIDI_OUT_JACK 0x03
143+
144+/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
145+#define UAC_MS_GENERAL 0x01
146+
147+/* Terminals - 2.1 USB Terminal Types */
148+#define UAC_TERMINAL_UNDEFINED 0x100
149+#define UAC_TERMINAL_STREAMING 0x101
150+#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
151+
152+/* Terminal Control Selectors */
153+/* 4.3.2 Class-Specific AC Interface Descriptor */
154+struct uac1_ac_header_descriptor {
155+ __u8 bLength; /* 8 + n */
156+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
157+ __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
158+ __le16 bcdADC; /* 0x0100 */
159+ __le16 wTotalLength; /* includes Unit and Terminal desc. */
160+ __u8 bInCollection; /* n */
161+ __u8 baInterfaceNr[]; /* [n] */
162+} __attribute__ ((packed));
163+
164+#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
165+
166+/* As above, but more useful for defining your own descriptors: */
167+#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
168+struct uac1_ac_header_descriptor_##n { \
169+ __u8 bLength; \
170+ __u8 bDescriptorType; \
171+ __u8 bDescriptorSubtype; \
172+ __le16 bcdADC; \
173+ __le16 wTotalLength; \
174+ __u8 bInCollection; \
175+ __u8 baInterfaceNr[n]; \
176+} __attribute__ ((packed))
177+
178+/* 4.3.2.1 Input Terminal Descriptor */
179+struct uac_input_terminal_descriptor {
180+ __u8 bLength; /* in bytes: 12 */
181+ __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
182+ __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
183+ __u8 bTerminalID; /* Constant uniquely terminal ID */
184+ __le16 wTerminalType; /* USB Audio Terminal Types */
185+ __u8 bAssocTerminal; /* ID of the Output Terminal associated */
186+ __u8 bNrChannels; /* Number of logical output channels */
187+ __le16 wChannelConfig;
188+ __u8 iChannelNames;
189+ __u8 iTerminal;
190+} __attribute__ ((packed));
191+
192+#define UAC_DT_INPUT_TERMINAL_SIZE 12
193+
194+/* Terminals - 2.2 Input Terminal Types */
195+#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
196+#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
197+#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
198+#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
199+#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
200+#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
201+#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
202+
203+/* Terminals - control selectors */
204+
205+#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
206+
207+/* 4.3.2.2 Output Terminal Descriptor */
208+struct uac1_output_terminal_descriptor {
209+ __u8 bLength; /* in bytes: 9 */
210+ __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
211+ __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
212+ __u8 bTerminalID; /* Constant uniquely terminal ID */
213+ __le16 wTerminalType; /* USB Audio Terminal Types */
214+ __u8 bAssocTerminal; /* ID of the Input Terminal associated */
215+ __u8 bSourceID; /* ID of the connected Unit or Terminal*/
216+ __u8 iTerminal;
217+} __attribute__ ((packed));
218+
219+#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
220+
221+/* Terminals - 2.3 Output Terminal Types */
222+#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
223+#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
224+#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
225+#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
226+#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
227+#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
228+#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
229+#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
230+
231+/* Set bControlSize = 2 as default setting */
232+#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
233+
234+/* As above, but more useful for defining your own descriptors: */
235+#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
236+struct uac_feature_unit_descriptor_##ch { \
237+ __u8 bLength; \
238+ __u8 bDescriptorType; \
239+ __u8 bDescriptorSubtype; \
240+ __u8 bUnitID; \
241+ __u8 bSourceID; \
242+ __u8 bControlSize; \
243+ __le16 bmaControls[ch + 1]; \
244+ __u8 iFeature; \
245+} __attribute__ ((packed))
246+
247+/* 4.3.2.3 Mixer Unit Descriptor */
248+struct uac_mixer_unit_descriptor {
249+ __u8 bLength;
250+ __u8 bDescriptorType;
251+ __u8 bDescriptorSubtype;
252+ __u8 bUnitID;
253+ __u8 bNrInPins;
254+ __u8 baSourceID[];
255+} __attribute__ ((packed));
256+
257+static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
258+{
259+ return desc->baSourceID[desc->bNrInPins];
260+}
261+
262+static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
263+ int protocol)
264+{
265+ if (protocol == UAC_VERSION_1)
266+ return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
267+ desc->baSourceID[desc->bNrInPins + 1];
268+ else
269+ return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
270+ (desc->baSourceID[desc->bNrInPins + 3] << 16) |
271+ (desc->baSourceID[desc->bNrInPins + 2] << 8) |
272+ (desc->baSourceID[desc->bNrInPins + 1]);
273+}
274+
275+static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
276+ int protocol)
277+{
278+ return (protocol == UAC_VERSION_1) ?
279+ desc->baSourceID[desc->bNrInPins + 3] :
280+ desc->baSourceID[desc->bNrInPins + 5];
281+}
282+
283+static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
284+ int protocol)
285+{
286+ return (protocol == UAC_VERSION_1) ?
287+ &desc->baSourceID[desc->bNrInPins + 4] :
288+ &desc->baSourceID[desc->bNrInPins + 6];
289+}
290+
291+static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
292+{
293+ __u8 *raw = (__u8 *) desc;
294+ return raw[desc->bLength - 1];
295+}
296+
297+/* 4.3.2.4 Selector Unit Descriptor */
298+struct uac_selector_unit_descriptor {
299+ __u8 bLength;
300+ __u8 bDescriptorType;
301+ __u8 bDescriptorSubtype;
302+ __u8 bUintID;
303+ __u8 bNrInPins;
304+ __u8 baSourceID[];
305+} __attribute__ ((packed));
306+
307+static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
308+{
309+ __u8 *raw = (__u8 *) desc;
310+ return raw[desc->bLength - 1];
311+}
312+
313+/* 4.3.2.5 Feature Unit Descriptor */
314+struct uac_feature_unit_descriptor {
315+ __u8 bLength;
316+ __u8 bDescriptorType;
317+ __u8 bDescriptorSubtype;
318+ __u8 bUnitID;
319+ __u8 bSourceID;
320+ __u8 bControlSize;
321+ __u8 bmaControls[0]; /* variable length */
322+} __attribute__((packed));
323+
324+static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
325+{
326+ __u8 *raw = (__u8 *) desc;
327+ return raw[desc->bLength - 1];
328+}
329+
330+/* 4.3.2.6 Processing Unit Descriptors */
331+struct uac_processing_unit_descriptor {
332+ __u8 bLength;
333+ __u8 bDescriptorType;
334+ __u8 bDescriptorSubtype;
335+ __u8 bUnitID;
336+ __u16 wProcessType;
337+ __u8 bNrInPins;
338+ __u8 baSourceID[];
339+} __attribute__ ((packed));
340+
341+static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
342+{
343+ return desc->baSourceID[desc->bNrInPins];
344+}
345+
346+static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
347+ int protocol)
348+{
349+ if (protocol == UAC_VERSION_1)
350+ return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
351+ desc->baSourceID[desc->bNrInPins + 1];
352+ else
353+ return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
354+ (desc->baSourceID[desc->bNrInPins + 3] << 16) |
355+ (desc->baSourceID[desc->bNrInPins + 2] << 8) |
356+ (desc->baSourceID[desc->bNrInPins + 1]);
357+}
358+
359+static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
360+ int protocol)
361+{
362+ return (protocol == UAC_VERSION_1) ?
363+ desc->baSourceID[desc->bNrInPins + 3] :
364+ desc->baSourceID[desc->bNrInPins + 5];
365+}
366+
367+static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
368+ int protocol)
369+{
370+ return (protocol == UAC_VERSION_1) ?
371+ desc->baSourceID[desc->bNrInPins + 4] :
372+ desc->baSourceID[desc->bNrInPins + 6];
373+}
374+
375+static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
376+ int protocol)
377+{
378+ return (protocol == UAC_VERSION_1) ?
379+ &desc->baSourceID[desc->bNrInPins + 5] :
380+ &desc->baSourceID[desc->bNrInPins + 7];
381+}
382+
383+static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
384+ int protocol)
385+{
386+ __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
387+ return desc->baSourceID[desc->bNrInPins + control_size];
388+}
389+
390+static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
391+ int protocol)
392+{
393+ __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
394+ return &desc->baSourceID[desc->bNrInPins + control_size + 1];
395+}
396+
397+/* 4.5.2 Class-Specific AS Interface Descriptor */
398+struct uac1_as_header_descriptor {
399+ __u8 bLength; /* in bytes: 7 */
400+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
401+ __u8 bDescriptorSubtype; /* AS_GENERAL */
402+ __u8 bTerminalLink; /* Terminal ID of connected Terminal */
403+ __u8 bDelay; /* Delay introduced by the data path */
404+ __le16 wFormatTag; /* The Audio Data Format */
405+} __attribute__ ((packed));
406+
407+#define UAC_DT_AS_HEADER_SIZE 7
408+
409+/* Formats - A.1.1 Audio Data Format Type I Codes */
410+#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
411+#define UAC_FORMAT_TYPE_I_PCM 0x1
412+#define UAC_FORMAT_TYPE_I_PCM8 0x2
413+#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
414+#define UAC_FORMAT_TYPE_I_ALAW 0x4
415+#define UAC_FORMAT_TYPE_I_MULAW 0x5
416+
417+struct uac_format_type_i_continuous_descriptor {
418+ __u8 bLength; /* in bytes: 8 + (ns * 3) */
419+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
420+ __u8 bDescriptorSubtype; /* FORMAT_TYPE */
421+ __u8 bFormatType; /* FORMAT_TYPE_1 */
422+ __u8 bNrChannels; /* physical channels in the stream */
423+ __u8 bSubframeSize; /* */
424+ __u8 bBitResolution;
425+ __u8 bSamFreqType;
426+ __u8 tLowerSamFreq[3];
427+ __u8 tUpperSamFreq[3];
428+} __attribute__ ((packed));
429+
430+#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
431+
432+struct uac_format_type_i_discrete_descriptor {
433+ __u8 bLength; /* in bytes: 8 + (ns * 3) */
434+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
435+ __u8 bDescriptorSubtype; /* FORMAT_TYPE */
436+ __u8 bFormatType; /* FORMAT_TYPE_1 */
437+ __u8 bNrChannels; /* physical channels in the stream */
438+ __u8 bSubframeSize; /* */
439+ __u8 bBitResolution;
440+ __u8 bSamFreqType;
441+ __u8 tSamFreq[][3];
442+} __attribute__ ((packed));
443+
444+#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
445+struct uac_format_type_i_discrete_descriptor_##n { \
446+ __u8 bLength; \
447+ __u8 bDescriptorType; \
448+ __u8 bDescriptorSubtype; \
449+ __u8 bFormatType; \
450+ __u8 bNrChannels; \
451+ __u8 bSubframeSize; \
452+ __u8 bBitResolution; \
453+ __u8 bSamFreqType; \
454+ __u8 tSamFreq[n][3]; \
455+} __attribute__ ((packed))
456+
457+#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
458+
459+struct uac_format_type_i_ext_descriptor {
460+ __u8 bLength;
461+ __u8 bDescriptorType;
462+ __u8 bDescriptorSubtype;
463+ __u8 bFormatType;
464+ __u8 bSubslotSize;
465+ __u8 bBitResolution;
466+ __u8 bHeaderLength;
467+ __u8 bControlSize;
468+ __u8 bSideBandProtocol;
469+} __attribute__((packed));
470+
471+/* Formats - Audio Data Format Type I Codes */
472+
473+#define UAC_FORMAT_TYPE_II_MPEG 0x1001
474+#define UAC_FORMAT_TYPE_II_AC3 0x1002
475+
476+struct uac_format_type_ii_discrete_descriptor {
477+ __u8 bLength;
478+ __u8 bDescriptorType;
479+ __u8 bDescriptorSubtype;
480+ __u8 bFormatType;
481+ __le16 wMaxBitRate;
482+ __le16 wSamplesPerFrame;
483+ __u8 bSamFreqType;
484+ __u8 tSamFreq[][3];
485+} __attribute__((packed));
486+
487+struct uac_format_type_ii_ext_descriptor {
488+ __u8 bLength;
489+ __u8 bDescriptorType;
490+ __u8 bDescriptorSubtype;
491+ __u8 bFormatType;
492+ __u16 wMaxBitRate;
493+ __u16 wSamplesPerFrame;
494+ __u8 bHeaderLength;
495+ __u8 bSideBandProtocol;
496+} __attribute__((packed));
497+
498+/* type III */
499+#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
500+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
501+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
502+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
503+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
504+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
505+
506+/* Formats - A.2 Format Type Codes */
507+#define UAC_FORMAT_TYPE_UNDEFINED 0x0
508+#define UAC_FORMAT_TYPE_I 0x1
509+#define UAC_FORMAT_TYPE_II 0x2
510+#define UAC_FORMAT_TYPE_III 0x3
511+#define UAC_EXT_FORMAT_TYPE_I 0x81
512+#define UAC_EXT_FORMAT_TYPE_II 0x82
513+#define UAC_EXT_FORMAT_TYPE_III 0x83
514+
515+struct uac_iso_endpoint_descriptor {
516+ __u8 bLength; /* in bytes: 7 */
517+ __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
518+ __u8 bDescriptorSubtype; /* EP_GENERAL */
519+ __u8 bmAttributes;
520+ __u8 bLockDelayUnits;
521+ __le16 wLockDelay;
522+} __attribute__((packed));
523+#define UAC_ISO_ENDPOINT_DESC_SIZE 7
524+
525+#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
526+#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
527+#define UAC_EP_CS_ATTR_FILL_MAX 0x80
528+
529+/* status word format (3.7.1.1) */
530+
531+#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
532+#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
533+#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
534+#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
535+
536+#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
537+#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
538+
539+struct uac1_status_word {
540+ __u8 bStatusType;
541+ __u8 bOriginator;
542+} __attribute__((packed));
543+
544+
545+#endif /* _UAPI__LINUX_USB_AUDIO_H */
include/uapi/linux/usb/cdc.h+412−0
@@ -0,0 +1,412 @@
1+/*
2+ * USB Communications Device Class (CDC) definitions
3+ *
4+ * CDC says how to talk to lots of different types of network adapters,
5+ * notably ethernet adapters and various modems. It's used mostly with
6+ * firmware based USB peripherals.
7+ */
8+
9+#ifndef __LINUX_USB_CDC_H
10+#define __LINUX_USB_CDC_H
11+
12+#include <linux/types.h>
13+
14+#define USB_CDC_SUBCLASS_ACM 0x02
15+#define USB_CDC_SUBCLASS_ETHERNET 0x06
16+#define USB_CDC_SUBCLASS_WHCM 0x08
17+#define USB_CDC_SUBCLASS_DMM 0x09
18+#define USB_CDC_SUBCLASS_MDLM 0x0a
19+#define USB_CDC_SUBCLASS_OBEX 0x0b
20+#define USB_CDC_SUBCLASS_EEM 0x0c
21+#define USB_CDC_SUBCLASS_NCM 0x0d
22+
23+#define USB_CDC_PROTO_NONE 0
24+
25+#define USB_CDC_ACM_PROTO_AT_V25TER 1
26+#define USB_CDC_ACM_PROTO_AT_PCCA101 2
27+#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
28+#define USB_CDC_ACM_PROTO_AT_GSM 4
29+#define USB_CDC_ACM_PROTO_AT_3G 5
30+#define USB_CDC_ACM_PROTO_AT_CDMA 6
31+#define USB_CDC_ACM_PROTO_VENDOR 0xff
32+
33+#define USB_CDC_PROTO_EEM 7
34+
35+#define USB_CDC_NCM_PROTO_NTB 1
36+
37+/*-------------------------------------------------------------------------*/
38+
39+/*
40+ * Class-Specific descriptors ... there are a couple dozen of them
41+ */
42+
43+#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
44+#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
45+#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
46+#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
47+#define USB_CDC_COUNTRY_TYPE 0x07
48+#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
49+#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
50+#define USB_CDC_WHCM_TYPE 0x11
51+#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
52+#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
53+#define USB_CDC_DMM_TYPE 0x14
54+#define USB_CDC_OBEX_TYPE 0x15
55+#define USB_CDC_NCM_TYPE 0x1a
56+
57+/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
58+struct usb_cdc_header_desc {
59+ __u8 bLength;
60+ __u8 bDescriptorType;
61+ __u8 bDescriptorSubType;
62+
63+ __le16 bcdCDC;
64+} __attribute__ ((packed));
65+
66+/* "Call Management Descriptor" from CDC spec 5.2.3.2 */
67+struct usb_cdc_call_mgmt_descriptor {
68+ __u8 bLength;
69+ __u8 bDescriptorType;
70+ __u8 bDescriptorSubType;
71+
72+ __u8 bmCapabilities;
73+#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
74+#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
75+
76+ __u8 bDataInterface;
77+} __attribute__ ((packed));
78+
79+/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
80+struct usb_cdc_acm_descriptor {
81+ __u8 bLength;
82+ __u8 bDescriptorType;
83+ __u8 bDescriptorSubType;
84+
85+ __u8 bmCapabilities;
86+} __attribute__ ((packed));
87+
88+/* capabilities from 5.2.3.3 */
89+
90+#define USB_CDC_COMM_FEATURE 0x01
91+#define USB_CDC_CAP_LINE 0x02
92+#define USB_CDC_CAP_BRK 0x04
93+#define USB_CDC_CAP_NOTIFY 0x08
94+
95+/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
96+struct usb_cdc_union_desc {
97+ __u8 bLength;
98+ __u8 bDescriptorType;
99+ __u8 bDescriptorSubType;
100+
101+ __u8 bMasterInterface0;
102+ __u8 bSlaveInterface0;
103+ /* ... and there could be other slave interfaces */
104+} __attribute__ ((packed));
105+
106+/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
107+struct usb_cdc_country_functional_desc {
108+ __u8 bLength;
109+ __u8 bDescriptorType;
110+ __u8 bDescriptorSubType;
111+
112+ __u8 iCountryCodeRelDate;
113+ __le16 wCountyCode0;
114+ /* ... and there can be a lot of country codes */
115+} __attribute__ ((packed));
116+
117+/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
118+struct usb_cdc_network_terminal_desc {
119+ __u8 bLength;
120+ __u8 bDescriptorType;
121+ __u8 bDescriptorSubType;
122+
123+ __u8 bEntityId;
124+ __u8 iName;
125+ __u8 bChannelIndex;
126+ __u8 bPhysicalInterface;
127+} __attribute__ ((packed));
128+
129+/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
130+struct usb_cdc_ether_desc {
131+ __u8 bLength;
132+ __u8 bDescriptorType;
133+ __u8 bDescriptorSubType;
134+
135+ __u8 iMACAddress;
136+ __le32 bmEthernetStatistics;
137+ __le16 wMaxSegmentSize;
138+ __le16 wNumberMCFilters;
139+ __u8 bNumberPowerFilters;
140+} __attribute__ ((packed));
141+
142+/* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */
143+struct usb_cdc_dmm_desc {
144+ __u8 bFunctionLength;
145+ __u8 bDescriptorType;
146+ __u8 bDescriptorSubtype;
147+ __u16 bcdVersion;
148+ __le16 wMaxCommand;
149+} __attribute__ ((packed));
150+
151+/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
152+struct usb_cdc_mdlm_desc {
153+ __u8 bLength;
154+ __u8 bDescriptorType;
155+ __u8 bDescriptorSubType;
156+
157+ __le16 bcdVersion;
158+ __u8 bGUID[16];
159+} __attribute__ ((packed));
160+
161+/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
162+struct usb_cdc_mdlm_detail_desc {
163+ __u8 bLength;
164+ __u8 bDescriptorType;
165+ __u8 bDescriptorSubType;
166+
167+ /* type is associated with mdlm_desc.bGUID */
168+ __u8 bGuidDescriptorType;
169+ __u8 bDetailData[0];
170+} __attribute__ ((packed));
171+
172+/* "OBEX Control Model Functional Descriptor" */
173+struct usb_cdc_obex_desc {
174+ __u8 bLength;
175+ __u8 bDescriptorType;
176+ __u8 bDescriptorSubType;
177+
178+ __le16 bcdVersion;
179+} __attribute__ ((packed));
180+
181+/* "NCM Control Model Functional Descriptor" */
182+struct usb_cdc_ncm_desc {
183+ __u8 bLength;
184+ __u8 bDescriptorType;
185+ __u8 bDescriptorSubType;
186+
187+ __le16 bcdNcmVersion;
188+ __u8 bmNetworkCapabilities;
189+} __attribute__ ((packed));
190+/*-------------------------------------------------------------------------*/
191+
192+/*
193+ * Class-Specific Control Requests (6.2)
194+ *
195+ * section 3.6.2.1 table 4 has the ACM profile, for modems.
196+ * section 3.8.2 table 10 has the ethernet profile.
197+ *
198+ * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
199+ * heavily dependent on the encapsulated (proprietary) command mechanism.
200+ */
201+
202+#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
203+#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
204+#define USB_CDC_REQ_SET_LINE_CODING 0x20
205+#define USB_CDC_REQ_GET_LINE_CODING 0x21
206+#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
207+#define USB_CDC_REQ_SEND_BREAK 0x23
208+#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
209+#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
210+#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
211+#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
212+#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
213+#define USB_CDC_GET_NTB_PARAMETERS 0x80
214+#define USB_CDC_GET_NET_ADDRESS 0x81
215+#define USB_CDC_SET_NET_ADDRESS 0x82
216+#define USB_CDC_GET_NTB_FORMAT 0x83
217+#define USB_CDC_SET_NTB_FORMAT 0x84
218+#define USB_CDC_GET_NTB_INPUT_SIZE 0x85
219+#define USB_CDC_SET_NTB_INPUT_SIZE 0x86
220+#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87
221+#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88
222+#define USB_CDC_GET_CRC_MODE 0x89
223+#define USB_CDC_SET_CRC_MODE 0x8a
224+
225+/* Line Coding Structure from CDC spec 6.2.13 */
226+struct usb_cdc_line_coding {
227+ __le32 dwDTERate;
228+ __u8 bCharFormat;
229+#define USB_CDC_1_STOP_BITS 0
230+#define USB_CDC_1_5_STOP_BITS 1
231+#define USB_CDC_2_STOP_BITS 2
232+
233+ __u8 bParityType;
234+#define USB_CDC_NO_PARITY 0
235+#define USB_CDC_ODD_PARITY 1
236+#define USB_CDC_EVEN_PARITY 2
237+#define USB_CDC_MARK_PARITY 3
238+#define USB_CDC_SPACE_PARITY 4
239+
240+ __u8 bDataBits;
241+} __attribute__ ((packed));
242+
243+/* table 62; bits in multicast filter */
244+#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
245+#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
246+#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
247+#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
248+#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
249+
250+
251+/*-------------------------------------------------------------------------*/
252+
253+/*
254+ * Class-Specific Notifications (6.3) sent by interrupt transfers
255+ *
256+ * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
257+ * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
258+ * RNDIS also defines its own bit-incompatible notifications
259+ */
260+
261+#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
262+#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
263+#define USB_CDC_NOTIFY_SERIAL_STATE 0x20
264+#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
265+
266+struct usb_cdc_notification {
267+ __u8 bmRequestType;
268+ __u8 bNotificationType;
269+ __le16 wValue;
270+ __le16 wIndex;
271+ __le16 wLength;
272+} __attribute__ ((packed));
273+
274+struct usb_cdc_speed_change {
275+ __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */
276+ __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */
277+} __attribute__ ((packed));
278+
279+/*-------------------------------------------------------------------------*/
280+
281+/*
282+ * Class Specific structures and constants
283+ *
284+ * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
285+ *
286+ */
287+
288+struct usb_cdc_ncm_ntb_parameters {
289+ __le16 wLength;
290+ __le16 bmNtbFormatsSupported;
291+ __le32 dwNtbInMaxSize;
292+ __le16 wNdpInDivisor;
293+ __le16 wNdpInPayloadRemainder;
294+ __le16 wNdpInAlignment;
295+ __le16 wPadding1;
296+ __le32 dwNtbOutMaxSize;
297+ __le16 wNdpOutDivisor;
298+ __le16 wNdpOutPayloadRemainder;
299+ __le16 wNdpOutAlignment;
300+ __le16 wNtbOutMaxDatagrams;
301+} __attribute__ ((packed));
302+
303+/*
304+ * CDC NCM transfer headers, CDC NCM subclass 3.2
305+ */
306+
307+#define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */
308+#define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */
309+
310+struct usb_cdc_ncm_nth16 {
311+ __le32 dwSignature;
312+ __le16 wHeaderLength;
313+ __le16 wSequence;
314+ __le16 wBlockLength;
315+ __le16 wNdpIndex;
316+} __attribute__ ((packed));
317+
318+struct usb_cdc_ncm_nth32 {
319+ __le32 dwSignature;
320+ __le16 wHeaderLength;
321+ __le16 wSequence;
322+ __le32 dwBlockLength;
323+ __le32 dwNdpIndex;
324+} __attribute__ ((packed));
325+
326+/*
327+ * CDC NCM datagram pointers, CDC NCM subclass 3.3
328+ */
329+
330+#define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
331+#define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
332+#define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
333+#define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
334+
335+/* 16-bit NCM Datagram Pointer Entry */
336+struct usb_cdc_ncm_dpe16 {
337+ __le16 wDatagramIndex;
338+ __le16 wDatagramLength;
339+} __attribute__((__packed__));
340+
341+/* 16-bit NCM Datagram Pointer Table */
342+struct usb_cdc_ncm_ndp16 {
343+ __le32 dwSignature;
344+ __le16 wLength;
345+ __le16 wNextNdpIndex;
346+ struct usb_cdc_ncm_dpe16 dpe16[0];
347+} __attribute__ ((packed));
348+
349+/* 32-bit NCM Datagram Pointer Entry */
350+struct usb_cdc_ncm_dpe32 {
351+ __le32 dwDatagramIndex;
352+ __le32 dwDatagramLength;
353+} __attribute__((__packed__));
354+
355+/* 32-bit NCM Datagram Pointer Table */
356+struct usb_cdc_ncm_ndp32 {
357+ __le32 dwSignature;
358+ __le16 wLength;
359+ __le16 wReserved6;
360+ __le32 dwNextNdpIndex;
361+ __le32 dwReserved12;
362+ struct usb_cdc_ncm_dpe32 dpe32[0];
363+} __attribute__ ((packed));
364+
365+/* CDC NCM subclass 3.2.1 and 3.2.2 */
366+#define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C
367+#define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010
368+
369+/* CDC NCM subclass 3.3.3 Datagram Formatting */
370+#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30
371+#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31
372+
373+/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
374+#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00
375+#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE
376+
377+/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
378+#define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0)
379+#define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1)
380+#define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2)
381+#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3)
382+#define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4)
383+#define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE (1 << 5)
384+
385+/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
386+#define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0)
387+#define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1)
388+
389+/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
390+#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04
391+#define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C
392+
393+/* CDC NCM subclass 6.2.5 SetNtbFormat */
394+#define USB_CDC_NCM_NTB16_FORMAT 0x00
395+#define USB_CDC_NCM_NTB32_FORMAT 0x01
396+
397+/* CDC NCM subclass 6.2.7 SetNtbInputSize */
398+#define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048
399+#define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048
400+
401+/* NTB Input Size Structure */
402+struct usb_cdc_ncm_ndp_input_size {
403+ __le32 dwNtbInMaxSize;
404+ __le16 wNtbInMaxDatagrams;
405+ __le16 wReserved;
406+} __attribute__ ((packed));
407+
408+/* CDC NCM subclass 6.2.11 SetCrcMode */
409+#define USB_CDC_NCM_CRC_NOT_APPENDED 0x00
410+#define USB_CDC_NCM_CRC_APPENDED 0x01
411+
412+#endif /* __LINUX_USB_CDC_H */
include/uapi/linux/usb/ch11.h+266−0
@@ -0,0 +1,266 @@
1+/*
2+ * This file holds Hub protocol constants and data structures that are
3+ * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
4+ *
5+ * It is used/shared between the USB core, the HCDs and couple of other USB
6+ * drivers.
7+ */
8+
9+#ifndef __LINUX_CH11_H
10+#define __LINUX_CH11_H
11+
12+#include <linux/types.h> /* __u8 etc */
13+
14+/*
15+ * Hub request types
16+ */
17+
18+#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
19+#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
20+
21+/*
22+ * Hub class requests
23+ * See USB 2.0 spec Table 11-16
24+ */
25+#define HUB_CLEAR_TT_BUFFER 8
26+#define HUB_RESET_TT 9
27+#define HUB_GET_TT_STATE 10
28+#define HUB_STOP_TT 11
29+
30+/*
31+ * Hub class additional requests defined by USB 3.0 spec
32+ * See USB 3.0 spec Table 10-6
33+ */
34+#define HUB_SET_DEPTH 12
35+#define HUB_GET_PORT_ERR_COUNT 13
36+
37+/*
38+ * Hub Class feature numbers
39+ * See USB 2.0 spec Table 11-17
40+ */
41+#define C_HUB_LOCAL_POWER 0
42+#define C_HUB_OVER_CURRENT 1
43+
44+/*
45+ * Port feature numbers
46+ * See USB 2.0 spec Table 11-17
47+ */
48+#define USB_PORT_FEAT_CONNECTION 0
49+#define USB_PORT_FEAT_ENABLE 1
50+#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
51+#define USB_PORT_FEAT_OVER_CURRENT 3
52+#define USB_PORT_FEAT_RESET 4
53+#define USB_PORT_FEAT_L1 5 /* L1 suspend */
54+#define USB_PORT_FEAT_POWER 8
55+#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
56+#define USB_PORT_FEAT_C_CONNECTION 16
57+#define USB_PORT_FEAT_C_ENABLE 17
58+#define USB_PORT_FEAT_C_SUSPEND 18
59+#define USB_PORT_FEAT_C_OVER_CURRENT 19
60+#define USB_PORT_FEAT_C_RESET 20
61+#define USB_PORT_FEAT_TEST 21
62+#define USB_PORT_FEAT_INDICATOR 22
63+#define USB_PORT_FEAT_C_PORT_L1 23
64+
65+/*
66+ * Port feature selectors added by USB 3.0 spec.
67+ * See USB 3.0 spec Table 10-7
68+ */
69+#define USB_PORT_FEAT_LINK_STATE 5
70+#define USB_PORT_FEAT_U1_TIMEOUT 23
71+#define USB_PORT_FEAT_U2_TIMEOUT 24
72+#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
73+#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
74+#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
75+#define USB_PORT_FEAT_BH_PORT_RESET 28
76+#define USB_PORT_FEAT_C_BH_PORT_RESET 29
77+#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
78+
79+#define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8)
80+
81+/* USB 3.0 hub remote wake mask bits, see table 10-14 */
82+#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8)
83+#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9)
84+#define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10)
85+
86+/*
87+ * Hub Status and Hub Change results
88+ * See USB 2.0 spec Table 11-19 and Table 11-20
89+ */
90+struct usb_port_status {
91+ __le16 wPortStatus;
92+ __le16 wPortChange;
93+} __attribute__ ((packed));
94+
95+/*
96+ * wPortStatus bit field
97+ * See USB 2.0 spec Table 11-21
98+ */
99+#define USB_PORT_STAT_CONNECTION 0x0001
100+#define USB_PORT_STAT_ENABLE 0x0002
101+#define USB_PORT_STAT_SUSPEND 0x0004
102+#define USB_PORT_STAT_OVERCURRENT 0x0008
103+#define USB_PORT_STAT_RESET 0x0010
104+#define USB_PORT_STAT_L1 0x0020
105+/* bits 6 to 7 are reserved */
106+#define USB_PORT_STAT_POWER 0x0100
107+#define USB_PORT_STAT_LOW_SPEED 0x0200
108+#define USB_PORT_STAT_HIGH_SPEED 0x0400
109+#define USB_PORT_STAT_TEST 0x0800
110+#define USB_PORT_STAT_INDICATOR 0x1000
111+/* bits 13 to 15 are reserved */
112+
113+/*
114+ * Additions to wPortStatus bit field from USB 3.0
115+ * See USB 3.0 spec Table 10-10
116+ */
117+#define USB_PORT_STAT_LINK_STATE 0x01e0
118+#define USB_SS_PORT_STAT_POWER 0x0200
119+#define USB_SS_PORT_STAT_SPEED 0x1c00
120+#define USB_PORT_STAT_SPEED_5GBPS 0x0000
121+/* Valid only if port is enabled */
122+/* Bits that are the same from USB 2.0 */
123+#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
124+ USB_PORT_STAT_ENABLE | \
125+ USB_PORT_STAT_OVERCURRENT | \
126+ USB_PORT_STAT_RESET)
127+
128+/*
129+ * Definitions for PORT_LINK_STATE values
130+ * (bits 5-8) in wPortStatus
131+ */
132+#define USB_SS_PORT_LS_U0 0x0000
133+#define USB_SS_PORT_LS_U1 0x0020
134+#define USB_SS_PORT_LS_U2 0x0040
135+#define USB_SS_PORT_LS_U3 0x0060
136+#define USB_SS_PORT_LS_SS_DISABLED 0x0080
137+#define USB_SS_PORT_LS_RX_DETECT 0x00a0
138+#define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
139+#define USB_SS_PORT_LS_POLLING 0x00e0
140+#define USB_SS_PORT_LS_RECOVERY 0x0100
141+#define USB_SS_PORT_LS_HOT_RESET 0x0120
142+#define USB_SS_PORT_LS_COMP_MOD 0x0140
143+#define USB_SS_PORT_LS_LOOPBACK 0x0160
144+
145+/*
146+ * wPortChange bit field
147+ * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
148+ * Bits 0 to 5 shown, bits 6 to 15 are reserved
149+ */
150+#define USB_PORT_STAT_C_CONNECTION 0x0001
151+#define USB_PORT_STAT_C_ENABLE 0x0002
152+#define USB_PORT_STAT_C_SUSPEND 0x0004
153+#define USB_PORT_STAT_C_OVERCURRENT 0x0008
154+#define USB_PORT_STAT_C_RESET 0x0010
155+#define USB_PORT_STAT_C_L1 0x0020
156+/*
157+ * USB 3.0 wPortChange bit fields
158+ * See USB 3.0 spec Table 10-11
159+ */
160+#define USB_PORT_STAT_C_BH_RESET 0x0020
161+#define USB_PORT_STAT_C_LINK_STATE 0x0040
162+#define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
163+
164+/*
165+ * wHubCharacteristics (masks)
166+ * See USB 2.0 spec Table 11-13, offset 3
167+ */
168+#define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */
169+#define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */
170+#define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */
171+#define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */
172+
173+#define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */
174+
175+#define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */
176+#define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */
177+#define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */
178+#define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */
179+
180+#define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */
181+#define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */
182+
183+struct usb_hub_status {
184+ __le16 wHubStatus;
185+ __le16 wHubChange;
186+} __attribute__ ((packed));
187+
188+/*
189+ * Hub Status & Hub Change bit masks
190+ * See USB 2.0 spec Table 11-19 and Table 11-20
191+ * Bits 0 and 1 for wHubStatus and wHubChange
192+ * Bits 2 to 15 are reserved for both
193+ */
194+#define HUB_STATUS_LOCAL_POWER 0x0001
195+#define HUB_STATUS_OVERCURRENT 0x0002
196+#define HUB_CHANGE_LOCAL_POWER 0x0001
197+#define HUB_CHANGE_OVERCURRENT 0x0002
198+
199+
200+/*
201+ * Hub descriptor
202+ * See USB 2.0 spec Table 11-13
203+ */
204+
205+#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
206+#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
207+#define USB_DT_HUB_NONVAR_SIZE 7
208+#define USB_DT_SS_HUB_SIZE 12
209+
210+/*
211+ * Hub Device descriptor
212+ * USB Hub class device protocols
213+ */
214+
215+#define USB_HUB_PR_FS 0 /* Full speed hub */
216+#define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */
217+#define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */
218+#define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */
219+#define USB_HUB_PR_SS 3 /* Super speed hub */
220+
221+struct usb_hub_descriptor {
222+ __u8 bDescLength;
223+ __u8 bDescriptorType;
224+ __u8 bNbrPorts;
225+ __le16 wHubCharacteristics;
226+ __u8 bPwrOn2PwrGood;
227+ __u8 bHubContrCurrent;
228+
229+ /* 2.0 and 3.0 hubs differ here */
230+ union {
231+ struct {
232+ /* add 1 bit for hub status change; round to bytes */
233+ __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
234+ __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
235+ } __attribute__ ((packed)) hs;
236+
237+ struct {
238+ __u8 bHubHdrDecLat;
239+ __le16 wHubDelay;
240+ __le16 DeviceRemovable;
241+ } __attribute__ ((packed)) ss;
242+ } u;
243+} __attribute__ ((packed));
244+
245+/* port indicator status selectors, tables 11-7 and 11-25 */
246+#define HUB_LED_AUTO 0
247+#define HUB_LED_AMBER 1
248+#define HUB_LED_GREEN 2
249+#define HUB_LED_OFF 3
250+
251+enum hub_led_mode {
252+ INDICATOR_AUTO = 0,
253+ INDICATOR_CYCLE,
254+ /* software blinks for attention: software, hardware, reserved */
255+ INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
256+ INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
257+ INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
258+} __attribute__ ((packed));
259+
260+/* Transaction Translator Think Times, in bits */
261+#define HUB_TTTT_8_BITS 0x00
262+#define HUB_TTTT_16_BITS 0x20
263+#define HUB_TTTT_24_BITS 0x40
264+#define HUB_TTTT_32_BITS 0x60
265+
266+#endif /* __LINUX_CH11_H */
include/uapi/linux/usb/ch9.h+993−0
@@ -0,0 +1,993 @@
1+/*
2+ * This file holds USB constants and structures that are needed for
3+ * USB device APIs. These are used by the USB device model, which is
4+ * defined in chapter 9 of the USB 2.0 specification and in the
5+ * Wireless USB 1.0 (spread around). Linux has several APIs in C that
6+ * need these:
7+ *
8+ * - the master/host side Linux-USB kernel driver API;
9+ * - the "usbfs" user space API; and
10+ * - the Linux "gadget" slave/device/peripheral side driver API.
11+ *
12+ * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
13+ * act either as a USB master/host or as a USB slave/device. That means
14+ * the master and slave side APIs benefit from working well together.
15+ *
16+ * There's also "Wireless USB", using low power short range radios for
17+ * peripheral interconnection but otherwise building on the USB framework.
18+ *
19+ * Note all descriptors are declared '__attribute__((packed))' so that:
20+ *
21+ * [a] they never get padded, either internally (USB spec writers
22+ * probably handled that) or externally;
23+ *
24+ * [b] so that accessing bigger-than-a-bytes fields will never
25+ * generate bus errors on any platform, even when the location of
26+ * its descriptor inside a bundle isn't "naturally aligned", and
27+ *
28+ * [c] for consistency, removing all doubt even when it appears to
29+ * someone that the two other points are non-issues for that
30+ * particular descriptor type.
31+ */
32+
33+#ifndef _UAPI__LINUX_USB_CH9_H
34+#define _UAPI__LINUX_USB_CH9_H
35+
36+#include <linux/types.h> /* __u8 etc */
37+#include <asm/byteorder.h> /* le16_to_cpu */
38+
39+/*-------------------------------------------------------------------------*/
40+
41+/* CONTROL REQUEST SUPPORT */
42+
43+/*
44+ * USB directions
45+ *
46+ * This bit flag is used in endpoint descriptors' bEndpointAddress field.
47+ * It's also one of three fields in control requests bRequestType.
48+ */
49+#define USB_DIR_OUT 0 /* to device */
50+#define USB_DIR_IN 0x80 /* to host */
51+
52+/*
53+ * USB types, the second of three bRequestType fields
54+ */
55+#define USB_TYPE_MASK (0x03 << 5)
56+#define USB_TYPE_STANDARD (0x00 << 5)
57+#define USB_TYPE_CLASS (0x01 << 5)
58+#define USB_TYPE_VENDOR (0x02 << 5)
59+#define USB_TYPE_RESERVED (0x03 << 5)
60+
61+/*
62+ * USB recipients, the third of three bRequestType fields
63+ */
64+#define USB_RECIP_MASK 0x1f
65+#define USB_RECIP_DEVICE 0x00
66+#define USB_RECIP_INTERFACE 0x01
67+#define USB_RECIP_ENDPOINT 0x02
68+#define USB_RECIP_OTHER 0x03
69+/* From Wireless USB 1.0 */
70+#define USB_RECIP_PORT 0x04
71+#define USB_RECIP_RPIPE 0x05
72+
73+/*
74+ * Standard requests, for the bRequest field of a SETUP packet.
75+ *
76+ * These are qualified by the bRequestType field, so that for example
77+ * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
78+ * by a GET_STATUS request.
79+ */
80+#define USB_REQ_GET_STATUS 0x00
81+#define USB_REQ_CLEAR_FEATURE 0x01
82+#define USB_REQ_SET_FEATURE 0x03
83+#define USB_REQ_SET_ADDRESS 0x05
84+#define USB_REQ_GET_DESCRIPTOR 0x06
85+#define USB_REQ_SET_DESCRIPTOR 0x07
86+#define USB_REQ_GET_CONFIGURATION 0x08
87+#define USB_REQ_SET_CONFIGURATION 0x09
88+#define USB_REQ_GET_INTERFACE 0x0A
89+#define USB_REQ_SET_INTERFACE 0x0B
90+#define USB_REQ_SYNCH_FRAME 0x0C
91+#define USB_REQ_SET_SEL 0x30
92+#define USB_REQ_SET_ISOCH_DELAY 0x31
93+
94+#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
95+#define USB_REQ_GET_ENCRYPTION 0x0E
96+#define USB_REQ_RPIPE_ABORT 0x0E
97+#define USB_REQ_SET_HANDSHAKE 0x0F
98+#define USB_REQ_RPIPE_RESET 0x0F
99+#define USB_REQ_GET_HANDSHAKE 0x10
100+#define USB_REQ_SET_CONNECTION 0x11
101+#define USB_REQ_SET_SECURITY_DATA 0x12
102+#define USB_REQ_GET_SECURITY_DATA 0x13
103+#define USB_REQ_SET_WUSB_DATA 0x14
104+#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
105+#define USB_REQ_LOOPBACK_DATA_READ 0x16
106+#define USB_REQ_SET_INTERFACE_DS 0x17
107+
108+/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
109+ * used by hubs to put ports into a new L1 suspend state, except that it
110+ * forgot to define its number ...
111+ */
112+
113+/*
114+ * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
115+ * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
116+ * are at most sixteen features of each type.) Hubs may also support a
117+ * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
118+ */
119+#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
120+#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
121+#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
122+#define USB_DEVICE_BATTERY 2 /* (wireless) */
123+#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
124+#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
125+#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
126+#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
127+#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
128+
129+/*
130+ * Test Mode Selectors
131+ * See USB 2.0 spec Table 9-7
132+ */
133+#define TEST_J 1
134+#define TEST_K 2
135+#define TEST_SE0_NAK 3
136+#define TEST_PACKET 4
137+#define TEST_FORCE_EN 5
138+
139+/*
140+ * New Feature Selectors as added by USB 3.0
141+ * See USB 3.0 spec Table 9-6
142+ */
143+#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
144+#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
145+#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
146+#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
147+
148+#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
149+/*
150+ * Suspend Options, Table 9-7 USB 3.0 spec
151+ */
152+#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
153+#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
154+
155+#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
156+
157+/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
158+#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
159+#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
160+#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
161+
162+/**
163+ * struct usb_ctrlrequest - SETUP data for a USB device control request
164+ * @bRequestType: matches the USB bmRequestType field
165+ * @bRequest: matches the USB bRequest field
166+ * @wValue: matches the USB wValue field (le16 byte order)
167+ * @wIndex: matches the USB wIndex field (le16 byte order)
168+ * @wLength: matches the USB wLength field (le16 byte order)
169+ *
170+ * This structure is used to send control requests to a USB device. It matches
171+ * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
172+ * USB spec for a fuller description of the different fields, and what they are
173+ * used for.
174+ *
175+ * Note that the driver for any interface can issue control requests.
176+ * For most devices, interfaces don't coordinate with each other, so
177+ * such requests may be made at any time.
178+ */
179+struct usb_ctrlrequest {
180+ __u8 bRequestType;
181+ __u8 bRequest;
182+ __le16 wValue;
183+ __le16 wIndex;
184+ __le16 wLength;
185+} __attribute__ ((packed));
186+
187+/*-------------------------------------------------------------------------*/
188+
189+/*
190+ * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
191+ * (rarely) accepted by SET_DESCRIPTOR.
192+ *
193+ * Note that all multi-byte values here are encoded in little endian
194+ * byte order "on the wire". Within the kernel and when exposed
195+ * through the Linux-USB APIs, they are not converted to cpu byte
196+ * order; it is the responsibility of the client code to do this.
197+ * The single exception is when device and configuration descriptors (but
198+ * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
199+ * in this case the fields are converted to host endianness by the kernel.
200+ */
201+
202+/*
203+ * Descriptor types ... USB 2.0 spec table 9.5
204+ */
205+#define USB_DT_DEVICE 0x01
206+#define USB_DT_CONFIG 0x02
207+#define USB_DT_STRING 0x03
208+#define USB_DT_INTERFACE 0x04
209+#define USB_DT_ENDPOINT 0x05
210+#define USB_DT_DEVICE_QUALIFIER 0x06
211+#define USB_DT_OTHER_SPEED_CONFIG 0x07
212+#define USB_DT_INTERFACE_POWER 0x08
213+/* these are from a minor usb 2.0 revision (ECN) */
214+#define USB_DT_OTG 0x09
215+#define USB_DT_DEBUG 0x0a
216+#define USB_DT_INTERFACE_ASSOCIATION 0x0b
217+/* these are from the Wireless USB spec */
218+#define USB_DT_SECURITY 0x0c
219+#define USB_DT_KEY 0x0d
220+#define USB_DT_ENCRYPTION_TYPE 0x0e
221+#define USB_DT_BOS 0x0f
222+#define USB_DT_DEVICE_CAPABILITY 0x10
223+#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
224+#define USB_DT_WIRE_ADAPTER 0x21
225+#define USB_DT_RPIPE 0x22
226+#define USB_DT_CS_RADIO_CONTROL 0x23
227+/* From the T10 UAS specification */
228+#define USB_DT_PIPE_USAGE 0x24
229+/* From the USB 3.0 spec */
230+#define USB_DT_SS_ENDPOINT_COMP 0x30
231+
232+/* Conventional codes for class-specific descriptors. The convention is
233+ * defined in the USB "Common Class" Spec (3.11). Individual class specs
234+ * are authoritative for their usage, not the "common class" writeup.
235+ */
236+#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
237+#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
238+#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
239+#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
240+#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
241+
242+/* All standard descriptors have these 2 fields at the beginning */
243+struct usb_descriptor_header {
244+ __u8 bLength;
245+ __u8 bDescriptorType;
246+} __attribute__ ((packed));
247+
248+
249+/*-------------------------------------------------------------------------*/
250+
251+/* USB_DT_DEVICE: Device descriptor */
252+struct usb_device_descriptor {
253+ __u8 bLength;
254+ __u8 bDescriptorType;
255+
256+ __le16 bcdUSB;
257+ __u8 bDeviceClass;
258+ __u8 bDeviceSubClass;
259+ __u8 bDeviceProtocol;
260+ __u8 bMaxPacketSize0;
261+ __le16 idVendor;
262+ __le16 idProduct;
263+ __le16 bcdDevice;
264+ __u8 iManufacturer;
265+ __u8 iProduct;
266+ __u8 iSerialNumber;
267+ __u8 bNumConfigurations;
268+} __attribute__ ((packed));
269+
270+#define USB_DT_DEVICE_SIZE 18
271+
272+
273+/*
274+ * Device and/or Interface Class codes
275+ * as found in bDeviceClass or bInterfaceClass
276+ * and defined by www.usb.org documents
277+ */
278+#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
279+#define USB_CLASS_AUDIO 1
280+#define USB_CLASS_COMM 2
281+#define USB_CLASS_HID 3
282+#define USB_CLASS_PHYSICAL 5
283+#define USB_CLASS_STILL_IMAGE 6
284+#define USB_CLASS_PRINTER 7
285+#define USB_CLASS_MASS_STORAGE 8
286+#define USB_CLASS_HUB 9
287+#define USB_CLASS_CDC_DATA 0x0a
288+#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
289+#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
290+#define USB_CLASS_VIDEO 0x0e
291+#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
292+#define USB_CLASS_MISC 0xef
293+#define USB_CLASS_APP_SPEC 0xfe
294+#define USB_CLASS_VENDOR_SPEC 0xff
295+
296+#define USB_SUBCLASS_VENDOR_SPEC 0xff
297+
298+/*-------------------------------------------------------------------------*/
299+
300+/* USB_DT_CONFIG: Configuration descriptor information.
301+ *
302+ * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
303+ * descriptor type is different. Highspeed-capable devices can look
304+ * different depending on what speed they're currently running. Only
305+ * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
306+ * descriptors.
307+ */
308+struct usb_config_descriptor {
309+ __u8 bLength;
310+ __u8 bDescriptorType;
311+
312+ __le16 wTotalLength;
313+ __u8 bNumInterfaces;
314+ __u8 bConfigurationValue;
315+ __u8 iConfiguration;
316+ __u8 bmAttributes;
317+ __u8 bMaxPower;
318+} __attribute__ ((packed));
319+
320+#define USB_DT_CONFIG_SIZE 9
321+
322+/* from config descriptor bmAttributes */
323+#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
324+#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
325+#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
326+#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
327+
328+/*-------------------------------------------------------------------------*/
329+
330+/* USB_DT_STRING: String descriptor */
331+struct usb_string_descriptor {
332+ __u8 bLength;
333+ __u8 bDescriptorType;
334+
335+ __le16 wData[1]; /* UTF-16LE encoded */
336+} __attribute__ ((packed));
337+
338+/* note that "string" zero is special, it holds language codes that
339+ * the device supports, not Unicode characters.
340+ */
341+
342+/*-------------------------------------------------------------------------*/
343+
344+/* USB_DT_INTERFACE: Interface descriptor */
345+struct usb_interface_descriptor {
346+ __u8 bLength;
347+ __u8 bDescriptorType;
348+
349+ __u8 bInterfaceNumber;
350+ __u8 bAlternateSetting;
351+ __u8 bNumEndpoints;
352+ __u8 bInterfaceClass;
353+ __u8 bInterfaceSubClass;
354+ __u8 bInterfaceProtocol;
355+ __u8 iInterface;
356+} __attribute__ ((packed));
357+
358+#define USB_DT_INTERFACE_SIZE 9
359+
360+/*-------------------------------------------------------------------------*/
361+
362+/* USB_DT_ENDPOINT: Endpoint descriptor */
363+struct usb_endpoint_descriptor {
364+ __u8 bLength;
365+ __u8 bDescriptorType;
366+
367+ __u8 bEndpointAddress;
368+ __u8 bmAttributes;
369+ __le16 wMaxPacketSize;
370+ __u8 bInterval;
371+
372+ /* NOTE: these two are _only_ in audio endpoints. */
373+ /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
374+ __u8 bRefresh;
375+ __u8 bSynchAddress;
376+} __attribute__ ((packed));
377+
378+#define USB_DT_ENDPOINT_SIZE 7
379+#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
380+
381+
382+/*
383+ * Endpoints
384+ */
385+#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
386+#define USB_ENDPOINT_DIR_MASK 0x80
387+
388+#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
389+#define USB_ENDPOINT_XFER_CONTROL 0
390+#define USB_ENDPOINT_XFER_ISOC 1
391+#define USB_ENDPOINT_XFER_BULK 2
392+#define USB_ENDPOINT_XFER_INT 3
393+#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
394+
395+/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
396+#define USB_ENDPOINT_INTRTYPE 0x30
397+#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
398+#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
399+
400+#define USB_ENDPOINT_SYNCTYPE 0x0c
401+#define USB_ENDPOINT_SYNC_NONE (0 << 2)
402+#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
403+#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
404+#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
405+
406+#define USB_ENDPOINT_USAGE_MASK 0x30
407+#define USB_ENDPOINT_USAGE_DATA 0x00
408+#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
409+#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
410+
411+/*-------------------------------------------------------------------------*/
412+
413+/**
414+ * usb_endpoint_num - get the endpoint's number
415+ * @epd: endpoint to be checked
416+ *
417+ * Returns @epd's number: 0 to 15.
418+ */
419+static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
420+{
421+ return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
422+}
423+
424+/**
425+ * usb_endpoint_type - get the endpoint's transfer type
426+ * @epd: endpoint to be checked
427+ *
428+ * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
429+ * to @epd's transfer type.
430+ */
431+static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
432+{
433+ return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
434+}
435+
436+/**
437+ * usb_endpoint_dir_in - check if the endpoint has IN direction
438+ * @epd: endpoint to be checked
439+ *
440+ * Returns true if the endpoint is of type IN, otherwise it returns false.
441+ */
442+static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
443+{
444+ return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
445+}
446+
447+/**
448+ * usb_endpoint_dir_out - check if the endpoint has OUT direction
449+ * @epd: endpoint to be checked
450+ *
451+ * Returns true if the endpoint is of type OUT, otherwise it returns false.
452+ */
453+static inline int usb_endpoint_dir_out(
454+ const struct usb_endpoint_descriptor *epd)
455+{
456+ return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
457+}
458+
459+/**
460+ * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
461+ * @epd: endpoint to be checked
462+ *
463+ * Returns true if the endpoint is of type bulk, otherwise it returns false.
464+ */
465+static inline int usb_endpoint_xfer_bulk(
466+ const struct usb_endpoint_descriptor *epd)
467+{
468+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
469+ USB_ENDPOINT_XFER_BULK);
470+}
471+
472+/**
473+ * usb_endpoint_xfer_control - check if the endpoint has control transfer type
474+ * @epd: endpoint to be checked
475+ *
476+ * Returns true if the endpoint is of type control, otherwise it returns false.
477+ */
478+static inline int usb_endpoint_xfer_control(
479+ const struct usb_endpoint_descriptor *epd)
480+{
481+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
482+ USB_ENDPOINT_XFER_CONTROL);
483+}
484+
485+/**
486+ * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
487+ * @epd: endpoint to be checked
488+ *
489+ * Returns true if the endpoint is of type interrupt, otherwise it returns
490+ * false.
491+ */
492+static inline int usb_endpoint_xfer_int(
493+ const struct usb_endpoint_descriptor *epd)
494+{
495+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
496+ USB_ENDPOINT_XFER_INT);
497+}
498+
499+/**
500+ * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
501+ * @epd: endpoint to be checked
502+ *
503+ * Returns true if the endpoint is of type isochronous, otherwise it returns
504+ * false.
505+ */
506+static inline int usb_endpoint_xfer_isoc(
507+ const struct usb_endpoint_descriptor *epd)
508+{
509+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
510+ USB_ENDPOINT_XFER_ISOC);
511+}
512+
513+/**
514+ * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
515+ * @epd: endpoint to be checked
516+ *
517+ * Returns true if the endpoint has bulk transfer type and IN direction,
518+ * otherwise it returns false.
519+ */
520+static inline int usb_endpoint_is_bulk_in(
521+ const struct usb_endpoint_descriptor *epd)
522+{
523+ return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
524+}
525+
526+/**
527+ * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
528+ * @epd: endpoint to be checked
529+ *
530+ * Returns true if the endpoint has bulk transfer type and OUT direction,
531+ * otherwise it returns false.
532+ */
533+static inline int usb_endpoint_is_bulk_out(
534+ const struct usb_endpoint_descriptor *epd)
535+{
536+ return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
537+}
538+
539+/**
540+ * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
541+ * @epd: endpoint to be checked
542+ *
543+ * Returns true if the endpoint has interrupt transfer type and IN direction,
544+ * otherwise it returns false.
545+ */
546+static inline int usb_endpoint_is_int_in(
547+ const struct usb_endpoint_descriptor *epd)
548+{
549+ return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
550+}
551+
552+/**
553+ * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
554+ * @epd: endpoint to be checked
555+ *
556+ * Returns true if the endpoint has interrupt transfer type and OUT direction,
557+ * otherwise it returns false.
558+ */
559+static inline int usb_endpoint_is_int_out(
560+ const struct usb_endpoint_descriptor *epd)
561+{
562+ return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
563+}
564+
565+/**
566+ * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
567+ * @epd: endpoint to be checked
568+ *
569+ * Returns true if the endpoint has isochronous transfer type and IN direction,
570+ * otherwise it returns false.
571+ */
572+static inline int usb_endpoint_is_isoc_in(
573+ const struct usb_endpoint_descriptor *epd)
574+{
575+ return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
576+}
577+
578+/**
579+ * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
580+ * @epd: endpoint to be checked
581+ *
582+ * Returns true if the endpoint has isochronous transfer type and OUT direction,
583+ * otherwise it returns false.
584+ */
585+static inline int usb_endpoint_is_isoc_out(
586+ const struct usb_endpoint_descriptor *epd)
587+{
588+ return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
589+}
590+
591+/**
592+ * usb_endpoint_maxp - get endpoint's max packet size
593+ * @epd: endpoint to be checked
594+ *
595+ * Returns @epd's max packet
596+ */
597+static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
598+{
599+ return __le16_to_cpu(epd->wMaxPacketSize);
600+}
601+
602+static inline int usb_endpoint_interrupt_type(
603+ const struct usb_endpoint_descriptor *epd)
604+{
605+ return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
606+}
607+
608+/*-------------------------------------------------------------------------*/
609+
610+/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
611+struct usb_ss_ep_comp_descriptor {
612+ __u8 bLength;
613+ __u8 bDescriptorType;
614+
615+ __u8 bMaxBurst;
616+ __u8 bmAttributes;
617+ __le16 wBytesPerInterval;
618+} __attribute__ ((packed));
619+
620+#define USB_DT_SS_EP_COMP_SIZE 6
621+
622+/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
623+static inline int
624+usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
625+{
626+ int max_streams;
627+
628+ if (!comp)
629+ return 0;
630+
631+ max_streams = comp->bmAttributes & 0x1f;
632+
633+ if (!max_streams)
634+ return 0;
635+
636+ max_streams = 1 << max_streams;
637+
638+ return max_streams;
639+}
640+
641+/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
642+#define USB_SS_MULT(p) (1 + ((p) & 0x3))
643+
644+/*-------------------------------------------------------------------------*/
645+
646+/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
647+struct usb_qualifier_descriptor {
648+ __u8 bLength;
649+ __u8 bDescriptorType;
650+
651+ __le16 bcdUSB;
652+ __u8 bDeviceClass;
653+ __u8 bDeviceSubClass;
654+ __u8 bDeviceProtocol;
655+ __u8 bMaxPacketSize0;
656+ __u8 bNumConfigurations;
657+ __u8 bRESERVED;
658+} __attribute__ ((packed));
659+
660+
661+/*-------------------------------------------------------------------------*/
662+
663+/* USB_DT_OTG (from OTG 1.0a supplement) */
664+struct usb_otg_descriptor {
665+ __u8 bLength;
666+ __u8 bDescriptorType;
667+
668+ __u8 bmAttributes; /* support for HNP, SRP, etc */
669+} __attribute__ ((packed));
670+
671+/* from usb_otg_descriptor.bmAttributes */
672+#define USB_OTG_SRP (1 << 0)
673+#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
674+
675+/*-------------------------------------------------------------------------*/
676+
677+/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
678+struct usb_debug_descriptor {
679+ __u8 bLength;
680+ __u8 bDescriptorType;
681+
682+ /* bulk endpoints with 8 byte maxpacket */
683+ __u8 bDebugInEndpoint;
684+ __u8 bDebugOutEndpoint;
685+} __attribute__((packed));
686+
687+/*-------------------------------------------------------------------------*/
688+
689+/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
690+struct usb_interface_assoc_descriptor {
691+ __u8 bLength;
692+ __u8 bDescriptorType;
693+
694+ __u8 bFirstInterface;
695+ __u8 bInterfaceCount;
696+ __u8 bFunctionClass;
697+ __u8 bFunctionSubClass;
698+ __u8 bFunctionProtocol;
699+ __u8 iFunction;
700+} __attribute__ ((packed));
701+
702+
703+/*-------------------------------------------------------------------------*/
704+
705+/* USB_DT_SECURITY: group of wireless security descriptors, including
706+ * encryption types available for setting up a CC/association.
707+ */
708+struct usb_security_descriptor {
709+ __u8 bLength;
710+ __u8 bDescriptorType;
711+
712+ __le16 wTotalLength;
713+ __u8 bNumEncryptionTypes;
714+} __attribute__((packed));
715+
716+/*-------------------------------------------------------------------------*/
717+
718+/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
719+ * may be retrieved.
720+ */
721+struct usb_key_descriptor {
722+ __u8 bLength;
723+ __u8 bDescriptorType;
724+
725+ __u8 tTKID[3];
726+ __u8 bReserved;
727+ __u8 bKeyData[0];
728+} __attribute__((packed));
729+
730+/*-------------------------------------------------------------------------*/
731+
732+/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
733+struct usb_encryption_descriptor {
734+ __u8 bLength;
735+ __u8 bDescriptorType;
736+
737+ __u8 bEncryptionType;
738+#define USB_ENC_TYPE_UNSECURE 0
739+#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
740+#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
741+#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
742+ __u8 bEncryptionValue; /* use in SET_ENCRYPTION */
743+ __u8 bAuthKeyIndex;
744+} __attribute__((packed));
745+
746+
747+/*-------------------------------------------------------------------------*/
748+
749+/* USB_DT_BOS: group of device-level capabilities */
750+struct usb_bos_descriptor {
751+ __u8 bLength;
752+ __u8 bDescriptorType;
753+
754+ __le16 wTotalLength;
755+ __u8 bNumDeviceCaps;
756+} __attribute__((packed));
757+
758+#define USB_DT_BOS_SIZE 5
759+/*-------------------------------------------------------------------------*/
760+
761+/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
762+struct usb_dev_cap_header {
763+ __u8 bLength;
764+ __u8 bDescriptorType;
765+ __u8 bDevCapabilityType;
766+} __attribute__((packed));
767+
768+#define USB_CAP_TYPE_WIRELESS_USB 1
769+
770+struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
771+ __u8 bLength;
772+ __u8 bDescriptorType;
773+ __u8 bDevCapabilityType;
774+
775+ __u8 bmAttributes;
776+#define USB_WIRELESS_P2P_DRD (1 << 1)
777+#define USB_WIRELESS_BEACON_MASK (3 << 2)
778+#define USB_WIRELESS_BEACON_SELF (1 << 2)
779+#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
780+#define USB_WIRELESS_BEACON_NONE (3 << 2)
781+ __le16 wPHYRates; /* bit rates, Mbps */
782+#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
783+#define USB_WIRELESS_PHY_80 (1 << 1)
784+#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
785+#define USB_WIRELESS_PHY_160 (1 << 3)
786+#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
787+#define USB_WIRELESS_PHY_320 (1 << 5)
788+#define USB_WIRELESS_PHY_400 (1 << 6)
789+#define USB_WIRELESS_PHY_480 (1 << 7)
790+ __u8 bmTFITXPowerInfo; /* TFI power levels */
791+ __u8 bmFFITXPowerInfo; /* FFI power levels */
792+ __le16 bmBandGroup;
793+ __u8 bReserved;
794+} __attribute__((packed));
795+
796+/* USB 2.0 Extension descriptor */
797+#define USB_CAP_TYPE_EXT 2
798+
799+struct usb_ext_cap_descriptor { /* Link Power Management */
800+ __u8 bLength;
801+ __u8 bDescriptorType;
802+ __u8 bDevCapabilityType;
803+ __le32 bmAttributes;
804+#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
805+#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
806+#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
807+#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
808+#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
809+#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
810+} __attribute__((packed));
811+
812+#define USB_DT_USB_EXT_CAP_SIZE 7
813+
814+/*
815+ * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
816+ * specific device level capabilities
817+ */
818+#define USB_SS_CAP_TYPE 3
819+struct usb_ss_cap_descriptor { /* Link Power Management */
820+ __u8 bLength;
821+ __u8 bDescriptorType;
822+ __u8 bDevCapabilityType;
823+ __u8 bmAttributes;
824+#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
825+ __le16 wSpeedSupported;
826+#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
827+#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
828+#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
829+#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
830+ __u8 bFunctionalitySupport;
831+ __u8 bU1devExitLat;
832+ __le16 bU2DevExitLat;
833+} __attribute__((packed));
834+
835+#define USB_DT_USB_SS_CAP_SIZE 10
836+
837+/*
838+ * Container ID Capability descriptor: Defines the instance unique ID used to
839+ * identify the instance across all operating modes
840+ */
841+#define CONTAINER_ID_TYPE 4
842+struct usb_ss_container_id_descriptor {
843+ __u8 bLength;
844+ __u8 bDescriptorType;
845+ __u8 bDevCapabilityType;
846+ __u8 bReserved;
847+ __u8 ContainerID[16]; /* 128-bit number */
848+} __attribute__((packed));
849+
850+#define USB_DT_USB_SS_CONTN_ID_SIZE 20
851+/*-------------------------------------------------------------------------*/
852+
853+/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
854+ * each endpoint descriptor for a wireless device
855+ */
856+struct usb_wireless_ep_comp_descriptor {
857+ __u8 bLength;
858+ __u8 bDescriptorType;
859+
860+ __u8 bMaxBurst;
861+ __u8 bMaxSequence;
862+ __le16 wMaxStreamDelay;
863+ __le16 wOverTheAirPacketSize;
864+ __u8 bOverTheAirInterval;
865+ __u8 bmCompAttributes;
866+#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
867+#define USB_ENDPOINT_SWITCH_NO 0
868+#define USB_ENDPOINT_SWITCH_SWITCH 1
869+#define USB_ENDPOINT_SWITCH_SCALE 2
870+} __attribute__((packed));
871+
872+/*-------------------------------------------------------------------------*/
873+
874+/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
875+ * host and a device for connection set up, mutual authentication, and
876+ * exchanging short lived session keys. The handshake depends on a CC.
877+ */
878+struct usb_handshake {
879+ __u8 bMessageNumber;
880+ __u8 bStatus;
881+ __u8 tTKID[3];
882+ __u8 bReserved;
883+ __u8 CDID[16];
884+ __u8 nonce[16];
885+ __u8 MIC[8];
886+} __attribute__((packed));
887+
888+/*-------------------------------------------------------------------------*/
889+
890+/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
891+ * A CC may also be set up using non-wireless secure channels (including
892+ * wired USB!), and some devices may support CCs with multiple hosts.
893+ */
894+struct usb_connection_context {
895+ __u8 CHID[16]; /* persistent host id */
896+ __u8 CDID[16]; /* device id (unique w/in host context) */
897+ __u8 CK[16]; /* connection key */
898+} __attribute__((packed));
899+
900+/*-------------------------------------------------------------------------*/
901+
902+/* USB 2.0 defines three speeds, here's how Linux identifies them */
903+
904+enum usb_device_speed {
905+ USB_SPEED_UNKNOWN = 0, /* enumerating */
906+ USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
907+ USB_SPEED_HIGH, /* usb 2.0 */
908+ USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
909+ USB_SPEED_SUPER, /* usb 3.0 */
910+};
911+
912+
913+enum usb_device_state {
914+ /* NOTATTACHED isn't in the USB spec, and this state acts
915+ * the same as ATTACHED ... but it's clearer this way.
916+ */
917+ USB_STATE_NOTATTACHED = 0,
918+
919+ /* chapter 9 and authentication (wireless) device states */
920+ USB_STATE_ATTACHED,
921+ USB_STATE_POWERED, /* wired */
922+ USB_STATE_RECONNECTING, /* auth */
923+ USB_STATE_UNAUTHENTICATED, /* auth */
924+ USB_STATE_DEFAULT, /* limited function */
925+ USB_STATE_ADDRESS,
926+ USB_STATE_CONFIGURED, /* most functions */
927+
928+ USB_STATE_SUSPENDED
929+
930+ /* NOTE: there are actually four different SUSPENDED
931+ * states, returning to POWERED, DEFAULT, ADDRESS, or
932+ * CONFIGURED respectively when SOF tokens flow again.
933+ * At this level there's no difference between L1 and L2
934+ * suspend states. (L2 being original USB 1.1 suspend.)
935+ */
936+};
937+
938+enum usb3_link_state {
939+ USB3_LPM_U0 = 0,
940+ USB3_LPM_U1,
941+ USB3_LPM_U2,
942+ USB3_LPM_U3
943+};
944+
945+/*
946+ * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
947+ * 0xff means the parent hub will accept transitions to U1, but will not
948+ * initiate a transition.
949+ *
950+ * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
951+ * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
952+ * values.
953+ *
954+ * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
955+ * 0xff means the parent hub will accept transitions to U2, but will not
956+ * initiate a transition.
957+ *
958+ * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
959+ * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
960+ * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
961+ * 65.024ms.
962+ */
963+#define USB3_LPM_DISABLED 0x0
964+#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
965+#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
966+#define USB3_LPM_DEVICE_INITIATED 0xFF
967+
968+struct usb_set_sel_req {
969+ __u8 u1_sel;
970+ __u8 u1_pel;
971+ __le16 u2_sel;
972+ __le16 u2_pel;
973+} __attribute__ ((packed));
974+
975+/*
976+ * The Set System Exit Latency control transfer provides one byte each for
977+ * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
978+ * are two bytes long.
979+ */
980+#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
981+#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
982+
983+/*-------------------------------------------------------------------------*/
984+
985+/*
986+ * As per USB compliance update, a device that is actively drawing
987+ * more than 100mA from USB must report itself as bus-powered in
988+ * the GetStatus(DEVICE) call.
989+ * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
990+ */
991+#define USB_SELF_POWER_VBUS_MAX_DRAW 100
992+
993+#endif /* _UAPI__LINUX_USB_CH9_H */
include/uapi/linux/usb/functionfs.h+169−0
@@ -0,0 +1,169 @@
1+#ifndef _UAPI__LINUX_FUNCTIONFS_H__
2+#define _UAPI__LINUX_FUNCTIONFS_H__
3+
4+
5+#include <linux/types.h>
6+#include <linux/ioctl.h>
7+
8+#include <linux/usb/ch9.h>
9+
10+
11+enum {
12+ FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13+ FUNCTIONFS_STRINGS_MAGIC = 2
14+};
15+
16+
17+#ifndef __KERNEL__
18+
19+/* Descriptor of an non-audio endpoint */
20+struct usb_endpoint_descriptor_no_audio {
21+ __u8 bLength;
22+ __u8 bDescriptorType;
23+
24+ __u8 bEndpointAddress;
25+ __u8 bmAttributes;
26+ __le16 wMaxPacketSize;
27+ __u8 bInterval;
28+} __attribute__((packed));
29+
30+
31+/*
32+ * All numbers must be in little endian order.
33+ */
34+
35+struct usb_functionfs_descs_head {
36+ __le32 magic;
37+ __le32 length;
38+ __le32 fs_count;
39+ __le32 hs_count;
40+} __attribute__((packed));
41+
42+/*
43+ * Descriptors format:
44+ *
45+ * | off | name | type | description |
46+ * |-----+-----------+--------------+--------------------------------------|
47+ * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48+ * | 4 | length | LE32 | length of the whole data chunk |
49+ * | 8 | fs_count | LE32 | number of full-speed descriptors |
50+ * | 12 | hs_count | LE32 | number of high-speed descriptors |
51+ * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
52+ * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
53+ *
54+ * descs are just valid USB descriptors and have the following format:
55+ *
56+ * | off | name | type | description |
57+ * |-----+-----------------+------+--------------------------|
58+ * | 0 | bLength | U8 | length of the descriptor |
59+ * | 1 | bDescriptorType | U8 | descriptor type |
60+ * | 2 | payload | | descriptor's payload |
61+ */
62+
63+struct usb_functionfs_strings_head {
64+ __le32 magic;
65+ __le32 length;
66+ __le32 str_count;
67+ __le32 lang_count;
68+} __attribute__((packed));
69+
70+/*
71+ * Strings format:
72+ *
73+ * | off | name | type | description |
74+ * |-----+------------+-----------------------+----------------------------|
75+ * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
76+ * | 4 | length | LE32 | length of the data chunk |
77+ * | 8 | str_count | LE32 | number of strings |
78+ * | 12 | lang_count | LE32 | number of languages |
79+ * | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
80+ *
81+ * For each language there is one stringtab entry (ie. there are lang_count
82+ * stringtab entires). Each StringTab has following format:
83+ *
84+ * | off | name | type | description |
85+ * |-----+---------+-------------------+------------------------------------|
86+ * | 0 | lang | LE16 | language code |
87+ * | 2 | strings | String[str_count] | array of strings in given language |
88+ *
89+ * For each string there is one strings entry (ie. there are str_count
90+ * string entries). Each String is a NUL terminated string encoded in
91+ * UTF-8.
92+ */
93+
94+#endif
95+
96+
97+/*
98+ * Events are delivered on the ep0 file descriptor, when the user mode driver
99+ * reads from this file descriptor after writing the descriptors. Don't
100+ * stop polling this descriptor.
101+ */
102+
103+enum usb_functionfs_event_type {
104+ FUNCTIONFS_BIND,
105+ FUNCTIONFS_UNBIND,
106+
107+ FUNCTIONFS_ENABLE,
108+ FUNCTIONFS_DISABLE,
109+
110+ FUNCTIONFS_SETUP,
111+
112+ FUNCTIONFS_SUSPEND,
113+ FUNCTIONFS_RESUME
114+};
115+
116+/* NOTE: this structure must stay the same size and layout on
117+ * both 32-bit and 64-bit kernels.
118+ */
119+struct usb_functionfs_event {
120+ union {
121+ /* SETUP: packet; DATA phase i/o precedes next event
122+ *(setup.bmRequestType & USB_DIR_IN) flags direction */
123+ struct usb_ctrlrequest setup;
124+ } __attribute__((packed)) u;
125+
126+ /* enum usb_functionfs_event_type */
127+ __u8 type;
128+ __u8 _pad[3];
129+} __attribute__((packed));
130+
131+
132+/* Endpoint ioctls */
133+/* The same as in gadgetfs */
134+
135+/* IN transfers may be reported to the gadget driver as complete
136+ * when the fifo is loaded, before the host reads the data;
137+ * OUT transfers may be reported to the host's "client" driver as
138+ * complete when they're sitting in the FIFO unread.
139+ * THIS returns how many bytes are "unclaimed" in the endpoint fifo
140+ * (needed for precise fault handling, when the hardware allows it)
141+ */
142+#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
143+
144+/* discards any unclaimed data in the fifo. */
145+#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
146+
147+/* resets endpoint halt+toggle; used to implement set_interface.
148+ * some hardware (like pxa2xx) can't support this.
149+ */
150+#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
151+
152+/* Specific for functionfs */
153+
154+/*
155+ * Returns reverse mapping of an interface. Called on EP0. If there
156+ * is no such interface returns -EDOM. If function is not active
157+ * returns -ENODEV.
158+ */
159+#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
160+
161+/*
162+ * Returns real bEndpointAddress of an endpoint. If function is not
163+ * active returns -ENODEV.
164+ */
165+#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
166+
167+
168+
169+#endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
include/uapi/linux/usb/g_printer.h+35−0
@@ -0,0 +1,35 @@
1+/*
2+ * g_printer.h -- Header file for USB Printer gadget driver
3+ *
4+ * Copyright (C) 2007 Craig W. Nadler
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; either version 2 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program; if not, write to the Free Software
18+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+ */
20+
21+#ifndef __LINUX_USB_G_PRINTER_H
22+#define __LINUX_USB_G_PRINTER_H
23+
24+#define PRINTER_NOT_ERROR 0x08
25+#define PRINTER_SELECTED 0x10
26+#define PRINTER_PAPER_EMPTY 0x20
27+
28+/* The 'g' code is also used by gadgetfs ioctl requests.
29+ * Don't add any colliding codes to either driver, and keep
30+ * them in unique ranges (size 0x20 for now).
31+ */
32+#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
33+#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
34+
35+#endif /* __LINUX_USB_G_PRINTER_H */
include/uapi/linux/usb/gadgetfs.h+88−0
@@ -0,0 +1,88 @@
1+/*
2+ * Filesystem based user-mode API to USB Gadget controller hardware
3+ *
4+ * Other than ep0 operations, most things are done by read() and write()
5+ * on endpoint files found in one directory. They are configured by
6+ * writing descriptors, and then may be used for normal stream style
7+ * i/o requests. When ep0 is configured, the device can enumerate;
8+ * when it's closed, the device disconnects from usb. Operations on
9+ * ep0 require ioctl() operations.
10+ *
11+ * Configuration and device descriptors get written to /dev/gadget/$CHIP,
12+ * which may then be used to read usb_gadgetfs_event structs. The driver
13+ * may activate endpoints as it handles SET_CONFIGURATION setup events,
14+ * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT
15+ * then performing data transfers by reading or writing.
16+ */
17+
18+#ifndef __LINUX_USB_GADGETFS_H
19+#define __LINUX_USB_GADGETFS_H
20+
21+#include <linux/types.h>
22+#include <linux/ioctl.h>
23+
24+#include <linux/usb/ch9.h>
25+
26+/*
27+ * Events are delivered on the ep0 file descriptor, when the user mode driver
28+ * reads from this file descriptor after writing the descriptors. Don't
29+ * stop polling this descriptor.
30+ */
31+
32+enum usb_gadgetfs_event_type {
33+ GADGETFS_NOP = 0,
34+
35+ GADGETFS_CONNECT,
36+ GADGETFS_DISCONNECT,
37+ GADGETFS_SETUP,
38+ GADGETFS_SUSPEND,
39+ /* and likely more ! */
40+};
41+
42+/* NOTE: this structure must stay the same size and layout on
43+ * both 32-bit and 64-bit kernels.
44+ */
45+struct usb_gadgetfs_event {
46+ union {
47+ /* NOP, DISCONNECT, SUSPEND: nothing
48+ * ... some hardware can't report disconnection
49+ */
50+
51+ /* CONNECT: just the speed */
52+ enum usb_device_speed speed;
53+
54+ /* SETUP: packet; DATA phase i/o precedes next event
55+ *(setup.bmRequestType & USB_DIR_IN) flags direction
56+ * ... includes SET_CONFIGURATION, SET_INTERFACE
57+ */
58+ struct usb_ctrlrequest setup;
59+ } u;
60+ enum usb_gadgetfs_event_type type;
61+};
62+
63+
64+/* The 'g' code is also used by printer gadget ioctl requests.
65+ * Don't add any colliding codes to either driver, and keep
66+ * them in unique ranges (size 0x20 for now).
67+ */
68+
69+/* endpoint ioctls */
70+
71+/* IN transfers may be reported to the gadget driver as complete
72+ * when the fifo is loaded, before the host reads the data;
73+ * OUT transfers may be reported to the host's "client" driver as
74+ * complete when they're sitting in the FIFO unread.
75+ * THIS returns how many bytes are "unclaimed" in the endpoint fifo
76+ * (needed for precise fault handling, when the hardware allows it)
77+ */
78+#define GADGETFS_FIFO_STATUS _IO('g', 1)
79+
80+/* discards any unclaimed data in the fifo. */
81+#define GADGETFS_FIFO_FLUSH _IO('g', 2)
82+
83+/* resets endpoint halt+toggle; used to implement set_interface.
84+ * some hardware (like pxa2xx) can't support this.
85+ */
86+#define GADGETFS_CLEAR_HALT _IO('g', 3)
87+
88+#endif /* __LINUX_USB_GADGETFS_H */
include/uapi/linux/usb/midi.h+112−0
@@ -0,0 +1,112 @@
1+/*
2+ * <linux/usb/midi.h> -- USB MIDI definitions.
3+ *
4+ * Copyright (C) 2006 Thumtronics Pty Ltd.
5+ * Developed for Thumtronics by Grey Innovation
6+ * Ben Williamson <ben.williamson@greyinnovation.com>
7+ *
8+ * This software is distributed under the terms of the GNU General Public
9+ * License ("GPL") version 2, as published by the Free Software Foundation.
10+ *
11+ * This file holds USB constants and structures defined
12+ * by the USB Device Class Definition for MIDI Devices.
13+ * Comments below reference relevant sections of that document:
14+ *
15+ * http://www.usb.org/developers/devclass_docs/midi10.pdf
16+ */
17+
18+#ifndef __LINUX_USB_MIDI_H
19+#define __LINUX_USB_MIDI_H
20+
21+#include <linux/types.h>
22+
23+/* A.1 MS Class-Specific Interface Descriptor Subtypes */
24+#define USB_MS_HEADER 0x01
25+#define USB_MS_MIDI_IN_JACK 0x02
26+#define USB_MS_MIDI_OUT_JACK 0x03
27+#define USB_MS_ELEMENT 0x04
28+
29+/* A.2 MS Class-Specific Endpoint Descriptor Subtypes */
30+#define USB_MS_GENERAL 0x01
31+
32+/* A.3 MS MIDI IN and OUT Jack Types */
33+#define USB_MS_EMBEDDED 0x01
34+#define USB_MS_EXTERNAL 0x02
35+
36+/* 6.1.2.1 Class-Specific MS Interface Header Descriptor */
37+struct usb_ms_header_descriptor {
38+ __u8 bLength;
39+ __u8 bDescriptorType;
40+ __u8 bDescriptorSubtype;
41+ __le16 bcdMSC;
42+ __le16 wTotalLength;
43+} __attribute__ ((packed));
44+
45+#define USB_DT_MS_HEADER_SIZE 7
46+
47+/* 6.1.2.2 MIDI IN Jack Descriptor */
48+struct usb_midi_in_jack_descriptor {
49+ __u8 bLength;
50+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
51+ __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */
52+ __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
53+ __u8 bJackID;
54+ __u8 iJack;
55+} __attribute__ ((packed));
56+
57+#define USB_DT_MIDI_IN_SIZE 6
58+
59+struct usb_midi_source_pin {
60+ __u8 baSourceID;
61+ __u8 baSourcePin;
62+} __attribute__ ((packed));
63+
64+/* 6.1.2.3 MIDI OUT Jack Descriptor */
65+struct usb_midi_out_jack_descriptor {
66+ __u8 bLength;
67+ __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
68+ __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */
69+ __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
70+ __u8 bJackID;
71+ __u8 bNrInputPins; /* p */
72+ struct usb_midi_source_pin pins[]; /* [p] */
73+ /*__u8 iJack; -- omitted due to variable-sized pins[] */
74+} __attribute__ ((packed));
75+
76+#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
77+
78+/* As above, but more useful for defining your own descriptors: */
79+#define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \
80+struct usb_midi_out_jack_descriptor_##p { \
81+ __u8 bLength; \
82+ __u8 bDescriptorType; \
83+ __u8 bDescriptorSubtype; \
84+ __u8 bJackType; \
85+ __u8 bJackID; \
86+ __u8 bNrInputPins; \
87+ struct usb_midi_source_pin pins[p]; \
88+ __u8 iJack; \
89+} __attribute__ ((packed))
90+
91+/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
92+struct usb_ms_endpoint_descriptor {
93+ __u8 bLength; /* 4+n */
94+ __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
95+ __u8 bDescriptorSubtype; /* USB_MS_GENERAL */
96+ __u8 bNumEmbMIDIJack; /* n */
97+ __u8 baAssocJackID[]; /* [n] */
98+} __attribute__ ((packed));
99+
100+#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
101+
102+/* As above, but more useful for defining your own descriptors: */
103+#define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \
104+struct usb_ms_endpoint_descriptor_##n { \
105+ __u8 bLength; \
106+ __u8 bDescriptorType; \
107+ __u8 bDescriptorSubtype; \
108+ __u8 bNumEmbMIDIJack; \
109+ __u8 baAssocJackID[n]; \
110+} __attribute__ ((packed))
111+
112+#endif /* __LINUX_USB_MIDI_H */
include/uapi/linux/usb/tmc.h+43−0
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
3+ * Copyright (C) 2008 Novell, Inc.
4+ * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
5+ *
6+ * This file holds USB constants defined by the USB Device Class
7+ * Definition for Test and Measurement devices published by the USB-IF.
8+ *
9+ * It also has the ioctl definitions for the usbtmc kernel driver that
10+ * userspace needs to know about.
11+ */
12+
13+#ifndef __LINUX_USB_TMC_H
14+#define __LINUX_USB_TMC_H
15+
16+/* USB TMC status values */
17+#define USBTMC_STATUS_SUCCESS 0x01
18+#define USBTMC_STATUS_PENDING 0x02
19+#define USBTMC_STATUS_FAILED 0x80
20+#define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
21+#define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
22+#define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83
23+
24+/* USB TMC requests values */
25+#define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1
26+#define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2
27+#define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3
28+#define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4
29+#define USBTMC_REQUEST_INITIATE_CLEAR 5
30+#define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6
31+#define USBTMC_REQUEST_GET_CAPABILITIES 7
32+#define USBTMC_REQUEST_INDICATOR_PULSE 64
33+
34+/* Request values for USBTMC driver's ioctl entry point */
35+#define USBTMC_IOC_NR 91
36+#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)
37+#define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2)
38+#define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3)
39+#define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
40+#define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6)
41+#define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
42+
43+#endif
include/uapi/linux/usb/video.h+568−0
@@ -0,0 +1,568 @@
1+/*
2+ * USB Video Class definitions.
3+ *
4+ * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
5+ *
6+ * This file holds USB constants and structures defined by the USB Device
7+ * Class Definition for Video Devices. Unless otherwise stated, comments
8+ * below reference relevant sections of the USB Video Class 1.1 specification
9+ * available at
10+ *
11+ * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
12+ */
13+
14+#ifndef __LINUX_USB_VIDEO_H
15+#define __LINUX_USB_VIDEO_H
16+
17+#include <linux/types.h>
18+
19+/* --------------------------------------------------------------------------
20+ * UVC constants
21+ */
22+
23+/* A.2. Video Interface Subclass Codes */
24+#define UVC_SC_UNDEFINED 0x00
25+#define UVC_SC_VIDEOCONTROL 0x01
26+#define UVC_SC_VIDEOSTREAMING 0x02
27+#define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
28+
29+/* A.3. Video Interface Protocol Codes */
30+#define UVC_PC_PROTOCOL_UNDEFINED 0x00
31+
32+/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
33+#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
34+#define UVC_VC_HEADER 0x01
35+#define UVC_VC_INPUT_TERMINAL 0x02
36+#define UVC_VC_OUTPUT_TERMINAL 0x03
37+#define UVC_VC_SELECTOR_UNIT 0x04
38+#define UVC_VC_PROCESSING_UNIT 0x05
39+#define UVC_VC_EXTENSION_UNIT 0x06
40+
41+/* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
42+#define UVC_VS_UNDEFINED 0x00
43+#define UVC_VS_INPUT_HEADER 0x01
44+#define UVC_VS_OUTPUT_HEADER 0x02
45+#define UVC_VS_STILL_IMAGE_FRAME 0x03
46+#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
47+#define UVC_VS_FRAME_UNCOMPRESSED 0x05
48+#define UVC_VS_FORMAT_MJPEG 0x06
49+#define UVC_VS_FRAME_MJPEG 0x07
50+#define UVC_VS_FORMAT_MPEG2TS 0x0a
51+#define UVC_VS_FORMAT_DV 0x0c
52+#define UVC_VS_COLORFORMAT 0x0d
53+#define UVC_VS_FORMAT_FRAME_BASED 0x10
54+#define UVC_VS_FRAME_FRAME_BASED 0x11
55+#define UVC_VS_FORMAT_STREAM_BASED 0x12
56+
57+/* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
58+#define UVC_EP_UNDEFINED 0x00
59+#define UVC_EP_GENERAL 0x01
60+#define UVC_EP_ENDPOINT 0x02
61+#define UVC_EP_INTERRUPT 0x03
62+
63+/* A.8. Video Class-Specific Request Codes */
64+#define UVC_RC_UNDEFINED 0x00
65+#define UVC_SET_CUR 0x01
66+#define UVC_GET_CUR 0x81
67+#define UVC_GET_MIN 0x82
68+#define UVC_GET_MAX 0x83
69+#define UVC_GET_RES 0x84
70+#define UVC_GET_LEN 0x85
71+#define UVC_GET_INFO 0x86
72+#define UVC_GET_DEF 0x87
73+
74+/* A.9.1. VideoControl Interface Control Selectors */
75+#define UVC_VC_CONTROL_UNDEFINED 0x00
76+#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
77+#define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
78+
79+/* A.9.2. Terminal Control Selectors */
80+#define UVC_TE_CONTROL_UNDEFINED 0x00
81+
82+/* A.9.3. Selector Unit Control Selectors */
83+#define UVC_SU_CONTROL_UNDEFINED 0x00
84+#define UVC_SU_INPUT_SELECT_CONTROL 0x01
85+
86+/* A.9.4. Camera Terminal Control Selectors */
87+#define UVC_CT_CONTROL_UNDEFINED 0x00
88+#define UVC_CT_SCANNING_MODE_CONTROL 0x01
89+#define UVC_CT_AE_MODE_CONTROL 0x02
90+#define UVC_CT_AE_PRIORITY_CONTROL 0x03
91+#define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
92+#define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
93+#define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
94+#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
95+#define UVC_CT_FOCUS_AUTO_CONTROL 0x08
96+#define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
97+#define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
98+#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
99+#define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
100+#define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
101+#define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
102+#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
103+#define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
104+#define UVC_CT_PRIVACY_CONTROL 0x11
105+
106+/* A.9.5. Processing Unit Control Selectors */
107+#define UVC_PU_CONTROL_UNDEFINED 0x00
108+#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
109+#define UVC_PU_BRIGHTNESS_CONTROL 0x02
110+#define UVC_PU_CONTRAST_CONTROL 0x03
111+#define UVC_PU_GAIN_CONTROL 0x04
112+#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
113+#define UVC_PU_HUE_CONTROL 0x06
114+#define UVC_PU_SATURATION_CONTROL 0x07
115+#define UVC_PU_SHARPNESS_CONTROL 0x08
116+#define UVC_PU_GAMMA_CONTROL 0x09
117+#define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
118+#define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
119+#define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
120+#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
121+#define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
122+#define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
123+#define UVC_PU_HUE_AUTO_CONTROL 0x10
124+#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
125+#define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
126+
127+/* A.9.7. VideoStreaming Interface Control Selectors */
128+#define UVC_VS_CONTROL_UNDEFINED 0x00
129+#define UVC_VS_PROBE_CONTROL 0x01
130+#define UVC_VS_COMMIT_CONTROL 0x02
131+#define UVC_VS_STILL_PROBE_CONTROL 0x03
132+#define UVC_VS_STILL_COMMIT_CONTROL 0x04
133+#define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
134+#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
135+#define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
136+#define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
137+#define UVC_VS_SYNC_DELAY_CONTROL 0x09
138+
139+/* B.1. USB Terminal Types */
140+#define UVC_TT_VENDOR_SPECIFIC 0x0100
141+#define UVC_TT_STREAMING 0x0101
142+
143+/* B.2. Input Terminal Types */
144+#define UVC_ITT_VENDOR_SPECIFIC 0x0200
145+#define UVC_ITT_CAMERA 0x0201
146+#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
147+
148+/* B.3. Output Terminal Types */
149+#define UVC_OTT_VENDOR_SPECIFIC 0x0300
150+#define UVC_OTT_DISPLAY 0x0301
151+#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
152+
153+/* B.4. External Terminal Types */
154+#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
155+#define UVC_COMPOSITE_CONNECTOR 0x0401
156+#define UVC_SVIDEO_CONNECTOR 0x0402
157+#define UVC_COMPONENT_CONNECTOR 0x0403
158+
159+/* 2.4.2.2. Status Packet Type */
160+#define UVC_STATUS_TYPE_CONTROL 1
161+#define UVC_STATUS_TYPE_STREAMING 2
162+
163+/* 2.4.3.3. Payload Header Information */
164+#define UVC_STREAM_EOH (1 << 7)
165+#define UVC_STREAM_ERR (1 << 6)
166+#define UVC_STREAM_STI (1 << 5)
167+#define UVC_STREAM_RES (1 << 4)
168+#define UVC_STREAM_SCR (1 << 3)
169+#define UVC_STREAM_PTS (1 << 2)
170+#define UVC_STREAM_EOF (1 << 1)
171+#define UVC_STREAM_FID (1 << 0)
172+
173+/* 4.1.2. Control Capabilities */
174+#define UVC_CONTROL_CAP_GET (1 << 0)
175+#define UVC_CONTROL_CAP_SET (1 << 1)
176+#define UVC_CONTROL_CAP_DISABLED (1 << 2)
177+#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
178+#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
179+
180+/* ------------------------------------------------------------------------
181+ * UVC structures
182+ */
183+
184+/* All UVC descriptors have these 3 fields at the beginning */
185+struct uvc_descriptor_header {
186+ __u8 bLength;
187+ __u8 bDescriptorType;
188+ __u8 bDescriptorSubType;
189+} __attribute__((packed));
190+
191+/* 3.7.2. Video Control Interface Header Descriptor */
192+struct uvc_header_descriptor {
193+ __u8 bLength;
194+ __u8 bDescriptorType;
195+ __u8 bDescriptorSubType;
196+ __u16 bcdUVC;
197+ __u16 wTotalLength;
198+ __u32 dwClockFrequency;
199+ __u8 bInCollection;
200+ __u8 baInterfaceNr[];
201+} __attribute__((__packed__));
202+
203+#define UVC_DT_HEADER_SIZE(n) (12+(n))
204+
205+#define UVC_HEADER_DESCRIPTOR(n) \
206+ uvc_header_descriptor_##n
207+
208+#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
209+struct UVC_HEADER_DESCRIPTOR(n) { \
210+ __u8 bLength; \
211+ __u8 bDescriptorType; \
212+ __u8 bDescriptorSubType; \
213+ __u16 bcdUVC; \
214+ __u16 wTotalLength; \
215+ __u32 dwClockFrequency; \
216+ __u8 bInCollection; \
217+ __u8 baInterfaceNr[n]; \
218+} __attribute__ ((packed))
219+
220+/* 3.7.2.1. Input Terminal Descriptor */
221+struct uvc_input_terminal_descriptor {
222+ __u8 bLength;
223+ __u8 bDescriptorType;
224+ __u8 bDescriptorSubType;
225+ __u8 bTerminalID;
226+ __u16 wTerminalType;
227+ __u8 bAssocTerminal;
228+ __u8 iTerminal;
229+} __attribute__((__packed__));
230+
231+#define UVC_DT_INPUT_TERMINAL_SIZE 8
232+
233+/* 3.7.2.2. Output Terminal Descriptor */
234+struct uvc_output_terminal_descriptor {
235+ __u8 bLength;
236+ __u8 bDescriptorType;
237+ __u8 bDescriptorSubType;
238+ __u8 bTerminalID;
239+ __u16 wTerminalType;
240+ __u8 bAssocTerminal;
241+ __u8 bSourceID;
242+ __u8 iTerminal;
243+} __attribute__((__packed__));
244+
245+#define UVC_DT_OUTPUT_TERMINAL_SIZE 9
246+
247+/* 3.7.2.3. Camera Terminal Descriptor */
248+struct uvc_camera_terminal_descriptor {
249+ __u8 bLength;
250+ __u8 bDescriptorType;
251+ __u8 bDescriptorSubType;
252+ __u8 bTerminalID;
253+ __u16 wTerminalType;
254+ __u8 bAssocTerminal;
255+ __u8 iTerminal;
256+ __u16 wObjectiveFocalLengthMin;
257+ __u16 wObjectiveFocalLengthMax;
258+ __u16 wOcularFocalLength;
259+ __u8 bControlSize;
260+ __u8 bmControls[3];
261+} __attribute__((__packed__));
262+
263+#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
264+
265+/* 3.7.2.4. Selector Unit Descriptor */
266+struct uvc_selector_unit_descriptor {
267+ __u8 bLength;
268+ __u8 bDescriptorType;
269+ __u8 bDescriptorSubType;
270+ __u8 bUnitID;
271+ __u8 bNrInPins;
272+ __u8 baSourceID[0];
273+ __u8 iSelector;
274+} __attribute__((__packed__));
275+
276+#define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
277+
278+#define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
279+ uvc_selector_unit_descriptor_##n
280+
281+#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
282+struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
283+ __u8 bLength; \
284+ __u8 bDescriptorType; \
285+ __u8 bDescriptorSubType; \
286+ __u8 bUnitID; \
287+ __u8 bNrInPins; \
288+ __u8 baSourceID[n]; \
289+ __u8 iSelector; \
290+} __attribute__ ((packed))
291+
292+/* 3.7.2.5. Processing Unit Descriptor */
293+struct uvc_processing_unit_descriptor {
294+ __u8 bLength;
295+ __u8 bDescriptorType;
296+ __u8 bDescriptorSubType;
297+ __u8 bUnitID;
298+ __u8 bSourceID;
299+ __u16 wMaxMultiplier;
300+ __u8 bControlSize;
301+ __u8 bmControls[2];
302+ __u8 iProcessing;
303+} __attribute__((__packed__));
304+
305+#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
306+
307+/* 3.7.2.6. Extension Unit Descriptor */
308+struct uvc_extension_unit_descriptor {
309+ __u8 bLength;
310+ __u8 bDescriptorType;
311+ __u8 bDescriptorSubType;
312+ __u8 bUnitID;
313+ __u8 guidExtensionCode[16];
314+ __u8 bNumControls;
315+ __u8 bNrInPins;
316+ __u8 baSourceID[0];
317+ __u8 bControlSize;
318+ __u8 bmControls[0];
319+ __u8 iExtension;
320+} __attribute__((__packed__));
321+
322+#define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
323+
324+#define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
325+ uvc_extension_unit_descriptor_##p_##n
326+
327+#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
328+struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
329+ __u8 bLength; \
330+ __u8 bDescriptorType; \
331+ __u8 bDescriptorSubType; \
332+ __u8 bUnitID; \
333+ __u8 guidExtensionCode[16]; \
334+ __u8 bNumControls; \
335+ __u8 bNrInPins; \
336+ __u8 baSourceID[p]; \
337+ __u8 bControlSize; \
338+ __u8 bmControls[n]; \
339+ __u8 iExtension; \
340+} __attribute__ ((packed))
341+
342+/* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
343+struct uvc_control_endpoint_descriptor {
344+ __u8 bLength;
345+ __u8 bDescriptorType;
346+ __u8 bDescriptorSubType;
347+ __u16 wMaxTransferSize;
348+} __attribute__((__packed__));
349+
350+#define UVC_DT_CONTROL_ENDPOINT_SIZE 5
351+
352+/* 3.9.2.1. Input Header Descriptor */
353+struct uvc_input_header_descriptor {
354+ __u8 bLength;
355+ __u8 bDescriptorType;
356+ __u8 bDescriptorSubType;
357+ __u8 bNumFormats;
358+ __u16 wTotalLength;
359+ __u8 bEndpointAddress;
360+ __u8 bmInfo;
361+ __u8 bTerminalLink;
362+ __u8 bStillCaptureMethod;
363+ __u8 bTriggerSupport;
364+ __u8 bTriggerUsage;
365+ __u8 bControlSize;
366+ __u8 bmaControls[];
367+} __attribute__((__packed__));
368+
369+#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
370+
371+#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
372+ uvc_input_header_descriptor_##n_##p
373+
374+#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
375+struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
376+ __u8 bLength; \
377+ __u8 bDescriptorType; \
378+ __u8 bDescriptorSubType; \
379+ __u8 bNumFormats; \
380+ __u16 wTotalLength; \
381+ __u8 bEndpointAddress; \
382+ __u8 bmInfo; \
383+ __u8 bTerminalLink; \
384+ __u8 bStillCaptureMethod; \
385+ __u8 bTriggerSupport; \
386+ __u8 bTriggerUsage; \
387+ __u8 bControlSize; \
388+ __u8 bmaControls[p][n]; \
389+} __attribute__ ((packed))
390+
391+/* 3.9.2.2. Output Header Descriptor */
392+struct uvc_output_header_descriptor {
393+ __u8 bLength;
394+ __u8 bDescriptorType;
395+ __u8 bDescriptorSubType;
396+ __u8 bNumFormats;
397+ __u16 wTotalLength;
398+ __u8 bEndpointAddress;
399+ __u8 bTerminalLink;
400+ __u8 bControlSize;
401+ __u8 bmaControls[];
402+} __attribute__((__packed__));
403+
404+#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
405+
406+#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
407+ uvc_output_header_descriptor_##n_##p
408+
409+#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
410+struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
411+ __u8 bLength; \
412+ __u8 bDescriptorType; \
413+ __u8 bDescriptorSubType; \
414+ __u8 bNumFormats; \
415+ __u16 wTotalLength; \
416+ __u8 bEndpointAddress; \
417+ __u8 bTerminalLink; \
418+ __u8 bControlSize; \
419+ __u8 bmaControls[p][n]; \
420+} __attribute__ ((packed))
421+
422+/* 3.9.2.6. Color matching descriptor */
423+struct uvc_color_matching_descriptor {
424+ __u8 bLength;
425+ __u8 bDescriptorType;
426+ __u8 bDescriptorSubType;
427+ __u8 bColorPrimaries;
428+ __u8 bTransferCharacteristics;
429+ __u8 bMatrixCoefficients;
430+} __attribute__((__packed__));
431+
432+#define UVC_DT_COLOR_MATCHING_SIZE 6
433+
434+/* 4.3.1.1. Video Probe and Commit Controls */
435+struct uvc_streaming_control {
436+ __u16 bmHint;
437+ __u8 bFormatIndex;
438+ __u8 bFrameIndex;
439+ __u32 dwFrameInterval;
440+ __u16 wKeyFrameRate;
441+ __u16 wPFrameRate;
442+ __u16 wCompQuality;
443+ __u16 wCompWindowSize;
444+ __u16 wDelay;
445+ __u32 dwMaxVideoFrameSize;
446+ __u32 dwMaxPayloadTransferSize;
447+ __u32 dwClockFrequency;
448+ __u8 bmFramingInfo;
449+ __u8 bPreferedVersion;
450+ __u8 bMinVersion;
451+ __u8 bMaxVersion;
452+} __attribute__((__packed__));
453+
454+/* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
455+struct uvc_format_uncompressed {
456+ __u8 bLength;
457+ __u8 bDescriptorType;
458+ __u8 bDescriptorSubType;
459+ __u8 bFormatIndex;
460+ __u8 bNumFrameDescriptors;
461+ __u8 guidFormat[16];
462+ __u8 bBitsPerPixel;
463+ __u8 bDefaultFrameIndex;
464+ __u8 bAspectRatioX;
465+ __u8 bAspectRatioY;
466+ __u8 bmInterfaceFlags;
467+ __u8 bCopyProtect;
468+} __attribute__((__packed__));
469+
470+#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
471+
472+/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
473+struct uvc_frame_uncompressed {
474+ __u8 bLength;
475+ __u8 bDescriptorType;
476+ __u8 bDescriptorSubType;
477+ __u8 bFrameIndex;
478+ __u8 bmCapabilities;
479+ __u16 wWidth;
480+ __u16 wHeight;
481+ __u32 dwMinBitRate;
482+ __u32 dwMaxBitRate;
483+ __u32 dwMaxVideoFrameBufferSize;
484+ __u32 dwDefaultFrameInterval;
485+ __u8 bFrameIntervalType;
486+ __u32 dwFrameInterval[];
487+} __attribute__((__packed__));
488+
489+#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
490+
491+#define UVC_FRAME_UNCOMPRESSED(n) \
492+ uvc_frame_uncompressed_##n
493+
494+#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
495+struct UVC_FRAME_UNCOMPRESSED(n) { \
496+ __u8 bLength; \
497+ __u8 bDescriptorType; \
498+ __u8 bDescriptorSubType; \
499+ __u8 bFrameIndex; \
500+ __u8 bmCapabilities; \
501+ __u16 wWidth; \
502+ __u16 wHeight; \
503+ __u32 dwMinBitRate; \
504+ __u32 dwMaxBitRate; \
505+ __u32 dwMaxVideoFrameBufferSize; \
506+ __u32 dwDefaultFrameInterval; \
507+ __u8 bFrameIntervalType; \
508+ __u32 dwFrameInterval[n]; \
509+} __attribute__ ((packed))
510+
511+/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
512+struct uvc_format_mjpeg {
513+ __u8 bLength;
514+ __u8 bDescriptorType;
515+ __u8 bDescriptorSubType;
516+ __u8 bFormatIndex;
517+ __u8 bNumFrameDescriptors;
518+ __u8 bmFlags;
519+ __u8 bDefaultFrameIndex;
520+ __u8 bAspectRatioX;
521+ __u8 bAspectRatioY;
522+ __u8 bmInterfaceFlags;
523+ __u8 bCopyProtect;
524+} __attribute__((__packed__));
525+
526+#define UVC_DT_FORMAT_MJPEG_SIZE 11
527+
528+/* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
529+struct uvc_frame_mjpeg {
530+ __u8 bLength;
531+ __u8 bDescriptorType;
532+ __u8 bDescriptorSubType;
533+ __u8 bFrameIndex;
534+ __u8 bmCapabilities;
535+ __u16 wWidth;
536+ __u16 wHeight;
537+ __u32 dwMinBitRate;
538+ __u32 dwMaxBitRate;
539+ __u32 dwMaxVideoFrameBufferSize;
540+ __u32 dwDefaultFrameInterval;
541+ __u8 bFrameIntervalType;
542+ __u32 dwFrameInterval[];
543+} __attribute__((__packed__));
544+
545+#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
546+
547+#define UVC_FRAME_MJPEG(n) \
548+ uvc_frame_mjpeg_##n
549+
550+#define DECLARE_UVC_FRAME_MJPEG(n) \
551+struct UVC_FRAME_MJPEG(n) { \
552+ __u8 bLength; \
553+ __u8 bDescriptorType; \
554+ __u8 bDescriptorSubType; \
555+ __u8 bFrameIndex; \
556+ __u8 bmCapabilities; \
557+ __u16 wWidth; \
558+ __u16 wHeight; \
559+ __u32 dwMinBitRate; \
560+ __u32 dwMaxBitRate; \
561+ __u32 dwMaxVideoFrameBufferSize; \
562+ __u32 dwDefaultFrameInterval; \
563+ __u8 bFrameIntervalType; \
564+ __u32 dwFrameInterval[n]; \
565+} __attribute__ ((packed))
566+
567+#endif /* __LINUX_USB_VIDEO_H */
568+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t