include/linux/usb/audio.h: add __attribute__((packed))
[safe/jmp/linux-2.6] / include / linux / usb / audio.h
index b5744bc..9fae6bd 100644 (file)
@@ -13,6 +13,9 @@
  * Comments below reference relevant sections of that document:
  *
  * http://www.usb.org/developers/devclass_docs/audio10.pdf
+ *
+ * Types and defines in this file are either specific to version 1.0 of
+ * this standard or common for newer versions.
  */
 
 #ifndef __LINUX_USB_AUDIO_H
 
 #include <linux/types.h>
 
+/* bInterfaceProtocol values to denote the version of the standard used */
+#define UAC_VERSION_1                  0x00
+#define UAC_VERSION_2                  0x20
+
 /* A.2 Audio Interface Subclass Codes */
 #define USB_SUBCLASS_AUDIOCONTROL      0x01
 #define USB_SUBCLASS_AUDIOSTREAMING    0x02
 #define USB_SUBCLASS_MIDISTREAMING     0x03
-#define USB_SUBCLASS_VENDOR_SPEC       0xff
-
-/* A.5 Audio Class-Specific AC interface Descriptor Subtypes*/
-#define HEADER                         0x01
-#define INPUT_TERMINAL                 0x02
-#define OUTPUT_TERMINAL                        0x03
-#define MIXER_UNIT                     0x04
-#define SELECTOR_UNIT                  0x05
-#define FEATURE_UNIT                   0x06
-#define PROCESSING_UNIT                        0x07
-#define EXTENSION_UNIT                 0x08
-
-#define AS_GENERAL                     0x01
-#define FORMAT_TYPE                    0x02
-#define FORMAT_SPECIFIC                        0x03
-
-#define EP_GENERAL                     0x01
-
-#define MS_GENERAL                     0x01
-#define MIDI_IN_JACK                   0x02
-#define MIDI_OUT_JACK                  0x03
-
-/* endpoint attributes */
-#define EP_ATTR_MASK                   0x0c
-#define EP_ATTR_ASYNC                  0x04
-#define EP_ATTR_ADAPTIVE               0x08
-#define EP_ATTR_SYNC                   0x0c
-
-/* cs endpoint attributes */
-#define EP_CS_ATTR_SAMPLE_RATE         0x01
-#define EP_CS_ATTR_PITCH_CONTROL       0x02
-#define EP_CS_ATTR_FILL_MAX            0x80
-
-/* Audio Class specific Request Codes */
-#define USB_AUDIO_SET_INTF             0x21
-#define USB_AUDIO_SET_ENDPOINT         0x22
-#define USB_AUDIO_GET_INTF             0xa1
-#define USB_AUDIO_GET_ENDPOINT         0xa2
-
-#define SET_   0x00
-#define GET_   0x80
-
-#define _CUR   0x1
-#define _MIN   0x2
-#define _MAX   0x3
-#define _RES   0x4
-#define _MEM   0x5
-
-#define SET_CUR                (SET_ | _CUR)
-#define GET_CUR                (GET_ | _CUR)
-#define SET_MIN                (SET_ | _MIN)
-#define GET_MIN                (GET_ | _MIN)
-#define SET_MAX                (SET_ | _MAX)
-#define GET_MAX                (GET_ | _MAX)
-#define SET_RES                (SET_ | _RES)
-#define GET_RES                (GET_ | _RES)
-#define SET_MEM                (SET_ | _MEM)
-#define GET_MEM                (GET_ | _MEM)
-
-#define GET_STAT       0xff
-
-#define USB_AC_TERMINAL_UNDEFINED      0x100
-#define USB_AC_TERMINAL_STREAMING      0x101
-#define USB_AC_TERMINAL_VENDOR_SPEC    0x1FF
+
+/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
+#define UAC_HEADER                     0x01
+#define UAC_INPUT_TERMINAL             0x02
+#define UAC_OUTPUT_TERMINAL            0x03
+#define UAC_MIXER_UNIT                 0x04
+#define UAC_SELECTOR_UNIT              0x05
+#define UAC_FEATURE_UNIT               0x06
+#define UAC_PROCESSING_UNIT_V1         0x07
+#define UAC_EXTENSION_UNIT_V1          0x08
+
+/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
+#define UAC_AS_GENERAL                 0x01
+#define UAC_FORMAT_TYPE                        0x02
+#define UAC_FORMAT_SPECIFIC            0x03
+
+/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
+#define UAC_EP_GENERAL                 0x01
+
+/* A.9 Audio Class-Specific Request Codes */
+#define UAC_SET_                       0x00
+#define UAC_GET_                       0x80
+
+#define UAC__CUR                       0x1
+#define UAC__MIN                       0x2
+#define UAC__MAX                       0x3
+#define UAC__RES                       0x4
+#define UAC__MEM                       0x5
+
+#define UAC_SET_CUR                    (UAC_SET_ | UAC__CUR)
+#define UAC_GET_CUR                    (UAC_GET_ | UAC__CUR)
+#define UAC_SET_MIN                    (UAC_SET_ | UAC__MIN)
+#define UAC_GET_MIN                    (UAC_GET_ | UAC__MIN)
+#define UAC_SET_MAX                    (UAC_SET_ | UAC__MAX)
+#define UAC_GET_MAX                    (UAC_GET_ | UAC__MAX)
+#define UAC_SET_RES                    (UAC_SET_ | UAC__RES)
+#define UAC_GET_RES                    (UAC_GET_ | UAC__RES)
+#define UAC_SET_MEM                    (UAC_SET_ | UAC__MEM)
+#define UAC_GET_MEM                    (UAC_GET_ | UAC__MEM)
+
+#define UAC_GET_STAT                   0xff
+
+/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
+#define UAC_MS_HEADER                  0x01
+#define UAC_MIDI_IN_JACK               0x02
+#define UAC_MIDI_OUT_JACK              0x03
+
+/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
+#define UAC_MS_GENERAL                 0x01
+
+/* Terminals - 2.1 USB Terminal Types */
+#define UAC_TERMINAL_UNDEFINED         0x100
+#define UAC_TERMINAL_STREAMING         0x101
+#define UAC_TERMINAL_VENDOR_SPEC       0x1FF
 
 /* Terminal Control Selectors */
 /* 4.3.2  Class-Specific AC Interface Descriptor */
