Say hello to a sound system update from FreeBSD. This includes the long
[dragonfly.git] / sys / dev / sound / usb / uaudioreg.h
CommitLineData
558a398b
SS
1/* $NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $ */
2/* $FreeBSD: src/sys/dev/sound/usb/uaudioreg.h,v 1.4 2005/01/06 01:43:22 imp Exp $ */
3/* $DragonFly: src/sys/dev/sound/usb/uaudioreg.h,v 1.3 2007/01/04 21:47:03 corecode Exp $ */
984263bc 4
558a398b 5/*-
984263bc
MD
6 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Lennart Augustsson (lennart@augustsson.net) at
11 * Carlstedt Research & Technology.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the NetBSD
24 * Foundation, Inc. and its contributors.
25 * 4. Neither the name of The NetBSD Foundation nor the names of its
26 * contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#define UAUDIO_VERSION 0x100
43
984263bc
MD
44#define UDESC_CS_CONFIG 0x22
45#define UDESC_CS_STRING 0x23
46#define UDESC_CS_INTERFACE 0x24
47#define UDESC_CS_ENDPOINT 0x25
48
49#define UDESCSUB_AC_HEADER 1
50#define UDESCSUB_AC_INPUT 2
51#define UDESCSUB_AC_OUTPUT 3
52#define UDESCSUB_AC_MIXER 4
53#define UDESCSUB_AC_SELECTOR 5
54#define UDESCSUB_AC_FEATURE 6
55#define UDESCSUB_AC_PROCESSING 7
56#define UDESCSUB_AC_EXTENSION 8
57
58/* The first fields are identical to usb_endpoint_descriptor_t */
59typedef struct {
60 uByte bLength;
61 uByte bDescriptorType;
62 uByte bEndpointAddress;
63 uByte bmAttributes;
64 uWord wMaxPacketSize;
65 uByte bInterval;
558a398b 66 /*
984263bc
MD
67 * The following two entries are only used by the Audio Class.
68 * And according to the specs the Audio Class is the only one
69 * allowed to extend the endpoint descriptor.
70 * Who knows what goes on in the minds of the people in the USB
71 * standardization? :-(
72 */
73 uByte bRefresh;
74 uByte bSynchAddress;
75} UPACKED usb_endpoint_descriptor_audio_t;
76
77struct usb_audio_control_descriptor {
78 uByte bLength;
79 uByte bDescriptorType;
80 uByte bDescriptorSubtype;
81 uWord bcdADC;
82 uWord wTotalLength;
83 uByte bInCollection;
84 uByte baInterfaceNr[1];
85} UPACKED;
86
87struct usb_audio_streaming_interface_descriptor {
88 uByte bLength;
89 uByte bDescriptorType;
90 uByte bDescriptorSubtype;
91 uByte bTerminalLink;
92 uByte bDelay;
93 uWord wFormatTag;
94} UPACKED;
95
96struct usb_audio_streaming_endpoint_descriptor {
97 uByte bLength;
98 uByte bDescriptorType;
99 uByte bDescriptorSubtype;
100 uByte bmAttributes;
558a398b
SS
101#define UA_SED_FREQ_CONTROL 0x01
102#define UA_SED_PITCH_CONTROL 0x02
103#define UA_SED_MAXPACKETSONLY 0x80
984263bc
MD
104 uByte bLockDelayUnits;
105 uWord wLockDelay;
106} UPACKED;
107
108struct usb_audio_streaming_type1_descriptor {
109 uByte bLength;
110 uByte bDescriptorType;
111 uByte bDescriptorSubtype;
112 uByte bFormatType;
113 uByte bNrChannels;
114 uByte bSubFrameSize;
115 uByte bBitResolution;
116 uByte bSamFreqType;
117#define UA_SAMP_CONTNUOUS 0
118 uByte tSamFreq[3*2]; /* room for low and high */
119#define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
120#define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
121#define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
122} UPACKED;
123
124struct usb_audio_cluster {
125 uByte bNrChannels;
126 uWord wChannelConfig;
558a398b
SS
127#define UA_CHANNEL_LEFT 0x0001
128#define UA_CHANNEL_RIGHT 0x0002
129#define UA_CHANNEL_CENTER 0x0004
130#define UA_CHANNEL_LFE 0x0008
131#define UA_CHANNEL_L_SURROUND 0x0010
132#define UA_CHANNEL_R_SURROUND 0x0020
133#define UA_CHANNEL_L_CENTER 0x0040
134#define UA_CHANNEL_R_CENTER 0x0080
135#define UA_CHANNEL_SURROUND 0x0100
136#define UA_CHANNEL_L_SIDE 0x0200
137#define UA_CHANNEL_R_SIDE 0x0400
138#define UA_CHANNEL_TOP 0x0800
984263bc
MD
139 uByte iChannelNames;
140} UPACKED;
141
558a398b
SS
142/* Shared by all units and terminals */
143struct usb_audio_unit {
144 uByte bLength;
145 uByte bDescriptorType;
146 uByte bDescriptorSubtype;
147 uByte bUnitId;
148};
149
984263bc
MD
150/* UDESCSUB_AC_INPUT */
151struct usb_audio_input_terminal {
152 uByte bLength;
153 uByte bDescriptorType;
154 uByte bDescriptorSubtype;
155 uByte bTerminalId;
156 uWord wTerminalType;
157 uByte bAssocTerminal;
158 uByte bNrChannels;
159 uWord wChannelConfig;
160 uByte iChannelNames;
161 uByte iTerminal;
162} UPACKED;
163
164/* UDESCSUB_AC_OUTPUT */
165struct usb_audio_output_terminal {
166 uByte bLength;
167 uByte bDescriptorType;
168 uByte bDescriptorSubtype;
169 uByte bTerminalId;
170 uWord wTerminalType;
171 uByte bAssocTerminal;
172 uByte bSourceId;
173 uByte iTerminal;
174} UPACKED;
175
176/* UDESCSUB_AC_MIXER */
177struct usb_audio_mixer_unit {
178 uByte bLength;
179 uByte bDescriptorType;
180 uByte bDescriptorSubtype;
181 uByte bUnitId;
182 uByte bNrInPins;
183 uByte baSourceId[255]; /* [bNrInPins] */
184 /* struct usb_audio_mixer_unit_1 */
185} UPACKED;
186struct usb_audio_mixer_unit_1 {
187 uByte bNrChannels;
188 uWord wChannelConfig;
189 uByte iChannelNames;
190 uByte bmControls[255]; /* [bNrChannels] */
191 /*uByte iMixer;*/
192} UPACKED;
193
194/* UDESCSUB_AC_SELECTOR */
195struct usb_audio_selector_unit {
196 uByte bLength;
197 uByte bDescriptorType;
198 uByte bDescriptorSubtype;
199 uByte bUnitId;
200 uByte bNrInPins;
201 uByte baSourceId[255]; /* [bNrInPins] */
202 /* uByte iSelector; */
203} UPACKED;
204
205/* UDESCSUB_AC_FEATURE */
206struct usb_audio_feature_unit {
207 uByte bLength;
208 uByte bDescriptorType;
209 uByte bDescriptorSubtype;
210 uByte bUnitId;
211 uByte bSourceId;
212 uByte bControlSize;
213 uByte bmaControls[255]; /* size for more than enough */
214 /* uByte iFeature; */
215} UPACKED;
216
217/* UDESCSUB_AC_PROCESSING */
218struct usb_audio_processing_unit {
219 uByte bLength;
220 uByte bDescriptorType;
221 uByte bDescriptorSubtype;
222 uByte bUnitId;
223 uWord wProcessType;
224 uByte bNrInPins;
225 uByte baSourceId[255]; /* [bNrInPins] */
226 /* struct usb_audio_processing_unit_1 */
227} UPACKED;
228struct usb_audio_processing_unit_1{
229 uByte bNrChannels;
230 uWord wChannelConfig;
231 uByte iChannelNames;
232 uByte bControlSize;
233 uByte bmControls[255]; /* [bControlSize] */
234#define UA_PROC_ENABLE_MASK 1
235} UPACKED;
236
237struct usb_audio_processing_unit_updown {
238 uByte iProcessing;
239 uByte bNrModes;
240 uWord waModes[255]; /* [bNrModes] */
241} UPACKED;
242
243/* UDESCSUB_AC_EXTENSION */
244struct usb_audio_extension_unit {
245 uByte bLength;
246 uByte bDescriptorType;
247 uByte bDescriptorSubtype;
248 uByte bUnitId;
249 uWord wExtensionCode;
250 uByte bNrInPins;
251 uByte baSourceId[255]; /* [bNrInPins] */
252 /* struct usb_audio_extension_unit_1 */
253} UPACKED;
254struct usb_audio_extension_unit_1 {
255 uByte bNrChannels;
256 uWord wChannelConfig;
257 uByte iChannelNames;
258 uByte bControlSize;
259 uByte bmControls[255]; /* [bControlSize] */
260#define UA_EXT_ENABLE_MASK 1
261#define UA_EXT_ENABLE 1
262 /*uByte iExtension;*/
263} UPACKED;
264
265/* USB terminal types */
266#define UAT_UNDEFINED 0x0100
267#define UAT_STREAM 0x0101
268#define UAT_VENDOR 0x01ff
269/* input terminal types */
270#define UATI_UNDEFINED 0x0200
271#define UATI_MICROPHONE 0x0201
272#define UATI_DESKMICROPHONE 0x0202
273#define UATI_PERSONALMICROPHONE 0x0203
274#define UATI_OMNIMICROPHONE 0x0204
275#define UATI_MICROPHONEARRAY 0x0205
276#define UATI_PROCMICROPHONEARR 0x0206
277/* output terminal types */
278#define UATO_UNDEFINED 0x0300
279#define UATO_SPEAKER 0x0301
280#define UATO_HEADPHONES 0x0302
281#define UATO_DISPLAYAUDIO 0x0303
282#define UATO_DESKTOPSPEAKER 0x0304
283#define UATO_ROOMSPEAKER 0x0305
284#define UATO_COMMSPEAKER 0x0306
285#define UATO_SUBWOOFER 0x0307
286/* bidir terminal types */
287#define UATB_UNDEFINED 0x0400
288#define UATB_HANDSET 0x0401
289#define UATB_HEADSET 0x0402
290#define UATB_SPEAKERPHONE 0x0403
291#define UATB_SPEAKERPHONEESUP 0x0404
292#define UATB_SPEAKERPHONEECANC 0x0405
293/* telephony terminal types */
294#define UATT_UNDEFINED 0x0500
295#define UATT_PHONELINE 0x0501
296#define UATT_TELEPHONE 0x0502
297#define UATT_DOWNLINEPHONE 0x0503
298/* external terminal types */
299#define UATE_UNDEFINED 0x0600
300#define UATE_ANALOGCONN 0x0601
301#define UATE_DIGITALAUIFC 0x0602
302#define UATE_LINECONN 0x0603
303#define UATE_LEGACYCONN 0x0604
304#define UATE_SPDIF 0x0605
305#define UATE_1394DA 0x0606
306#define UATE_1394DV 0x0607
307/* embedded function terminal types */
308#define UATF_UNDEFINED 0x0700
309#define UATF_CALIBNOISE 0x0701
310#define UATF_EQUNOISE 0x0702
311#define UATF_CDPLAYER 0x0703
312#define UATF_DAT 0x0704
313#define UATF_DCC 0x0705
314#define UATF_MINIDISK 0x0706
315#define UATF_ANALOGTAPE 0x0707
316#define UATF_PHONOGRAPH 0x0708
317#define UATF_VCRAUDIO 0x0709
318#define UATF_VIDEODISCAUDIO 0x070a
319#define UATF_DVDAUDIO 0x070b
320#define UATF_TVTUNERAUDIO 0x070c
321#define UATF_SATELLITE 0x070d
322#define UATF_CABLETUNER 0x070e
323#define UATF_DSS 0x070f
324#define UATF_RADIORECV 0x0710
325#define UATF_RADIOXMIT 0x0711
326#define UATF_MULTITRACK 0x0712
327#define UATF_SYNTHESIZER 0x0713
328
329
330#define SET_CUR 0x01
331#define GET_CUR 0x81
332#define SET_MIN 0x02
333#define GET_MIN 0x82
334#define SET_MAX 0x03
335#define GET_MAX 0x83
336#define SET_RES 0x04
337#define GET_RES 0x84
338#define SET_MEM 0x05
339#define GET_MEM 0x85
340#define GET_STAT 0xff
341
342#define MUTE_CONTROL 0x01
343#define VOLUME_CONTROL 0x02
344#define BASS_CONTROL 0x03
345#define MID_CONTROL 0x04
346#define TREBLE_CONTROL 0x05
347#define GRAPHIC_EQUALIZER_CONTROL 0x06
348#define AGC_CONTROL 0x07
349#define DELAY_CONTROL 0x08
350#define BASS_BOOST_CONTROL 0x09
351#define LOUDNESS_CONTROL 0x0a
352
353#define FU_MASK(u) (1 << ((u)-1))
354
355#define MASTER_CHAN 0
356
357#define AS_GENERAL 1
358#define FORMAT_TYPE 2
359#define FORMAT_SPECIFIC 3
360
361#define UA_FMT_PCM 1
362#define UA_FMT_PCM8 2
363#define UA_FMT_IEEE_FLOAT 3
364#define UA_FMT_ALAW 4
365#define UA_FMT_MULAW 5
558a398b
SS
366#define UA_FMT_MPEG 0x1001
367#define UA_FMT_AC3 0x1002
984263bc 368
558a398b
SS
369#define SAMPLING_FREQ_CONTROL 0x01
370#define PITCH_CONTROL 0x02
984263bc
MD
371
372#define FORMAT_TYPE_UNDEFINED 0
373#define FORMAT_TYPE_I 1
374#define FORMAT_TYPE_II 2
375#define FORMAT_TYPE_III 3
376
377#define UA_PROC_MASK(n) (1<< ((n)-1))
378#define PROCESS_UNDEFINED 0
379#define XX_ENABLE_CONTROL 1
380#define UPDOWNMIX_PROCESS 1
381#define UD_ENABLE_CONTROL 1
382#define UD_MODE_SELECT_CONTROL 2
383#define DOLBY_PROLOGIC_PROCESS 2
384#define DP_ENABLE_CONTROL 1
385#define DP_MODE_SELECT_CONTROL 2
386#define P3D_STEREO_EXTENDER_PROCESS 3
387#define P3D_ENABLE_CONTROL 1
388#define P3D_SPACIOUSNESS_CONTROL 2
389#define REVERBATION_PROCESS 4
390#define RV_ENABLE_CONTROL 1
391#define RV_LEVEL_CONTROL 2
392#define RV_TIME_CONTROL 3
393#define RV_FEEDBACK_CONTROL 4
394#define CHORUS_PROCESS 5
395#define CH_ENABLE_CONTROL 1
396#define CH_LEVEL_CONTROL 2
397#define CH_RATE_CONTROL 3
398#define CH_DEPTH_CONTROL 4
399#define DYN_RANGE_COMP_PROCESS 6
400#define DR_ENABLE_CONTROL 1
401#define DR_COMPRESSION_RATE_CONTROL 2
402#define DR_MAXAMPL_CONTROL 3
403#define DR_THRESHOLD_CONTROL 4
404#define DR_ATTACK_TIME_CONTROL 5
405#define DR_RELEASE_TIME_CONTROL 6