0x10000040
     ˆÂÁƒh¹ÃÅ      0
     ˆÀÁ„B¿¿ÃÅ 7    // SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de>
 *
 * This file holds USB constants and structures defined
 * by the USB Device Class Definition for Audio Devices in version 2.0.
 * Comments below reference relevant sections of the documents contained
 * in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip
 */

#ifndef __LINUX_USB_AUDIO_V2_H
#define __LINUX_USB_AUDIO_V2_H

#include <linux/types.h>

/* v1.0 and v2.0 of this standard have many things in common. For the rest
 * of the definitions, please refer to audio.h */

/*
 * bmControl field decoders
 *
 * From the USB Audio spec v2.0:
 *
 *   bmaControls() is a (ch+1)-element array of 4-byte bitmaps,
 *   each containing a set of bit pairs. If a Control is present,
 *   it must be Host readable. If a certain Control is not
 *   present then the bit pair must be set to 0b00.
 *   If a Control is present but read-only, the bit pair must be
 *   set to 0b01. If a Control is also Host programmable, the bit
 *   pair must be set to 0b11. The value 0b10 is not allowed.
 *
 */

static inline bool uac_v2v3_control_is_readable(u32 bmControls, u8 control)
{
	return (bmControls >> ((control - 1) * 2)) & 0x1;
}

static inline bool uac_v2v3_control_is_writeable(u32 bmControls, u8 control)
{
	return (bmControls >> ((control - 1) * 2)) & 0x2;
}

/* 4.7.2 Class-Specific AC Interface Descriptor */
struct uac2_ac_header_descriptor {
	__u8  bLength;			/* 9 */
	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
	__u8  bDescriptorSubtype;	/* UAC_MS_HEADER */
	__le16 bcdADC;			/* 0x0200 */
	__u8  bCategory;
	__le16 wTotalLength;		/* includes Unit and Terminal desc. */
	__u8  bmControls;
} __packed;

/* 2.3.1.6 Type I Format Type Descriptor (Frmts20 final.pdf)*/
struct uac2_format_type_i_descriptor {
	__u8  bLength;			/* in bytes: 6 */
	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
	__u8  bDescriptorSubtype;	/* FORMAT_TYPE */
	__u8  bFormatType;		/* FORMAT_TYPE_1 */
	__u8  bSubslotSize;		/* {1,2,3,4} */
	__u8  bBitResolution;
} __packed;

/* 4.7.2.1 Clock Source Descriptor */

struct uac_clock_source_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bClockID;
	__u8 bmAttributes;
	__u8 bmControls;
	__u8 bAssocTerminal;
	__u8 iClockSource;
} __attribute__((packed));

/* bmAttribute fields */
#define UAC_CLOCK_SOURCE_TYPE_EXT	0x0
#define UAC_CLOCK_SOURCE_TYPE_INT_FIXED	0x1
#define UAC_CLOCK_SOURCE_TYPE_INT_VAR	0x2
#define UAC_CLOCK_SOURCE_TYPE_INT_PROG	0x3
#define UAC_CLOCK_SOURCE_SYNCED_TO_SOF	(1 << 2)

/* 4.7.2.2 Clock Selector Descriptor */

struct uac_clock_selector_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bClockID;
	__u8 bNrInPins;
	__u8 baCSourceID[];
	/* bmControls and iClockSelector omitted */
} __attribute__((packed));

/* 4.7.2.3 Clock Multiplier Descriptor */

struct uac_clock_multiplier_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bClockID;
	__u8 bCSourceID;
	__u8 bmControls;
	__u8 iClockMultiplier;
} __attribute__((packed));

/* 4.7.2.4 Input terminal descriptor */

struct uac2_input_terminal_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bTerminalID;
	__le16 wTerminalType;
	__u8 bAssocTerminal;
	__u8 bCSourceID;
	__u8 bNrChannels;
	__le32 bmChannelConfig;
	__u8 iChannelNames;
	__le16 bmControls;
	__u8 iTerminal;
} __attribute__((packed));

/* 4.7.2.5 Output terminal descriptor */

struct uac2_output_terminal_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bTerminalID;
	__le16 wTerminalType;
	__u8 bAssocTerminal;
	__u8 bSourceID;
	__u8 bCSourceID;
	__le16 bmControls;
	__u8 iTerminal;
} __attribute__((packed));



/* 4.7.2.8 Feature Unit Descriptor */

struct uac2_feature_unit_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubtype;
	__u8 bUnitID;
	__u8 bSourceID;
	/* bmaControls is actually u32,
	 * but u8 is needed for the hybrid parser */
	__u8 bmaC