sound/usb/mixer_s1810c.c

Source file repositories/reference/linux-study-clean/sound/usb/mixer_s1810c.c

File Facts

System
Linux kernel
Corpus path
sound/usb/mixer_s1810c.c
Extension
.c
Size
19571 bytes
Lines
700
Domain
Driver Families
Bucket
sound/usb
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct s1810c_ctl_packet {
	__le32 selector;
	__le32 b;
	__le32 tag;
	__le32 len;
	__le32 c;
	__le32 d;
	__le32 e;
};

/* selectors for CMD request
 */
#define SC1810C_SEL_DEVICE 0
#define SC1810C_SEL_MIXER 0x64
#define SC1810C_SEL_OUTPUT 0x65


/* control ids */
#define SC1810C_CTL_LINE_SW	0
#define SC1810C_CTL_MUTE_SW	1
#define SC1824C_CTL_MONO_SW	2
#define SC1810C_CTL_AB_SW	3
#define SC1810C_CTL_48V_SW	4

/* USB Control (vendor) requests
 */
#define SC1810C_CMD_REQ	160
#define SC1810C_CMD_REQTYPE \
	(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT)
#define SC1810C_CMD_TAG		0x50617269
#define SC1810C_CMD_LEN		0x14

#define SC1810C_SET_STATE_REQ	161
#define SC1810C_SET_STATE_REQTYPE SC1810C_CMD_REQTYPE
#define SC1810C_SET_STATE_TAG	0x64656D73
#define SC1810C_SET_STATE_LEN	0xF4

#define SC1810C_GET_STATE_REQ	162
#define SC1810C_GET_STATE_REQTYPE \
	(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN)
#define SC1810C_GET_STATE_TAG	SC1810C_SET_STATE_TAG
#define SC1810C_GET_STATE_LEN	SC1810C_SET_STATE_LEN

/* Mixer levels normally range from 0 (off) to 0x0100 0000 (0 dB).
 * raw_level = 2^24 * 10^(db_level / 20), thus
 * -3dB = 0xb53bf0 (technically, half-power -3.01...dB would be 0xb504f3)
 * -96dB = 0x109
 * -99dB = 0xBC
 * PC software sliders cover -96 to +10dB (0x0329 8b08),
 * but the value 0 (-inf dB) can be used when e.g. Mixer Bypass is enabled.
 * Unclear what the hardware's maximum value is.
 *
 * Note, when a channel is panned to two channels (stereo),
 * the mixer level is set to slider value (by default -96dB) minus 3dB,
 * which explains the -99dB value seen in USB captures.
 */
#define MIXER_LEVEL_MUTE 0
#define MIXER_LEVEL_N99DB 0xbc
#define MIXER_LEVEL_N3DB 0xb53bf0
#define MIXER_LEVEL_0DB 0x1000000

/*
 * This packet includes mixer volumes and
 * various other fields, it's an extended
 * version of ctl_packet, with a and b
 * being zero and different tag/length.
 */
struct s1810c_state_packet {
	__le32 fields[63];
};

/* indices into s1810c_state_packet.fields[]
 */
#define SC1810C_STATE_TAG_IDX	2
#define SC1810C_STATE_LEN_IDX	3

#define SC1810C_STATE_48V_SW	58
#define SC1810C_STATE_LINE_SW	59
#define SC1810C_STATE_MUTE_SW	60
#define SC1824C_STATE_MONO_SW	61
#define SC1810C_STATE_AB_SW	62

struct s1810_mixer_state {
	uint16_t seqnum;
	struct mutex usb_mutex;
	struct mutex data_mutex;
};

static int
snd_s1810c_send_ctl_packet(struct usb_device *dev, u32 sel,

Annotation

Implementation Notes