Home | History | Annotate | Line # | Download | only in usb
uaudioreg.h revision 1.1
      1 /*	$NetBSD: uaudioreg.h,v 1.1 1999/09/09 12:28:26 augustss Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Author: Lennart Augustsson <augustss (at) carlstedt.se>
      8  *         Carlstedt Research & Technology
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #define UAUDIO_VERSION		0x100
     40 
     41 #define UDESC_CS_DEVICE		0x21
     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 } 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 };
     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 };
     93 
     94 struct usb_audio_streaming_endpoint_descriptor {
     95 	uByte		bLength;
     96 	uByte		bDescriptorType;
     97 	uByte		bDescriptorSubtype;
     98 	uByte		bmAttributes;
     99 	uByte		bLockDelayUnits;
    100 	uWord		wLockDelay;
    101 };
    102 
    103 struct usb_audio_streaming_type1_descriptor {
    104 	uByte		bLength;
    105 	uByte		bDescriptorType;
    106 	uByte		bDescriptorSubtype;
    107 	uByte		bFormatType;
    108 	uByte		bNrChannels;
    109 	uByte		bSubFrameSize;
    110 	uByte		bBitResolution;
    111 	uByte		bSamFreqType;
    112 #define UA_SAMP_CONTNUOUS 0
    113 	uByte		tSamFreq[3*2]; /* room for low and high */
    114 #define UA_GETSAMP(p, n) ((p)->tSamFreq[(n)*3+0] | ((p)->tSamFreq[(n)*3+1] << 8) | ((p)->tSamFreq[(n)*3+2] << 16))
    115 #define UA_SAMP_LO(p) UA_GETSAMP(p, 0)
    116 #define UA_SAMP_HI(p) UA_GETSAMP(p, 1)
    117 };
    118 
    119 struct usb_audio_cluster {
    120 	uByte		bNrChannels;
    121 	uWord		wChannelConfig;
    122 	uByte		iChannelNames;
    123 };
    124 
    125 /* UDESCSUB_AC_INPUT */
    126 struct usb_audio_input_terminal {
    127 	uByte		bLength;
    128 	uByte		bDescriptorType;
    129 	uByte		bDescriptorSubtype;
    130 	uByte		bTerminalId;
    131 	uWord		wTerminalType;
    132 	uByte		bAssocTerminal;
    133 	uByte		bNrChannels;
    134 	uWord		wChannelConfig;
    135 	uByte		iChannelNames;
    136 	uByte		iTerminal;
    137 };
    138 
    139 /* UDESCSUB_AC_OUTPUT */
    140 struct usb_audio_output_terminal {
    141 	uByte		bLength;
    142 	uByte		bDescriptorType;
    143 	uByte		bDescriptorSubtype;
    144 	uByte		bTerminalId;
    145 	uWord		wTerminalType;
    146 	uByte		bAssocTerminal;
    147 	uByte		bSourceId;
    148 	uByte		iTerminal;
    149 };
    150 
    151 /* UDESCSUB_AC_MIXER */
    152 struct usb_audio_mixer_unit {
    153 	uByte		bLength;
    154 	uByte		bDescriptorType;
    155 	uByte		bDescriptorSubtype;
    156 	uByte		bUnitId;
    157 	uByte		bNrInPins;
    158 	uByte		baSourceId[255]; /* length is really bNrInPins */
    159 	/* struct usb_audio_mixer_unit_1 */
    160 };
    161 struct usb_audio_mixer_unit_1 {
    162 	uByte		bNrChannels;
    163 	uWord		wChannelConfig;
    164 	uByte		iChannelNames;
    165 	uByte		bmControls[255];
    166 	/*uByte		iMixer;*/
    167 };
    168 
    169 /* UDESCSUB_AC_SELECTOR */
    170 struct usb_audio_selector_unit {
    171 	uByte		bLength;
    172 	uByte		bDescriptorType;
    173 	uByte		bDescriptorSubtype;
    174 	uByte		bUnitId;
    175 	uByte		bNrInPins;
    176 	uByte		baSourceId[255];
    177 	/* uByte	iSelector; */
    178 };
    179 
    180 /* UDESCSUB_AC_FEATURE */
    181 struct usb_audio_feature_unit {
    182 	uByte		bLength;
    183 	uByte		bDescriptorType;
    184 	uByte		bDescriptorSubtype;
    185 	uByte		bUnitId;
    186 	uByte		bSourceId;
    187 	uByte		bControlSize;
    188 	uByte		bmaControls[255]; /* size for more than enough */
    189 	/* uByte	iFeature; */
    190 };
    191 
    192 /* UDESCSUB_AC_PROCESSING */
    193 struct usb_audio_processing_unit {
    194 	uByte		bLength;
    195 	uByte		bDescriptorType;
    196 	uByte		bDescriptorSubtype;
    197 	uByte		bUnitId;
    198 	uWord		wProcessType;
    199 	uByte		bNrInPins;
    200 	uByte		baSourceId[255];
    201 	/* struct usb_audio_processing_unit_1 */
    202 };
    203 struct usb_audio_processing_unit_1{
    204 	uByte		bNrChannels;
    205 	uWord		wChannelConfig;
    206 	uByte		iChannelNames;
    207 	uByte		bControlSize;
    208 	uByte		bmControls[255];
    209 	/*uByte		iProcessing;*/
    210 };
    211 
    212 /* UDESCSUB_AC_EXTENSION */
    213 struct usb_audio_extension_unit {
    214 	uByte		bLength;
    215 	uByte		bDescriptorType;
    216 	uByte		bDescriptorSubtype;
    217 	uByte		bUnitId;
    218 	uWord		wExtensionCode;
    219 	uByte		bNrInPins;
    220 	uByte		baSourceId[255];
    221 	/* struct usb_audio_extension_unit_1 */
    222 };
    223 struct usb_audio_extension_unit_1 {
    224 	uByte		bNrChannels;
    225 	uWord		wChannelConfig;
    226 	uByte		iChannelNames;
    227 	uByte		bControlSize;
    228 	uByte		bmControls[255];
    229 #define UA_EXT_ENABLE 0
    230 	/*uByte		iExtension;*/
    231 };
    232 
    233 #define UAT_STREAM 0x0101
    234 
    235 #define SET_CUR 0x01
    236 #define GET_CUR 0x81
    237 #define SET_MIN 0x02
    238 #define GET_MIN 0x82
    239 #define SET_MAX 0x03
    240 #define GET_MAX 0x83
    241 #define SET_RES 0x04
    242 #define GET_RES 0x84
    243 #define SET_MEM 0x05
    244 #define GET_MEM 0x85
    245 #define GET_STAT 0xff
    246 
    247 #define MUTE_CONTROL	0x01
    248 #define VOLUME_CONTROL	0x02
    249 #define BASS_CONTROL	0x03
    250 #define MID_CONTROL	0x04
    251 #define TREBLE_CONTROL	0x05
    252 #define GRAPHIC_EQUALIZER_CONTROL	0x06
    253 #define AGC_CONTROL	0x07
    254 #define DELAY_CONTROL	0x08
    255 #define BASS_BOOST_CONTROL 0x09
    256 #define LOUDNESS_CONTROL 0x0a
    257 
    258 #define FU_MASK(u) (1 << ((u)-1))
    259 
    260 #define MASTER_CHAN 0
    261 
    262 #define AS_GENERAL 1
    263 #define FORMAT_TYPE 2
    264 #define FORMAT_SPECIFIC 3
    265 
    266 #define PCM 1
    267 #define PCM8 2
    268 #define IEEE_FLOAT 3
    269 #define ALAW 4
    270 #define MULAW 5
    271 
    272 #define SAMPLING_FREQ_CONTROL 0x01
    273