130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/*
230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * <linux/usb/audio.h> -- USB Audio definitions.
330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (C) 2006 Thumtronics Pty Ltd.
530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Developed for Thumtronics by Grey Innovation
630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Ben Williamson <ben.williamson@greyinnovation.com>
730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This software is distributed under the terms of the GNU General Public
930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * License ("GPL") version 2, as published by the Free Software Foundation.
1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This file holds USB constants and structures defined
1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * by the USB Device Class Definition for Audio Devices.
1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Comments below reference relevant sections of that document:
1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * http://www.usb.org/developers/devclass_docs/audio10.pdf
1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Types and defines in this file are either specific to version 1.0 of
1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * this standard or common for newer versions.
1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */
2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef _UAPI__LINUX_USB_AUDIO_H
2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define _UAPI__LINUX_USB_AUDIO_H
2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#include <linux/types.h>
2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* bInterfaceProtocol values to denote the version of the standard used */
2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_VERSION_1			0x00
2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_VERSION_2			0x20
2930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.2 Audio Interface Subclass Codes */
3130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define USB_SUBCLASS_AUDIOCONTROL	0x01
3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define USB_SUBCLASS_AUDIOSTREAMING	0x02
3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define USB_SUBCLASS_MIDISTREAMING	0x03
3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_HEADER			0x01
3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL		0x02
3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL		0x03
3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_MIXER_UNIT			0x04
4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SELECTOR_UNIT		0x05
4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FEATURE_UNIT		0x06
4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_PROCESSING_UNIT		0x07
4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_EXTENSION_UNIT		0x08
4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_AS_GENERAL			0x01
4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE			0x02
4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_SPECIFIC		0x03
4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
5030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.7 Processing Unit Process Types */
5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_UNDEFINED		0x00
5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_UP_DOWNMIX		0x01
5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_DOLBY_PROLOGIC	0x02
5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_STEREO_EXTENDER	0x03
5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_REVERB		0x04
5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_CHORUS		0x05
5730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_PROCESS_DYN_RANGE_COMP	0x06
5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
6030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EP_GENERAL			0x01
6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.9 Audio Class-Specific Request Codes */
6330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_			0x00
6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_			0x80
6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC__CUR			0x1
6730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC__MIN			0x2
6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC__MAX			0x3
6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC__RES			0x4
7030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC__MEM			0x5
7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
7230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_CUR			(UAC_SET_ | UAC__CUR)
7330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_CUR			(UAC_GET_ | UAC__CUR)
7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_MIN			(UAC_SET_ | UAC__MIN)
7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_MIN			(UAC_GET_ | UAC__MIN)
7630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_MAX			(UAC_SET_ | UAC__MAX)
7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_MAX			(UAC_GET_ | UAC__MAX)
7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_RES			(UAC_SET_ | UAC__RES)
7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_RES			(UAC_GET_ | UAC__RES)
8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_SET_MEM			(UAC_SET_ | UAC__MEM)
8130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_MEM			(UAC_GET_ | UAC__MEM)
8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_GET_STAT			0xff
8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10 Control Selector Codes */
8630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
8730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.1 Terminal Control Selectors */
8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_TERM_COPY_PROTECT		0x01
8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.2 Feature Unit Control Selectors */
9130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_MUTE			0x01
9230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_VOLUME			0x02
9330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_BASS			0x03
9430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_MID			0x04
9530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_TREBLE			0x05
9630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_GRAPHIC_EQUALIZER	0x06
9730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_AUTOMATIC_GAIN		0x07
9830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_DELAY			0x08
9930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_BASS_BOOST		0x09
10030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FU_LOUDNESS			0x0a
10130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
10230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_CONTROL_BIT(CS)	(1 << ((CS) - 1))
10330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
10430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
10530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_UD_ENABLE			0x01
10630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_UD_MODE_SELECT		0x02
10730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
10830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
10930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DP_ENABLE			0x01
11030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DP_MODE_SELECT		0x02
11130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
11230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
11330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_3D_ENABLE			0x01
11430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_3D_SPACE			0x02
11530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
11630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.4 Reverberation Processing Unit Control Selectors */
11730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_REVERB_ENABLE		0x01
11830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_REVERB_LEVEL		0x02
11930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_REVERB_TIME			0x03
12030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_REVERB_FEEDBACK		0x04
12130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
12230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.5 Chorus Processing Unit Control Selectors */
12330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_CHORUS_ENABLE		0x01
12430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_CHORUS_LEVEL		0x02
12530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_CHORUS_RATE			0x03
12630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_CHORUS_DEPTH		0x04
12730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
12830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
12930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_ENABLE			0x01
13030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_RATE			0x02
13130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_MAXAMPL			0x03
13230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_THRESHOLD		0x04
13330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_ATTACK_TIME		0x05
13430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DCR_RELEASE_TIME		0x06
13530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
13630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* A.10.4 Extension Unit Control Selectors */
13730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_XU_ENABLE			0x01
13830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
13930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
14030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_MS_HEADER			0x01
14130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_MIDI_IN_JACK		0x02
14230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_MIDI_OUT_JACK		0x03
14330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
14430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
14530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_MS_GENERAL			0x01
14630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
14730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Terminals - 2.1 USB Terminal Types */
14830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_TERMINAL_UNDEFINED		0x100
14930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_TERMINAL_STREAMING		0x101
15030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_TERMINAL_VENDOR_SPEC	0x1FF
15130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
15230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Terminal Control Selectors */
15330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2  Class-Specific AC Interface Descriptor */
15430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac1_ac_header_descriptor {
15530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* 8 + n */
15630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
15730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* UAC_MS_HEADER */
15830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 bcdADC;			/* 0x0100 */
15930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wTotalLength;		/* includes Unit and Terminal desc. */
16030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bInCollection;		/* n */
16130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  baInterfaceNr[];		/* [n] */
16230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
16330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
16430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DT_AC_HEADER_SIZE(n)	(8 + (n))
16530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
16630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* As above, but more useful for defining your own descriptors: */
16730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n)			\
16830692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac1_ac_header_descriptor_##n {			\
16930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;						\
17030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;					\
17130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;				\
17230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 bcdADC;						\
17330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wTotalLength;					\
17430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bInCollection;					\
17530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  baInterfaceNr[n];					\
17630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed))
17730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
17830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.1 Input Terminal Descriptor */
17930692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_input_terminal_descriptor {
18030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 12 */
18130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
18230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* INPUT_TERMINAL descriptor subtype */
18330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bTerminalID;		/* Constant uniquely terminal ID */
18430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wTerminalType;		/* USB Audio Terminal Types */
18530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bAssocTerminal;		/* ID of the Output Terminal associated */
18630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bNrChannels;		/* Number of logical output channels */
18730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wChannelConfig;
18830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  iChannelNames;
18930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  iTerminal;
19030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
19130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
19230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DT_INPUT_TERMINAL_SIZE			12
19330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
19430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Terminals - 2.2 Input Terminal Types */
19530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_UNDEFINED			0x200
19630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_MICROPHONE			0x201
19730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE		0x202
19830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE		0x203
19930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE		0x204
20030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY		0x205
20130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY	0x206
20230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
20330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Terminals - control selectors */
20430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
20530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL		0x01
20630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
20730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.2 Output Terminal Descriptor */
20830692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac1_output_terminal_descriptor {
20930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 9 */
21030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* CS_INTERFACE descriptor type */
21130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* OUTPUT_TERMINAL descriptor subtype */
21230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bTerminalID;		/* Constant uniquely terminal ID */
21330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wTerminalType;		/* USB Audio Terminal Types */
21430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bAssocTerminal;		/* ID of the Input Terminal associated */
21530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSourceID;		/* ID of the connected Unit or Terminal*/
21630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  iTerminal;
21730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
21830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
21930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DT_OUTPUT_TERMINAL_SIZE			9
22030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
22130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Terminals - 2.3 Output Terminal Types */
22230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_UNDEFINED			0x300
22330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_SPEAKER			0x301
22430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_HEADPHONES			0x302
22530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO	0x303
22630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER		0x304
22730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER		0x305
22830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER	0x306
22930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER	0x307
23030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
23130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Set bControlSize = 2 as default setting */
23230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DT_FEATURE_UNIT_SIZE(ch)		(7 + ((ch) + 1) * 2)
23330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
23430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* As above, but more useful for defining your own descriptors: */
23530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch)			\
23630692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_feature_unit_descriptor_##ch {			\
23730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;						\
23830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;					\
23930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;				\
24030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bUnitID;						\
24130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSourceID;					\
24230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bControlSize;					\
24330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 bmaControls[ch + 1];				\
24430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  iFeature;						\
24530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed))
24630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
24730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.3 Mixer Unit Descriptor */
24830692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_mixer_unit_descriptor {
24930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
25030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
25130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
25230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bUnitID;
25330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bNrInPins;
25430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 baSourceID[];
25530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
25630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
25730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
25830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
25930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return desc->baSourceID[desc->bNrInPins];
26030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
26130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
26230692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
26330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						  int protocol)
26430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
26530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	if (protocol == UAC_VERSION_1)
26630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
26730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			desc->baSourceID[desc->bNrInPins + 1];
26830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	else
26930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
27030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
27130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
27230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 1]);
27330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
27430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
27530692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
27630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						int protocol)
27730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
27830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return (protocol == UAC_VERSION_1) ?
27930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 3] :
28030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 5];
28130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
28230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
28330692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
28430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng					      int protocol)
28530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
28630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return (protocol == UAC_VERSION_1) ?
28730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		&desc->baSourceID[desc->bNrInPins + 4] :
28830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		&desc->baSourceID[desc->bNrInPins + 6];
28930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
29030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
29130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
29230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
29330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 *raw = (__u8 *) desc;
29430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return raw[desc->bLength - 1];
29530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
29630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
29730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.4 Selector Unit Descriptor */
29830692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_selector_unit_descriptor {
29930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
30030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
30130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
30230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bUintID;
30330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bNrInPins;
30430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 baSourceID[];
30530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
30630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
30730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
30830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
30930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 *raw = (__u8 *) desc;
31030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return raw[desc->bLength - 1];
31130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
31230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
31330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.5 Feature Unit Descriptor */
31430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_feature_unit_descriptor {
31530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
31630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
31730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
31830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bUnitID;
31930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bSourceID;
32030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bControlSize;
32130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bmaControls[0]; /* variable length */
32230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
32330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
32430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
32530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
32630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 *raw = (__u8 *) desc;
32730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return raw[desc->bLength - 1];
32830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
32930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
33030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.3.2.6 Processing Unit Descriptors */
33130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_processing_unit_descriptor {
33230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
33330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
33430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
33530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bUnitID;
33630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u16 wProcessType;
33730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bNrInPins;
33830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 baSourceID[];
33930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
34030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
34130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
34230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
34330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return desc->baSourceID[desc->bNrInPins];
34430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
34530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
34630692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
34730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						       int protocol)
34830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
34930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	if (protocol == UAC_VERSION_1)
35030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
35130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			desc->baSourceID[desc->bNrInPins + 1];
35230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	else
35330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		return  (desc->baSourceID[desc->bNrInPins + 4] << 24) |
35430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 3] << 16) |
35530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 2] << 8)  |
35630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			(desc->baSourceID[desc->bNrInPins + 1]);
35730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
35830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
35930692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
36030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						     int protocol)
36130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
36230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return (protocol == UAC_VERSION_1) ?
36330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 3] :
36430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 5];
36530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
36630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
36730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
36830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						    int protocol)
36930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
37030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return (protocol == UAC_VERSION_1) ?
37130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 4] :
37230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		desc->baSourceID[desc->bNrInPins + 6];
37330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
37430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
37530692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
37630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						   int protocol)
37730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
37830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return (protocol == UAC_VERSION_1) ?
37930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		&desc->baSourceID[desc->bNrInPins + 5] :
38030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng		&desc->baSourceID[desc->bNrInPins + 7];
38130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
38230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
38330692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
38430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						   int protocol)
38530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
38630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
38730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return *(uac_processing_unit_bmControls(desc, protocol)
38830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			+ control_size);
38930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
39030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
39130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstatic inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
39230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng						 int protocol)
39330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng{
39430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
39530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	return uac_processing_unit_bmControls(desc, protocol)
39630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng			+ control_size + 1;
39730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}
39830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
39930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4.5.2 Class-Specific AS Interface Descriptor */
40030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac1_as_header_descriptor {
40130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 7 */
40230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
40330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* AS_GENERAL */
40430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bTerminalLink;		/* Terminal ID of connected Terminal */
40530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDelay;			/* Delay introduced by the data path */
40630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wFormatTag;		/* The Audio Data Format */
40730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
40830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
40930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_DT_AS_HEADER_SIZE		7
41030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
41130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Formats - A.1.1 Audio Data Format Type I Codes */
41230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_UNDEFINED	0x0
41330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_PCM		0x1
41430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_PCM8		0x2
41530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_IEEE_FLOAT	0x3
41630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_ALAW		0x4
41730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_MULAW		0x5
41830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
41930692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_i_continuous_descriptor {
42030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
42130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
42230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
42330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bFormatType;		/* FORMAT_TYPE_1 */
42430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bNrChannels;		/* physical channels in the stream */
42530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSubframeSize;		/* */
42630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bBitResolution;
42730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSamFreqType;
42830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  tLowerSamFreq[3];
42930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  tUpperSamFreq[3];
43030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
43130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
43230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE	14
43330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
43430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_i_discrete_descriptor {
43530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 8 + (ns * 3) */
43630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
43730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
43830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bFormatType;		/* FORMAT_TYPE_1 */
43930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bNrChannels;		/* physical channels in the stream */
44030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSubframeSize;		/* */
44130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bBitResolution;
44230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSamFreqType;
44330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  tSamFreq[][3];
44430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed));
44530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
44630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n)		\
44730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_i_discrete_descriptor_##n {		\
44830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;						\
44930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;					\
45030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;				\
45130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bFormatType;					\
45230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bNrChannels;					\
45330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSubframeSize;					\
45430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bBitResolution;					\
45530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bSamFreqType;					\
45630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  tSamFreq[n][3];					\
45730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__ ((packed))
45830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
45930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n)	(8 + (n * 3))
46030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
46130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_i_ext_descriptor {
46230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
46330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
46430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
46530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bFormatType;
46630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bSubslotSize;
46730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bBitResolution;
46830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bHeaderLength;
46930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bControlSize;
47030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bSideBandProtocol;
47130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
47230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
47330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Formats - Audio Data Format Type I Codes */
47430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
47530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_II_MPEG	0x1001
47630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_II_AC3	0x1002
47730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
47830692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_ii_discrete_descriptor {
47930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
48030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
48130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
48230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bFormatType;
48330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wMaxBitRate;
48430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wSamplesPerFrame;
48530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bSamFreqType;
48630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 tSamFreq[][3];
48730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
48830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
48930692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_format_type_ii_ext_descriptor {
49030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bLength;
49130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorType;
49230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bDescriptorSubtype;
49330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bFormatType;
49430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u16 wMaxBitRate;
49530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u16 wSamplesPerFrame;
49630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bHeaderLength;
49730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bSideBandProtocol;
49830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
49930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
50030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* type III */
50130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_AC3	0x2001
50230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1	0x2002
50330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT	0x2003
50430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT	0x2004
50530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS	0x2005
50630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS	0x2006
50730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
50830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* Formats - A.2 Format Type Codes */
50930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_UNDEFINED	0x0
51030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_I		0x1
51130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_II		0x2
51230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_FORMAT_TYPE_III		0x3
51330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EXT_FORMAT_TYPE_I		0x81
51430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EXT_FORMAT_TYPE_II		0x82
51530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EXT_FORMAT_TYPE_III		0x83
51630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
51730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac_iso_endpoint_descriptor {
51830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLength;			/* in bytes: 7 */
51930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorType;		/* USB_DT_CS_ENDPOINT */
52030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bDescriptorSubtype;	/* EP_GENERAL */
52130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bmAttributes;
52230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8  bLockDelayUnits;
52330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__le16 wLockDelay;
52430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
52530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_ISO_ENDPOINT_DESC_SIZE	7
52630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
52730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EP_CS_ATTR_SAMPLE_RATE	0x01
52830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EP_CS_ATTR_PITCH_CONTROL	0x02
52930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC_EP_CS_ATTR_FILL_MAX		0x80
53030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
53130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* status word format (3.7.1.1) */
53230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
53330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_ORIG_MASK		0x0f
53430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF	0x0
53530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF	0x1
53630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP	0x2
53730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
53830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_IRQ_PENDING		(1 << 7)
53930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define UAC1_STATUS_TYPE_MEM_CHANGED		(1 << 6)
54030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
54130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct uac1_status_word {
54230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bStatusType;
54330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	__u8 bOriginator;
54430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed));
54530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
54630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
54730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* _UAPI__LINUX_USB_AUDIO_H */
548