Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * <linux/usb/audio.h> -- USB Audio definitions.
0004  *
0005  * Copyright (C) 2006 Thumtronics Pty Ltd.
0006  * Developed for Thumtronics by Grey Innovation
0007  * Ben Williamson <ben.williamson@greyinnovation.com>
0008  *
0009  * This software is distributed under the terms of the GNU General Public
0010  * License ("GPL") version 2, as published by the Free Software Foundation.
0011  *
0012  * This file holds USB constants and structures defined
0013  * by the USB Device Class Definition for Audio Devices.
0014  * Comments below reference relevant sections of that document:
0015  *
0016  * http://www.usb.org/developers/devclass_docs/audio10.pdf
0017  *
0018  * Types and defines in this file are either specific to version 1.0 of
0019  * this standard or common for newer versions.
0020  */
0021 
0022 #ifndef _UAPI__LINUX_USB_AUDIO_H
0023 #define _UAPI__LINUX_USB_AUDIO_H
0024 
0025 #include <linux/types.h>
0026 
0027 /* bInterfaceProtocol values to denote the version of the standard used */
0028 #define UAC_VERSION_1           0x00
0029 #define UAC_VERSION_2           0x20
0030 #define UAC_VERSION_3           0x30
0031 
0032 /* A.2 Audio Interface Subclass Codes */
0033 #define USB_SUBCLASS_AUDIOCONTROL   0x01
0034 #define USB_SUBCLASS_AUDIOSTREAMING 0x02
0035 #define USB_SUBCLASS_MIDISTREAMING  0x03
0036 
0037 /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
0038 #define UAC_HEADER          0x01
0039 #define UAC_INPUT_TERMINAL      0x02
0040 #define UAC_OUTPUT_TERMINAL     0x03
0041 #define UAC_MIXER_UNIT          0x04
0042 #define UAC_SELECTOR_UNIT       0x05
0043 #define UAC_FEATURE_UNIT        0x06
0044 #define UAC1_PROCESSING_UNIT        0x07
0045 #define UAC1_EXTENSION_UNIT     0x08
0046 
0047 /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
0048 #define UAC_AS_GENERAL          0x01
0049 #define UAC_FORMAT_TYPE         0x02
0050 #define UAC_FORMAT_SPECIFIC     0x03
0051 
0052 /* A.7 Processing Unit Process Types */
0053 #define UAC_PROCESS_UNDEFINED       0x00
0054 #define UAC_PROCESS_UP_DOWNMIX      0x01
0055 #define UAC_PROCESS_DOLBY_PROLOGIC  0x02
0056 #define UAC_PROCESS_STEREO_EXTENDER 0x03
0057 #define UAC_PROCESS_REVERB      0x04
0058 #define UAC_PROCESS_CHORUS      0x05
0059 #define UAC_PROCESS_DYN_RANGE_COMP  0x06
0060 
0061 /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
0062 #define UAC_EP_GENERAL          0x01
0063 
0064 /* A.9 Audio Class-Specific Request Codes */
0065 #define UAC_SET_            0x00
0066 #define UAC_GET_            0x80
0067 
0068 #define UAC__CUR            0x1
0069 #define UAC__MIN            0x2
0070 #define UAC__MAX            0x3
0071 #define UAC__RES            0x4
0072 #define UAC__MEM            0x5
0073 
0074 #define UAC_SET_CUR         (UAC_SET_ | UAC__CUR)
0075 #define UAC_GET_CUR         (UAC_GET_ | UAC__CUR)
0076 #define UAC_SET_MIN         (UAC_SET_ | UAC__MIN)
0077 #define UAC_GET_MIN         (UAC_GET_ | UAC__MIN)
0078 #define UAC_SET_MAX         (UAC_SET_ | UAC__MAX)
0079 #define UAC_GET_MAX         (UAC_GET_ | UAC__MAX)
0080 #define UAC_SET_RES         (UAC_SET_ | UAC__RES)
0081 #define UAC_GET_RES         (UAC_GET_ | UAC__RES)
0082 #define UAC_SET_MEM         (UAC_SET_ | UAC__MEM)
0083 #define UAC_GET_MEM         (UAC_GET_ | UAC__MEM)
0084 
0085 #define UAC_GET_STAT            0xff
0086 
0087 /* A.10 Control Selector Codes */
0088 
0089 /* A.10.1 Terminal Control Selectors */
0090 #define UAC_TERM_COPY_PROTECT       0x01
0091 
0092 /* A.10.2 Feature Unit Control Selectors */
0093 #define UAC_FU_MUTE         0x01
0094 #define UAC_FU_VOLUME           0x02
0095 #define UAC_FU_BASS         0x03
0096 #define UAC_FU_MID          0x04
0097 #define UAC_FU_TREBLE           0x05
0098 #define UAC_FU_GRAPHIC_EQUALIZER    0x06
0099 #define UAC_FU_AUTOMATIC_GAIN       0x07
0100 #define UAC_FU_DELAY            0x08
0101 #define UAC_FU_BASS_BOOST       0x09
0102 #define UAC_FU_LOUDNESS         0x0a
0103 
0104 #define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
0105 
0106 /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
0107 #define UAC_UD_ENABLE           0x01
0108 #define UAC_UD_MODE_SELECT      0x02
0109 
0110 /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
0111 #define UAC_DP_ENABLE           0x01
0112 #define UAC_DP_MODE_SELECT      0x02
0113 
0114 /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
0115 #define UAC_3D_ENABLE           0x01
0116 #define UAC_3D_SPACE            0x02
0117 
0118 /* A.10.3.4 Reverberation Processing Unit Control Selectors */
0119 #define UAC_REVERB_ENABLE       0x01
0120 #define UAC_REVERB_LEVEL        0x02
0121 #define UAC_REVERB_TIME         0x03
0122 #define UAC_REVERB_FEEDBACK     0x04
0123 
0124 /* A.10.3.5 Chorus Processing Unit Control Selectors */
0125 #define UAC_CHORUS_ENABLE       0x01
0126 #define UAC_CHORUS_LEVEL        0x02
0127 #define UAC_CHORUS_RATE         0x03
0128 #define UAC_CHORUS_DEPTH        0x04
0129 
0130 /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
0131 #define UAC_DCR_ENABLE          0x01
0132 #define UAC_DCR_RATE            0x02
0133 #define UAC_DCR_MAXAMPL         0x03
0134 #define UAC_DCR_THRESHOLD       0x04
0135 #define UAC_DCR_ATTACK_TIME     0x05
0136 #define UAC_DCR_RELEASE_TIME        0x06
0137 
0138 /* A.10.4 Extension Unit Control Selectors */
0139 #define UAC_XU_ENABLE           0x01
0140 
0141 /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
0142 #define UAC_MS_HEADER           0x01
0143 #define UAC_MIDI_IN_JACK        0x02
0144 #define UAC_MIDI_OUT_JACK       0x03
0145 
0146 /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
0147 #define UAC_MS_GENERAL          0x01
0148 
0149 /* Terminals - 2.1 USB Terminal Types */
0150 #define UAC_TERMINAL_UNDEFINED      0x100
0151 #define UAC_TERMINAL_STREAMING      0x101
0152 #define UAC_TERMINAL_VENDOR_SPEC    0x1FF
0153 
0154 /* Terminal Control Selectors */
0155 /* 4.3.2  Class-Specific AC Interface Descriptor */
0156 struct uac1_ac_header_descriptor {
0157     __u8  bLength;          /* 8 + n */
0158     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0159     __u8  bDescriptorSubtype;   /* UAC_MS_HEADER */
0160     __le16 bcdADC;          /* 0x0100 */
0161     __le16 wTotalLength;        /* includes Unit and Terminal desc. */
0162     __u8  bInCollection;        /* n */
0163     __u8  baInterfaceNr[];      /* [n] */
0164 } __attribute__ ((packed));
0165 
0166 #define UAC_DT_AC_HEADER_SIZE(n)    (8 + (n))
0167 
0168 /* As above, but more useful for defining your own descriptors: */
0169 #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n)         \
0170 struct uac1_ac_header_descriptor_##n {          \
0171     __u8  bLength;                      \
0172     __u8  bDescriptorType;                  \
0173     __u8  bDescriptorSubtype;               \
0174     __le16 bcdADC;                      \
0175     __le16 wTotalLength;                    \
0176     __u8  bInCollection;                    \
0177     __u8  baInterfaceNr[n];                 \
0178 } __attribute__ ((packed))
0179 
0180 /* 4.3.2.1 Input Terminal Descriptor */
0181 struct uac_input_terminal_descriptor {
0182     __u8  bLength;          /* in bytes: 12 */
0183     __u8  bDescriptorType;      /* CS_INTERFACE descriptor type */
0184     __u8  bDescriptorSubtype;   /* INPUT_TERMINAL descriptor subtype */
0185     __u8  bTerminalID;      /* Constant uniquely terminal ID */
0186     __le16 wTerminalType;       /* USB Audio Terminal Types */
0187     __u8  bAssocTerminal;       /* ID of the Output Terminal associated */
0188     __u8  bNrChannels;      /* Number of logical output channels */
0189     __le16 wChannelConfig;
0190     __u8  iChannelNames;
0191     __u8  iTerminal;
0192 } __attribute__ ((packed));
0193 
0194 #define UAC_DT_INPUT_TERMINAL_SIZE          12
0195 
0196 /* Terminals - 2.2 Input Terminal Types */
0197 #define UAC_INPUT_TERMINAL_UNDEFINED            0x200
0198 #define UAC_INPUT_TERMINAL_MICROPHONE           0x201
0199 #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE       0x202
0200 #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE      0x203
0201 #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE      0x204
0202 #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY     0x205
0203 #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY    0x206
0204 
0205 /* Terminals - control selectors */
0206 
0207 #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL        0x01
0208 
0209 /* 4.3.2.2 Output Terminal Descriptor */
0210 struct uac1_output_terminal_descriptor {
0211     __u8  bLength;          /* in bytes: 9 */
0212     __u8  bDescriptorType;      /* CS_INTERFACE descriptor type */
0213     __u8  bDescriptorSubtype;   /* OUTPUT_TERMINAL descriptor subtype */
0214     __u8  bTerminalID;      /* Constant uniquely terminal ID */
0215     __le16 wTerminalType;       /* USB Audio Terminal Types */
0216     __u8  bAssocTerminal;       /* ID of the Input Terminal associated */
0217     __u8  bSourceID;        /* ID of the connected Unit or Terminal*/
0218     __u8  iTerminal;
0219 } __attribute__ ((packed));
0220 
0221 #define UAC_DT_OUTPUT_TERMINAL_SIZE         9
0222 
0223 /* Terminals - 2.3 Output Terminal Types */
0224 #define UAC_OUTPUT_TERMINAL_UNDEFINED           0x300
0225 #define UAC_OUTPUT_TERMINAL_SPEAKER         0x301
0226 #define UAC_OUTPUT_TERMINAL_HEADPHONES          0x302
0227 #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO  0x303
0228 #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER     0x304
0229 #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER        0x305
0230 #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER   0x306
0231 #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER    0x307
0232 
0233 /* Terminals - 2.4 Bi-directional Terminal Types */
0234 #define UAC_BIDIR_TERMINAL_UNDEFINED            0x400
0235 #define UAC_BIDIR_TERMINAL_HANDSET          0x401
0236 #define UAC_BIDIR_TERMINAL_HEADSET          0x402
0237 #define UAC_BIDIR_TERMINAL_SPEAKER_PHONE        0x403
0238 #define UAC_BIDIR_TERMINAL_ECHO_SUPPRESSING     0x404
0239 #define UAC_BIDIR_TERMINAL_ECHO_CANCELING       0x405
0240 
0241 /* Set bControlSize = 2 as default setting */
0242 #define UAC_DT_FEATURE_UNIT_SIZE(ch)        (7 + ((ch) + 1) * 2)
0243 
0244 /* As above, but more useful for defining your own descriptors: */
0245 #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch)         \
0246 struct uac_feature_unit_descriptor_##ch {           \
0247     __u8  bLength;                      \
0248     __u8  bDescriptorType;                  \
0249     __u8  bDescriptorSubtype;               \
0250     __u8  bUnitID;                      \
0251     __u8  bSourceID;                    \
0252     __u8  bControlSize;                 \
0253     __le16 bmaControls[ch + 1];             \
0254     __u8  iFeature;                     \
0255 } __attribute__ ((packed))
0256 
0257 /* 4.3.2.3 Mixer Unit Descriptor */
0258 struct uac_mixer_unit_descriptor {
0259     __u8 bLength;
0260     __u8 bDescriptorType;
0261     __u8 bDescriptorSubtype;
0262     __u8 bUnitID;
0263     __u8 bNrInPins;
0264     __u8 baSourceID[];
0265 } __attribute__ ((packed));
0266 
0267 static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
0268 {
0269     return desc->baSourceID[desc->bNrInPins];
0270 }
0271 
0272 static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
0273                           int protocol)
0274 {
0275     if (protocol == UAC_VERSION_1)
0276         return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
0277             desc->baSourceID[desc->bNrInPins + 1];
0278     else
0279         return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
0280             (desc->baSourceID[desc->bNrInPins + 3] << 16) |
0281             (desc->baSourceID[desc->bNrInPins + 2] << 8)  |
0282             (desc->baSourceID[desc->bNrInPins + 1]);
0283 }
0284 
0285 static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
0286                         int protocol)
0287 {
0288     return (protocol == UAC_VERSION_1) ?
0289         desc->baSourceID[desc->bNrInPins + 3] :
0290         desc->baSourceID[desc->bNrInPins + 5];
0291 }
0292 
0293 static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
0294                           int protocol)
0295 {
0296     switch (protocol) {
0297     case UAC_VERSION_1:
0298         return &desc->baSourceID[desc->bNrInPins + 4];
0299     case UAC_VERSION_2:
0300         return &desc->baSourceID[desc->bNrInPins + 6];
0301     case UAC_VERSION_3:
0302         return &desc->baSourceID[desc->bNrInPins + 2];
0303     default:
0304         return NULL;
0305     }
0306 }
0307 
0308 static inline __u16 uac3_mixer_unit_wClusterDescrID(struct uac_mixer_unit_descriptor *desc)
0309 {
0310     return (desc->baSourceID[desc->bNrInPins + 1] << 8) |
0311         desc->baSourceID[desc->bNrInPins];
0312 }
0313 
0314 static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
0315 {
0316     __u8 *raw = (__u8 *) desc;
0317     return raw[desc->bLength - 1];
0318 }
0319 
0320 /* 4.3.2.4 Selector Unit Descriptor */
0321 struct uac_selector_unit_descriptor {
0322     __u8 bLength;
0323     __u8 bDescriptorType;
0324     __u8 bDescriptorSubtype;
0325     __u8 bUintID;
0326     __u8 bNrInPins;
0327     __u8 baSourceID[];
0328 } __attribute__ ((packed));
0329 
0330 static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
0331 {
0332     __u8 *raw = (__u8 *) desc;
0333     return raw[desc->bLength - 1];
0334 }
0335 
0336 /* 4.3.2.5 Feature Unit Descriptor */
0337 struct uac_feature_unit_descriptor {
0338     __u8 bLength;
0339     __u8 bDescriptorType;
0340     __u8 bDescriptorSubtype;
0341     __u8 bUnitID;
0342     __u8 bSourceID;
0343     __u8 bControlSize;
0344     __u8 bmaControls[]; /* variable length */
0345 } __attribute__((packed));
0346 
0347 static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
0348 {
0349     __u8 *raw = (__u8 *) desc;
0350     return raw[desc->bLength - 1];
0351 }
0352 
0353 /* 4.3.2.6 Processing Unit Descriptors */
0354 struct uac_processing_unit_descriptor {
0355     __u8 bLength;
0356     __u8 bDescriptorType;
0357     __u8 bDescriptorSubtype;
0358     __u8 bUnitID;
0359     __le16 wProcessType;
0360     __u8 bNrInPins;
0361     __u8 baSourceID[];
0362 } __attribute__ ((packed));
0363 
0364 static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
0365 {
0366     return desc->baSourceID[desc->bNrInPins];
0367 }
0368 
0369 static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
0370                                int protocol)
0371 {
0372     if (protocol == UAC_VERSION_1)
0373         return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
0374             desc->baSourceID[desc->bNrInPins + 1];
0375     else
0376         return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
0377             (desc->baSourceID[desc->bNrInPins + 3] << 16) |
0378             (desc->baSourceID[desc->bNrInPins + 2] << 8)  |
0379             (desc->baSourceID[desc->bNrInPins + 1]);
0380 }
0381 
0382 static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
0383                              int protocol)
0384 {
0385     return (protocol == UAC_VERSION_1) ?
0386         desc->baSourceID[desc->bNrInPins + 3] :
0387         desc->baSourceID[desc->bNrInPins + 5];
0388 }
0389 
0390 static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
0391                             int protocol)
0392 {
0393     switch (protocol) {
0394     case UAC_VERSION_1:
0395         return desc->baSourceID[desc->bNrInPins + 4];
0396     case UAC_VERSION_2:
0397         return 2; /* in UAC2, this value is constant */
0398     case UAC_VERSION_3:
0399         return 4; /* in UAC3, this value is constant */
0400     default:
0401         return 1;
0402     }
0403 }
0404 
0405 static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
0406                            int protocol)
0407 {
0408     switch (protocol) {
0409     case UAC_VERSION_1:
0410         return &desc->baSourceID[desc->bNrInPins + 5];
0411     case UAC_VERSION_2:
0412         return &desc->baSourceID[desc->bNrInPins + 6];
0413     case UAC_VERSION_3:
0414         return &desc->baSourceID[desc->bNrInPins + 2];
0415     default:
0416         return NULL;
0417     }
0418 }
0419 
0420 static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
0421                            int protocol)
0422 {
0423     __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
0424 
0425     switch (protocol) {
0426     case UAC_VERSION_1:
0427     case UAC_VERSION_2:
0428     default:
0429         return *(uac_processing_unit_bmControls(desc, protocol)
0430              + control_size);
0431     case UAC_VERSION_3:
0432         return 0; /* UAC3 does not have this field */
0433     }
0434 }
0435 
0436 static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
0437                          int protocol)
0438 {
0439     __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
0440 
0441     switch (protocol) {
0442     case UAC_VERSION_1:
0443     case UAC_VERSION_2:
0444     default:
0445         return uac_processing_unit_bmControls(desc, protocol)
0446             + control_size + 1;
0447     case UAC_VERSION_3:
0448         return uac_processing_unit_bmControls(desc, protocol)
0449             + control_size;
0450     }
0451 }
0452 
0453 /*
0454  * Extension Unit (XU) has almost compatible layout with Processing Unit, but
0455  * on UAC2, it has a different bmControls size (bControlSize); it's 1 byte for
0456  * XU while 2 bytes for PU.  The last iExtension field is a one-byte index as
0457  * well as iProcessing field of PU.
0458  */
0459 static inline __u8 uac_extension_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
0460                            int protocol)
0461 {
0462     switch (protocol) {
0463     case UAC_VERSION_1:
0464         return desc->baSourceID[desc->bNrInPins + 4];
0465     case UAC_VERSION_2:
0466         return 1; /* in UAC2, this value is constant */
0467     case UAC_VERSION_3:
0468         return 4; /* in UAC3, this value is constant */
0469     default:
0470         return 1;
0471     }
0472 }
0473 
0474 static inline __u8 uac_extension_unit_iExtension(struct uac_processing_unit_descriptor *desc,
0475                          int protocol)
0476 {
0477     __u8 control_size = uac_extension_unit_bControlSize(desc, protocol);
0478 
0479     switch (protocol) {
0480     case UAC_VERSION_1:
0481     case UAC_VERSION_2:
0482     default:
0483         return *(uac_processing_unit_bmControls(desc, protocol)
0484              + control_size);
0485     case UAC_VERSION_3:
0486         return 0; /* UAC3 does not have this field */
0487     }
0488 }
0489 
0490 /* 4.5.2 Class-Specific AS Interface Descriptor */
0491 struct uac1_as_header_descriptor {
0492     __u8  bLength;          /* in bytes: 7 */
0493     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0494     __u8  bDescriptorSubtype;   /* AS_GENERAL */
0495     __u8  bTerminalLink;        /* Terminal ID of connected Terminal */
0496     __u8  bDelay;           /* Delay introduced by the data path */
0497     __le16 wFormatTag;      /* The Audio Data Format */
0498 } __attribute__ ((packed));
0499 
0500 #define UAC_DT_AS_HEADER_SIZE       7
0501 
0502 /* Formats - A.1.1 Audio Data Format Type I Codes */
0503 #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
0504 #define UAC_FORMAT_TYPE_I_PCM       0x1
0505 #define UAC_FORMAT_TYPE_I_PCM8      0x2
0506 #define UAC_FORMAT_TYPE_I_IEEE_FLOAT    0x3
0507 #define UAC_FORMAT_TYPE_I_ALAW      0x4
0508 #define UAC_FORMAT_TYPE_I_MULAW     0x5
0509 
0510 struct uac_format_type_i_continuous_descriptor {
0511     __u8  bLength;          /* in bytes: 8 + (ns * 3) */
0512     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0513     __u8  bDescriptorSubtype;   /* FORMAT_TYPE */
0514     __u8  bFormatType;      /* FORMAT_TYPE_1 */
0515     __u8  bNrChannels;      /* physical channels in the stream */
0516     __u8  bSubframeSize;        /* */
0517     __u8  bBitResolution;
0518     __u8  bSamFreqType;
0519     __u8  tLowerSamFreq[3];
0520     __u8  tUpperSamFreq[3];
0521 } __attribute__ ((packed));
0522 
0523 #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE  14
0524 
0525 struct uac_format_type_i_discrete_descriptor {
0526     __u8  bLength;          /* in bytes: 8 + (ns * 3) */
0527     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0528     __u8  bDescriptorSubtype;   /* FORMAT_TYPE */
0529     __u8  bFormatType;      /* FORMAT_TYPE_1 */
0530     __u8  bNrChannels;      /* physical channels in the stream */
0531     __u8  bSubframeSize;        /* */
0532     __u8  bBitResolution;
0533     __u8  bSamFreqType;
0534     __u8  tSamFreq[][3];
0535 } __attribute__ ((packed));
0536 
0537 #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n)      \
0538 struct uac_format_type_i_discrete_descriptor_##n {      \
0539     __u8  bLength;                      \
0540     __u8  bDescriptorType;                  \
0541     __u8  bDescriptorSubtype;               \
0542     __u8  bFormatType;                  \
0543     __u8  bNrChannels;                  \
0544     __u8  bSubframeSize;                    \
0545     __u8  bBitResolution;                   \
0546     __u8  bSamFreqType;                 \
0547     __u8  tSamFreq[n][3];                   \
0548 } __attribute__ ((packed))
0549 
0550 #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
0551 
0552 struct uac_format_type_i_ext_descriptor {
0553     __u8 bLength;
0554     __u8 bDescriptorType;
0555     __u8 bDescriptorSubtype;
0556     __u8 bFormatType;
0557     __u8 bSubslotSize;
0558     __u8 bBitResolution;
0559     __u8 bHeaderLength;
0560     __u8 bControlSize;
0561     __u8 bSideBandProtocol;
0562 } __attribute__((packed));
0563 
0564 /* Formats - Audio Data Format Type I Codes */
0565 
0566 #define UAC_FORMAT_TYPE_II_MPEG 0x1001
0567 #define UAC_FORMAT_TYPE_II_AC3  0x1002
0568 
0569 struct uac_format_type_ii_discrete_descriptor {
0570     __u8 bLength;
0571     __u8 bDescriptorType;
0572     __u8 bDescriptorSubtype;
0573     __u8 bFormatType;
0574     __le16 wMaxBitRate;
0575     __le16 wSamplesPerFrame;
0576     __u8 bSamFreqType;
0577     __u8 tSamFreq[][3];
0578 } __attribute__((packed));
0579 
0580 struct uac_format_type_ii_ext_descriptor {
0581     __u8 bLength;
0582     __u8 bDescriptorType;
0583     __u8 bDescriptorSubtype;
0584     __u8 bFormatType;
0585     __le16 wMaxBitRate;
0586     __le16 wSamplesPerFrame;
0587     __u8 bHeaderLength;
0588     __u8 bSideBandProtocol;
0589 } __attribute__((packed));
0590 
0591 /* type III */
0592 #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
0593 #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1    0x2002
0594 #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
0595 #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT   0x2004
0596 #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
0597 #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS    0x2006
0598 
0599 /* Formats - A.2 Format Type Codes */
0600 #define UAC_FORMAT_TYPE_UNDEFINED   0x0
0601 #define UAC_FORMAT_TYPE_I       0x1
0602 #define UAC_FORMAT_TYPE_II      0x2
0603 #define UAC_FORMAT_TYPE_III     0x3
0604 #define UAC_EXT_FORMAT_TYPE_I       0x81
0605 #define UAC_EXT_FORMAT_TYPE_II      0x82
0606 #define UAC_EXT_FORMAT_TYPE_III     0x83
0607 
0608 struct uac_iso_endpoint_descriptor {
0609     __u8  bLength;          /* in bytes: 7 */
0610     __u8  bDescriptorType;      /* USB_DT_CS_ENDPOINT */
0611     __u8  bDescriptorSubtype;   /* EP_GENERAL */
0612     __u8  bmAttributes;
0613     __u8  bLockDelayUnits;
0614     __le16 wLockDelay;
0615 } __attribute__((packed));
0616 #define UAC_ISO_ENDPOINT_DESC_SIZE  7
0617 
0618 #define UAC_EP_CS_ATTR_SAMPLE_RATE  0x01
0619 #define UAC_EP_CS_ATTR_PITCH_CONTROL    0x02
0620 #define UAC_EP_CS_ATTR_FILL_MAX     0x80
0621 
0622 /* status word format (3.7.1.1) */
0623 
0624 #define UAC1_STATUS_TYPE_ORIG_MASK      0x0f
0625 #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF  0x0
0626 #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF   0x1
0627 #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP   0x2
0628 
0629 #define UAC1_STATUS_TYPE_IRQ_PENDING        (1 << 7)
0630 #define UAC1_STATUS_TYPE_MEM_CHANGED        (1 << 6)
0631 
0632 struct uac1_status_word {
0633     __u8 bStatusType;
0634     __u8 bOriginator;
0635 } __attribute__((packed));
0636 
0637 
0638 #endif /* _UAPI__LINUX_USB_AUDIO_H */