-struct usb_ac_header_descriptor {
+struct uac_ac_header_descriptor_v1 {
        __u8  bLength;                  /* 8 + n */
        __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
-       __u8  bDescriptorSubtype;       /* USB_MS_HEADER */
+       __u8  bDescriptorSubtype;       /* UAC_MS_HEADER */
        __le16 bcdADC;                  /* 0x0100 */
        __le16 wTotalLength;            /* includes Unit and Terminal desc. */
        __u8  bInCollection;            /* n */
        __u8  baInterfaceNr[];          /* [n] */
 } __attribute__ ((packed));
 
-#define USB_DT_AC_HEADER_SIZE(n)       (8 + (n))
+#define UAC_DT_AC_HEADER_SIZE(n)       (8 + (n))
 
 /* As above, but more useful for defining your own descriptors: */
-#define DECLARE_USB_AC_HEADER_DESCRIPTOR(n)                    \
-struct usb_ac_header_descriptor_##n {                          \
+#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n)                    \
+struct uac_ac_header_descriptor_v1_##n {                       \
        __u8  bLength;                                          \
        __u8  bDescriptorType;                                  \
        __u8  bDescriptorSubtype;                               \
@@ -116,7 +113,7 @@ struct usb_ac_header_descriptor_##n {                               \
 } __attribute__ ((packed))
 
 /* 4.3.2.1 Input Terminal Descriptor */
