sound/usb/mixer_quirks.c
Source file repositories/reference/linux-study-clean/sound/usb/mixer_quirks.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/mixer_quirks.c- Extension
.c- Size
- 137473 bytes
- Lines
- 4804
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/bitfield.hlinux/hid.hlinux/init.hlinux/input.hlinux/math64.hlinux/slab.hlinux/usb.hlinux/usb/audio.hsound/asoundef.hsound/core.hsound/control.hsound/hda_verbs.hsound/hwdep.hsound/info.hsound/tlv.husbaudio.hmixer.hmixer_quirks.hmixer_scarlett.hmixer_scarlett2.hmixer_us16x08.hmixer_s1810c.hhelper.hfcp.h
Detected Declarations
struct std_mono_tablestruct dualsense_mixer_elem_infostruct snd_djm_devicestruct snd_djm_ctlenum snd_rme_domainenum snd_rme_clock_statusfunction snd_create_std_mono_ctl_offsetfunction snd_create_std_mono_ctlfunction snd_create_std_mono_tablefunction add_single_ctl_with_resumefunction snd_usb_soundblaster_remote_completefunction snd_usb_sbrc_hwdep_readfunction snd_usb_sbrc_hwdep_pollfunction snd_usb_soundblaster_remote_initfunction snd_audigy2nx_led_getfunction snd_audigy2nx_led_updatefunction snd_audigy2nx_led_putfunction snd_audigy2nx_led_resumefunction snd_audigy2nx_controls_createfunction snd_audigy2nx_proc_readfunction snd_emu0204_ch_switch_infofunction snd_emu0204_ch_switch_getfunction snd_emu0204_ch_switch_updatefunction snd_emu0204_ch_switch_putfunction snd_emu0204_ch_switch_resumefunction snd_emu0204_controls_createfunction snd_dualsense_ih_eventfunction snd_dualsense_ih_matchfunction snd_dualsense_ih_connectfunction snd_dualsense_ih_disconnectfunction snd_dualsense_ih_startfunction snd_dualsense_jack_getfunction snd_dualsense_resume_jackfunction snd_dualsense_mixer_elem_freefunction snd_dualsense_jack_createfunction snd_dualsense_controls_createfunction snd_xonar_u1_switch_getfunction snd_xonar_u1_switch_updatefunction snd_xonar_u1_switch_putfunction snd_xonar_u1_switch_resumefunction snd_xonar_u1_controls_createfunction snd_mbox1_is_spdif_syncedfunction snd_mbox1_set_clk_sourcefunction snd_mbox1_is_spdif_inputfunction snd_mbox1_set_input_sourcefunction snd_mbox1_clk_switch_getfunction snd_mbox1_clk_switch_updatefunction snd_mbox1_clk_switch_put
Annotated Snippet
struct std_mono_table {
unsigned int unitid, control, cmask;
int val_type;
const char *name;
snd_kcontrol_tlv_rw_t *tlv_callback;
};
/* This function allows for the creation of standard UAC controls.
* See the quirks for M-Audio FTUs or Ebox-44.
* If you don't want to set a TLV callback pass NULL.
*
* Since there doesn't seem to be a devices that needs a multichannel
* version, we keep it mono for simplicity.
*/
static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
unsigned int unitid,
unsigned int control,
unsigned int cmask,
int val_type,
unsigned int idx_off,
const char *name,
snd_kcontrol_tlv_rw_t *tlv_callback)
{
struct usb_mixer_elem_info *cval;
struct snd_kcontrol *kctl;
cval = kzalloc_obj(*cval);
if (!cval)
return -ENOMEM;
snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid);
cval->val_type = val_type;
cval->channels = 1;
cval->control = control;
cval->cmask = cmask;
cval->idx_off = idx_off;
/* get_min_max() is called only for integer volumes later,
* so provide a short-cut for booleans
*/
cval->min = 0;
cval->max = 1;
cval->res = 0;
cval->dBmin = 0;
cval->dBmax = 0;
/* Create control */
kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
if (!kctl) {
kfree(cval);
return -ENOMEM;
}
/* Set name */
snprintf(kctl->id.name, sizeof(kctl->id.name), name);
kctl->private_free = snd_usb_mixer_elem_free;
/* set TLV */
if (tlv_callback) {
kctl->tlv.c = tlv_callback;
kctl->vd[0].access |=
SNDRV_CTL_ELEM_ACCESS_TLV_READ |
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
}
/* Add control to mixer */
return snd_usb_mixer_add_control(&cval->head, kctl);
}
static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
unsigned int unitid,
unsigned int control,
unsigned int cmask,
int val_type,
const char *name,
snd_kcontrol_tlv_rw_t *tlv_callback)
{
return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask,
val_type, 0 /* Offset */,
name, tlv_callback);
}
/*
* Create a set of standard UAC controls from a table
*/
static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
const struct std_mono_table *t)
{
int err;
while (t->name) {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/hid.h`, `linux/init.h`, `linux/input.h`, `linux/math64.h`, `linux/slab.h`, `linux/usb.h`, `linux/usb/audio.h`.
- Detected declarations: `struct std_mono_table`, `struct dualsense_mixer_elem_info`, `struct snd_djm_device`, `struct snd_djm_ctl`, `enum snd_rme_domain`, `enum snd_rme_clock_status`, `function snd_create_std_mono_ctl_offset`, `function snd_create_std_mono_ctl`, `function snd_create_std_mono_table`, `function add_single_ctl_with_resume`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.