USBLib API Guide  1.00.00.01
usbaudio.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbaudio.h - Definitions used by Audio Class devices.
4 //
5 // Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 //
22 //*****************************************************************************
23 
24 #ifndef __USBAUDIO_H__
25 #define __USBAUDIO_H__
26 
27 
28 //*****************************************************************************
29 //
30 // Standard Audio descriptor sub types.
31 //
32 //*****************************************************************************
33 #define USB_AI_UNDEFINED 0
34 #define USB_AI_HEADER 1
35 #define USB_AI_INPUT_TERMINAL 2
36 #define USB_AI_OUTPUT_TERMINAL 3
37 #define USB_AI_MIXER_UNIT 4
38 #define USB_AI_SELECTOR_UNIT 5
39 #define USB_AI_FEATURE_UNIT 6
40 #define USB_AI_PROCESSING_UNIT 7
41 #define USB_AI_EXTENSION_UNIT 8
42 
43 //*****************************************************************************
44 //
45 // Standard Audio Streaming Interface descriptor types.
46 //
47 //*****************************************************************************
48 #define USB_AS_UNDEFINED 0
49 #define USB_AS_GENERAL 1
50 #define USB_AS_FORMAT_TYPE 2
51 #define USB_AS_FORMAT_SPECIFIC 3
52 
53 //*****************************************************************************
54 //
55 // Standard USB terminal types used with audio terminal descriptors. These
56 // are defined in the "Universal Serial Bus Device Class Definition for
57 // Terminal Types" version 1.0 released March 18, 1998.
58 //
59 //*****************************************************************************
60 #define USB_TTYPE_UNDEFINED 0x0100
61 #define USB_TTYPE_STREAMING 0x0101
62 #define USB_TTYPE_VENDOR 0x01ff
63 
64 #define USB_TTYPE_OUT_UNDEF 0x0300
65 #define USB_TTYPE_OUT_SPEAKER 0x0301
66 #define USB_TTYPE_OUT_HEADPHONE 0x0302
67 #define USB_TTYPE_OUT_DESK_SPKR 0x0304
68 #define USB_TTYPE_OUT_ROOM_SPKR 0x0305
69 #define USB_TTYPE_OUT_COMM_SPKR 0x0306
70 #define USB_TTYPE_OUT_LFE 0x0307
71 
72 #define USB_TTYPE_EXT_UNDEF 0x0600
73 #define USB_TTYPE_EXT_ANALOG 0x0601
74 #define USB_TTYPE_EXT_DIGITAL 0x0602
75 #define USB_TTYPE_EXT_LINE 0x0603
76 #define USB_TTYPE_EXT_LEGACY 0x0604
77 #define USB_TTYPE_EXT_SPDIF 0x0605
78 #define USB_TTYPE_EXT_1394_DA 0x0606
79 #define USB_TTYPE_EXT_1394_DV 0x0607
80 
81 //*****************************************************************************
82 //
83 // Audio Interface Subclass Codes
84 //
85 //*****************************************************************************
86 #define USB_ASC_UNDEFINED 0x00
87 #define USB_ASC_AUDIO_CONTROL 0x01
88 #define USB_ASC_AUDIO_STREAMING 0x02
89 #define USB_ASC_MIDI_STREAMING 0x03
90 
91 //*****************************************************************************
92 //
93 // Audio Class-Specific Descriptor Types
94 // (Table A-4)
95 //
96 //*****************************************************************************
97 #define USB_ACSDT_UNDEFINED 0x20
98 #define USB_ACSDT_DEVICE 0x21
99 #define USB_ACSDT_CONFIGURATION 0x22
100 #define USB_ACSDT_STRING 0x23
101 #define USB_ACSDT_INTERFACE 0x24
102 #define USB_ACSDT_ENDPOINT 0x25
103 
104 //*****************************************************************************
105 //
106 // Audio Class-Specific AC Interface Descriptor Subtypes
107 // (Table A-5)
108 //
109 //*****************************************************************************
110 #define USB_ACDSTYPE_UNDEFINED 0x00
111 #define USB_ACDSTYPE_HEADER 0x01
112 #define USB_ACDSTYPE_IN_TERMINAL 0x02
113 #define USB_ACDSTYPE_OUT_TERMINAL 0x03
114 #define USB_ACDSTYPE_MIXER_UNIT 0x04
115 #define USB_ACDSTYPE_SELECTOR_UNIT 0x05
116 #define USB_ACDSTYPE_FEATURE_UNIT 0x06
117 #define USB_ACDSTYPE_PROCESSING_UNIT 0x07
118 #define USB_ACDSTYPE_EXTENSION_UNIT 0x08
119 
120 //*****************************************************************************
121 //
122 // Audio Class-Specific AS Interface Descriptor Subtypes
123 // (Table A-6)
124 //
125 //*****************************************************************************
126 #define USB_ASDSTYPE_UNDEFINED 0x00
127 #define USB_ASDSTYPE_GENERAL 0x01
128 #define USB_ASDSTYPE_FORMAT_TYPE 0x02
129 #define USB_ASDSTYPE_FORMAT_SPECIFIC 0x03
130 
131 //*****************************************************************************
132 //
133 // Audio Data Format Type I Codes.
134 //
135 //*****************************************************************************
136 #define USB_ADF_UNDEFINED 0x0000
137 #define USB_ADF_PCM 0x0001
138 #define USB_ADF_PCM8 0x0002
139 #define USB_ADF_IEEE_FLOAT 0x0003
140 #define USB_ADF_ALAW 0x0004
141 #define USB_ADF_MULAW 0x0005
142 
143 //*****************************************************************************
144 //
145 // Audio Format Type Codes
146 //
147 //*****************************************************************************
148 #define USB_AF_TYPE_UNDEFINED 0x00
149 #define USB_AF_TYPE_TYPE_I 0x01
150 #define USB_AF_TYPE_TYPE_II 0x02
151 #define USB_AF_TYPE_TYPE_III 0x03
152 
153 //*****************************************************************************
154 //
155 // Audio Class-Specific controls used with bmaControls values.
156 //
157 //*****************************************************************************
158 #define USB_ACONTROL_MUTE 0x0001 // Mute
159 #define USB_ACONTROL_VOLUME 0x0002 // Volume
160 #define USB_ACONTROL_BASS 0x0004 // Bass
161 #define USB_ACONTROL_MID 0x0008 // Mid
162 #define USB_ACONTROL_TREBLE 0x0010 // Treble
163 #define USB_ACONTROL_EQ 0x0020 // Graphic Equalizer
164 #define USB_ACONTROL_AGC 0x0040 // Automatic Gain
165 #define USB_ACONTROL_DELAY 0x0080 // Delay
166 #define USB_ACONTROL_BASS_BOOST 0x0100 // Bass Boost
167 #define USB_ACONTROL_LOUD 0x0200 // Loudness
168 
169 //*****************************************************************************
170 //
171 // Audio Class-Specific Output terminal types.
172 //
173 //*****************************************************************************
174 #define USB_ATTYPE_UNDEFINED 0x0300 // Output Terminal, undefined Type.
175 #define USB_ATTYPE_SPEAKER 0x0301 // A generic speaker.
176 #define USB_ATTYPE_HEADPHONES 0x0302 // A head-mounted audio output device.
177 #define USB_ATTYPE_HMD 0x0303 // The audio part of a VR head mounted
178  // display.
179 #define USB_ATTYPE_SPEAKER_DT 0x0304 // Desktop or Monitor speaker(s).
180 #define USB_ATTYPE_SPEAKER_RM 0x0305 // Larger room speaker(s).
181 #define USB_ATTYPE_SPEAKER_COM 0x0306 // Communications Speaker (phone).
182 #define USB_ATTYPE_SPEAKER_LFE 0x0307 // Speaker designed for low
183  // frequencies.
184 
185 //*****************************************************************************
186 //
187 // USB Audio channel configuration bits for wChannelConfig values.
188 // wChannelConfig: a bit field that indicates which spatial locations are
189 // present in the cluster. The bit allocations are as follows:
190 //
191 //*****************************************************************************
192 #define USB_CHANNEL_L 0x0001 // Left Front (L)
193 #define USB_CHANNEL_R 0x0002 // Right Front (R)
194 #define USB_CHANNEL_C 0x0004 // Center Front (C)
195 #define USB_CHANNEL_LFE 0x0008 // Low Frequency Enhancement (LFE)
196 #define USB_CHANNEL_LS 0x0010 // Left Surround (LS)
197 #define USB_CHANNEL_RS 0x0020 // Right Surround (RS)
198 #define USB_CHANNEL_LC 0x0040 // Left of Center (LC)
199 #define USB_CHANNEL_RC 0x0080 // Right of Center (RC)
200 #define USB_CHANNEL_S 0x0100 // Surround (S)
201 #define USB_CHANNEL_SL 0x0200 // Side Left (SL)
202 #define USB_CHANNEL_SR 0x0400 // Side Right (SR)
203 #define USB_CHANNEL_T 0x0800 // Top (T)
204 
205 //*****************************************************************************
206 //
207 // Endpoint attributes for Audio Class General type.
208 //
209 //*****************************************************************************
210 #define USB_EP_ATTR_ACG_SAMPLING 0x01 // Sampling Frequency
211 #define USB_EP_ATTR_ACG_PITCH 0x02 // Pitch
212 #define USB_EP_ATTR_ACG_MAXPACKET 0x80 // MaxPacketsOnly
213 
214 //*****************************************************************************
215 //
216 // Indicates the units used for the wLockDelay field for Audio Class General
217 // type.
218 //
219 //*****************************************************************************
220 #define USB_EP_LOCKDELAY_UNDEF 0x00 // Undefined
221 #define USB_EP_LOCKDELAY_MS 0x01 // Milliseconds
222 #define USB_EP_LOCKDELAY_PCM 0x02 // Decoded PCM samples
223 
224 //*****************************************************************************
225 //
226 // Audio Class-Specific Request Codes
227 //
228 //*****************************************************************************
229 #define USB_AC_SET_CUR 0x01
230 #define USB_AC_SET_MIN 0x02
231 #define USB_AC_SET_MAX 0x03
232 #define USB_AC_SET_RES 0x04
233 #define USB_AC_SET_MEM 0x05
234 #define USB_AC_GET_CUR 0x81
235 #define USB_AC_GET_MIN 0x82
236 #define USB_AC_GET_MAX 0x83
237 #define USB_AC_GET_RES 0x84
238 #define USB_AC_GET_MEM 0x85
239 #define USB_AC_GET_STAT 0xff
240 
241 #define USB_CS_CONTROL_M 0xff00
242 #define USB_CS_CHANNEL_M 0x00ff
243 
244 //*****************************************************************************
245 //
246 // Endpoint Control Selectors
247 //
248 //*****************************************************************************
249 #define EP_CONTROL_UNDEFINED 0x0000
250 #define SAMPLING_FREQ_CONTROL 0x0100
251 #define PITCH_CONTROL 0x0200
252 
253 //*****************************************************************************
254 //
255 // Feature Unit Control Selectors
256 //
257 //*****************************************************************************
258 #define FU_CONTROL_UNDEFINED 0x0000
259 #define MUTE_CONTROL 0x0100
260 #define VOLUME_CONTROL 0x0200
261 #define BASS_CONTROL 0x0300
262 #define MID_CONTROL 0x0400
263 #define TREBLE_CONTROL 0x0500
264 #define EQUALIZER_CONTROL 0x0600
265 #define AUTOMATIC_GAIN_CONTROL 0x0700
266 #define DELAY_CONTROL 0x0800
267 #define BASS_BOOST_CONTROL 0x0900
268 #define LOUDNESS_CONTROL 0x0A00
269 
270 //*****************************************************************************
271 //
272 // All structures defined in this section of the header require byte packing of
273 // fields. This is usually accomplished using the PACKED macro but, for IAR
274 // Embedded Workbench, this requires a pragma.
275 //
276 //*****************************************************************************
277 #ifdef __ICCARM__
278 #pragma pack(1)
279 #endif
280 
281 //*****************************************************************************
282 //
286 //
287 //*****************************************************************************
288 typedef struct
289 {
290  //
292  //
293  uint8_t bLength;
294 
295  //
298  //
300 
301  //
303  //
305 
306  //
309  //
310  uint16_t bcdADC;
311 
312  //
316  //
317  uint16_t wTotai32Length;
318 
319  //
322  //
323  uint8_t bInCollection;
324 
325  //
328  //
329  uint8_t baInterfaceNr;
330 }
331 PACKED tACHeader;
332 
333 //*****************************************************************************
334 //
335 // These are the possible bits set in the tACInputTerminal.wChannelConfig
336 // value.
337 //
338 //*****************************************************************************
339 #define USB_AC_CC_LEFT 0x0001
340 #define USB_AC_CC_RIGHT 0x0002
341 #define USB_AC_CC_CENTER 0x0004
342 #define USB_AC_CC_LFE 0x0008
343 #define USB_AC_CC_LEFTSURROUND 0x0010
344 #define USB_AC_CC_RIGHTSURROUND 0x0020
345 #define USB_AC_CC_LEFT_CENTER 0x0040
346 #define USB_AC_CC_RIGHT_CENTER 0x0080
347 #define USB_AC_CC_SURROUND 0x0100
348 #define USB_AC_CC_SIDE_LEFT 0x0200
349 #define USB_AC_CC_SIDE_RIGHT 0x0400
350 #define USB_AC_CC_TOP 0x0800
351 
352 //*****************************************************************************
353 //
356 //
357 //*****************************************************************************
358 typedef struct
359 {
360  //
362  //
363  uint8_t bLength;
364 
365  //
368  //
369  uint8_t bDescriptorType;
370 
371  //
373  //
374  uint8_t bDescriptorSubtype;
375 
376  //
379  //
380  uint8_t bUnitID;
381 
382  //
384  //
385  uint8_t bSourceID;
386 
387  //
389  //
390  uint8_t bControlSize;
391 
392  //
397  //
398  uint16_t bmaControls;
399 }
400 PACKED tACFeatureUnit;
401 
402 //*****************************************************************************
403 //
406 //
407 //*****************************************************************************
408 typedef struct
409 {
410  //
412  //
413  uint8_t bLength;
414 
415  //
418  //
419  uint8_t bDescriptorType;
420 
421  //
423  //
424  uint8_t bDescriptorSubtype;
425 
426  //
429  //
430  uint8_t bTerminalID;
431 
432  //
435  //
436  uint16_t wTerminalType;
437 
438  //
441  //
442  uint8_t bAssocTerminal;
443 
444  //
446  //
447  uint8_t bSourceID;
448 
449  //
451  //
452  uint8_t iTerminal;
453 }
454 PACKED tACOutputTerminal;
455 
456 //*****************************************************************************
457 //
460 //
461 //*****************************************************************************
462 typedef struct
463 {
464  //
466  //
467  uint8_t bLength;
468 
469  //
472  //
473  uint8_t bDescriptorType;
474 
475  //
477  //
478  uint8_t bDescriptorSubtype;
479 
480  //
483  //
484  uint8_t bTerminalID;
485 
486  //
489  //
490  uint16_t wTerminalType;
491 
492  //
495  //
496  uint8_t bAssocTerminal;
497 
498  //
501  //
502  uint8_t bNrChannels;
503 
504  //
506  //
507  uint16_t wChannelConfig;
508 
509  //
512  //
513  uint8_t iChannelNames;
514 
515  //
517  //
518  uint8_t iTerminal;
519 }
520 PACKED tACInputTerminal;
521 
522 //*****************************************************************************
523 //
526 //
527 //*****************************************************************************
528 typedef struct
529 {
530  //
532  //
533  uint8_t bLength;
534 
535  //
538  //
539  uint8_t bDescriptorType;
540 
541  //
543  //
544  uint8_t bDescriptorSubtype;
545 
546  //
549  //
550  uint8_t bUnitID;
551 
552  //
554  //
555  uint8_t bNrInPins;
556 
557  //
560  //
561  uint8_t baSourceID;
562 }
563 PACKED tACMixer;
564 
565 //*****************************************************************************
566 //
569 //
570 //*****************************************************************************
571 typedef struct
572 {
573  //
575  //
576  uint8_t bLength;
577 
578  //
581  //
582  uint8_t bDescriptorType;
583 
584  //
586  //
587  uint8_t bDescriptorSubtype;
588 
589  //
592  //
593  uint8_t bUnitID;
594 
595  //
597  //
598  uint8_t bNrInPins;
599 
600  //
603  //
604  uint8_t baSourceID;
605 }
606 PACKED tACSelector;
607 
608 //*****************************************************************************
609 //
612 //
613 //*****************************************************************************
614 typedef struct
615 {
616  //
618  //
619  uint8_t bLength;
620 
621  //
624  //
625  uint8_t bDescriptorType;
626 
627  //
629  //
630  uint8_t bDescriptorSubtype;
631 
632  //
635  //
636  uint8_t bTerminalLink;
637 
638  //
640  //
641  uint8_t bDelay;
642 
643  //
646  //
647  uint16_t wFormatTag;
648 }
649 PACKED tACGeneral;
650 
651 //*****************************************************************************
652 //
655 //
656 //*****************************************************************************
657 typedef struct
658 {
659  //
661  //
662  uint8_t bLength;
663 
664  //
667  //
668  uint8_t bDescriptorType;
669 
670  //
672  //
673  uint8_t bDescriptorSubtype;
674 
675  //
677  //
678  uint8_t bFormatType;
679 
680  //
682  //
683  uint8_t bNrChannels;
684 
685  //
687  //
688  uint8_t bSubFrameSize;
689 
690  //
692  //
693  uint8_t bBitResolution;
694 
695  //
697  //
698  uint8_t bSamFreqType;
699 
700  //
702  //
703  uint8_t tSamFreq;
704 }
705 PACKED tASFormat;
706 
707 //*****************************************************************************
708 //
709 // Return to default packing when using the IAR Embedded Workbench compiler.
710 //
711 //*****************************************************************************
712 #ifdef __ICCARM__
713 #pragma pack()
714 #endif
715 
716 #endif
717 
uint8_t bAssocTerminal
Definition: usbaudio.h:442
uint8_t bDelay
Delay introduced by the data path. Expressed in number of frames.
Definition: usbaudio.h:641
uint8_t bBitResolution
Number of bits per sample.
Definition: usbaudio.h:693
uint8_t baInterfaceNr
Definition: usbaudio.h:329
uint8_t bDescriptorSubtype
This will be USB_DSUBTYPE_HEADER for the header.
Definition: usbaudio.h:304
uint8_t bSubFrameSize
Number of bytes per audio sub-frame or channel.
Definition: usbaudio.h:688
uint16_t bmaControls
Definition: usbaudio.h:398
uint8_t bTerminalLink
Definition: usbaudio.h:636
uint8_t bDescriptorType
Definition: usbaudio.h:299
uint16_t bcdADC
Definition: usbaudio.h:310
uint8_t bTerminalID
Definition: usbaudio.h:430
uint8_t bSamFreqType
Number of sample rates that are supported.
Definition: usbaudio.h:698
uint16_t wFormatTag
Definition: usbaudio.h:647
uint8_t iChannelNames
Definition: usbaudio.h:513
uint16_t wChannelConfig
Describes the spatial location of the logical channels.
Definition: usbaudio.h:507
uint16_t wTerminalType
Definition: usbaudio.h:436
uint8_t bUnitID
Definition: usbaudio.h:380
uint8_t iTerminal
Index of a string descriptor, describing the Output Terminal.
Definition: usbaudio.h:452
uint8_t tSamFreq
Number of bits per sample.
Definition: usbaudio.h:703
uint8_t bSourceID
ID of the Unit or Terminal to which this Feature Unit is connected.
Definition: usbaudio.h:385
uint8_t baSourceID
Definition: usbaudio.h:561
uint8_t bControlSize
ID of the Output Terminal to which this Input Terminal is associated.
Definition: usbaudio.h:390
uint8_t bInCollection
Definition: usbaudio.h:323
uint8_t bNrInPins
Number of Input Pins of this Unit.
Definition: usbaudio.h:555
uint16_t wTotai32Length
Definition: usbaudio.h:317
uint8_t bNrChannels
Number of channels on this streaming interface.
Definition: usbaudio.h:502
uint8_t bFormatType
This will be USB_AS_FORMAT_TYPE_I.
Definition: usbaudio.h:678
USB_CDC_GET/SET_LINE_CODING request-specific data.
Definition: usbdhidgamepad.h:217
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale