uaudioreg.h revision 1.18 1 /* $NetBSD: uaudioreg.h,v 1.18 2023/04/10 15:14:50 mlelstv Exp $ */
2
3 /*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart (at) augustsson.net) at
9 * Carlstedt Research & Technology.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #define UAUDIO_VERSION1 0x100
34 #define UAUDIO_VERSION2 0x200
35
36 #define UDESC_CS_CONFIG 0x22
37 #define UDESC_CS_STRING 0x23
38 #define UDESC_CS_INTERFACE 0x24
39 #define UDESC_CS_ENDPOINT 0x25
40
41 #define UDESCSUB_AC_HEADER 1
42 #define UDESCSUB_AC_INPUT 2
43 #define UDESCSUB_AC_OUTPUT 3
44 #define UDESCSUB_AC_MIXER 4
45 #define UDESCSUB_AC_SELECTOR 5
46 #define UDESCSUB_AC_FEATURE 6
47 #define UDESCSUB_AC_EFFECT 7
48 #define UDESCSUB_AC_PROCESSING 8
49 #define UDESCSUB_AC_EXTENSION 9
50 #define UDESCSUB_AC_CLKSRC 10
51 #define UDESCSUB_AC_CLKSEL 11
52 #define UDESCSUB_AC_CLKMULT 12
53 #define UDESCSUB_AC_RATECONV 13
54
55 /* The first fields are identical to usb_endpoint_descriptor_t */
56 typedef struct {
57 uByte bLength;
58 uByte bDescriptorType;
59 uByte bEndpointAddress;
60 uByte bmAttributes;
61 uWord wMaxPacketSize;
62 uByte bInterval;
63 /*
64 * The following two entries are only used by the Audio Class.
65 * And according to the specs the Audio Class is the only one
66 * allowed to extend the endpoint descriptor.
67 * Who knows what goes on in the minds of the people in the USB
68 * standardization? :-(
69 */
70 uByte bRefresh;
71 uByte bSynchAddress;
72 } UPACKED usb_endpoint_descriptor_audio_t;
73
74 /* generic, for iteration */
75 typedef struct {
76 uByte bLength;
77 uByte bDescriptorType;
78 uByte bDescriptorSubtype;
79 } UPACKED uaudio_cs_descriptor_t;
80
81 struct usb_audio_control_descriptor {
82 uByte bLength;
83 uByte bDescriptorType;
84 uByte bDescriptorSubtype;
85 uWord bcdADC;
86 uWord wTotalLength;
87 uByte bInCollection;
88 uByte baInterfaceNr[1];
89 } UPACKED;
90
91 struct usb_audio_streaming_interface_v1_descriptor {
92 uByte bLength;
93 uByte bDescriptorType;
94 uByte bDescriptorSubtype;
95 uByte bTerminalLink;
96 uByte bDelay;
97 uWord wFormatTag;
98 } UPACKED;
99
100 struct usb_audio_streaming_interface_v2_descriptor {
101 uByte bLength;
102 uByte bDescriptorType;
103 uByte bDescriptorSubtype;
104 uByte bTerminalLink;
105 uByte bmControls;
106 uByte bFormatType;
107 uDWord bmFormats;
108 uByte bNrChannels;
109 uDWord bmChannelConfig;
110 uByte iChannelNames;
111 } UPACKED;
112
113 union usb_audio_streaming_interface_descriptor {
114 struct usb_audio_streaming_interface_v1_descriptor v1;
115 struct usb_audio_streaming_interface_v2_descriptor v2;
116 };
117
118 struct usb_audio_streaming_endpoint_descriptor {
119 uByte bLength;
120 uByte bDescriptorType;
121 uByte bDescriptorSubtype;
122 uByte bmAttributes;
123 #define UA_SED_FREQ_CONTROL 0x01
124 #define UA_SED_PITCH_CONTROL 0x02
125 #define UA_SED_MAXPACKETSONLY 0x80
126 uByte bLockDelayUnits;
127 uWord wLockDelay;
128 } UPACKED;
129
130 struct usb_audio_streaming_type1_v1_descriptor {
131 uByte bLength;
132 uByte bDescriptorType;
133 uByte bDescriptorSubtype;
134 uByte bFormatType;
135 uByte bNrChannels;
136 uByte bSubFrameSize;
137 uByte bBitResolution;
138 uByte bSamFreqType;
139 #define UA_SAMP_CONTINUOUS 0
140 uByte tSamFreq[3*AUFMT_MAX_FREQUENCIES];
141 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
142 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
143 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
144 } UPACKED;
145
146 struct usb_audio_streaming_type1_v2_descriptor {
147 uByte bLength;
148 uByte bDescriptorType;
149 uByte bDescriptorSubtype;
150 uByte bFormatType;
151 uByte bSubslotSize;
152 uByte bBitResolution;
153 } UPACKED;
154
155 union usb_audio_streaming_type1_descriptor {
156 struct usb_audio_streaming_type1_v1_descriptor v1;
157 struct usb_audio_streaming_type1_v2_descriptor v2;
158 };
159
160 struct usb_audio_v1_cluster {
161 uByte bNrChannels;
162 uWord wChannelConfig;
163 #define UA_CHANNEL_LEFT 0x0001
164 #define UA_CHANNEL_RIGHT 0x0002
165 #define UA_CHANNEL_CENTER 0x0004
166 #define UA_CHANNEL_LFE 0x0008
167 #define UA_CHANNEL_L_SURROUND 0x0010
168 #define UA_CHANNEL_R_SURROUND 0x0020
169 #define UA_CHANNEL_L_CENTER 0x0040
170 #define UA_CHANNEL_R_CENTER 0x0080
171 #define UA_CHANNEL_SURROUND 0x0100
172 #define UA_CHANNEL_L_SIDE 0x0200
173 #define UA_CHANNEL_R_SIDE 0x0400
174 #define UA_CHANNEL_TOP 0x0800
175 uByte iChannelNames;
176 } UPACKED;
177
178 struct usb_audio_v2_cluster {
179 uByte bNrChannels;
180 uDWord bmChannelConfig;
181 /*#define UA_CHANNEL_LEFT 0x00000001 */
182 /*#define UA_CHANNEL_RIGHT 0x00000002 */
183 /*#define UA_CHANNEL_CENTER 0x00000004 */
184 /*#define UA_CHANNEL_LFE 0x00000008 */
185 #define UA_CHANNEL_BL 0x00000010
186 #define UA_CHANNEL_BR 0x00000020
187 #define UA_CHANNEL_FLC 0x00000040
188 #define UA_CHANNEL_FRC 0x00000080
189 #define UA_CHANNEL_BC 0x00000100
190 #define UA_CHANNEL_SL 0x00000200
191 #define UA_CHANNEL_SR 0x00000400
192 #define UA_CHANNEL_TC 0x00000800
193 #define UA_CHANNEL_TFL 0x00001000
194 #define UA_CHANNEL_TFC 0x00002000
195 #define UA_CHANNEL_TFR 0x00004000
196 #define UA_CHANNEL_TBL 0x00008000
197 #define UA_CHANNEL_TBC 0x00010000
198 #define UA_CHANNEL_TBR 0x00020000
199 #define UA_CHANNEL_TFLC 0x00040000
200 #define UA_CHANNEL_TFRC 0x00080000
201 #define UA_CHANNEL_LLFE 0x00100000
202 #define UA_CHANNEL_RLFE 0x00200000
203 #define UA_CHANNEL_TSL 0x00400000
204 #define UA_CHANNEL_TSR 0x00800000
205 #define UA_CHANNEL_BOTTOM 0x01000000
206 #define UA_CHANNEL_BOTTOMLC 0x02000000
207 #define UA_CHANNEL_BOTTOMRC 0x04000000
208 #define UA_CHANNEL_RD 0x80000000
209 uByte iChannelNames;
210 } UPACKED;
211
212 union usb_audio_cluster {
213 struct usb_audio_v1_cluster v1;
214 struct usb_audio_v2_cluster v2;
215 };
216
217 /* Shared by all units and terminals */
218 struct usb_audio_unit {
219 uByte bLength;
220 uByte bDescriptorType;
221 uByte bDescriptorSubtype;
222 uByte bUnitId;
223 };
224
225 /* UDESCSUB_AC_INPUT */
226 struct usb_audio_input_v1_terminal {
227 uByte bLength;
228 uByte bDescriptorType;
229 uByte bDescriptorSubtype;
230 uByte bTerminalId;
231 uWord wTerminalType;
232 uByte bAssocTerminal;
233 uByte bNrChannels;
234 uWord wChannelConfig;
235 uByte iChannelNames;
236 uByte iTerminal;
237 } UPACKED;
238 struct usb_audio_input_v2_terminal {
239 uByte bLength;
240 uByte bDescriptorType;
241 uByte bDescriptorSubtype;
242 uByte bTerminalId;
243 uWord wTerminalType;
244 uByte bAssocTerminal;
245 uByte bCSourceId;
246 uByte bNrChannels;
247 uDWord bmChannelConfig;
248 uByte iChannelNames;
249 uWord bmControls;
250 uByte iTerminal;
251 } UPACKED;
252
253 union usb_audio_input_terminal {
254 struct usb_audio_input_v1_terminal v1;
255 struct usb_audio_input_v2_terminal v2;
256 };
257
258 /* UDESCSUB_AC_OUTPUT */
259 struct usb_audio_output_v1_terminal {
260 uByte bLength;
261 uByte bDescriptorType;
262 uByte bDescriptorSubtype;
263 uByte bTerminalId;
264 uWord wTerminalType;
265 uByte bAssocTerminal;
266 uByte bSourceId;
267 uByte iTerminal;
268 } UPACKED;
269 struct usb_audio_output_v2_terminal {
270 uByte bLength;
271 uByte bDescriptorType;
272 uByte bDescriptorSubtype;
273 uByte bTerminalId;
274 uWord wTerminalType;
275 uByte bAssocTerminal;
276 uByte bSourceId;
277 uByte bCSourceId;
278 uWord bmControls;
279 uByte iTerminal;
280 } UPACKED;
281
282 union usb_audio_output_terminal {
283 struct usb_audio_output_v1_terminal v1;
284 struct usb_audio_output_v2_terminal v2;
285 };
286
287 /* UDESCSUB_AC_MIXER */
288 struct usb_audio_mixer_unit {
289 uByte bLength;
290 uByte bDescriptorType;
291 uByte bDescriptorSubtype;
292 uByte bUnitId;
293 uByte bNrInPins;
294 uByte baSourceId[255]; /* [bNrInPins] */
295 /* union usb_audio_mixer_unit_1 */
296 } UPACKED;
297 struct usb_audio_mixer_v1_unit_1 {
298 uByte bNrChannels;
299 uWord wChannelConfig;
300 uByte iChannelNames;
301 uByte bmControls[255]; /* [bNrChannels] */
302 /*uByte iMixer;*/
303 } UPACKED;
304 struct usb_audio_mixer_v2_unit_1 {
305 uByte bNrChannels;
306 uDWord bmChannelConfig;
307 uByte iChannelNames;
308 uByte bmControls[255]; /* [bNrChannels] */
309 /*uByte iMixer;*/
310 } UPACKED;
311
312 union usb_audio_mixer_unit_1 {
313 struct usb_audio_mixer_v1_unit_1 v1;
314 struct usb_audio_mixer_v2_unit_1 v2;
315 };
316
317 /* UDESCSUB_AC_SELECTOR */
318 struct usb_audio_selector_unit {
319 uByte bLength;
320 uByte bDescriptorType;
321 uByte bDescriptorSubtype;
322 uByte bUnitId;
323 uByte bNrInPins;
324 uByte baSourceId[255]; /* [bNrInPins] */
325 /* uByte iSelector; */
326 } UPACKED;
327
328 /* UDESCSUB_AC_FEATURE */
329 struct usb_audio_feature_unit {
330 uByte bLength;
331 uByte bDescriptorType;
332 uByte bDescriptorSubtype;
333 uByte bUnitId;
334 uByte bSourceId;
335 uByte bControlSize;
336 uByte bmaControls[255]; /* size for more than enough */
337 /* uByte iFeature; */
338 } UPACKED;
339
340 /* UDESCSUB_AC_PROCESSING */
341 struct usb_audio_processing_unit {
342 uByte bLength;
343 uByte bDescriptorType;
344 uByte bDescriptorSubtype;
345 uByte bUnitId;
346 uWord wProcessType;
347 uByte bNrInPins;
348 uByte baSourceId[255]; /* [bNrInPins] */
349 /* struct usb_audio_processing_unit_1 */
350 } UPACKED;
351 struct usb_audio_processing_unit_1{
352 uByte bNrChannels;
353 uWord wChannelConfig;
354 uByte iChannelNames;
355 uByte bControlSize;
356 uByte bmControls[255]; /* [bControlSize] */
357 #define UA_PROC_ENABLE_MASK 1
358 } UPACKED;
359
360 struct usb_audio_processing_unit_updown {
361 uByte iProcessing;
362 uByte bNrModes;
363 uWord waModes[255]; /* [bNrModes] */
364 } UPACKED;
365
366 /* UDESCSUB_AC_EXTENSION */
367 struct usb_audio_extension_unit {
368 uByte bLength;
369 uByte bDescriptorType;
370 uByte bDescriptorSubtype;
371 uByte bUnitId;
372 uWord wExtensionCode;
373 uByte bNrInPins;
374 uByte baSourceId[255]; /* [bNrInPins] */
375 /* struct usb_audio_extension_unit_1 */
376 } UPACKED;
377 struct usb_audio_extension_unit_1 {
378 uByte bNrChannels;
379 uWord wChannelConfig;
380 uByte iChannelNames;
381 uByte bControlSize;
382 uByte bmControls[255]; /* [bControlSize] */
383 #define UA_EXT_ENABLE_MASK 1
384 #define UA_EXT_ENABLE 1
385 /*uByte iExtension;*/
386 } UPACKED;
387
388 /* UDESCSUB_AC_CLKSRC */
389 struct usb_audio_clksrc_unit {
390 uByte bLength;
391 uByte bDescriptorType;
392 uByte bDescriptorSubtype;
393 uByte bClockId;
394 uByte bmAttributes;
395 uByte bmControls;
396 uByte bAssocTerminal;
397 uByte iClockSource;
398 } UPACKED;
399
400 /* UDESCSUB_AC_CLKSEL */
401 struct usb_audio_clksel_unit {
402 uByte bLength;
403 uByte bDescriptorType;
404 uByte bDescriptorSubtype;
405 uByte bClockId;
406 uByte bNrInPins;
407 uByte baCSourceId[255];
408 /*uByte bmControls;*/
409 /*uByte iClockSelector;*/
410 } UPACKED;
411
412 /* UDESCSUB_AC_CLKMULT */
413 struct usb_audio_clkmult_unit {
414 uByte bLength;
415 uByte bDescriptorType;
416 uByte bDescriptorSubtype;
417 uByte bClockId;
418 uByte bCSourceId;
419 uByte bmControls;
420 uByte iClockMultiplier;
421 } UPACKED;
422
423 /* USB terminal types */
424 #define UAT_UNDEFINED 0x0100
425 #define UAT_STREAM 0x0101
426 #define UAT_VENDOR 0x01ff
427 /* input terminal types */
428 #define UATI_UNDEFINED 0x0200
429 #define UATI_MICROPHONE 0x0201
430 #define UATI_DESKMICROPHONE 0x0202
431 #define UATI_PERSONALMICROPHONE 0x0203
432 #define UATI_OMNIMICROPHONE 0x0204
433 #define UATI_MICROPHONEARRAY 0x0205
434 #define UATI_PROCMICROPHONEARR 0x0206
435 /* output terminal types */
436 #define UATO_UNDEFINED 0x0300
437 #define UATO_SPEAKER 0x0301
438 #define UATO_HEADPHONES 0x0302
439 #define UATO_DISPLAYAUDIO 0x0303
440 #define UATO_DESKTOPSPEAKER 0x0304
441 #define UATO_ROOMSPEAKER 0x0305
442 #define UATO_COMMSPEAKER 0x0306
443 #define UATO_SUBWOOFER 0x0307
444 /* bidir terminal types */
445 #define UATB_UNDEFINED 0x0400
446 #define UATB_HANDSET 0x0401
447 #define UATB_HEADSET 0x0402
448 #define UATB_SPEAKERPHONE 0x0403
449 #define UATB_SPEAKERPHONEESUP 0x0404
450 #define UATB_SPEAKERPHONEECANC 0x0405
451 /* telephony terminal types */
452 #define UATT_UNDEFINED 0x0500
453 #define UATT_PHONELINE 0x0501
454 #define UATT_TELEPHONE 0x0502
455 #define UATT_DOWNLINEPHONE 0x0503
456 /* external terminal types */
457 #define UATE_UNDEFINED 0x0600
458 #define UATE_ANALOGCONN 0x0601
459 #define UATE_DIGITALAUIFC 0x0602
460 #define UATE_LINECONN 0x0603
461 #define UATE_LEGACYCONN 0x0604
462 #define UATE_SPDIF 0x0605
463 #define UATE_1394DA 0x0606
464 #define UATE_1394DV 0x0607
465 /* embedded function terminal types */
466 #define UATF_UNDEFINED 0x0700
467 #define UATF_CALIBNOISE 0x0701
468 #define UATF_EQUNOISE 0x0702
469 #define UATF_CDPLAYER 0x0703
470 #define UATF_DAT 0x0704
471 #define UATF_DCC 0x0705
472 #define UATF_MINIDISK 0x0706
473 #define UATF_ANALOGTAPE 0x0707
474 #define UATF_PHONOGRAPH 0x0708
475 #define UATF_VCRAUDIO 0x0709
476 #define UATF_VIDEODISCAUDIO 0x070a
477 #define UATF_DVDAUDIO 0x070b
478 #define UATF_TVTUNERAUDIO 0x070c
479 #define UATF_SATELLITE 0x070d
480 #define UATF_CABLETUNER 0x070e
481 #define UATF_DSS 0x070f
482 #define UATF_RADIORECV 0x0710
483 #define UATF_RADIOXMIT 0x0711
484 #define UATF_MULTITRACK 0x0712
485 #define UATF_SYNTHESIZER 0x0713
486
487
488 #define SET_CUR 0x01
489 #define GET_CUR 0x81
490 #define SET_MIN 0x02
491 #define GET_MIN 0x82
492 #define SET_MAX 0x03
493 #define GET_MAX 0x83
494 #define SET_RES 0x04
495 #define GET_RES 0x84
496 #define SET_MEM 0x05
497 #define GET_MEM 0x85
498 #define GET_STAT 0xff
499 #define V2_CUR 0x01
500 #define V2_RANGES 0x02
501
502 #define V2_CUR_CLKFREQ 0x01
503 #define V2_CUR_CLKSEL 0x01
504
505
506 #define MUTE_CONTROL 0x01
507 #define VOLUME_CONTROL 0x02
508 #define BASS_CONTROL 0x03
509 #define MID_CONTROL 0x04
510 #define TREBLE_CONTROL 0x05
511 #define GRAPHIC_EQUALIZER_CONTROL 0x06
512 #define AGC_CONTROL 0x07
513 #define DELAY_CONTROL 0x08
514 #define BASS_BOOST_CONTROL 0x09
515 #define LOUDNESS_CONTROL 0x0a
516 #define GAIN_CONTROL 0x0b
517 #define GAINPAD_CONTROL 0x0c
518 #define PHASEINV_CONTROL 0x0d
519
520 #define FU_MASK(u) (1 << ((u)-1))
521
522 #define MASTER_CHAN 0
523
524 #define AS_GENERAL 1
525 #define FORMAT_TYPE 2
526 #define FORMAT_SPECIFIC 3
527
528 #define UA_FMT_PCM 1
529 #define UA_FMT_PCM8 2
530 #define UA_FMT_IEEE_FLOAT 3
531 #define UA_FMT_ALAW 4
532 #define UA_FMT_MULAW 5
533 #define UA_FMT_MPEG 0x1001
534 #define UA_FMT_AC3 0x1002
535
536 #define UA_V2_FMT_PCM 0x01
537 #define UA_V2_FMT_PCM8 0x02
538 #define UA_V2_FMT_IEEE_FLOAT 0x04
539 #define UA_V2_FMT_ALAW 0x08
540 #define UA_V2_FMT_MULAW 0x10
541
542 #define SAMPLING_FREQ_CONTROL 0x01
543 #define PITCH_CONTROL 0x02
544
545 #define FORMAT_TYPE_UNDEFINED 0
546 #define FORMAT_TYPE_I 1
547 #define FORMAT_TYPE_II 2
548 #define FORMAT_TYPE_III 3
549
550 #define UA_PROC_MASK(n) (1<< ((n)-1))
551 #define PROCESS_UNDEFINED 0
552 #define XX_ENABLE_CONTROL 1
553 #define UPDOWNMIX_PROCESS 1
554 #define UD_ENABLE_CONTROL 1
555 #define UD_MODE_SELECT_CONTROL 2
556 #define DOLBY_PROLOGIC_PROCESS 2
557 #define DP_ENABLE_CONTROL 1
558 #define DP_MODE_SELECT_CONTROL 2
559 #define P3D_STEREO_EXTENDER_PROCESS 3
560 #define P3D_ENABLE_CONTROL 1
561 #define P3D_SPACIOUSNESS_CONTROL 2
562 #define REVERBATION_PROCESS 4
563 #define RV_ENABLE_CONTROL 1
564 #define RV_LEVEL_CONTROL 2
565 #define RV_TIME_CONTROL 3
566 #define RV_FEEDBACK_CONTROL 4
567 #define CHORUS_PROCESS 5
568 #define CH_ENABLE_CONTROL 1
569 #define CH_LEVEL_CONTROL 2
570 #define CH_RATE_CONTROL 3
571 #define CH_DEPTH_CONTROL 4
572 #define DYN_RANGE_COMP_PROCESS 6
573 #define DR_ENABLE_CONTROL 1
574 #define DR_COMPRESSION_RATE_CONTROL 2
575 #define DR_MAXAMPL_CONTROL 3
576 #define DR_THRESHOLD_CONTROL 4
577 #define DR_ATTACK_TIME_CONTROL 5
578 #define DR_RELEASE_TIME_CONTROL 6
579