-struct usb_input_terminal_descriptor {
+struct uac_input_terminal_descriptor {
        __u8  bLength;                  /* in bytes: 12 */
        __u8  bDescriptorType;          /* CS_INTERFACE descriptor type */
        __u8  bDescriptorSubtype;       /* INPUT_TERMINAL descriptor subtype */
@@ -129,18 +126,23 @@ struct usb_input_terminal_descriptor {
        __u8  iTerminal;
 } __attribute__ ((packed));
 
-#define USB_DT_AC_INPUT_TERMINAL_SIZE                  12
+#define UAC_DT_INPUT_TERMINAL_SIZE                     12
+
+/* Terminals - 2.2 Input Terminal Types */
+#define UAC_INPUT_TERMINAL_UNDEFINED                   0x200
+#define UAC_INPUT_TERMINAL_MICROPHONE                  0x201
+#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE          0x202
+#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE         0x203
+#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE         0x204
+#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY            0x205
+#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY       0x206
+
+/* Terminals - control selectors */
 
-#define USB_AC_INPUT_TERMINAL_UNDEFINED                        0x200
-#define USB_AC_INPUT_TERMINAL_MICROPHONE               0x201
-#define USB_AC_INPUT_TERMINAL_DESKTOP_MICROPHONE       0x202
-#define USB_AC_INPUT_TERMINAL_PERSONAL_MICROPHONE      0x203
-#define USB_AC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE      0x204
-#define USB_AC_INPUT_TERMINAL_MICROPHONE_ARRAY         0x205
-#define USB_AC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY    0x206
+#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL           0x01
 
 /* 4.3.2.2 Output Terminal Descriptor */
-struct usb_output_terminal_descriptor {
+struct uac_output_terminal_descriptor_v1 {
        __u8  bLength;                  /* in bytes: 9 */
        __u8  bDescriptorType;          /* CS_INTERFACE descriptor type */
        __u8  bDescriptorSubtype;       /* OUTPUT_TERMINAL descriptor subtype */
@@ -151,23 +153,24 @@ struct usb_output_terminal_descriptor {
        __u8  iTerminal;
 } __attribute__ ((packed));
 
-#define USB_DT_AC_OUTPUT_TERMINAL_SIZE                         9
+#define UAC_DT_OUTPUT_TERMINAL_SIZE                    9
 
-#define USB_AC_OUTPUT_TERMINAL_UNDEFINED                       0x300
-#define USB_AC_OUTPUT_TERMINAL_SPEAKER                         0x301
-#define USB_AC_OUTPUT_TERMINAL_HEADPHONES                      0x302
-#define USB_AC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO      0x303
-#define USB_AC_OUTPUT_TERMINAL_DESKTOP_SPEAKER                 0x304
-#define USB_AC_OUTPUT_TERMINAL_ROOM_SPEAKER                    0x305
-#define USB_AC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER           0x306
-#define USB_AC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER                0x307
+/* Terminals - 2.3 Output Terminal Types */
+#define UAC_OUTPUT_TERMINAL_UNDEFINED                  0x300
+#define UAC_OUTPUT_TERMINAL_SPEAKER                    0x301
+#define UAC_OUTPUT_TERMINAL_HEADPHONES                 0x302
+#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
+#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER            0x304
+#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER               0x305
+#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER      0x306
+#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER   0x307
 
 /* Set bControlSize = 2 as default setting */
-#define USB_DT_AC_FEATURE_UNIT_SIZE(ch)                (7 + ((ch) + 1) * 2)
+#define UAC_DT_FEATURE_UNIT_SIZE(ch)           (7 + ((ch) + 1) * 2)
 
 /* As above, but more useful for defining your own descriptors: */
-#define DECLARE_USB_AC_FEATURE_UNIT_DESCRIPTOR(ch)             \
-struct usb_ac_feature_unit_descriptor_##ch {                   \
+#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch)                \
+struct uac_feature_unit_descriptor_##ch {                      \
        __u8  bLength;                                          \
        __u8  bDescriptorType;                                  \
        __u8  bDescriptorSubtype;                               \
@@ -178,8 +181,158 @@ struct usb_ac_feature_unit_descriptor_##ch {                      \
        __u8  iFeature;                                         \
 } __attribute__ ((packed))
 
+/* 4.3.2.3 Mixer Unit Descriptor */
+struct uac_mixer_unit_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bUnitID;
+       __u8 bNrInPins;
+       __u8 baSourceID[];
+} __attribute__ ((packed));
+
+static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
+{
+       return desc->baSourceID[desc->bNrInPins];
+}
+
+static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
+                                                 int protocol)
+{
+       if (protocol == UAC_VERSION_1)
+               return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
+                       desc->baSourceID[desc->bNrInPins + 1];
+       else
+               return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
+                       (desc->baSourceID[desc->bNrInPins + 3] << 16) |
+                       (desc->baSourceID[desc->bNrInPins + 2] << 8)  |
+                       (desc->baSourceID[desc->bNrInPins + 1]);
+}
+
+static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
+                                               int protocol)
+{
+       return (protocol == UAC_VERSION_1) ?
+               desc->baSourceID[desc->bNrInPins + 3] :
+               desc->baSourceID[desc->bNrInPins + 5];
+}
+
+static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
+                                             int protocol)
+{
+       return (protocol == UAC_VERSION_1) ?
+               &desc->baSourceID[desc->bNrInPins + 4] :
+               &desc->baSourceID[desc->bNrInPins + 6];
+}
+
+static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
+{
+       __u8 *raw = (__u8 *) desc;
+       return raw[desc->bLength - 1];
+}
+
+/* 4.3.2.4 Selector Unit Descriptor */
+struct uac_selector_unit_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bUintID;
+       __u8 bNrInPins;
+       __u8 baSourceID[];
+} __attribute__ ((packed));
+
+static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
+{
+       __u8 *raw = (__u8 *) desc;
+       return raw[9 + desc->bLength - 1];
+}
+
+/* 4.3.2.5 Feature Unit Descriptor */
+struct uac_feature_unit_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bUnitID;
+       __u8 bSourceID;
+       __u8 bControlSize;
+       __u8 bmaControls[0]; /* variable length */
+} __attribute__((packed));
+
+static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
+{
+       __u8 *raw = (__u8 *) desc;
+       return raw[desc->bLength - 1];
+}
+
+/* 4.3.2.6 Processing Unit Descriptors */
+struct uac_processing_unit_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bUnitID;
+       __u16 wProcessType;
+       __u8 bNrInPins;
+       __u8 baSourceID[];
+} __attribute__ ((packed));
+
+static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
+{
+       return desc->baSourceID[desc->bNrInPins];
+}
+
+static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
+                                                      int protocol)
+{
+       if (protocol == UAC_VERSION_1)
+               return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
+                       desc->baSourceID[desc->bNrInPins + 1];
+       else
+               return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
+                       (desc->baSourceID[desc->bNrInPins + 3] << 16) |
+                       (desc->baSourceID[desc->bNrInPins + 2] << 8)  |
+                       (desc->baSourceID[desc->bNrInPins + 1]);
+}
+
+static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
+                                                    int protocol)
+{
+       return (protocol == UAC_VERSION_1) ?
+               desc->baSourceID[desc->bNrInPins + 3] :
+               desc->baSourceID[desc->bNrInPins + 5];
+}
+
+static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
+                                                   int protocol)
+{
+       return (protocol == UAC_VERSION_1) ?
+               desc->baSourceID[desc->bNrInPins + 4] :
+               desc->baSourceID[desc->bNrInPins + 6];
+}
+
+static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
+                                                  int protocol)
+{
+       return (protocol == UAC_VERSION_1) ?
+               &desc->baSourceID[desc->bNrInPins + 5] :
+               &desc->baSourceID[desc->bNrInPins + 7];
+}
+
+static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
+                                                  int protocol)
+{
+       __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
+       return desc->baSourceID[desc->bNrInPins + control_size];
+}
+
+static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
+                                                int protocol)
+{
+       __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
+       return &desc->baSourceID[desc->bNrInPins + control_size + 1];
+}
+
 /* 4.5.2 Class-Specific AS Interface Descriptor */
