1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2017 Ruslan Bilovol <ruslan.bilovol@gmail.com>
5 * This file holds USB constants and structures defined
6 * by the USB DEVICE CLASS DEFINITION FOR AUDIO DEVICES Release 3.0.
9 #ifndef __LINUX_USB_AUDIO_V3_H
10 #define __LINUX_USB_AUDIO_V3_H
12 #include <linux/types.h>
15 * v1.0, v2.0 and v3.0 of this standard have many things in common. For the rest
16 * of the definitions, please refer to audio.h and audio-v2.h
19 /* All High Capability descriptors have these 2 fields at the beginning */
20 struct uac3_hc_descriptor_header
{
23 __u8 bDescriptorSubtype
;
25 } __attribute__ ((packed
));
27 /* 4.3.1 CLUSTER DESCRIPTOR HEADER */
28 struct uac3_cluster_header_descriptor
{
31 __u8 bDescriptorSubtype
;
34 } __attribute__ ((packed
));
36 /* 4.3.2.1 SEGMENTS */
37 struct uac3_cluster_segment_descriptor
{
40 /* __u8[0]; segment-specific data */
41 } __attribute__ ((packed
));
43 /* 4.3.2.1.1 END SEGMENT */
44 struct uac3_cluster_end_segment_descriptor
{
46 __u8 bSegmentType
; /* Constant END_SEGMENT */
47 } __attribute__ ((packed
));
49 /* 4.3.2.1.3.1 INFORMATION SEGMENT */
50 struct uac3_cluster_information_segment_descriptor
{
56 } __attribute__ ((packed
));
58 /* 4.5.2 CLASS-SPECIFIC AC INTERFACE DESCRIPTOR */
59 struct uac3_ac_header_descriptor
{
60 __u8 bLength
; /* 10 */
61 __u8 bDescriptorType
; /* CS_INTERFACE descriptor type */
62 __u8 bDescriptorSubtype
; /* HEADER descriptor subtype */
65 /* includes Clock Source, Unit, Terminal, and Power Domain desc. */
69 } __attribute__ ((packed
));
71 /* 4.5.2.1 INPUT TERMINAL DESCRIPTOR */
72 struct uac3_input_terminal_descriptor
{
75 __u8 bDescriptorSubtype
;
81 __le16 wClusterDescrID
;
82 __le16 wExTerminalDescrID
;
83 __le16 wConnectorsDescrID
;
84 __le16 wTerminalDescrStr
;
85 } __attribute__((packed
));
87 /* 4.5.2.2 OUTPUT TERMINAL DESCRIPTOR */
88 struct uac3_output_terminal_descriptor
{
91 __u8 bDescriptorSubtype
;
98 __le16 wExTerminalDescrID
;
99 __le16 wConnectorsDescrID
;
100 __le16 wTerminalDescrStr
;
101 } __attribute__((packed
));
103 /* 4.5.2.7 FEATURE UNIT DESCRIPTOR */
104 struct uac3_feature_unit_descriptor
{
106 __u8 bDescriptorType
;
107 __u8 bDescriptorSubtype
;
110 /* bmaControls is actually u32,
111 * but u8 is needed for the hybrid parser */
112 __u8 bmaControls
[]; /* variable length */
113 /* wFeatureDescrStr omitted */
114 } __attribute__((packed
));
116 #define UAC3_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 4)
118 /* As above, but more useful for defining your own descriptors */
119 #define DECLARE_UAC3_FEATURE_UNIT_DESCRIPTOR(ch) \
120 struct uac3_feature_unit_descriptor_##ch { \
122 __u8 bDescriptorType; \
123 __u8 bDescriptorSubtype; \
126 __le32 bmaControls[ch + 1]; \
127 __le16 wFeatureDescrStr; \
128 } __attribute__ ((packed))
130 /* 4.5.2.12 CLOCK SOURCE DESCRIPTOR */
131 struct uac3_clock_source_descriptor
{
133 __u8 bDescriptorType
;
134 __u8 bDescriptorSubtype
;
138 __u8 bReferenceTerminal
;
139 __le16 wClockSourceStr
;
140 } __attribute__((packed
));
142 /* bmAttribute fields */
143 #define UAC3_CLOCK_SOURCE_TYPE_EXT 0x0
144 #define UAC3_CLOCK_SOURCE_TYPE_INT 0x1
145 #define UAC3_CLOCK_SOURCE_ASYNC (0 << 2)
146 #define UAC3_CLOCK_SOURCE_SYNCED_TO_SOF (1 << 1)
148 /* 4.5.2.13 CLOCK SELECTOR DESCRIPTOR */
149 struct uac3_clock_selector_descriptor
{
151 __u8 bDescriptorType
;
152 __u8 bDescriptorSubtype
;
156 /* bmControls and wCSelectorDescrStr omitted */
157 } __attribute__((packed
));
159 /* 4.5.2.14 CLOCK MULTIPLIER DESCRIPTOR */
160 struct uac3_clock_multiplier_descriptor
{
162 __u8 bDescriptorType
;
163 __u8 bDescriptorSubtype
;
167 __le16 wCMultiplierDescrStr
;
168 } __attribute__((packed
));
170 /* 4.5.2.15 POWER DOMAIN DESCRIPTOR */
171 struct uac3_power_domain_descriptor
{
173 __u8 bDescriptorType
;
174 __u8 bDescriptorSubtype
;
176 __le16 waRecoveryTime1
;
177 __le16 waRecoveryTime2
;
180 /* wPDomainDescrStr omitted */
181 } __attribute__((packed
));
183 /* As above, but more useful for defining your own descriptors */
184 #define DECLARE_UAC3_POWER_DOMAIN_DESCRIPTOR(n) \
185 struct uac3_power_domain_descriptor_##n { \
187 __u8 bDescriptorType; \
188 __u8 bDescriptorSubtype; \
189 __u8 bPowerDomainID; \
190 __le16 waRecoveryTime1; \
191 __le16 waRecoveryTime2; \
193 __u8 baEntityID[n]; \
194 __le16 wPDomainDescrStr; \
195 } __attribute__ ((packed))
197 /* 4.7.2 CLASS-SPECIFIC AS INTERFACE DESCRIPTOR */
198 struct uac3_as_header_descriptor
{
200 __u8 bDescriptorType
;
201 __u8 bDescriptorSubtype
;
204 __le16 wClusterDescrID
;
208 __le16 bmAuxProtocols
;
210 } __attribute__((packed
));
212 #define UAC3_FORMAT_TYPE_I_RAW_DATA (1 << 6)
214 /* 4.8.1.2 CLASS-SPECIFIC AS ISOCHRONOUS AUDIO DATA ENDPOINT DESCRIPTOR */
215 struct uac3_iso_endpoint_descriptor
{
217 __u8 bDescriptorType
;
218 __u8 bDescriptorSubtype
;
220 __u8 bLockDelayUnits
;
222 } __attribute__((packed
));
224 /* 5.2.1.6.1 INSERTION CONTROL PARAMETER BLOCK */
225 struct uac3_insertion_ctl_blk
{
228 } __attribute__ ((packed
));
230 /* 6.1 INTERRUPT DATA MESSAGE */
231 struct uac3_interrupt_data_msg
{
236 } __attribute__((packed
));
238 /* A.2 AUDIO AUDIO FUNCTION SUBCLASS CODES */
239 #define UAC3_FUNCTION_SUBCLASS_UNDEFINED 0x00
240 #define UAC3_FUNCTION_SUBCLASS_FULL_ADC_3_0 0x01
242 #define UAC3_FUNCTION_SUBCLASS_GENERIC_IO 0x20
243 #define UAC3_FUNCTION_SUBCLASS_HEADPHONE 0x21
244 #define UAC3_FUNCTION_SUBCLASS_SPEAKER 0x22
245 #define UAC3_FUNCTION_SUBCLASS_MICROPHONE 0x23
246 #define UAC3_FUNCTION_SUBCLASS_HEADSET 0x24
247 #define UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER 0x25
248 #define UAC3_FUNCTION_SUBCLASS_SPEAKERPHONE 0x26
250 /* A.7 AUDIO FUNCTION CATEGORY CODES */
251 #define UAC3_FUNCTION_SUBCLASS_UNDEFINED 0x00
252 #define UAC3_FUNCTION_DESKTOP_SPEAKER 0x01
253 #define UAC3_FUNCTION_HOME_THEATER 0x02
254 #define UAC3_FUNCTION_MICROPHONE 0x03
255 #define UAC3_FUNCTION_HEADSET 0x04
256 #define UAC3_FUNCTION_TELEPHONE 0x05
257 #define UAC3_FUNCTION_CONVERTER 0x06
258 #define UAC3_FUNCTION_SOUND_RECORDER 0x07
259 #define UAC3_FUNCTION_IO_BOX 0x08
260 #define UAC3_FUNCTION_MUSICAL_INSTRUMENT 0x09
261 #define UAC3_FUNCTION_PRO_AUDIO 0x0a
262 #define UAC3_FUNCTION_AUDIO_VIDEO 0x0b
263 #define UAC3_FUNCTION_CONTROL_PANEL 0x0c
264 #define UAC3_FUNCTION_HEADPHONE 0x0d
265 #define UAC3_FUNCTION_GENERIC_SPEAKER 0x0e
266 #define UAC3_FUNCTION_HEADSET_ADAPTER 0x0f
267 #define UAC3_FUNCTION_SPEAKERPHONE 0x10
268 #define UAC3_FUNCTION_OTHER 0xff
270 /* A.8 AUDIO CLASS-SPECIFIC DESCRIPTOR TYPES */
271 #define UAC3_CS_UNDEFINED 0x20
272 #define UAC3_CS_DEVICE 0x21
273 #define UAC3_CS_CONFIGURATION 0x22
274 #define UAC3_CS_STRING 0x23
275 #define UAC3_CS_INTERFACE 0x24
276 #define UAC3_CS_ENDPOINT 0x25
277 #define UAC3_CS_CLUSTER 0x26
279 /* A.10 CLUSTER DESCRIPTOR SEGMENT TYPES */
280 #define UAC3_SEGMENT_UNDEFINED 0x00
281 #define UAC3_CLUSTER_DESCRIPTION 0x01
282 #define UAC3_CLUSTER_VENDOR_DEFINED 0x1F
283 #define UAC3_CHANNEL_INFORMATION 0x20
284 #define UAC3_CHANNEL_AMBISONIC 0x21
285 #define UAC3_CHANNEL_DESCRIPTION 0x22
286 #define UAC3_CHANNEL_VENDOR_DEFINED 0xFE
287 #define UAC3_END_SEGMENT 0xFF
289 /* A.11 CHANNEL PURPOSE DEFINITIONS */
290 #define UAC3_PURPOSE_UNDEFINED 0x00
291 #define UAC3_PURPOSE_GENERIC_AUDIO 0x01
292 #define UAC3_PURPOSE_VOICE 0x02
293 #define UAC3_PURPOSE_SPEECH 0x03
294 #define UAC3_PURPOSE_AMBIENT 0x04
295 #define UAC3_PURPOSE_REFERENCE 0x05
296 #define UAC3_PURPOSE_ULTRASONIC 0x06
297 #define UAC3_PURPOSE_VIBROKINETIC 0x07
298 #define UAC3_PURPOSE_NON_AUDIO 0xFF
300 /* A.12 CHANNEL RELATIONSHIP DEFINITIONS */
301 #define UAC3_CH_RELATIONSHIP_UNDEFINED 0x00
302 #define UAC3_CH_MONO 0x01
303 #define UAC3_CH_LEFT 0x02
304 #define UAC3_CH_RIGHT 0x03
305 #define UAC3_CH_ARRAY 0x04
306 #define UAC3_CH_PATTERN_X 0x20
307 #define UAC3_CH_PATTERN_Y 0x21
308 #define UAC3_CH_PATTERN_A 0x22
309 #define UAC3_CH_PATTERN_B 0x23
310 #define UAC3_CH_PATTERN_M 0x24
311 #define UAC3_CH_PATTERN_S 0x25
312 #define UAC3_CH_FRONT_LEFT 0x80
313 #define UAC3_CH_FRONT_RIGHT 0x81
314 #define UAC3_CH_FRONT_CENTER 0x82
315 #define UAC3_CH_FRONT_LEFT_OF_CENTER 0x83
316 #define UAC3_CH_FRONT_RIGHT_OF_CENTER 0x84
317 #define UAC3_CH_FRONT_WIDE_LEFT 0x85
318 #define UAC3_CH_FRONT_WIDE_RIGHT 0x86
319 #define UAC3_CH_SIDE_LEFT 0x87
320 #define UAC3_CH_SIDE_RIGHT 0x88
321 #define UAC3_CH_SURROUND_ARRAY_LEFT 0x89
322 #define UAC3_CH_SURROUND_ARRAY_RIGHT 0x8A
323 #define UAC3_CH_BACK_LEFT 0x8B
324 #define UAC3_CH_BACK_RIGHT 0x8C
325 #define UAC3_CH_BACK_CENTER 0x8D
326 #define UAC3_CH_BACK_LEFT_OF_CENTER 0x8E
327 #define UAC3_CH_BACK_RIGHT_OF_CENTER 0x8F
328 #define UAC3_CH_BACK_WIDE_LEFT 0x90
329 #define UAC3_CH_BACK_WIDE_RIGHT 0x91
330 #define UAC3_CH_TOP_CENTER 0x92
331 #define UAC3_CH_TOP_FRONT_LEFT 0x93
332 #define UAC3_CH_TOP_FRONT_RIGHT 0x94
333 #define UAC3_CH_TOP_FRONT_CENTER 0x95
334 #define UAC3_CH_TOP_FRONT_LOC 0x96
335 #define UAC3_CH_TOP_FRONT_ROC 0x97
336 #define UAC3_CH_TOP_FRONT_WIDE_LEFT 0x98
337 #define UAC3_CH_TOP_FRONT_WIDE_RIGHT 0x99
338 #define UAC3_CH_TOP_SIDE_LEFT 0x9A
339 #define UAC3_CH_TOP_SIDE_RIGHT 0x9B
340 #define UAC3_CH_TOP_SURR_ARRAY_LEFT 0x9C
341 #define UAC3_CH_TOP_SURR_ARRAY_RIGHT 0x9D
342 #define UAC3_CH_TOP_BACK_LEFT 0x9E
343 #define UAC3_CH_TOP_BACK_RIGHT 0x9F
344 #define UAC3_CH_TOP_BACK_CENTER 0xA0
345 #define UAC3_CH_TOP_BACK_LOC 0xA1
346 #define UAC3_CH_TOP_BACK_ROC 0xA2
347 #define UAC3_CH_TOP_BACK_WIDE_LEFT 0xA3
348 #define UAC3_CH_TOP_BACK_WIDE_RIGHT 0xA4
349 #define UAC3_CH_BOTTOM_CENTER 0xA5
350 #define UAC3_CH_BOTTOM_FRONT_LEFT 0xA6
351 #define UAC3_CH_BOTTOM_FRONT_RIGHT 0xA7
352 #define UAC3_CH_BOTTOM_FRONT_CENTER 0xA8
353 #define UAC3_CH_BOTTOM_FRONT_LOC 0xA9
354 #define UAC3_CH_BOTTOM_FRONT_ROC 0xAA
355 #define UAC3_CH_BOTTOM_FRONT_WIDE_LEFT 0xAB
356 #define UAC3_CH_BOTTOM_FRONT_WIDE_RIGHT 0xAC
357 #define UAC3_CH_BOTTOM_SIDE_LEFT 0xAD
358 #define UAC3_CH_BOTTOM_SIDE_RIGHT 0xAE
359 #define UAC3_CH_BOTTOM_SURR_ARRAY_LEFT 0xAF
360 #define UAC3_CH_BOTTOM_SURR_ARRAY_RIGHT 0xB0
361 #define UAC3_CH_BOTTOM_BACK_LEFT 0xB1
362 #define UAC3_CH_BOTTOM_BACK_RIGHT 0xB2
363 #define UAC3_CH_BOTTOM_BACK_CENTER 0xB3
364 #define UAC3_CH_BOTTOM_BACK_LOC 0xB4
365 #define UAC3_CH_BOTTOM_BACK_ROC 0xB5
366 #define UAC3_CH_BOTTOM_BACK_WIDE_LEFT 0xB6
367 #define UAC3_CH_BOTTOM_BACK_WIDE_RIGHT 0xB7
368 #define UAC3_CH_LOW_FREQUENCY_EFFECTS 0xB8
369 #define UAC3_CH_LFE_LEFT 0xB9
370 #define UAC3_CH_LFE_RIGHT 0xBA
371 #define UAC3_CH_HEADPHONE_LEFT 0xBB
372 #define UAC3_CH_HEADPHONE_RIGHT 0xBC
374 /* A.15 AUDIO CLASS-SPECIFIC AC INTERFACE DESCRIPTOR SUBTYPES */
375 /* see audio.h for the rest, which is identical to v1 */
376 #define UAC3_EXTENDED_TERMINAL 0x04
377 #define UAC3_MIXER_UNIT 0x05
378 #define UAC3_SELECTOR_UNIT 0x06
379 #define UAC3_FEATURE_UNIT 0x07
380 #define UAC3_EFFECT_UNIT 0x08
381 #define UAC3_PROCESSING_UNIT 0x09
382 #define UAC3_EXTENSION_UNIT 0x0a
383 #define UAC3_CLOCK_SOURCE 0x0b
384 #define UAC3_CLOCK_SELECTOR 0x0c
385 #define UAC3_CLOCK_MULTIPLIER 0x0d
386 #define UAC3_SAMPLE_RATE_CONVERTER 0x0e
387 #define UAC3_CONNECTORS 0x0f
388 #define UAC3_POWER_DOMAIN 0x10
390 /* A.20 PROCESSING UNIT PROCESS TYPES */
391 #define UAC3_PROCESS_UNDEFINED 0x00
392 #define UAC3_PROCESS_UP_DOWNMIX 0x01
393 #define UAC3_PROCESS_STEREO_EXTENDER 0x02
394 #define UAC3_PROCESS_MULTI_FUNCTION 0x03
396 /* A.22 AUDIO CLASS-SPECIFIC REQUEST CODES */
397 /* see audio-v2.h for the rest, which is identical to v2 */
398 #define UAC3_CS_REQ_INTEN 0x04
399 #define UAC3_CS_REQ_STRING 0x05
400 #define UAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR 0x06
402 /* A.23.1 AUDIOCONTROL INTERFACE CONTROL SELECTORS */
403 #define UAC3_AC_CONTROL_UNDEFINED 0x00
404 #define UAC3_AC_ACTIVE_INTERFACE_CONTROL 0x01
405 #define UAC3_AC_POWER_DOMAIN_CONTROL 0x02
407 /* A.23.5 TERMINAL CONTROL SELECTORS */
408 #define UAC3_TE_UNDEFINED 0x00
409 #define UAC3_TE_INSERTION 0x01
410 #define UAC3_TE_OVERLOAD 0x02
411 #define UAC3_TE_UNDERFLOW 0x03
412 #define UAC3_TE_OVERFLOW 0x04
413 #define UAC3_TE_LATENCY 0x05
415 /* A.23.10 PROCESSING UNITS CONTROL SELECTROS */
418 #define UAC3_UD_MODE_SELECT 0x01
420 /* Stereo Extender */
421 #define UAC3_EXT_WIDTH_CONTROL 0x01
424 /* BADD predefined Unit/Terminal values */
425 #define UAC3_BADD_IT_ID1 1 /* Input Terminal ID1: bTerminalID = 1 */
426 #define UAC3_BADD_FU_ID2 2 /* Feature Unit ID2: bUnitID = 2 */
427 #define UAC3_BADD_OT_ID3 3 /* Output Terminal ID3: bTerminalID = 3 */
428 #define UAC3_BADD_IT_ID4 4 /* Input Terminal ID4: bTerminalID = 4 */
429 #define UAC3_BADD_FU_ID5 5 /* Feature Unit ID5: bUnitID = 5 */
430 #define UAC3_BADD_OT_ID6 6 /* Output Terminal ID6: bTerminalID = 6 */
431 #define UAC3_BADD_FU_ID7 7 /* Feature Unit ID7: bUnitID = 7 */
432 #define UAC3_BADD_MU_ID8 8 /* Mixer Unit ID8: bUnitID = 8 */
433 #define UAC3_BADD_CS_ID9 9 /* Clock Source Entity ID9: bClockID = 9 */
434 #define UAC3_BADD_PD_ID10 10 /* Power Domain ID10: bPowerDomainID = 10 */
435 #define UAC3_BADD_PD_ID11 11 /* Power Domain ID11: bPowerDomainID = 11 */
437 /* BADD wMaxPacketSize of AS endpoints */
438 #define UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_16 0x0060
439 #define UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_16 0x0062
440 #define UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_24 0x0090
441 #define UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_24 0x0093
442 #define UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_16 0x00C0
443 #define UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_16 0x00C4
444 #define UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_24 0x0120
445 #define UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_24 0x0126
447 /* BADD sample rate is always fixed to 48kHz */
448 #define UAC3_BADD_SAMPLING_RATE 48000
450 /* BADD power domains recovery times in 50us increments */
451 #define UAC3_BADD_PD_RECOVER_D1D0 0x0258 /* 30ms */
452 #define UAC3_BADD_PD_RECOVER_D2D0 0x1770 /* 300ms */
454 #endif /* __LINUX_USB_AUDIO_V3_H */