Home | History | Annotate | Line # | Download | only in usb
uaudioreg.h revision 1.17
      1 /*	$NetBSD: uaudioreg.h,v 1.17 2023/04/02 14:43:35 mlelstv 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  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #define UAUDIO_VERSION1		0x100
     34 #define UAUDIO_VERSION2		0x200
     35 
     36 #define UDESC_CS_CONFIG		0x22
     37 #define UDESC_CS_STRING		0x23
     38 #define UDESC_CS_INTERFACE	0x24
     39 #define UDESC_CS_ENDPOINT	0x25
     40 
     41 #define UDESCSUB_AC_HEADER	1
     42 #define UDESCSUB_AC_INPUT	2
     43 #define UDESCSUB_AC_OUTPUT	3
     44 #define UDESCSUB_AC_MIXER	4
     45 #define UDESCSUB_AC_SELECTOR	5
     46 #define UDESCSUB_AC_FEATURE	6
     47 #define UDESCSUB_AC_EFFECT      7
     48 #define UDESCSUB_AC_PROCESSING	8
     49 #define UDESCSUB_AC_EXTENSION	9
     50 #define UDESCSUB_AC_CLKSRC	10
     51 #define UDESCSUB_AC_CLKSEL	11
     52 #define UDESCSUB_AC_CLKMULT	12
     53 #define UDESCSUB_AC_RATECONV    13
     54 
     55 /* The first fields are identical to usb_endpoint_descriptor_t */
     56 typedef struct {
     57 	uByte		bLength;
     58 	uByte		bDescriptorType;
     59 	uByte		bEndpointAddress;
     60 	uByte		bmAttributes;
     61 	uWord		wMaxPacketSize;
     62 	uByte		bInterval;
     63 	/*
     64 	 * The following two entries are only used by the Audio Class.
     65 	 * And according to the specs the Audio Class is the only one
     66 	 * allowed to extend the endpoint descriptor.
     67 	 * Who knows what goes on in the minds of the people in the USB
     68 	 * standardization?  :-(
     69 	 */
     70 	uByte		bRefresh;
     71 	uByte		bSynchAddress;
     72 } UPACKED usb_endpoint_descriptor_audio_t;
     73 
     74 /* generic, for iteration */
     75 typedef struct {
     76 	uByte		bLength;
     77 	uByte		bDescriptorType;
     78 	uByte		bDescriptorSubtype;
     79 } UPACKED uaudio_cs_descriptor_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_v1_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_interface_v2_descriptor {
    101 	uByte		bLength;
    102 	uByte		bDescriptorType;
    103 	uByte		bDescriptorSubtype;
    104 	uByte		bTerminalLink;
    105 	uByte		bmControls;
    106 	uByte		bFormatType;
    107 	uDWord		bmFormats;
    108 	uByte		bNrChannels;
    109 	uDWord		bmChannelConfig;
    110 	uByte		iChannelNames;
    111 } UPACKED;
    112 
    113 union usb_audio_streaming_interface_descriptor {
    114 	struct usb_audio_streaming_interface_v1_descriptor v1;
    115 	struct usb_audio_streaming_interface_v2_descriptor v2;
    116 };
    117 
    118 struct usb_audio_streaming_endpoint_descriptor {
    119 	uByte		bLength;
    120 	uByte		bDescriptorType;
    121 	uByte		bDescriptorSubtype;
    122 	uByte		bmAttributes;
    123 #define UA_SED_FREQ_CONTROL	0x01
    124 #define UA_SED_PITCH_CONTROL	0x02
    125 #define UA_SED_MAXPACKETSONLY	0x80
    126 	uByte		bLockDelayUnits;
    127 	uWord		wLockDelay;
    128 } UPACKED;
    129 
    130 struct usb_audio_streaming_type1_v1_descriptor {
    131 	uByte		bLength;
    132 	uByte		bDescriptorType;
    133 	uByte		bDescriptorSubtype;
    134 	uByte		bFormatType;
    135 	uByte		bNrChannels;
    136 	uByte		bSubFrameSize;
    137 	uByte		bBitResolution;
    138 	uByte		bSamFreqType;
    139 #define UA_SAMP_CONTINUOUS 0
    140 	uByte		tSamFreq[3*AUFMT_MAX_FREQUENCIES];
    141 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
    142 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
    143 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
    144 } UPACKED;
    145 
    146 struct usb_audio_streaming_type1_v2_descriptor {
    147 	uByte		bLength;
    148 	uByte		bDescriptorType;
    149 	uByte		bDescriptorSubtype;
    150 	uByte		bFormatType;
    151 	uByte		bSubslotSize;
    152 	uByte		bBitResolution;
    153 } UPACKED;
    154 
    155 union usb_audio_streaming_type1_descriptor {
    156 	struct usb_audio_streaming_type1_v1_descriptor v1;
    157 	struct usb_audio_streaming_type1_v2_descriptor v2;
    158 };
    159 
    160 struct usb_audio_cluster {
    161 	uByte		bNrChannels;
    162 	uWord		wChannelConfig;
    163 #define	UA_CHANNEL_LEFT		0x0001
    164 #define	UA_CHANNEL_RIGHT	0x0002
    165 #define	UA_CHANNEL_CENTER	0x0004
    166 #define	UA_CHANNEL_LFE		0x0008
    167 #define	UA_CHANNEL_L_SURROUND	0x0010
    168 #define	UA_CHANNEL_R_SURROUND	0x0020
    169 #define	UA_CHANNEL_L_CENTER	0x0040
    170 #define	UA_CHANNEL_R_CENTER	0x0080
    171 #define	UA_CHANNEL_SURROUND	0x0100
    172 #define	UA_CHANNEL_L_SIDE	0x0200
    173 #define	UA_CHANNEL_R_SIDE	0x0400
    174 #define	UA_CHANNEL_TOP		0x0800
    175 	uByte		iChannelNames;
    176 } UPACKED;
    177 
    178 /* Shared by all units and terminals */
    179 struct usb_audio_unit {
    180 	uByte		bLength;
    181 	uByte		bDescriptorType;
    182 	uByte		bDescriptorSubtype;
    183 	uByte		bUnitId;
    184 };
    185 
    186 /* UDESCSUB_AC_INPUT */
    187 struct usb_audio_input_terminal {
    188 	uByte		bLength;
    189 	uByte		bDescriptorType;
    190 	uByte		bDescriptorSubtype;
    191 	uByte		bTerminalId;
    192 	uWord		wTerminalType;
    193 	uByte		bAssocTerminal;
    194 	uByte		bNrChannels;
    195 	uWord		wChannelConfig;
    196 	uByte		iChannelNames;
    197 	uByte		iTerminal;
    198 } UPACKED;
    199 
    200 /* UDESCSUB_AC_OUTPUT */
    201 struct usb_audio_output_terminal {
    202 	uByte		bLength;
    203 	uByte		bDescriptorType;
    204 	uByte		bDescriptorSubtype;
    205 	uByte		bTerminalId;
    206 	uWord		wTerminalType;
    207 	uByte		bAssocTerminal;
    208 	uByte		bSourceId;
    209 	uByte		iTerminal;
    210 } UPACKED;
    211 
    212 /* UDESCSUB_AC_MIXER */
    213 struct usb_audio_mixer_unit {
    214 	uByte		bLength;
    215 	uByte		bDescriptorType;
    216 	uByte		bDescriptorSubtype;
    217 	uByte		bUnitId;
    218 	uByte		bNrInPins;
    219 	uByte		baSourceId[255]; /* [bNrInPins] */
    220 	/* struct usb_audio_mixer_unit_1 */
    221 } UPACKED;
    222 struct usb_audio_mixer_unit_1 {
    223 	uByte		bNrChannels;
    224 	uWord		wChannelConfig;
    225 	uByte		iChannelNames;
    226 	uByte		bmControls[255]; /* [bNrChannels] */
    227 	/*uByte		iMixer;*/
    228 } UPACKED;
    229 
    230 /* UDESCSUB_AC_SELECTOR */
    231 struct usb_audio_selector_unit {
    232 	uByte		bLength;
    233 	uByte		bDescriptorType;
    234 	uByte		bDescriptorSubtype;
    235 	uByte		bUnitId;
    236 	uByte		bNrInPins;
    237 	uByte		baSourceId[255]; /* [bNrInPins] */
    238 	/* uByte	iSelector; */
    239 } UPACKED;
    240 
    241 /* UDESCSUB_AC_FEATURE */
    242 struct usb_audio_feature_unit {
    243 	uByte		bLength;
    244 	uByte		bDescriptorType;
    245 	uByte		bDescriptorSubtype;
    246 	uByte		bUnitId;
    247 	uByte		bSourceId;
    248 	uByte		bControlSize;
    249 	uByte		bmaControls[255]; /* size for more than enough */
    250 	/* uByte	iFeature; */
    251 } UPACKED;
    252 
    253 /* UDESCSUB_AC_PROCESSING */
    254 struct usb_audio_processing_unit {
    255 	uByte		bLength;
    256 	uByte		bDescriptorType;
    257 	uByte		bDescriptorSubtype;
    258 	uByte		bUnitId;
    259 	uWord		wProcessType;
    260 	uByte		bNrInPins;
    261 	uByte		baSourceId[255]; /* [bNrInPins] */
    262 	/* struct usb_audio_processing_unit_1 */
    263 } UPACKED;
    264 struct usb_audio_processing_unit_1{
    265 	uByte		bNrChannels;
    266 	uWord		wChannelConfig;
    267 	uByte		iChannelNames;
    268 	uByte		bControlSize;
    269 	uByte		bmControls[255]; /* [bControlSize] */
    270 #define UA_PROC_ENABLE_MASK 1
    271 } UPACKED;
    272 
    273 struct usb_audio_processing_unit_updown {
    274 	uByte		iProcessing;
    275 	uByte		bNrModes;
    276 	uWord		waModes[255]; /* [bNrModes] */
    277 } UPACKED;
    278 
    279 /* UDESCSUB_AC_EXTENSION */
    280 struct usb_audio_extension_unit {
    281 	uByte		bLength;
    282 	uByte		bDescriptorType;
    283 	uByte		bDescriptorSubtype;
    284 	uByte		bUnitId;
    285 	uWord		wExtensionCode;
    286 	uByte		bNrInPins;
    287 	uByte		baSourceId[255]; /* [bNrInPins] */
    288 	/* struct usb_audio_extension_unit_1 */
    289 } UPACKED;
    290 struct usb_audio_extension_unit_1 {
    291 	uByte		bNrChannels;
    292 	uWord		wChannelConfig;
    293 	uByte		iChannelNames;
    294 	uByte		bControlSize;
    295 	uByte		bmControls[255]; /* [bControlSize] */
    296 #define UA_EXT_ENABLE_MASK 1
    297 #define UA_EXT_ENABLE 1
    298 	/*uByte		iExtension;*/
    299 } UPACKED;
    300 
    301 /* UDESCSUB_AC_CLKSRC */
    302 struct usb_audio_clksrc_unit {
    303 	uByte		bLength;
    304 	uByte		bDescriptorType;
    305 	uByte		bDescriptorSubtype;
    306 	uByte		bClockId;
    307 	uByte		bmAttributes;
    308 	uByte		bmControls;
    309 	uByte		bAssocTerminal;
    310 	uByte		iClockSource;
    311 } UPACKED;
    312 
    313 /* UDESCSUB_AC_CLKSEL */
    314 struct usb_audio_clksel_unit {
    315 	uByte		bLength;
    316 	uByte		bDescriptorType;
    317 	uByte		bDescriptorSubtype;
    318 	uByte		bClockId;
    319 	uByte		bNrInPins;
    320 	uByte		baCSourceId[255];
    321 	/*uByte		bmControls;*/
    322 	/*uByte		iClockSelector;*/
    323 } UPACKED;
    324 
    325 /* UDESCSUB_AC_CLKMULT */
    326 struct usb_audio_clkmult_unit {
    327 	uByte		bLength;
    328 	uByte		bDescriptorType;
    329 	uByte		bDescriptorSubtype;
    330 	uByte		bClockId;
    331 	uByte		bCSourceId;
    332 	uByte		bmControls;
    333 	uByte		iClockMultiplier;
    334 } UPACKED;
    335 
    336 /* USB terminal types */
    337 #define UAT_UNDEFINED		0x0100
    338 #define UAT_STREAM		0x0101
    339 #define UAT_VENDOR		0x01ff
    340 /* input terminal types */
    341 #define UATI_UNDEFINED		0x0200
    342 #define UATI_MICROPHONE		0x0201
    343 #define UATI_DESKMICROPHONE	0x0202
    344 #define UATI_PERSONALMICROPHONE	0x0203
    345 #define UATI_OMNIMICROPHONE	0x0204
    346 #define UATI_MICROPHONEARRAY	0x0205
    347 #define UATI_PROCMICROPHONEARR	0x0206
    348 /* output terminal types */
    349 #define UATO_UNDEFINED		0x0300
    350 #define UATO_SPEAKER		0x0301
    351 #define UATO_HEADPHONES		0x0302
    352 #define UATO_DISPLAYAUDIO	0x0303
    353 #define UATO_DESKTOPSPEAKER	0x0304
    354 #define UATO_ROOMSPEAKER	0x0305
    355 #define UATO_COMMSPEAKER	0x0306
    356 #define UATO_SUBWOOFER		0x0307
    357 /* bidir terminal types */
    358 #define UATB_UNDEFINED		0x0400
    359 #define UATB_HANDSET		0x0401
    360 #define UATB_HEADSET		0x0402
    361 #define UATB_SPEAKERPHONE	0x0403
    362 #define UATB_SPEAKERPHONEESUP	0x0404
    363 #define UATB_SPEAKERPHONEECANC	0x0405
    364 /* telephony terminal types */
    365 #define UATT_UNDEFINED		0x0500
    366 #define UATT_PHONELINE		0x0501
    367 #define UATT_TELEPHONE		0x0502
    368 #define UATT_DOWNLINEPHONE	0x0503
    369 /* external terminal types */
    370 #define UATE_UNDEFINED		0x0600
    371 #define UATE_ANALOGCONN		0x0601
    372 #define UATE_DIGITALAUIFC	0x0602
    373 #define UATE_LINECONN		0x0603
    374 #define UATE_LEGACYCONN		0x0604
    375 #define UATE_SPDIF		0x0605
    376 #define UATE_1394DA		0x0606
    377 #define UATE_1394DV		0x0607
    378 /* embedded function terminal types */
    379 #define UATF_UNDEFINED		0x0700
    380 #define UATF_CALIBNOISE		0x0701
    381 #define UATF_EQUNOISE		0x0702
    382 #define UATF_CDPLAYER		0x0703
    383 #define UATF_DAT		0x0704
    384 #define UATF_DCC		0x0705
    385 #define UATF_MINIDISK		0x0706
    386 #define UATF_ANALOGTAPE		0x0707
    387 #define UATF_PHONOGRAPH		0x0708
    388 #define UATF_VCRAUDIO		0x0709
    389 #define UATF_VIDEODISCAUDIO	0x070a
    390 #define UATF_DVDAUDIO		0x070b
    391 #define UATF_TVTUNERAUDIO	0x070c
    392 #define UATF_SATELLITE		0x070d
    393 #define UATF_CABLETUNER		0x070e
    394 #define UATF_DSS		0x070f
    395 #define UATF_RADIORECV		0x0710
    396 #define UATF_RADIOXMIT		0x0711
    397 #define UATF_MULTITRACK		0x0712
    398 #define UATF_SYNTHESIZER	0x0713
    399 
    400 
    401 #define SET_CUR 0x01
    402 #define GET_CUR 0x81
    403 #define SET_MIN 0x02
    404 #define GET_MIN 0x82
    405 #define SET_MAX 0x03
    406 #define GET_MAX 0x83
    407 #define SET_RES 0x04
    408 #define GET_RES 0x84
    409 #define SET_MEM 0x05
    410 #define GET_MEM 0x85
    411 #define GET_STAT 0xff
    412 #define V2_CUR        0x01
    413 #define V2_RANGES     0x02
    414 
    415 #define V2_CUR_CLKFREQ	0x01
    416 #define V2_CUR_CLKSEL	0x01
    417 
    418 
    419 #define MUTE_CONTROL	0x01
    420 #define VOLUME_CONTROL	0x02
    421 #define BASS_CONTROL	0x03
    422 #define MID_CONTROL	0x04
    423 #define TREBLE_CONTROL	0x05
    424 #define GRAPHIC_EQUALIZER_CONTROL	0x06
    425 #define AGC_CONTROL	0x07
    426 #define DELAY_CONTROL	0x08
    427 #define BASS_BOOST_CONTROL 0x09
    428 #define LOUDNESS_CONTROL 0x0a
    429 #define GAIN_CONTROL	0x0b
    430 #define GAINPAD_CONTROL	0x0c
    431 #define PHASEINV_CONTROL 0x0d
    432 
    433 #define FU_MASK(u) (1 << ((u)-1))
    434 
    435 #define MASTER_CHAN	0
    436 
    437 #define AS_GENERAL	1
    438 #define FORMAT_TYPE	2
    439 #define FORMAT_SPECIFIC 3
    440 
    441 #define UA_FMT_PCM	1
    442 #define UA_FMT_PCM8	2
    443 #define UA_FMT_IEEE_FLOAT 3
    444 #define UA_FMT_ALAW	4
    445 #define UA_FMT_MULAW	5
    446 #define UA_FMT_MPEG	0x1001
    447 #define UA_FMT_AC3	0x1002
    448 
    449 #define UA_V2_FMT_PCM		0x01
    450 #define UA_V2_FMT_PCM8		0x02
    451 #define UA_V2_FMT_IEEE_FLOAT	0x04
    452 #define UA_V2_FMT_ALAW		0x08
    453 #define UA_V2_FMT_MULAW		0x10
    454 
    455 #define SAMPLING_FREQ_CONTROL	0x01
    456 #define PITCH_CONTROL		0x02
    457 
    458 #define FORMAT_TYPE_UNDEFINED 0
    459 #define FORMAT_TYPE_I 1
    460 #define FORMAT_TYPE_II 2
    461 #define FORMAT_TYPE_III 3
    462 
    463 #define UA_PROC_MASK(n) (1<< ((n)-1))
    464 #define PROCESS_UNDEFINED		0
    465 #define  XX_ENABLE_CONTROL			1
    466 #define UPDOWNMIX_PROCESS		1
    467 #define  UD_ENABLE_CONTROL			1
    468 #define  UD_MODE_SELECT_CONTROL			2
    469 #define DOLBY_PROLOGIC_PROCESS		2
    470 #define  DP_ENABLE_CONTROL			1
    471 #define  DP_MODE_SELECT_CONTROL			2
    472 #define P3D_STEREO_EXTENDER_PROCESS	3
    473 #define  P3D_ENABLE_CONTROL			1
    474 #define  P3D_SPACIOUSNESS_CONTROL		2
    475 #define REVERBATION_PROCESS		4
    476 #define  RV_ENABLE_CONTROL			1
    477 #define  RV_LEVEL_CONTROL			2
    478 #define  RV_TIME_CONTROL			3
    479 #define  RV_FEEDBACK_CONTROL			4
    480 #define CHORUS_PROCESS			5
    481 #define  CH_ENABLE_CONTROL			1
    482 #define  CH_LEVEL_CONTROL			2
    483 #define  CH_RATE_CONTROL			3
    484 #define  CH_DEPTH_CONTROL			4
    485 #define DYN_RANGE_COMP_PROCESS		6
    486 #define  DR_ENABLE_CONTROL			1
    487 #define  DR_COMPRESSION_RATE_CONTROL		2
    488 #define  DR_MAXAMPL_CONTROL			3
    489 #define  DR_THRESHOLD_CONTROL			4
    490 #define  DR_ATTACK_TIME_CONTROL			5
    491 #define  DR_RELEASE_TIME_CONTROL		6
    492