-struct usb_as_header_descriptor {
+struct uac_as_header_descriptor_v1 {
        __u8  bLength;                  /* in bytes: 7 */
        __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
        __u8  bDescriptorSubtype;       /* AS_GENERAL */
@@ -188,16 +341,17 @@ struct usb_as_header_descriptor {
        __le16 wFormatTag;              /* The Audio Data Format */
 } __attribute__ ((packed));
 
-#define USB_DT_AS_HEADER_SIZE          7
+#define UAC_DT_AS_HEADER_SIZE          7
 
-#define USB_AS_AUDIO_FORMAT_TYPE_I_UNDEFINED   0x0
-#define USB_AS_AUDIO_FORMAT_TYPE_I_PCM         0x1
-#define USB_AS_AUDIO_FORMAT_TYPE_I_PCM8                0x2
-#define USB_AS_AUDIO_FORMAT_TYPE_I_IEEE_FLOAT  0x3
-#define USB_AS_AUDIO_FORMAT_TYPE_I_ALAW                0x4
-#define USB_AS_AUDIO_FORMAT_TYPE_I_MULAW       0x5
+/* Formats - A.1.1 Audio Data Format Type I Codes */
+#define UAC_FORMAT_TYPE_I_UNDEFINED    0x0
+#define UAC_FORMAT_TYPE_I_PCM          0x1
+#define UAC_FORMAT_TYPE_I_PCM8         0x2
+#define UAC_FORMAT_TYPE_I_IEEE_FLOAT   0x3
+#define UAC_FORMAT_TYPE_I_ALAW         0x4
+#define UAC_FORMAT_TYPE_I_MULAW                0x5
 
-struct usb_as_format_type_i_continuous_descriptor {
+struct uac_format_type_i_continuous_descriptor {
        __u8  bLength;                  /* in bytes: 8 + (ns * 3) */
        __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
        __u8  bDescriptorSubtype;       /* FORMAT_TYPE */
@@ -210,9 +364,9 @@ struct usb_as_format_type_i_continuous_descriptor {
        __u8  tUpperSamFreq[3];
 } __attribute__ ((packed));
 
-#define USB_AS_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE      14
+#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
 
-struct usb_as_formate_type_i_discrete_descriptor {
+struct uac_format_type_i_discrete_descriptor {
        __u8  bLength;                  /* in bytes: 8 + (ns * 3) */
        __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
        __u8  bDescriptorSubtype;       /* FORMAT_TYPE */
@@ -224,8 +378,8 @@ struct usb_as_formate_type_i_discrete_descriptor {
        __u8  tSamFreq[][3];
 } __attribute__ ((packed));
 
-#define DECLARE_USB_AS_FORMAT_TYPE_I_DISCRETE_DESC(n)          \
-struct usb_as_formate_type_i_discrete_descriptor_##n {         \
+#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n)             \
+struct uac_format_type_i_discrete_descriptor_##n {             \
        __u8  bLength;                                          \
        __u8  bDescriptorType;                                  \
        __u8  bDescriptorSubtype;                               \
@@ -237,49 +391,104 @@ struct usb_as_formate_type_i_discrete_descriptor_##n {           \
        __u8  tSamFreq[n][3];                                   \
 } __attribute__ ((packed))
 
-#define USB_AS_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n)     (8 + (n * 3))
-
-#define USB_AS_FORMAT_TYPE_UNDEFINED   0x0
-#define USB_AS_FORMAT_TYPE_I           0x1
-#define USB_AS_FORMAT_TYPE_II          0x2
-#define USB_AS_FORMAT_TYPE_III         0x3
-
-#define USB_AS_ENDPOINT_ASYNC          (1 << 2)
-#define USB_AS_ENDPOINT_ADAPTIVE       (2 << 2)
-#define USB_AS_ENDPOINT_SYNC           (3 << 2)
-
-struct usb_as_iso_endpoint_descriptor {
+#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n)        (8 + (n * 3))
+
+struct uac_format_type_i_ext_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bFormatType;
+       __u8 bSubslotSize;
+       __u8 bBitResolution;
+       __u8 bHeaderLength;
+       __u8 bControlSize;
+       __u8 bSideBandProtocol;
+} __attribute__((packed));
+
+/* Formats - Audio Data Format Type I Codes */
+
+#define UAC_FORMAT_TYPE_II_MPEG        0x1001
+#define UAC_FORMAT_TYPE_II_AC3 0x1002
+
+struct uac_format_type_ii_discrete_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bFormatType;
+       __le16 wMaxBitRate;
+       __le16 wSamplesPerFrame;
+       __u8 bSamFreqType;
+       __u8 tSamFreq[][3];
+} __attribute__((packed));
+
+struct uac_format_type_ii_ext_descriptor {
+       __u8 bLength;
+       __u8 bDescriptorType;
+       __u8 bDescriptorSubtype;
+       __u8 bFormatType;
+       __u16 wMaxBitRate;
+       __u16 wSamplesPerFrame;
+       __u8 bHeaderLength;
+       __u8 bSideBandProtocol;
+} __attribute__((packed));
+
+/* type III */
+#define UAC_FORMAT_TYPE_III_IEC1937_AC3        0x2001
+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1       0x2002
+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT        0x2003
+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT  0x2004
+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS    0x2005
+#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS   0x2006
+
+/* Formats - A.2 Format Type Codes */
+#define UAC_FORMAT_TYPE_UNDEFINED      0x0
+#define UAC_FORMAT_TYPE_I              0x1
+#define UAC_FORMAT_TYPE_II             0x2
+#define UAC_FORMAT_TYPE_III            0x3
+#define UAC_EXT_FORMAT_TYPE_I          0x81
+#define UAC_EXT_FORMAT_TYPE_II         0x82
+#define UAC_EXT_FORMAT_TYPE_III                0x83
+
+struct uac_iso_endpoint_descriptor {
        __u8  bLength;                  /* in bytes: 7 */
        __u8  bDescriptorType;          /* USB_DT_CS_ENDPOINT */
        __u8  bDescriptorSubtype;       /* EP_GENERAL */
        __u8  bmAttributes;
        __u8  bLockDelayUnits;
        __le16 wLockDelay;
-};
-#define USB_AS_ISO_ENDPOINT_DESC_SIZE  7
-
-#define FU_CONTROL_UNDEFINED           0x00
-#define MUTE_CONTROL                   0x01
-#define VOLUME_CONTROL                 0x02
-#define BASS_CONTROL                   0x03
-#define MID_CONTROL                    0x04
-#define TREBLE_CONTROL                 0x05
-#define GRAPHIC_EQUALIZER_CONTROL      0x06
-#define AUTOMATIC_GAIN_CONTROL         0x07
-#define DELAY_CONTROL                  0x08
-#define BASS_BOOST_CONTROL             0x09
-#define LOUDNESS_CONTROL               0x0a
-
-#define FU_MUTE                (1 << (MUTE_CONTROL - 1))
-#define FU_VOLUME      (1 << (VOLUME_CONTROL - 1))
-#define FU_BASS                (1 << (BASS_CONTROL - 1))
-#define FU_MID         (1 << (MID_CONTROL - 1))
-#define FU_TREBLE      (1 << (TREBLE_CONTROL - 1))
-#define FU_GRAPHIC_EQ  (1 << (GRAPHIC_EQUALIZER_CONTROL - 1))
-#define FU_AUTO_GAIN   (1 << (AUTOMATIC_GAIN_CONTROL - 1))
-#define FU_DELAY       (1 << (DELAY_CONTROL - 1))
-#define FU_BASS_BOOST  (1 << (BASS_BOOST_CONTROL - 1))
-#define FU_LOUDNESS    (1 << (LOUDNESS_CONTROL - 1))
+} __attribute__((packed));
+#define UAC_ISO_ENDPOINT_DESC_SIZE     7
+
+#define UAC_EP_CS_ATTR_SAMPLE_RATE     0x01
+#define UAC_EP_CS_ATTR_PITCH_CONTROL   0x02
+#define UAC_EP_CS_ATTR_FILL_MAX                0x80
+
+/* A.10.2 Feature Unit Control Selectors */
+
+#define UAC_FU_CONTROL_UNDEFINED       0x00
+#define UAC_MUTE_CONTROL               0x01
+#define UAC_VOLUME_CONTROL             0x02
+#define UAC_BASS_CONTROL               0x03
+#define UAC_MID_CONTROL                        0x04
+#define UAC_TREBLE_CONTROL             0x05
+#define UAC_GRAPHIC_EQUALIZER_CONTROL  0x06
+#define UAC_AUTOMATIC_GAIN_CONTROL     0x07
+#define UAC_DELAY_CONTROL              0x08
+#define UAC_BASS_BOOST_CONTROL         0x09
+#define UAC_LOUDNESS_CONTROL           0x0a
+
+#define UAC_FU_MUTE            (1 << (UAC_MUTE_CONTROL - 1))
+#define UAC_FU_VOLUME          (1 << (UAC_VOLUME_CONTROL - 1))
+#define UAC_FU_BASS            (1 << (UAC_BASS_CONTROL - 1))
+#define UAC_FU_MID             (1 << (UAC_MID_CONTROL - 1))
+#define UAC_FU_TREBLE          (1 << (UAC_TREBLE_CONTROL - 1))
+#define UAC_FU_GRAPHIC_EQ      (1 << (UAC_GRAPHIC_EQUALIZER_CONTROL - 1))
+#define UAC_FU_AUTO_GAIN       (1 << (UAC_AUTOMATIC_GAIN_CONTROL - 1))
+#define UAC_FU_DELAY           (1 << (UAC_DELAY_CONTROL - 1))
+#define UAC_FU_BASS_BOOST      (1 << (UAC_BASS_BOOST_CONTROL - 1))
+#define UAC_FU_LOUDNESS                (1 << (UAC_LOUDNESS_CONTROL - 1))
+
+#ifdef __KERNEL__
 
 struct usb_audio_control {
        struct list_head list;
@@ -290,18 +499,6 @@ struct usb_audio_control {
        int (*get)(struct usb_audio_control *con, u8 cmd);
 };
 
-static inline int generic_set_cmd(struct usb_audio_control *con, u8 cmd, int value)
-{
-       con->data[cmd] = value;
-
-       return 0;
-}
-
-static inline int generic_get_cmd(struct usb_audio_control *con, u8 cmd)
-{
-       return con->data[cmd];
-}
-
 struct usb_audio_control_selector {
        struct list_head list;
        struct list_head control;
@@ -311,4 +508,6 @@ struct usb_audio_control_selector {
        struct usb_descriptor_header *desc;
 };
 
+#endif /* __KERNEL__ */
+
 #endif /* __LINUX_USB_AUDIO_H */