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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/usb.hlinux/usb/audio-v2.hlinux/slab.hsound/core.hsound/control.husbaudio.hmixer.hmixer_quirks.hhelper.hmixer_s1810c.h
Detected Declarations
struct s1810c_ctl_packetstruct s1810c_state_packetstruct s1810_mixer_statefunction snd_s1810c_send_ctl_packetfunction snd_sc1810c_get_status_fieldfunction snd_s1810c_init_mixer_mapsfunction infunction infunction snd_s1810c_switch_getfunction snd_s1810c_switch_setfunction snd_s1810c_switch_initfunction snd_s1810c_line_sw_infofunction snd_s1810c_ab_sw_infofunction snd_sc1810_mixer_state_freefunction snd_sc1810_init_mixer
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
- Immediate include surface: `linux/usb.h`, `linux/usb/audio-v2.h`, `linux/slab.h`, `sound/core.h`, `sound/control.h`, `usbaudio.h`, `mixer.h`, `mixer_quirks.h`.
- Detected declarations: `struct s1810c_ctl_packet`, `struct s1810c_state_packet`, `struct s1810_mixer_state`, `function snd_s1810c_send_ctl_packet`, `function snd_sc1810c_get_status_field`, `function snd_s1810c_init_mixer_maps`, `function in`, `function in`, `function snd_s1810c_switch_get`, `function snd_s1810c_switch_set`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.