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