15e1ddb481776a487b15b40579a000b279ce527c9David Howells/*
25e1ddb481776a487b15b40579a000b279ce527c9David Howells * <linux/usb/audio.h> -- USB Audio definitions.
35e1ddb481776a487b15b40579a000b279ce527c9David Howells *
45e1ddb481776a487b15b40579a000b279ce527c9David Howells * Copyright (C) 2006 Thumtronics Pty Ltd.
55e1ddb481776a487b15b40579a000b279ce527c9David Howells * Developed for Thumtronics by Grey Innovation
65e1ddb481776a487b15b40579a000b279ce527c9David Howells * Ben Williamson <ben.williamson@greyinnovation.com>
75e1ddb481776a487b15b40579a000b279ce527c9David Howells *
85e1ddb481776a487b15b40579a000b279ce527c9David Howells * This software is distributed under the terms of the GNU General Public
95e1ddb481776a487b15b40579a000b279ce527c9David Howells * License ("GPL") version 2, as published by the Free Software Foundation.
105e1ddb481776a487b15b40579a000b279ce527c9David Howells *
115e1ddb481776a487b15b40579a000b279ce527c9David Howells * This file holds USB constants and structures defined
125e1ddb481776a487b15b40579a000b279ce527c9David Howells * by the USB Device Class Definition for Audio Devices.
135e1ddb481776a487b15b40579a000b279ce527c9David Howells * Comments below reference relevant sections of that document:
145e1ddb481776a487b15b40579a000b279ce527c9David Howells *
155e1ddb481776a487b15b40579a000b279ce527c9David Howells * http://www.usb.org/developers/devclass_docs/audio10.pdf
165e1ddb481776a487b15b40579a000b279ce527c9David Howells *
175e1ddb481776a487b15b40579a000b279ce527c9David Howells * Types and defines in this file are either specific to version 1.0 of
185e1ddb481776a487b15b40579a000b279ce527c9David Howells * this standard or common for newer versions.
195e1ddb481776a487b15b40579a000b279ce527c9David Howells */
205e1ddb481776a487b15b40579a000b279ce527c9David Howells
215e1ddb481776a487b15b40579a000b279ce527c9David Howells#ifndef _UAPI__LINUX_USB_AUDIO_H
225e1ddb481776a487b15b40579a000b279ce527c9David Howells#define _UAPI__LINUX_USB_AUDIO_H
235e1ddb481776a487b15b40579a000b279ce527c9David Howells
245e1ddb481776a487b15b40579a000b279ce527c9David Howells#include <linux/types.h>
255e1ddb481776a487b15b40579a000b279ce527c9David Howells
265e1ddb481776a487b15b40579a000b279ce527c9David Howells/* bInterfaceProtocol values to denote the version of the standard used */
275e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_VERSION_1			0x00
285e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_VERSION_2			0x20
295e1ddb481776a487b15b40579a000b279ce527c9David Howells
305e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.2 Audio Interface Subclass Codes */
315e1ddb481776a487b15b40579a000b279ce527c9David Howells#define USB_SUBCLASS_AUDIOCONTROL	0x01
325e1ddb481776a487b15b40579a000b279ce527c9David Howells#define USB_SUBCLASS_AUDIOSTREAMING	0x02
335e1ddb481776a487b15b40579a000b279ce527c9David Howells#define USB_SUBCLASS_MIDISTREAMING	0x03
345e1ddb481776a487b15b40579a000b279ce527c9David Howells
355e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
365e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_HEADER			0x01
375e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL		0x02
385e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL		0x03
395e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_MIXER_UNIT			0x04
405e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SELECTOR_UNIT		0x05
415e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FEATURE_UNIT		0x06
425e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_PROCESSING_UNIT		0x07
435e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_EXTENSION_UNIT		0x08
445e1ddb481776a487b15b40579a000b279ce527c9David Howells
455e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
465e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_AS_GENERAL			0x01
475e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE			0x02
485e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_SPECIFIC		0x03
495e1ddb481776a487b15b40579a000b279ce527c9David Howells
505e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.7 Processing Unit Process Types */
515e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_UNDEFINED		0x00
525e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_UP_DOWNMIX		0x01
535e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_DOLBY_PROLOGIC	0x02
545e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_STEREO_EXTENDER	0x03
555e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_REVERB		0x04
565e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_CHORUS		0x05
575e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_PROCESS_DYN_RANGE_COMP	0x06
585e1ddb481776a487b15b40579a000b279ce527c9David Howells
595e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
605e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EP_GENERAL			0x01
615e1ddb481776a487b15b40579a000b279ce527c9David Howells
625e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.9 Audio Class-Specific Request Codes */
635e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_			0x00
645e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_			0x80
655e1ddb481776a487b15b40579a000b279ce527c9David Howells
665e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC__CUR			0x1
675e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC__MIN			0x2
685e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC__MAX			0x3
695e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC__RES			0x4
705e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC__MEM			0x5
715e1ddb481776a487b15b40579a000b279ce527c9David Howells
725e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_CUR			(UAC_SET_ | UAC__CUR)
735e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_CUR			(UAC_GET_ | UAC__CUR)
745e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_MIN			(UAC_SET_ | UAC__MIN)
755e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_MIN			(UAC_GET_ | UAC__MIN)
765e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_MAX			(UAC_SET_ | UAC__MAX)
775e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_MAX			(UAC_GET_ | UAC__MAX)
785e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_RES			(UAC_SET_ | UAC__RES)
795e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_RES			(UAC_GET_ | UAC__RES)
805e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_SET_MEM			(UAC_SET_ | UAC__MEM)
815e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_MEM			(UAC_GET_ | UAC__MEM)
825e1ddb481776a487b15b40579a000b279ce527c9David Howells
835e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_GET_STAT			0xff
845e1ddb481776a487b15b40579a000b279ce527c9David Howells
855e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10 Control Selector Codes */
865e1ddb481776a487b15b40579a000b279ce527c9David Howells
875e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.1 Terminal Control Selectors */
885e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_TERM_COPY_PROTECT		0x01
895e1ddb481776a487b15b40579a000b279ce527c9David Howells
905e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.2 Feature Unit Control Selectors */
915e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_MUTE			0x01
925e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_VOLUME			0x02
935e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_BASS			0x03
945e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_MID			0x04
955e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_TREBLE			0x05
965e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_GRAPHIC_EQUALIZER	0x06
975e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_AUTOMATIC_GAIN		0x07
985e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_DELAY			0x08
995e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_BASS_BOOST		0x09
1005e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FU_LOUDNESS			0x0a
1015e1ddb481776a487b15b40579a000b279ce527c9David Howells
1025e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_CONTROL_BIT(CS)	(1 << ((CS) - 1))
1035e1ddb481776a487b15b40579a000b279ce527c9David Howells
1045e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
1055e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_UD_ENABLE			0x01
1065e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_UD_MODE_SELECT		0x02
1075e1ddb481776a487b15b40579a000b279ce527c9David Howells
1085e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
1095e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DP_ENABLE			0x01
1105e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DP_MODE_SELECT		0x02
1115e1ddb481776a487b15b40579a000b279ce527c9David Howells
1125e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
1135e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_3D_ENABLE			0x01
1145e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_3D_SPACE			0x02
1155e1ddb481776a487b15b40579a000b279ce527c9David Howells
1165e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.4 Reverberation Processing Unit Control Selectors */
1175e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_REVERB_ENABLE		0x01
1185e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_REVERB_LEVEL		0x02
1195e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_REVERB_TIME			0x03
1205e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_REVERB_FEEDBACK		0x04
1215e1ddb481776a487b15b40579a000b279ce527c9David Howells
1225e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.5 Chorus Processing Unit Control Selectors */
1235e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_CHORUS_ENABLE		0x01
1245e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_CHORUS_LEVEL		0x02
1255e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_CHORUS_RATE			0x03
1265e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_CHORUS_DEPTH		0x04
1275e1ddb481776a487b15b40579a000b279ce527c9David Howells
1285e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
1295e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_ENABLE			0x01
1305e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_RATE			0x02
1315e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_MAXAMPL			0x03
1325e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_THRESHOLD		0x04
1335e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_ATTACK_TIME		0x05
1345e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DCR_RELEASE_TIME		0x06
1355e1ddb481776a487b15b40579a000b279ce527c9David Howells
1365e1ddb481776a487b15b40579a000b279ce527c9David Howells/* A.10.4 Extension Unit Control Selectors */
1375e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_XU_ENABLE			0x01
1385e1ddb481776a487b15b40579a000b279ce527c9David Howells
1395e1ddb481776a487b15b40579a000b279ce527c9David Howells/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
1405e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_MS_HEADER			0x01
1415e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_MIDI_IN_JACK		0x02
1425e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_MIDI_OUT_JACK		0x03
1435e1ddb481776a487b15b40579a000b279ce527c9David Howells
1445e1ddb481776a487b15b40579a000b279ce527c9David Howells/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
1455e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_MS_GENERAL			0x01
1465e1ddb481776a487b15b40579a000b279ce527c9David Howells
1475e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Terminals - 2.1 USB Terminal Types */
1485e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_TERMINAL_UNDEFINED		0x100
1495e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_TERMINAL_STREAMING		0x101
1505e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_TERMINAL_VENDOR_SPEC	0x1FF
1515e1ddb481776a487b15b40579a000b279ce527c9David Howells
1525e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Terminal Control Selectors */
1535e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2  Class-Specific AC Interface Descriptor */
1545e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac1_ac_header_descriptor {
1555e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* 8 + n */
1565e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
1575e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* UAC_MS_HEADER */
1585e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 bcdADC;			/* 0x0100 */
1595e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wTotalLength;		/* includes Unit and Terminal desc. */
1605e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bInCollection;		/* n */
1615e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  baInterfaceNr[];		/* [n] */
1625e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
1635e1ddb481776a487b15b40579a000b279ce527c9David Howells
1645e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DT_AC_HEADER_SIZE(n)	(8 + (n))
1655e1ddb481776a487b15b40579a000b279ce527c9David Howells
1665e1ddb481776a487b15b40579a000b279ce527c9David Howells/* As above, but more useful for defining your own descriptors: */
1675e1ddb481776a487b15b40579a000b279ce527c9David Howells#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n)			\
1685e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac1_ac_header_descriptor_##n {			\
1695e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;						\
1705e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;					\
1715e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;				\
1725e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 bcdADC;						\
1735e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wTotalLength;					\
1745e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bInCollection;					\
1755e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  baInterfaceNr[n];					\
1765e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed))
1775e1ddb481776a487b15b40579a000b279ce527c9David Howells
1785e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.1 Input Terminal Descriptor */
1795e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_input_terminal_descriptor {
1805e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 12 */
1815e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
1825e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* INPUT_TERMINAL descriptor subtype */
1835e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bTerminalID;		/* Constant uniquely terminal ID */
1845e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wTerminalType;		/* USB Audio Terminal Types */
1855e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bAssocTerminal;		/* ID of the Output Terminal associated */
1865e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bNrChannels;		/* Number of logical output channels */
1875e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wChannelConfig;
1885e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  iChannelNames;
1895e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  iTerminal;
1905e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
1915e1ddb481776a487b15b40579a000b279ce527c9David Howells
1925e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DT_INPUT_TERMINAL_SIZE			12
1935e1ddb481776a487b15b40579a000b279ce527c9David Howells
1945e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Terminals - 2.2 Input Terminal Types */
1955e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_UNDEFINED			0x200
1965e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_MICROPHONE			0x201
1975e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE		0x202
1985e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE		0x203
1995e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE		0x204
2005e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY		0x205
2015e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY	0x206
2025e1ddb481776a487b15b40579a000b279ce527c9David Howells
2035e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Terminals - control selectors */
2045e1ddb481776a487b15b40579a000b279ce527c9David Howells
2055e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL		0x01
2065e1ddb481776a487b15b40579a000b279ce527c9David Howells
2075e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.2 Output Terminal Descriptor */
2085e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac1_output_terminal_descriptor {
2095e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 9 */
2105e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
2115e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* OUTPUT_TERMINAL descriptor subtype */
2125e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bTerminalID;		/* Constant uniquely terminal ID */
2135e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wTerminalType;		/* USB Audio Terminal Types */
2145e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bAssocTerminal;		/* ID of the Input Terminal associated */
2155e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSourceID;		/* ID of the connected Unit or Terminal*/
2165e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  iTerminal;
2175e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
2185e1ddb481776a487b15b40579a000b279ce527c9David Howells
2195e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DT_OUTPUT_TERMINAL_SIZE			9
2205e1ddb481776a487b15b40579a000b279ce527c9David Howells
2215e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Terminals - 2.3 Output Terminal Types */
2225e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_UNDEFINED			0x300
2235e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_SPEAKER			0x301
2245e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_HEADPHONES			0x302
2255e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO	0x303
2265e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER		0x304
2275e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER		0x305
2285e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER	0x306
2295e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER	0x307
2305e1ddb481776a487b15b40579a000b279ce527c9David Howells
2315e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Set bControlSize = 2 as default setting */
2325e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DT_FEATURE_UNIT_SIZE(ch)		(7 + ((ch) + 1) * 2)
2335e1ddb481776a487b15b40579a000b279ce527c9David Howells
2345e1ddb481776a487b15b40579a000b279ce527c9David Howells/* As above, but more useful for defining your own descriptors: */
2355e1ddb481776a487b15b40579a000b279ce527c9David Howells#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch)			\
2365e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_feature_unit_descriptor_##ch {			\
2375e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;						\
2385e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;					\
2395e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;				\
2405e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bUnitID;						\
2415e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSourceID;					\
2425e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bControlSize;					\
2435e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 bmaControls[ch + 1];				\
2445e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  iFeature;						\
2455e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed))
2465e1ddb481776a487b15b40579a000b279ce527c9David Howells
2475e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.3 Mixer Unit Descriptor */
2485e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_mixer_unit_descriptor {
2495e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
2505e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
2515e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
2525e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bUnitID;
2535e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bNrInPins;
2545e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 baSourceID[];
2555e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
2565e1ddb481776a487b15b40579a000b279ce527c9David Howells
2575e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
2585e1ddb481776a487b15b40579a000b279ce527c9David Howells{
2595e1ddb481776a487b15b40579a000b279ce527c9David Howells	return desc->baSourceID[desc->bNrInPins];
2605e1ddb481776a487b15b40579a000b279ce527c9David Howells}
2615e1ddb481776a487b15b40579a000b279ce527c9David Howells
2625e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
2635e1ddb481776a487b15b40579a000b279ce527c9David Howells						  int protocol)
2645e1ddb481776a487b15b40579a000b279ce527c9David Howells{
2655e1ddb481776a487b15b40579a000b279ce527c9David Howells	if (protocol == UAC_VERSION_1)
2665e1ddb481776a487b15b40579a000b279ce527c9David Howells		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
2675e1ddb481776a487b15b40579a000b279ce527c9David Howells			desc->baSourceID[desc->bNrInPins + 1];
2685e1ddb481776a487b15b40579a000b279ce527c9David Howells	else
2695e1ddb481776a487b15b40579a000b279ce527c9David Howells		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
2705e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
2715e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
2725e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 1]);
2735e1ddb481776a487b15b40579a000b279ce527c9David Howells}
2745e1ddb481776a487b15b40579a000b279ce527c9David Howells
2755e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
2765e1ddb481776a487b15b40579a000b279ce527c9David Howells						int protocol)
2775e1ddb481776a487b15b40579a000b279ce527c9David Howells{
2785e1ddb481776a487b15b40579a000b279ce527c9David Howells	return (protocol == UAC_VERSION_1) ?
2795e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 3] :
2805e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 5];
2815e1ddb481776a487b15b40579a000b279ce527c9David Howells}
2825e1ddb481776a487b15b40579a000b279ce527c9David Howells
2835e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
2845e1ddb481776a487b15b40579a000b279ce527c9David Howells					      int protocol)
2855e1ddb481776a487b15b40579a000b279ce527c9David Howells{
2865e1ddb481776a487b15b40579a000b279ce527c9David Howells	return (protocol == UAC_VERSION_1) ?
2875e1ddb481776a487b15b40579a000b279ce527c9David Howells		&desc->baSourceID[desc->bNrInPins + 4] :
2885e1ddb481776a487b15b40579a000b279ce527c9David Howells		&desc->baSourceID[desc->bNrInPins + 6];
2895e1ddb481776a487b15b40579a000b279ce527c9David Howells}
2905e1ddb481776a487b15b40579a000b279ce527c9David Howells
2915e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
2925e1ddb481776a487b15b40579a000b279ce527c9David Howells{
2935e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 *raw = (__u8 *) desc;
2945e1ddb481776a487b15b40579a000b279ce527c9David Howells	return raw[desc->bLength - 1];
2955e1ddb481776a487b15b40579a000b279ce527c9David Howells}
2965e1ddb481776a487b15b40579a000b279ce527c9David Howells
2975e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.4 Selector Unit Descriptor */
2985e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_selector_unit_descriptor {
2995e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
3005e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
3015e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
3025e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bUintID;
3035e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bNrInPins;
3045e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 baSourceID[];
3055e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
3065e1ddb481776a487b15b40579a000b279ce527c9David Howells
3075e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
3085e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3095e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 *raw = (__u8 *) desc;
3105e1ddb481776a487b15b40579a000b279ce527c9David Howells	return raw[desc->bLength - 1];
3115e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3125e1ddb481776a487b15b40579a000b279ce527c9David Howells
3135e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.5 Feature Unit Descriptor */
3145e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_feature_unit_descriptor {
3155e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
3165e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
3175e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
3185e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bUnitID;
3195e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bSourceID;
3205e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bControlSize;
3215e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bmaControls[0]; /* variable length */
3225e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
3235e1ddb481776a487b15b40579a000b279ce527c9David Howells
3245e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
3255e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3265e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 *raw = (__u8 *) desc;
3275e1ddb481776a487b15b40579a000b279ce527c9David Howells	return raw[desc->bLength - 1];
3285e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3295e1ddb481776a487b15b40579a000b279ce527c9David Howells
3305e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.3.2.6 Processing Unit Descriptors */
3315e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_processing_unit_descriptor {
3325e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
3335e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
3345e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
3355e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bUnitID;
3365e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u16 wProcessType;
3375e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bNrInPins;
3385e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 baSourceID[];
3395e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
3405e1ddb481776a487b15b40579a000b279ce527c9David Howells
3415e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
3425e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3435e1ddb481776a487b15b40579a000b279ce527c9David Howells	return desc->baSourceID[desc->bNrInPins];
3445e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3455e1ddb481776a487b15b40579a000b279ce527c9David Howells
3465e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
3475e1ddb481776a487b15b40579a000b279ce527c9David Howells						       int protocol)
3485e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3495e1ddb481776a487b15b40579a000b279ce527c9David Howells	if (protocol == UAC_VERSION_1)
3505e1ddb481776a487b15b40579a000b279ce527c9David Howells		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
3515e1ddb481776a487b15b40579a000b279ce527c9David Howells			desc->baSourceID[desc->bNrInPins + 1];
3525e1ddb481776a487b15b40579a000b279ce527c9David Howells	else
3535e1ddb481776a487b15b40579a000b279ce527c9David Howells		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
3545e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
3555e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
3565e1ddb481776a487b15b40579a000b279ce527c9David Howells			(desc->baSourceID[desc->bNrInPins + 1]);
3575e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3585e1ddb481776a487b15b40579a000b279ce527c9David Howells
3595e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
3605e1ddb481776a487b15b40579a000b279ce527c9David Howells						     int protocol)
3615e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3625e1ddb481776a487b15b40579a000b279ce527c9David Howells	return (protocol == UAC_VERSION_1) ?
3635e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 3] :
3645e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 5];
3655e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3665e1ddb481776a487b15b40579a000b279ce527c9David Howells
3675e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
3685e1ddb481776a487b15b40579a000b279ce527c9David Howells						    int protocol)
3695e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3705e1ddb481776a487b15b40579a000b279ce527c9David Howells	return (protocol == UAC_VERSION_1) ?
3715e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 4] :
3725e1ddb481776a487b15b40579a000b279ce527c9David Howells		desc->baSourceID[desc->bNrInPins + 6];
3735e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3745e1ddb481776a487b15b40579a000b279ce527c9David Howells
3755e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
3765e1ddb481776a487b15b40579a000b279ce527c9David Howells						   int protocol)
3775e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3785e1ddb481776a487b15b40579a000b279ce527c9David Howells	return (protocol == UAC_VERSION_1) ?
3795e1ddb481776a487b15b40579a000b279ce527c9David Howells		&desc->baSourceID[desc->bNrInPins + 5] :
3805e1ddb481776a487b15b40579a000b279ce527c9David Howells		&desc->baSourceID[desc->bNrInPins + 7];
3815e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3825e1ddb481776a487b15b40579a000b279ce527c9David Howells
3835e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
3845e1ddb481776a487b15b40579a000b279ce527c9David Howells						   int protocol)
3855e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3865e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
387b531f81b0d70ffbe8d70500512483227cc532608Pawel Moll	return *(uac_processing_unit_bmControls(desc, protocol)
388b531f81b0d70ffbe8d70500512483227cc532608Pawel Moll			+ control_size);
3895e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3905e1ddb481776a487b15b40579a000b279ce527c9David Howells
3915e1ddb481776a487b15b40579a000b279ce527c9David Howellsstatic inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
3925e1ddb481776a487b15b40579a000b279ce527c9David Howells						 int protocol)
3935e1ddb481776a487b15b40579a000b279ce527c9David Howells{
3945e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
395b531f81b0d70ffbe8d70500512483227cc532608Pawel Moll	return uac_processing_unit_bmControls(desc, protocol)
396b531f81b0d70ffbe8d70500512483227cc532608Pawel Moll			+ control_size + 1;
3975e1ddb481776a487b15b40579a000b279ce527c9David Howells}
3985e1ddb481776a487b15b40579a000b279ce527c9David Howells
3995e1ddb481776a487b15b40579a000b279ce527c9David Howells/* 4.5.2 Class-Specific AS Interface Descriptor */
4005e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac1_as_header_descriptor {
4015e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 7 */
4025e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
4035e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* AS_GENERAL */
4045e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bTerminalLink;		/* Terminal ID of connected Terminal */
4055e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDelay;			/* Delay introduced by the data path */
4065e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wFormatTag;		/* The Audio Data Format */
4075e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
4085e1ddb481776a487b15b40579a000b279ce527c9David Howells
4095e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_DT_AS_HEADER_SIZE		7
4105e1ddb481776a487b15b40579a000b279ce527c9David Howells
4115e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Formats - A.1.1 Audio Data Format Type I Codes */
4125e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_UNDEFINED	0x0
4135e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_PCM		0x1
4145e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_PCM8		0x2
4155e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_IEEE_FLOAT	0x3
4165e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_ALAW		0x4
4175e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_MULAW		0x5
4185e1ddb481776a487b15b40579a000b279ce527c9David Howells
4195e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_i_continuous_descriptor {
4205e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
4215e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
4225e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
4235e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bFormatType;		/* FORMAT_TYPE_1 */
4245e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bNrChannels;		/* physical channels in the stream */
4255e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSubframeSize;		/* */
4265e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bBitResolution;
4275e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSamFreqType;
4285e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  tLowerSamFreq[3];
4295e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  tUpperSamFreq[3];
4305e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
4315e1ddb481776a487b15b40579a000b279ce527c9David Howells
4325e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE	14
4335e1ddb481776a487b15b40579a000b279ce527c9David Howells
4345e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_i_discrete_descriptor {
4355e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
4365e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
4375e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
4385e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bFormatType;		/* FORMAT_TYPE_1 */
4395e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bNrChannels;		/* physical channels in the stream */
4405e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSubframeSize;		/* */
4415e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bBitResolution;
4425e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSamFreqType;
4435e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  tSamFreq[][3];
4445e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed));
4455e1ddb481776a487b15b40579a000b279ce527c9David Howells
4465e1ddb481776a487b15b40579a000b279ce527c9David Howells#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n)		\
4475e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_i_discrete_descriptor_##n {		\
4485e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;						\
4495e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;					\
4505e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;				\
4515e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bFormatType;					\
4525e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bNrChannels;					\
4535e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSubframeSize;					\
4545e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bBitResolution;					\
4555e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bSamFreqType;					\
4565e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  tSamFreq[n][3];					\
4575e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__ ((packed))
4585e1ddb481776a487b15b40579a000b279ce527c9David Howells
4595e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n)	(8 + (n * 3))
4605e1ddb481776a487b15b40579a000b279ce527c9David Howells
4615e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_i_ext_descriptor {
4625e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
4635e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
4645e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
4655e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bFormatType;
4665e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bSubslotSize;
4675e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bBitResolution;
4685e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bHeaderLength;
4695e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bControlSize;
4705e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bSideBandProtocol;
4715e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
4725e1ddb481776a487b15b40579a000b279ce527c9David Howells
4735e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Formats - Audio Data Format Type I Codes */
4745e1ddb481776a487b15b40579a000b279ce527c9David Howells
4755e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_II_MPEG	0x1001
4765e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_II_AC3	0x1002
4775e1ddb481776a487b15b40579a000b279ce527c9David Howells
4785e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_ii_discrete_descriptor {
4795e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
4805e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
4815e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
4825e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bFormatType;
4835e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wMaxBitRate;
4845e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wSamplesPerFrame;
4855e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bSamFreqType;
4865e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 tSamFreq[][3];
4875e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
4885e1ddb481776a487b15b40579a000b279ce527c9David Howells
4895e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_format_type_ii_ext_descriptor {
4905e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bLength;
4915e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorType;
4925e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bDescriptorSubtype;
4935e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bFormatType;
4945e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u16 wMaxBitRate;
4955e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u16 wSamplesPerFrame;
4965e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bHeaderLength;
4975e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bSideBandProtocol;
4985e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
4995e1ddb481776a487b15b40579a000b279ce527c9David Howells
5005e1ddb481776a487b15b40579a000b279ce527c9David Howells/* type III */
5015e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_AC3	0x2001
5025e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1	0x2002
5035e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT	0x2003
5045e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT	0x2004
5055e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS	0x2005
5065e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS	0x2006
5075e1ddb481776a487b15b40579a000b279ce527c9David Howells
5085e1ddb481776a487b15b40579a000b279ce527c9David Howells/* Formats - A.2 Format Type Codes */
5095e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_UNDEFINED	0x0
5105e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_I		0x1
5115e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_II		0x2
5125e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_FORMAT_TYPE_III		0x3
5135e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EXT_FORMAT_TYPE_I		0x81
5145e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EXT_FORMAT_TYPE_II		0x82
5155e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EXT_FORMAT_TYPE_III		0x83
5165e1ddb481776a487b15b40579a000b279ce527c9David Howells
5175e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac_iso_endpoint_descriptor {
5185e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLength;			/* in bytes: 7 */
5195e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorType;		/* USB_DT_CS_ENDPOINT */
5205e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bDescriptorSubtype;	/* EP_GENERAL */
5215e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bmAttributes;
5225e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8  bLockDelayUnits;
5235e1ddb481776a487b15b40579a000b279ce527c9David Howells	__le16 wLockDelay;
5245e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
5255e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_ISO_ENDPOINT_DESC_SIZE	7
5265e1ddb481776a487b15b40579a000b279ce527c9David Howells
5275e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EP_CS_ATTR_SAMPLE_RATE	0x01
5285e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EP_CS_ATTR_PITCH_CONTROL	0x02
5295e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC_EP_CS_ATTR_FILL_MAX		0x80
5305e1ddb481776a487b15b40579a000b279ce527c9David Howells
5315e1ddb481776a487b15b40579a000b279ce527c9David Howells/* status word format (3.7.1.1) */
5325e1ddb481776a487b15b40579a000b279ce527c9David Howells
5335e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_ORIG_MASK		0x0f
5345e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF	0x0
5355e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF	0x1
5365e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP	0x2
5375e1ddb481776a487b15b40579a000b279ce527c9David Howells
5385e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_IRQ_PENDING		(1 << 7)
5395e1ddb481776a487b15b40579a000b279ce527c9David Howells#define UAC1_STATUS_TYPE_MEM_CHANGED		(1 << 6)
5405e1ddb481776a487b15b40579a000b279ce527c9David Howells
5415e1ddb481776a487b15b40579a000b279ce527c9David Howellsstruct uac1_status_word {
5425e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bStatusType;
5435e1ddb481776a487b15b40579a000b279ce527c9David Howells	__u8 bOriginator;
5445e1ddb481776a487b15b40579a000b279ce527c9David Howells} __attribute__((packed));
5455e1ddb481776a487b15b40579a000b279ce527c9David Howells
5465e1ddb481776a487b15b40579a000b279ce527c9David Howells
5475e1ddb481776a487b15b40579a000b279ce527c9David Howells#endif /* _UAPI__LINUX_USB_AUDIO_H */
548