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