xref: /linux/include/uapi/linux/usb/audio.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
25e1ddb48SDavid Howells /*
35e1ddb48SDavid Howells  * <linux/usb/audio.h> -- USB Audio definitions.
45e1ddb48SDavid Howells  *
55e1ddb48SDavid Howells  * Copyright (C) 2006 Thumtronics Pty Ltd.
65e1ddb48SDavid Howells  * Developed for Thumtronics by Grey Innovation
75e1ddb48SDavid Howells  * Ben Williamson <ben.williamson@greyinnovation.com>
85e1ddb48SDavid Howells  *
95e1ddb48SDavid Howells  * This software is distributed under the terms of the GNU General Public
105e1ddb48SDavid Howells  * License ("GPL") version 2, as published by the Free Software Foundation.
115e1ddb48SDavid Howells  *
125e1ddb48SDavid Howells  * This file holds USB constants and structures defined
135e1ddb48SDavid Howells  * by the USB Device Class Definition for Audio Devices.
145e1ddb48SDavid Howells  * Comments below reference relevant sections of that document:
155e1ddb48SDavid Howells  *
165e1ddb48SDavid Howells  * http://www.usb.org/developers/devclass_docs/audio10.pdf
175e1ddb48SDavid Howells  *
185e1ddb48SDavid Howells  * Types and defines in this file are either specific to version 1.0 of
195e1ddb48SDavid Howells  * this standard or common for newer versions.
205e1ddb48SDavid Howells  */
215e1ddb48SDavid Howells 
225e1ddb48SDavid Howells #ifndef _UAPI__LINUX_USB_AUDIO_H
235e1ddb48SDavid Howells #define _UAPI__LINUX_USB_AUDIO_H
245e1ddb48SDavid Howells 
255e1ddb48SDavid Howells #include <linux/types.h>
265e1ddb48SDavid Howells 
275e1ddb48SDavid Howells /* bInterfaceProtocol values to denote the version of the standard used */
285e1ddb48SDavid Howells #define UAC_VERSION_1			0x00
295e1ddb48SDavid Howells #define UAC_VERSION_2			0x20
309a2fe9b8SRuslan Bilovol #define UAC_VERSION_3			0x30
315e1ddb48SDavid Howells 
325e1ddb48SDavid Howells /* A.2 Audio Interface Subclass Codes */
335e1ddb48SDavid Howells #define USB_SUBCLASS_AUDIOCONTROL	0x01
345e1ddb48SDavid Howells #define USB_SUBCLASS_AUDIOSTREAMING	0x02
355e1ddb48SDavid Howells #define USB_SUBCLASS_MIDISTREAMING	0x03
365e1ddb48SDavid Howells 
375e1ddb48SDavid Howells /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
385e1ddb48SDavid Howells #define UAC_HEADER			0x01
395e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL		0x02
405e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL		0x03
415e1ddb48SDavid Howells #define UAC_MIXER_UNIT			0x04
425e1ddb48SDavid Howells #define UAC_SELECTOR_UNIT		0x05
435e1ddb48SDavid Howells #define UAC_FEATURE_UNIT		0x06
445e1ddb48SDavid Howells #define UAC1_PROCESSING_UNIT		0x07
455e1ddb48SDavid Howells #define UAC1_EXTENSION_UNIT		0x08
465e1ddb48SDavid Howells 
475e1ddb48SDavid Howells /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
485e1ddb48SDavid Howells #define UAC_AS_GENERAL			0x01
495e1ddb48SDavid Howells #define UAC_FORMAT_TYPE			0x02
505e1ddb48SDavid Howells #define UAC_FORMAT_SPECIFIC		0x03
515e1ddb48SDavid Howells 
525e1ddb48SDavid Howells /* A.7 Processing Unit Process Types */
535e1ddb48SDavid Howells #define UAC_PROCESS_UNDEFINED		0x00
545e1ddb48SDavid Howells #define UAC_PROCESS_UP_DOWNMIX		0x01
555e1ddb48SDavid Howells #define UAC_PROCESS_DOLBY_PROLOGIC	0x02
565e1ddb48SDavid Howells #define UAC_PROCESS_STEREO_EXTENDER	0x03
575e1ddb48SDavid Howells #define UAC_PROCESS_REVERB		0x04
585e1ddb48SDavid Howells #define UAC_PROCESS_CHORUS		0x05
595e1ddb48SDavid Howells #define UAC_PROCESS_DYN_RANGE_COMP	0x06
605e1ddb48SDavid Howells 
615e1ddb48SDavid Howells /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
625e1ddb48SDavid Howells #define UAC_EP_GENERAL			0x01
635e1ddb48SDavid Howells 
645e1ddb48SDavid Howells /* A.9 Audio Class-Specific Request Codes */
655e1ddb48SDavid Howells #define UAC_SET_			0x00
665e1ddb48SDavid Howells #define UAC_GET_			0x80
675e1ddb48SDavid Howells 
685e1ddb48SDavid Howells #define UAC__CUR			0x1
695e1ddb48SDavid Howells #define UAC__MIN			0x2
705e1ddb48SDavid Howells #define UAC__MAX			0x3
715e1ddb48SDavid Howells #define UAC__RES			0x4
725e1ddb48SDavid Howells #define UAC__MEM			0x5
735e1ddb48SDavid Howells 
745e1ddb48SDavid Howells #define UAC_SET_CUR			(UAC_SET_ | UAC__CUR)
755e1ddb48SDavid Howells #define UAC_GET_CUR			(UAC_GET_ | UAC__CUR)
765e1ddb48SDavid Howells #define UAC_SET_MIN			(UAC_SET_ | UAC__MIN)
775e1ddb48SDavid Howells #define UAC_GET_MIN			(UAC_GET_ | UAC__MIN)
785e1ddb48SDavid Howells #define UAC_SET_MAX			(UAC_SET_ | UAC__MAX)
795e1ddb48SDavid Howells #define UAC_GET_MAX			(UAC_GET_ | UAC__MAX)
805e1ddb48SDavid Howells #define UAC_SET_RES			(UAC_SET_ | UAC__RES)
815e1ddb48SDavid Howells #define UAC_GET_RES			(UAC_GET_ | UAC__RES)
825e1ddb48SDavid Howells #define UAC_SET_MEM			(UAC_SET_ | UAC__MEM)
835e1ddb48SDavid Howells #define UAC_GET_MEM			(UAC_GET_ | UAC__MEM)
845e1ddb48SDavid Howells 
855e1ddb48SDavid Howells #define UAC_GET_STAT			0xff
865e1ddb48SDavid Howells 
875e1ddb48SDavid Howells /* A.10 Control Selector Codes */
885e1ddb48SDavid Howells 
895e1ddb48SDavid Howells /* A.10.1 Terminal Control Selectors */
905e1ddb48SDavid Howells #define UAC_TERM_COPY_PROTECT		0x01
915e1ddb48SDavid Howells 
925e1ddb48SDavid Howells /* A.10.2 Feature Unit Control Selectors */
935e1ddb48SDavid Howells #define UAC_FU_MUTE			0x01
945e1ddb48SDavid Howells #define UAC_FU_VOLUME			0x02
955e1ddb48SDavid Howells #define UAC_FU_BASS			0x03
965e1ddb48SDavid Howells #define UAC_FU_MID			0x04
975e1ddb48SDavid Howells #define UAC_FU_TREBLE			0x05
985e1ddb48SDavid Howells #define UAC_FU_GRAPHIC_EQUALIZER	0x06
995e1ddb48SDavid Howells #define UAC_FU_AUTOMATIC_GAIN		0x07
1005e1ddb48SDavid Howells #define UAC_FU_DELAY			0x08
1015e1ddb48SDavid Howells #define UAC_FU_BASS_BOOST		0x09
1025e1ddb48SDavid Howells #define UAC_FU_LOUDNESS			0x0a
1035e1ddb48SDavid Howells 
1045e1ddb48SDavid Howells #define UAC_CONTROL_BIT(CS)	(1 << ((CS) - 1))
1055e1ddb48SDavid Howells 
1065e1ddb48SDavid Howells /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
1075e1ddb48SDavid Howells #define UAC_UD_ENABLE			0x01
1085e1ddb48SDavid Howells #define UAC_UD_MODE_SELECT		0x02
1095e1ddb48SDavid Howells 
1105e1ddb48SDavid Howells /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
1115e1ddb48SDavid Howells #define UAC_DP_ENABLE			0x01
1125e1ddb48SDavid Howells #define UAC_DP_MODE_SELECT		0x02
1135e1ddb48SDavid Howells 
1145e1ddb48SDavid Howells /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
1155e1ddb48SDavid Howells #define UAC_3D_ENABLE			0x01
1165e1ddb48SDavid Howells #define UAC_3D_SPACE			0x02
1175e1ddb48SDavid Howells 
1185e1ddb48SDavid Howells /* A.10.3.4 Reverberation Processing Unit Control Selectors */
1195e1ddb48SDavid Howells #define UAC_REVERB_ENABLE		0x01
1205e1ddb48SDavid Howells #define UAC_REVERB_LEVEL		0x02
1215e1ddb48SDavid Howells #define UAC_REVERB_TIME			0x03
1225e1ddb48SDavid Howells #define UAC_REVERB_FEEDBACK		0x04
1235e1ddb48SDavid Howells 
1245e1ddb48SDavid Howells /* A.10.3.5 Chorus Processing Unit Control Selectors */
1255e1ddb48SDavid Howells #define UAC_CHORUS_ENABLE		0x01
1265e1ddb48SDavid Howells #define UAC_CHORUS_LEVEL		0x02
1275e1ddb48SDavid Howells #define UAC_CHORUS_RATE			0x03
1285e1ddb48SDavid Howells #define UAC_CHORUS_DEPTH		0x04
1295e1ddb48SDavid Howells 
1305e1ddb48SDavid Howells /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
1315e1ddb48SDavid Howells #define UAC_DCR_ENABLE			0x01
1325e1ddb48SDavid Howells #define UAC_DCR_RATE			0x02
1335e1ddb48SDavid Howells #define UAC_DCR_MAXAMPL			0x03
1345e1ddb48SDavid Howells #define UAC_DCR_THRESHOLD		0x04
1355e1ddb48SDavid Howells #define UAC_DCR_ATTACK_TIME		0x05
1365e1ddb48SDavid Howells #define UAC_DCR_RELEASE_TIME		0x06
1375e1ddb48SDavid Howells 
1385e1ddb48SDavid Howells /* A.10.4 Extension Unit Control Selectors */
1395e1ddb48SDavid Howells #define UAC_XU_ENABLE			0x01
1405e1ddb48SDavid Howells 
1415e1ddb48SDavid Howells /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
1425e1ddb48SDavid Howells #define UAC_MS_HEADER			0x01
1435e1ddb48SDavid Howells #define UAC_MIDI_IN_JACK		0x02
1445e1ddb48SDavid Howells #define UAC_MIDI_OUT_JACK		0x03
1455e1ddb48SDavid Howells 
1465e1ddb48SDavid Howells /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
1475e1ddb48SDavid Howells #define UAC_MS_GENERAL			0x01
1485e1ddb48SDavid Howells 
1495e1ddb48SDavid Howells /* Terminals - 2.1 USB Terminal Types */
1505e1ddb48SDavid Howells #define UAC_TERMINAL_UNDEFINED		0x100
1515e1ddb48SDavid Howells #define UAC_TERMINAL_STREAMING		0x101
1525e1ddb48SDavid Howells #define UAC_TERMINAL_VENDOR_SPEC	0x1FF
1535e1ddb48SDavid Howells 
1545e1ddb48SDavid Howells /* Terminal Control Selectors */
1555e1ddb48SDavid Howells /* 4.3.2  Class-Specific AC Interface Descriptor */
1565e1ddb48SDavid Howells struct uac1_ac_header_descriptor {
1575e1ddb48SDavid Howells 	__u8  bLength;			/* 8 + n */
1585e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
1595e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* UAC_MS_HEADER */
1605e1ddb48SDavid Howells 	__le16 bcdADC;			/* 0x0100 */
1615e1ddb48SDavid Howells 	__le16 wTotalLength;		/* includes Unit and Terminal desc. */
1625e1ddb48SDavid Howells 	__u8  bInCollection;		/* n */
1635e1ddb48SDavid Howells 	__u8  baInterfaceNr[];		/* [n] */
1645e1ddb48SDavid Howells } __attribute__ ((packed));
1655e1ddb48SDavid Howells 
1665e1ddb48SDavid Howells #define UAC_DT_AC_HEADER_SIZE(n)	(8 + (n))
1675e1ddb48SDavid Howells 
1685e1ddb48SDavid Howells /* As above, but more useful for defining your own descriptors: */
1695e1ddb48SDavid Howells #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n)			\
1705e1ddb48SDavid Howells struct uac1_ac_header_descriptor_##n {			\
1715e1ddb48SDavid Howells 	__u8  bLength;						\
1725e1ddb48SDavid Howells 	__u8  bDescriptorType;					\
1735e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;				\
1745e1ddb48SDavid Howells 	__le16 bcdADC;						\
1755e1ddb48SDavid Howells 	__le16 wTotalLength;					\
1765e1ddb48SDavid Howells 	__u8  bInCollection;					\
1775e1ddb48SDavid Howells 	__u8  baInterfaceNr[n];					\
1785e1ddb48SDavid Howells } __attribute__ ((packed))
1795e1ddb48SDavid Howells 
1805e1ddb48SDavid Howells /* 4.3.2.1 Input Terminal Descriptor */
1815e1ddb48SDavid Howells struct uac_input_terminal_descriptor {
1825e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 12 */
1835e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
1845e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* INPUT_TERMINAL descriptor subtype */
1855e1ddb48SDavid Howells 	__u8  bTerminalID;		/* Constant uniquely terminal ID */
1865e1ddb48SDavid Howells 	__le16 wTerminalType;		/* USB Audio Terminal Types */
1875e1ddb48SDavid Howells 	__u8  bAssocTerminal;		/* ID of the Output Terminal associated */
1885e1ddb48SDavid Howells 	__u8  bNrChannels;		/* Number of logical output channels */
1895e1ddb48SDavid Howells 	__le16 wChannelConfig;
1905e1ddb48SDavid Howells 	__u8  iChannelNames;
1915e1ddb48SDavid Howells 	__u8  iTerminal;
1925e1ddb48SDavid Howells } __attribute__ ((packed));
1935e1ddb48SDavid Howells 
1945e1ddb48SDavid Howells #define UAC_DT_INPUT_TERMINAL_SIZE			12
1955e1ddb48SDavid Howells 
1965e1ddb48SDavid Howells /* Terminals - 2.2 Input Terminal Types */
1975e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_UNDEFINED			0x200
1985e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_MICROPHONE			0x201
1995e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE		0x202
2005e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE		0x203
2015e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE		0x204
2025e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY		0x205
2035e1ddb48SDavid Howells #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY	0x206
2045e1ddb48SDavid Howells 
2055e1ddb48SDavid Howells /* Terminals - control selectors */
2065e1ddb48SDavid Howells 
2075e1ddb48SDavid Howells #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL		0x01
2085e1ddb48SDavid Howells 
2095e1ddb48SDavid Howells /* 4.3.2.2 Output Terminal Descriptor */
2105e1ddb48SDavid Howells struct uac1_output_terminal_descriptor {
2115e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 9 */
2125e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
2135e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* OUTPUT_TERMINAL descriptor subtype */
2145e1ddb48SDavid Howells 	__u8  bTerminalID;		/* Constant uniquely terminal ID */
2155e1ddb48SDavid Howells 	__le16 wTerminalType;		/* USB Audio Terminal Types */
2165e1ddb48SDavid Howells 	__u8  bAssocTerminal;		/* ID of the Input Terminal associated */
2175e1ddb48SDavid Howells 	__u8  bSourceID;		/* ID of the connected Unit or Terminal*/
2185e1ddb48SDavid Howells 	__u8  iTerminal;
2195e1ddb48SDavid Howells } __attribute__ ((packed));
2205e1ddb48SDavid Howells 
2215e1ddb48SDavid Howells #define UAC_DT_OUTPUT_TERMINAL_SIZE			9
2225e1ddb48SDavid Howells 
2235e1ddb48SDavid Howells /* Terminals - 2.3 Output Terminal Types */
2245e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_UNDEFINED			0x300
2255e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_SPEAKER			0x301
2265e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_HEADPHONES			0x302
2275e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO	0x303
2285e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER		0x304
2295e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER		0x305
2305e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER	0x306
2315e1ddb48SDavid Howells #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER	0x307
2325e1ddb48SDavid Howells 
2332dd5aa15SJorge Sanjuan /* Terminals - 2.4 Bi-directional Terminal Types */
2342dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_UNDEFINED			0x400
2352dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_HANDSET			0x401
2362dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_HEADSET			0x402
2372dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_SPEAKER_PHONE		0x403
2382dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_ECHO_SUPPRESSING		0x404
2392dd5aa15SJorge Sanjuan #define UAC_BIDIR_TERMINAL_ECHO_CANCELING		0x405
2402dd5aa15SJorge Sanjuan 
2415e1ddb48SDavid Howells /* Set bControlSize = 2 as default setting */
2425e1ddb48SDavid Howells #define UAC_DT_FEATURE_UNIT_SIZE(ch)		(7 + ((ch) + 1) * 2)
2435e1ddb48SDavid Howells 
2445e1ddb48SDavid Howells /* As above, but more useful for defining your own descriptors: */
2455e1ddb48SDavid Howells #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch)			\
2465e1ddb48SDavid Howells struct uac_feature_unit_descriptor_##ch {			\
2475e1ddb48SDavid Howells 	__u8  bLength;						\
2485e1ddb48SDavid Howells 	__u8  bDescriptorType;					\
2495e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;				\
2505e1ddb48SDavid Howells 	__u8  bUnitID;						\
2515e1ddb48SDavid Howells 	__u8  bSourceID;					\
2525e1ddb48SDavid Howells 	__u8  bControlSize;					\
2535e1ddb48SDavid Howells 	__le16 bmaControls[ch + 1];				\
2545e1ddb48SDavid Howells 	__u8  iFeature;						\
2555e1ddb48SDavid Howells } __attribute__ ((packed))
2565e1ddb48SDavid Howells 
2575e1ddb48SDavid Howells /* 4.3.2.3 Mixer Unit Descriptor */
2585e1ddb48SDavid Howells struct uac_mixer_unit_descriptor {
2595e1ddb48SDavid Howells 	__u8 bLength;
2605e1ddb48SDavid Howells 	__u8 bDescriptorType;
2615e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
2625e1ddb48SDavid Howells 	__u8 bUnitID;
2635e1ddb48SDavid Howells 	__u8 bNrInPins;
2645e1ddb48SDavid Howells 	__u8 baSourceID[];
2655e1ddb48SDavid Howells } __attribute__ ((packed));
2665e1ddb48SDavid Howells 
uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor * desc)2675e1ddb48SDavid Howells static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
2685e1ddb48SDavid Howells {
2695e1ddb48SDavid Howells 	return desc->baSourceID[desc->bNrInPins];
2705e1ddb48SDavid Howells }
2715e1ddb48SDavid Howells 
uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor * desc,int protocol)2725e1ddb48SDavid Howells static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
2735e1ddb48SDavid Howells 						  int protocol)
2745e1ddb48SDavid Howells {
2755e1ddb48SDavid Howells 	if (protocol == UAC_VERSION_1)
2765e1ddb48SDavid Howells 		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
2775e1ddb48SDavid Howells 			desc->baSourceID[desc->bNrInPins + 1];
2785e1ddb48SDavid Howells 	else
2795e1ddb48SDavid Howells 		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
2805e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
2815e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
2825e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 1]);
2835e1ddb48SDavid Howells }
2845e1ddb48SDavid Howells 
uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor * desc,int protocol)2855e1ddb48SDavid Howells static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
2865e1ddb48SDavid Howells 						int protocol)
2875e1ddb48SDavid Howells {
2885e1ddb48SDavid Howells 	return (protocol == UAC_VERSION_1) ?
2895e1ddb48SDavid Howells 		desc->baSourceID[desc->bNrInPins + 3] :
2905e1ddb48SDavid Howells 		desc->baSourceID[desc->bNrInPins + 5];
2915e1ddb48SDavid Howells }
2925e1ddb48SDavid Howells 
uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor * desc,int protocol)2935e1ddb48SDavid Howells static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
2945e1ddb48SDavid Howells 					      int protocol)
2955e1ddb48SDavid Howells {
2966cfd839aSJorge Sanjuan 	switch (protocol) {
2976cfd839aSJorge Sanjuan 	case UAC_VERSION_1:
2986cfd839aSJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 4];
2996cfd839aSJorge Sanjuan 	case UAC_VERSION_2:
3006cfd839aSJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 6];
3016cfd839aSJorge Sanjuan 	case UAC_VERSION_3:
3026cfd839aSJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 2];
3036cfd839aSJorge Sanjuan 	default:
3046cfd839aSJorge Sanjuan 		return NULL;
3056cfd839aSJorge Sanjuan 	}
3066cfd839aSJorge Sanjuan }
3076cfd839aSJorge Sanjuan 
uac3_mixer_unit_wClusterDescrID(struct uac_mixer_unit_descriptor * desc)3086cfd839aSJorge Sanjuan static inline __u16 uac3_mixer_unit_wClusterDescrID(struct uac_mixer_unit_descriptor *desc)
3096cfd839aSJorge Sanjuan {
3106cfd839aSJorge Sanjuan 	return (desc->baSourceID[desc->bNrInPins + 1] << 8) |
3116cfd839aSJorge Sanjuan 		desc->baSourceID[desc->bNrInPins];
3125e1ddb48SDavid Howells }
3135e1ddb48SDavid Howells 
uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor * desc)3145e1ddb48SDavid Howells static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
3155e1ddb48SDavid Howells {
3165e1ddb48SDavid Howells 	__u8 *raw = (__u8 *) desc;
3175e1ddb48SDavid Howells 	return raw[desc->bLength - 1];
3185e1ddb48SDavid Howells }
3195e1ddb48SDavid Howells 
3205e1ddb48SDavid Howells /* 4.3.2.4 Selector Unit Descriptor */
3215e1ddb48SDavid Howells struct uac_selector_unit_descriptor {
3225e1ddb48SDavid Howells 	__u8 bLength;
3235e1ddb48SDavid Howells 	__u8 bDescriptorType;
3245e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
3255e1ddb48SDavid Howells 	__u8 bUintID;
3265e1ddb48SDavid Howells 	__u8 bNrInPins;
3275e1ddb48SDavid Howells 	__u8 baSourceID[];
3285e1ddb48SDavid Howells } __attribute__ ((packed));
3295e1ddb48SDavid Howells 
uac_selector_unit_iSelector(struct uac_selector_unit_descriptor * desc)3305e1ddb48SDavid Howells static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
3315e1ddb48SDavid Howells {
3325e1ddb48SDavid Howells 	__u8 *raw = (__u8 *) desc;
3335e1ddb48SDavid Howells 	return raw[desc->bLength - 1];
3345e1ddb48SDavid Howells }
3355e1ddb48SDavid Howells 
3365e1ddb48SDavid Howells /* 4.3.2.5 Feature Unit Descriptor */
3375e1ddb48SDavid Howells struct uac_feature_unit_descriptor {
3385e1ddb48SDavid Howells 	__u8 bLength;
3395e1ddb48SDavid Howells 	__u8 bDescriptorType;
3405e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
3415e1ddb48SDavid Howells 	__u8 bUnitID;
3425e1ddb48SDavid Howells 	__u8 bSourceID;
3435e1ddb48SDavid Howells 	__u8 bControlSize;
344*94dfc73eSGustavo A. R. Silva 	__u8 bmaControls[]; /* variable length */
3455e1ddb48SDavid Howells } __attribute__((packed));
3465e1ddb48SDavid Howells 
uac_feature_unit_iFeature(struct uac_feature_unit_descriptor * desc)3475e1ddb48SDavid Howells static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
3485e1ddb48SDavid Howells {
3495e1ddb48SDavid Howells 	__u8 *raw = (__u8 *) desc;
3505e1ddb48SDavid Howells 	return raw[desc->bLength - 1];
3515e1ddb48SDavid Howells }
3525e1ddb48SDavid Howells 
3535e1ddb48SDavid Howells /* 4.3.2.6 Processing Unit Descriptors */
3545e1ddb48SDavid Howells struct uac_processing_unit_descriptor {
3555e1ddb48SDavid Howells 	__u8 bLength;
3565e1ddb48SDavid Howells 	__u8 bDescriptorType;
3575e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
3585e1ddb48SDavid Howells 	__u8 bUnitID;
3598bd226f9SRuslan Bilovol 	__le16 wProcessType;
3605e1ddb48SDavid Howells 	__u8 bNrInPins;
3615e1ddb48SDavid Howells 	__u8 baSourceID[];
3625e1ddb48SDavid Howells } __attribute__ ((packed));
3635e1ddb48SDavid Howells 
uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor * desc)3645e1ddb48SDavid Howells static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
3655e1ddb48SDavid Howells {
3665e1ddb48SDavid Howells 	return desc->baSourceID[desc->bNrInPins];
3675e1ddb48SDavid Howells }
3685e1ddb48SDavid Howells 
uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor * desc,int protocol)3695e1ddb48SDavid Howells static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
3705e1ddb48SDavid Howells 						       int protocol)
3715e1ddb48SDavid Howells {
3725e1ddb48SDavid Howells 	if (protocol == UAC_VERSION_1)
3735e1ddb48SDavid Howells 		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
3745e1ddb48SDavid Howells 			desc->baSourceID[desc->bNrInPins + 1];
3755e1ddb48SDavid Howells 	else
3765e1ddb48SDavid Howells 		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
3775e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
3785e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
3795e1ddb48SDavid Howells 			(desc->baSourceID[desc->bNrInPins + 1]);
3805e1ddb48SDavid Howells }
3815e1ddb48SDavid Howells 
uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor * desc,int protocol)3825e1ddb48SDavid Howells static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
3835e1ddb48SDavid Howells 						     int protocol)
3845e1ddb48SDavid Howells {
3855e1ddb48SDavid Howells 	return (protocol == UAC_VERSION_1) ?
3865e1ddb48SDavid Howells 		desc->baSourceID[desc->bNrInPins + 3] :
3875e1ddb48SDavid Howells 		desc->baSourceID[desc->bNrInPins + 5];
3885e1ddb48SDavid Howells }
3895e1ddb48SDavid Howells 
uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor * desc,int protocol)3905e1ddb48SDavid Howells static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
3915e1ddb48SDavid Howells 						    int protocol)
3925e1ddb48SDavid Howells {
3930f292f02SJorge Sanjuan 	switch (protocol) {
3940f292f02SJorge Sanjuan 	case UAC_VERSION_1:
3950f292f02SJorge Sanjuan 		return desc->baSourceID[desc->bNrInPins + 4];
3960f292f02SJorge Sanjuan 	case UAC_VERSION_2:
3970f292f02SJorge Sanjuan 		return 2; /* in UAC2, this value is constant */
3980f292f02SJorge Sanjuan 	case UAC_VERSION_3:
3990f292f02SJorge Sanjuan 		return 4; /* in UAC3, this value is constant */
4000f292f02SJorge Sanjuan 	default:
4010f292f02SJorge Sanjuan 		return 1;
4020f292f02SJorge Sanjuan 	}
4035e1ddb48SDavid Howells }
4045e1ddb48SDavid Howells 
uac_processing_unit_bmControls(struct uac_processing_unit_descriptor * desc,int protocol)4055e1ddb48SDavid Howells static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
4065e1ddb48SDavid Howells 						   int protocol)
4075e1ddb48SDavid Howells {
4080f292f02SJorge Sanjuan 	switch (protocol) {
4090f292f02SJorge Sanjuan 	case UAC_VERSION_1:
4100f292f02SJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 5];
4110f292f02SJorge Sanjuan 	case UAC_VERSION_2:
4120f292f02SJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 6];
4130f292f02SJorge Sanjuan 	case UAC_VERSION_3:
4140f292f02SJorge Sanjuan 		return &desc->baSourceID[desc->bNrInPins + 2];
4150f292f02SJorge Sanjuan 	default:
4160f292f02SJorge Sanjuan 		return NULL;
4170f292f02SJorge Sanjuan 	}
4185e1ddb48SDavid Howells }
4195e1ddb48SDavid Howells 
uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor * desc,int protocol)4205e1ddb48SDavid Howells static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
4215e1ddb48SDavid Howells 						   int protocol)
4225e1ddb48SDavid Howells {
4235e1ddb48SDavid Howells 	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
4240f292f02SJorge Sanjuan 
4250f292f02SJorge Sanjuan 	switch (protocol) {
4260f292f02SJorge Sanjuan 	case UAC_VERSION_1:
4270f292f02SJorge Sanjuan 	case UAC_VERSION_2:
4280f292f02SJorge Sanjuan 	default:
429b531f81bSPawel Moll 		return *(uac_processing_unit_bmControls(desc, protocol)
430b531f81bSPawel Moll 			 + control_size);
4310f292f02SJorge Sanjuan 	case UAC_VERSION_3:
4320f292f02SJorge Sanjuan 		return 0; /* UAC3 does not have this field */
4330f292f02SJorge Sanjuan 	}
4345e1ddb48SDavid Howells }
4355e1ddb48SDavid Howells 
uac_processing_unit_specific(struct uac_processing_unit_descriptor * desc,int protocol)4365e1ddb48SDavid Howells static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
4375e1ddb48SDavid Howells 						 int protocol)
4385e1ddb48SDavid Howells {
4395e1ddb48SDavid Howells 	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
4400f292f02SJorge Sanjuan 
4410f292f02SJorge Sanjuan 	switch (protocol) {
4420f292f02SJorge Sanjuan 	case UAC_VERSION_1:
4430f292f02SJorge Sanjuan 	case UAC_VERSION_2:
4440f292f02SJorge Sanjuan 	default:
445b531f81bSPawel Moll 		return uac_processing_unit_bmControls(desc, protocol)
446b531f81bSPawel Moll 			+ control_size + 1;
4470f292f02SJorge Sanjuan 	case UAC_VERSION_3:
4480f292f02SJorge Sanjuan 		return uac_processing_unit_bmControls(desc, protocol)
4490f292f02SJorge Sanjuan 			+ control_size;
4500f292f02SJorge Sanjuan 	}
4515e1ddb48SDavid Howells }
4525e1ddb48SDavid Howells 
453ca95c7bfSTakashi Iwai /*
454ca95c7bfSTakashi Iwai  * Extension Unit (XU) has almost compatible layout with Processing Unit, but
455ca95c7bfSTakashi Iwai  * on UAC2, it has a different bmControls size (bControlSize); it's 1 byte for
456ca95c7bfSTakashi Iwai  * XU while 2 bytes for PU.  The last iExtension field is a one-byte index as
457ca95c7bfSTakashi Iwai  * well as iProcessing field of PU.
458ca95c7bfSTakashi Iwai  */
uac_extension_unit_bControlSize(struct uac_processing_unit_descriptor * desc,int protocol)459ca95c7bfSTakashi Iwai static inline __u8 uac_extension_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
460ca95c7bfSTakashi Iwai 						   int protocol)
461ca95c7bfSTakashi Iwai {
462ca95c7bfSTakashi Iwai 	switch (protocol) {
463ca95c7bfSTakashi Iwai 	case UAC_VERSION_1:
464ca95c7bfSTakashi Iwai 		return desc->baSourceID[desc->bNrInPins + 4];
465ca95c7bfSTakashi Iwai 	case UAC_VERSION_2:
466ca95c7bfSTakashi Iwai 		return 1; /* in UAC2, this value is constant */
467ca95c7bfSTakashi Iwai 	case UAC_VERSION_3:
468ca95c7bfSTakashi Iwai 		return 4; /* in UAC3, this value is constant */
469ca95c7bfSTakashi Iwai 	default:
470ca95c7bfSTakashi Iwai 		return 1;
471ca95c7bfSTakashi Iwai 	}
472ca95c7bfSTakashi Iwai }
473ca95c7bfSTakashi Iwai 
uac_extension_unit_iExtension(struct uac_processing_unit_descriptor * desc,int protocol)474ca95c7bfSTakashi Iwai static inline __u8 uac_extension_unit_iExtension(struct uac_processing_unit_descriptor *desc,
475ca95c7bfSTakashi Iwai 						 int protocol)
476ca95c7bfSTakashi Iwai {
477ca95c7bfSTakashi Iwai 	__u8 control_size = uac_extension_unit_bControlSize(desc, protocol);
478ca95c7bfSTakashi Iwai 
479ca95c7bfSTakashi Iwai 	switch (protocol) {
480ca95c7bfSTakashi Iwai 	case UAC_VERSION_1:
481ca95c7bfSTakashi Iwai 	case UAC_VERSION_2:
482ca95c7bfSTakashi Iwai 	default:
483ca95c7bfSTakashi Iwai 		return *(uac_processing_unit_bmControls(desc, protocol)
484ca95c7bfSTakashi Iwai 			 + control_size);
485ca95c7bfSTakashi Iwai 	case UAC_VERSION_3:
486ca95c7bfSTakashi Iwai 		return 0; /* UAC3 does not have this field */
487ca95c7bfSTakashi Iwai 	}
488ca95c7bfSTakashi Iwai }
489ca95c7bfSTakashi Iwai 
4905e1ddb48SDavid Howells /* 4.5.2 Class-Specific AS Interface Descriptor */
4915e1ddb48SDavid Howells struct uac1_as_header_descriptor {
4925e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 7 */
4935e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
4945e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* AS_GENERAL */
4955e1ddb48SDavid Howells 	__u8  bTerminalLink;		/* Terminal ID of connected Terminal */
4965e1ddb48SDavid Howells 	__u8  bDelay;			/* Delay introduced by the data path */
4975e1ddb48SDavid Howells 	__le16 wFormatTag;		/* The Audio Data Format */
4985e1ddb48SDavid Howells } __attribute__ ((packed));
4995e1ddb48SDavid Howells 
5005e1ddb48SDavid Howells #define UAC_DT_AS_HEADER_SIZE		7
5015e1ddb48SDavid Howells 
5025e1ddb48SDavid Howells /* Formats - A.1.1 Audio Data Format Type I Codes */
5035e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_UNDEFINED	0x0
5045e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_PCM		0x1
5055e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_PCM8		0x2
5065e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_IEEE_FLOAT	0x3
5075e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_ALAW		0x4
5085e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_MULAW		0x5
5095e1ddb48SDavid Howells 
5105e1ddb48SDavid Howells struct uac_format_type_i_continuous_descriptor {
5115e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
5125e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
5135e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
5145e1ddb48SDavid Howells 	__u8  bFormatType;		/* FORMAT_TYPE_1 */
5155e1ddb48SDavid Howells 	__u8  bNrChannels;		/* physical channels in the stream */
5165e1ddb48SDavid Howells 	__u8  bSubframeSize;		/* */
5175e1ddb48SDavid Howells 	__u8  bBitResolution;
5185e1ddb48SDavid Howells 	__u8  bSamFreqType;
5195e1ddb48SDavid Howells 	__u8  tLowerSamFreq[3];
5205e1ddb48SDavid Howells 	__u8  tUpperSamFreq[3];
5215e1ddb48SDavid Howells } __attribute__ ((packed));
5225e1ddb48SDavid Howells 
5235e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE	14
5245e1ddb48SDavid Howells 
5255e1ddb48SDavid Howells struct uac_format_type_i_discrete_descriptor {
5265e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
5275e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
5285e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
5295e1ddb48SDavid Howells 	__u8  bFormatType;		/* FORMAT_TYPE_1 */
5305e1ddb48SDavid Howells 	__u8  bNrChannels;		/* physical channels in the stream */
5315e1ddb48SDavid Howells 	__u8  bSubframeSize;		/* */
5325e1ddb48SDavid Howells 	__u8  bBitResolution;
5335e1ddb48SDavid Howells 	__u8  bSamFreqType;
5345e1ddb48SDavid Howells 	__u8  tSamFreq[][3];
5355e1ddb48SDavid Howells } __attribute__ ((packed));
5365e1ddb48SDavid Howells 
5375e1ddb48SDavid Howells #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n)		\
5385e1ddb48SDavid Howells struct uac_format_type_i_discrete_descriptor_##n {		\
5395e1ddb48SDavid Howells 	__u8  bLength;						\
5405e1ddb48SDavid Howells 	__u8  bDescriptorType;					\
5415e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;				\
5425e1ddb48SDavid Howells 	__u8  bFormatType;					\
5435e1ddb48SDavid Howells 	__u8  bNrChannels;					\
5445e1ddb48SDavid Howells 	__u8  bSubframeSize;					\
5455e1ddb48SDavid Howells 	__u8  bBitResolution;					\
5465e1ddb48SDavid Howells 	__u8  bSamFreqType;					\
5475e1ddb48SDavid Howells 	__u8  tSamFreq[n][3];					\
5485e1ddb48SDavid Howells } __attribute__ ((packed))
5495e1ddb48SDavid Howells 
5505e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n)	(8 + (n * 3))
5515e1ddb48SDavid Howells 
5525e1ddb48SDavid Howells struct uac_format_type_i_ext_descriptor {
5535e1ddb48SDavid Howells 	__u8 bLength;
5545e1ddb48SDavid Howells 	__u8 bDescriptorType;
5555e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
5565e1ddb48SDavid Howells 	__u8 bFormatType;
5575e1ddb48SDavid Howells 	__u8 bSubslotSize;
5585e1ddb48SDavid Howells 	__u8 bBitResolution;
5595e1ddb48SDavid Howells 	__u8 bHeaderLength;
5605e1ddb48SDavid Howells 	__u8 bControlSize;
5615e1ddb48SDavid Howells 	__u8 bSideBandProtocol;
5625e1ddb48SDavid Howells } __attribute__((packed));
5635e1ddb48SDavid Howells 
5645e1ddb48SDavid Howells /* Formats - Audio Data Format Type I Codes */
5655e1ddb48SDavid Howells 
5665e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_II_MPEG	0x1001
5675e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_II_AC3	0x1002
5685e1ddb48SDavid Howells 
5695e1ddb48SDavid Howells struct uac_format_type_ii_discrete_descriptor {
5705e1ddb48SDavid Howells 	__u8 bLength;
5715e1ddb48SDavid Howells 	__u8 bDescriptorType;
5725e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
5735e1ddb48SDavid Howells 	__u8 bFormatType;
5745e1ddb48SDavid Howells 	__le16 wMaxBitRate;
5755e1ddb48SDavid Howells 	__le16 wSamplesPerFrame;
5765e1ddb48SDavid Howells 	__u8 bSamFreqType;
5775e1ddb48SDavid Howells 	__u8 tSamFreq[][3];
5785e1ddb48SDavid Howells } __attribute__((packed));
5795e1ddb48SDavid Howells 
5805e1ddb48SDavid Howells struct uac_format_type_ii_ext_descriptor {
5815e1ddb48SDavid Howells 	__u8 bLength;
5825e1ddb48SDavid Howells 	__u8 bDescriptorType;
5835e1ddb48SDavid Howells 	__u8 bDescriptorSubtype;
5845e1ddb48SDavid Howells 	__u8 bFormatType;
5858bd226f9SRuslan Bilovol 	__le16 wMaxBitRate;
5868bd226f9SRuslan Bilovol 	__le16 wSamplesPerFrame;
5875e1ddb48SDavid Howells 	__u8 bHeaderLength;
5885e1ddb48SDavid Howells 	__u8 bSideBandProtocol;
5895e1ddb48SDavid Howells } __attribute__((packed));
5905e1ddb48SDavid Howells 
5915e1ddb48SDavid Howells /* type III */
5925e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_AC3	0x2001
5935e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1	0x2002
5945e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT	0x2003
5955e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT	0x2004
5965e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS	0x2005
5975e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS	0x2006
5985e1ddb48SDavid Howells 
5995e1ddb48SDavid Howells /* Formats - A.2 Format Type Codes */
6005e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_UNDEFINED	0x0
6015e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_I		0x1
6025e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_II		0x2
6035e1ddb48SDavid Howells #define UAC_FORMAT_TYPE_III		0x3
6045e1ddb48SDavid Howells #define UAC_EXT_FORMAT_TYPE_I		0x81
6055e1ddb48SDavid Howells #define UAC_EXT_FORMAT_TYPE_II		0x82
6065e1ddb48SDavid Howells #define UAC_EXT_FORMAT_TYPE_III		0x83
6075e1ddb48SDavid Howells 
6085e1ddb48SDavid Howells struct uac_iso_endpoint_descriptor {
6095e1ddb48SDavid Howells 	__u8  bLength;			/* in bytes: 7 */
6105e1ddb48SDavid Howells 	__u8  bDescriptorType;		/* USB_DT_CS_ENDPOINT */
6115e1ddb48SDavid Howells 	__u8  bDescriptorSubtype;	/* EP_GENERAL */
6125e1ddb48SDavid Howells 	__u8  bmAttributes;
6135e1ddb48SDavid Howells 	__u8  bLockDelayUnits;
6145e1ddb48SDavid Howells 	__le16 wLockDelay;
6155e1ddb48SDavid Howells } __attribute__((packed));
6165e1ddb48SDavid Howells #define UAC_ISO_ENDPOINT_DESC_SIZE	7
6175e1ddb48SDavid Howells 
6185e1ddb48SDavid Howells #define UAC_EP_CS_ATTR_SAMPLE_RATE	0x01
6195e1ddb48SDavid Howells #define UAC_EP_CS_ATTR_PITCH_CONTROL	0x02
6205e1ddb48SDavid Howells #define UAC_EP_CS_ATTR_FILL_MAX		0x80
6215e1ddb48SDavid Howells 
6225e1ddb48SDavid Howells /* status word format (3.7.1.1) */
6235e1ddb48SDavid Howells 
6245e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_ORIG_MASK		0x0f
6255e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF	0x0
6265e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF	0x1
6275e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP	0x2
6285e1ddb48SDavid Howells 
6295e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_IRQ_PENDING		(1 << 7)
6305e1ddb48SDavid Howells #define UAC1_STATUS_TYPE_MEM_CHANGED		(1 << 6)
6315e1ddb48SDavid Howells 
6325e1ddb48SDavid Howells struct uac1_status_word {
6335e1ddb48SDavid Howells 	__u8 bStatusType;
6345e1ddb48SDavid Howells 	__u8 bOriginator;
6355e1ddb48SDavid Howells } __attribute__((packed));
6365e1ddb48SDavid Howells 
6375e1ddb48SDavid Howells 
6385e1ddb48SDavid Howells #endif /* _UAPI__LINUX_USB_AUDIO_H */
639