libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
audio.h
Go to the documentation of this file.
1/** @defgroup usb_audio_defines USB Audio Type Definitions
2
3@brief <b>Defined Constants and Types for the USB Audio Type Definitions</b>
4
5@ingroup USB_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2014
10Daniel Thompson <daniel@redfelineninja.org.uk>
11Seb Holzapfel <schnommus@gmail.com>
12
13@date 19 April 2014
14
15LGPL License Terms @ref lgpl_license
16*/
17
18/*
19 * This file is part of the libopencm3 project.
20 *
21 * Copyright (C) 2014 Daniel Thompson <daniel@redfelineninja.org.uk>
22 * Copyright (C) 2018 Seb Holzapfel <schnommus@gmail.com>
23 *
24 * This library is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU Lesser General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
28 *
29 * This library is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * along with this library. If not, see <http://www.gnu.org/licenses/>.
36 */
37
38/**@{*/
39
40#ifndef LIBOPENCM3_USB_AUDIO_H
41#define LIBOPENCM3_USB_AUDIO_H
42
43#include <stdint.h>
44
45/*
46 * Definitions from the USB_AUDIO_ or usb_audio_ namespace come from:
47 * "Universal Serial Bus Class Definitions for Audio Devices, Revision 1.0"
48 */
49
50/* Table A-1: Audio Interface Class Code */
51#define USB_CLASS_AUDIO 0x01
52
53/* Table A-2: Audio Interface Subclass Codes */
54#define USB_AUDIO_SUBCLASS_UNDEFINED 0x00
55#define USB_AUDIO_SUBCLASS_CONTROL 0x01
56#define USB_AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
57#define USB_AUDIO_SUBCLASS_MIDISTREAMING 0x03
58
59/* Table A-4: Audio Class-specific Descriptor Types */
60#define USB_AUDIO_DT_CS_UNDEFINED 0x20
61#define USB_AUDIO_DT_CS_DEVICE 0x21
62#define USB_AUDIO_DT_CS_CONFIGURATION 0x22
63#define USB_AUDIO_DT_CS_STRING 0x23
64#define USB_AUDIO_DT_CS_INTERFACE 0x24
65#define USB_AUDIO_DT_CS_ENDPOINT 0x25
66
67/* Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes */
68#define USB_AUDIO_TYPE_AC_DESCRIPTOR_UNDEFINED 0x00
69#define USB_AUDIO_TYPE_HEADER 0x01
70#define USB_AUDIO_TYPE_INPUT_TERMINAL 0x02
71#define USB_AUDIO_TYPE_OUTPUT_TERMINAL 0x03
72#define USB_AUDIO_TYPE_MIXER_UNIT 0x04
73#define USB_AUDIO_TYPE_SELECTOR_UNIT 0x05
74#define USB_AUDIO_TYPE_FEATURE_UNIT 0x06
75#define USB_AUDIO_TYPE_PROCESSING_UNIT 0x07
76#define USB_AUDIO_TYPE_EXTENSION_UNIT 0x08
77
78/* Table 4-2: Class-Specific AC Interface Header Descriptor (head) */
80 uint8_t bLength;
83 uint16_t bcdADC;
84 uint16_t wTotalLength;
86 /* ... */
87} __attribute__((packed));
88
89/* Table 4-2: Class-Specific AC Interface Header Descriptor (body) */
91 /* ... */
93} __attribute__((packed));
94
95/* Table 4-3: Input Terminal Descriptor */
97 uint8_t bLength;
100 uint8_t bTerminalID;
103 uint8_t bNrChannels;
106 uint8_t iTerminal;
107} __attribute__((packed));
108
109/* Table 4-3: Output Terminal Descriptor */
111 uint8_t bLength;
114 uint8_t bTerminalID;
117 uint8_t bSourceID;
118 uint8_t iTerminal;
119} __attribute__((packed));
120
121/* Table 4-7: Feature Unit Descriptor (head) */
123 uint8_t bLength;
126 uint8_t bUnitID;
127 uint8_t bSourceID;
129 uint16_t bmaControlMaster; /* device can assume 16-bit, given highest
130 * defined bit in spec is bit #9.
131 * (it is thus required bControlSize=2) */
132 /* ... */
133} __attribute__((packed));
134
135/* Table 4-7: Feature Unit Descriptor (body) */
137 /* ... */
138 uint16_t bmaControl;
139 /* ... */
140} __attribute__((packed));
141
142/* Table 4-7: Feature Unit Descriptor (tail) */
144 /* ... */
145 uint8_t iFeature;
146} __attribute__((packed));
147
148/* Table 4-7: Feature Unit Descriptor (2-channel)
149 *
150 * This structure is a convenience covering the (common) case where
151 * there are 2 channels associated with the feature unit
152 */
157} __attribute__((packed));
158
159/* Table 4-19: Class-Specific AS Interface Descriptor */
161 uint8_t bLength;
165 uint8_t bDelay;
166 uint16_t wFormatTag;
167} __attribute__((packed));
168
169/* Table 4-20: Standard AS Isochronous Audio Data Endpoint Descriptor */
171 uint8_t bLength;
176 uint8_t bInterval;
177 uint8_t bRefresh;
179} __attribute__((packed));
180
181/* Table 4-21: Class-Specific AS Isochronous Audio Data Endpoint Descriptor */
183 uint8_t bLength;
188 uint16_t wLockDelay;
189} __attribute__((packed));
190
191/*
192 * Definitions from the USB_AUDIO_FORMAT_ or usb_audio_format_ namespace come from:
193 * "Universal Serial Bus Device Class Definition for Audio Data Formats, Revision 1.0"
194 */
195
196/* Table 2-1: Type I Format Type Descriptor (head) */
198 uint8_t bLength;
201 uint8_t bFormatType;
202 uint8_t bNrChannels;
206 /* ... */
207} __attribute__((packed));
208
209/* Table 2-2: Continuous Sampling Frequency */
211 /* ... */
212 uint32_t tLowerSamFreq : 24;
213 uint32_t tUpperSamFreq : 24;
214} __attribute__((packed));
215
216/* Table 2-3: Discrete Number of Sampling Frequencies */
218 /* ... */
219 uint32_t tSamFreq : 24;
220} __attribute__((packed));
221
222/* Table 2-1: Type I Format Type Descriptor (1 sampling frequency)
223 *
224 * This structure is a convenience covering the (common) case where
225 * only 1 discrete sampling frequency is used
226 */
230} __attribute__((packed));
231
232#endif
233
234/**@}*/
235
struct usb_audio_feature_unit_descriptor_head head
Definition: audio.h:154
struct usb_audio_feature_unit_descriptor_tail tail
Definition: audio.h:156
struct usb_audio_feature_unit_descriptor_body channel_control[2]
Definition: audio.h:155
struct usb_audio_format_type1_descriptor_head head
Definition: audio.h:228
struct usb_audio_format_discrete_sampling_frequency freqs[1]
Definition: audio.h:229