sound/usb/mixer.c
Source file repositories/reference/linux-study-clean/sound/usb/mixer.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/mixer.c- Extension
.c- Size
- 107276 bytes
- Lines
- 3963
- 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/bitops.hlinux/init.hlinux/list.hlinux/log2.hlinux/slab.hlinux/string.hlinux/usb.hlinux/usb/audio.hlinux/usb/audio-v2.hlinux/usb/audio-v3.hsound/core.hsound/control.hsound/hwdep.hsound/info.hsound/tlv.husbaudio.hmixer.hhelper.hmixer_quirks.hpower.hmixer_maps.c
Detected Declarations
struct usb_audio_termstruct usbmix_name_mapstruct mixer_buildstruct usb_feature_control_infostruct procunit_value_infostruct procunit_infostruct uac3_badd_profilefunction find_mapfunction check_mapped_namefunction check_ignored_ctlfunction check_mapped_dBfunction check_mapped_selector_namefunction snd_usb_copy_string_descfunction convert_signed_valuefunction convert_bytes_valuefunction get_relative_valuefunction get_abs_valuefunction uac2_ctl_value_sizefunction mixer_ctrl_intffunction get_ctl_value_v1function get_ctl_value_v2function get_ctl_valuefunction get_cur_ctl_valuefunction get_cur_mix_rawfunction snd_usb_get_cur_mix_valuefunction snd_usb_mixer_set_ctl_valuefunction set_cur_ctl_valuefunction snd_usb_set_cur_mix_valuefunction snd_usb_mixer_vol_tlvfunction check_matrix_bitmapfunction snd_usb_mixer_add_listfunction get_term_namefunction get_cluster_channels_v3function uac_mixer_unit_get_channelsfunction parse_term_uac1_iterm_unitfunction parse_term_uac2_iterm_unitfunction parse_term_uac3_iterm_unitfunction parse_term_mixer_unitfunction parse_term_selector_unitfunction parse_term_proc_unitfunction parse_term_effect_unitfunction parse_term_uac2_clock_sourcefunction parse_term_uac3_clock_sourcefunction __check_input_termfunction check_input_termfunction usb_mixer_elem_info_freefunction snd_usb_mixer_elem_freefunction volume_control_quirks
Annotated Snippet
struct usb_audio_term {
int id;
int type;
int channels;
unsigned int chconfig;
int name;
};
struct usbmix_name_map;
struct mixer_build {
struct snd_usb_audio *chip;
struct usb_mixer_interface *mixer;
unsigned char *buffer;
unsigned int buflen;
DECLARE_BITMAP(unitbitmap, MAX_ID_ELEMS);
DECLARE_BITMAP(termbitmap, MAX_ID_ELEMS);
struct usb_audio_term oterm;
const struct usbmix_name_map *map;
const struct usbmix_selector_map *selector_map;
};
/*E-mu 0202/0404/0204 eXtension Unit(XU) control*/
enum {
USB_XU_CLOCK_RATE = 0xe301,
USB_XU_CLOCK_SOURCE = 0xe302,
USB_XU_DIGITAL_IO_STATUS = 0xe303,
USB_XU_DEVICE_OPTIONS = 0xe304,
USB_XU_DIRECT_MONITORING = 0xe305,
USB_XU_METERING = 0xe306
};
enum {
USB_XU_CLOCK_SOURCE_SELECTOR = 0x02, /* clock source*/
USB_XU_CLOCK_RATE_SELECTOR = 0x03, /* clock rate */
USB_XU_DIGITAL_FORMAT_SELECTOR = 0x01, /* the spdif format */
USB_XU_SOFT_LIMIT_SELECTOR = 0x03 /* soft limiter */
};
/*
* manual mapping of mixer names
* if the mixer topology is too complicated and the parsed names are
* ambiguous, add the entries in usbmixer_maps.c.
*/
#include "mixer_maps.c"
static const struct usbmix_name_map *
find_map(const struct usbmix_name_map *p, int unitid, int control)
{
if (!p)
return NULL;
for (; p->id; p++) {
if (p->id == unitid &&
(!control || !p->control || control == p->control))
return p;
}
return NULL;
}
/* get the mapped name if the unit matches */
static int
check_mapped_name(const struct usbmix_name_map *p, char *buf, int buflen)
{
int len;
if (!p || !p->name)
return 0;
buflen--;
len = strscpy(buf, p->name, buflen);
return len < 0 ? buflen : len;
}
/* ignore the error value if ignore_ctl_error flag is set */
#define filter_error(cval, err) \
((cval)->head.mixer->ignore_ctl_error ? 0 : (err))
/* check whether the control should be ignored */
static inline int
check_ignored_ctl(const struct usbmix_name_map *p)
{
if (!p || p->name || p->dB)
return 0;
return 1;
}
/* dB mapping */
static inline void check_mapped_dB(const struct usbmix_name_map *p,
struct usb_mixer_elem_info *cval)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/init.h`, `linux/list.h`, `linux/log2.h`, `linux/slab.h`, `linux/string.h`, `linux/usb.h`, `linux/usb/audio.h`.
- Detected declarations: `struct usb_audio_term`, `struct usbmix_name_map`, `struct mixer_build`, `struct usb_feature_control_info`, `struct procunit_value_info`, `struct procunit_info`, `struct uac3_badd_profile`, `function find_map`, `function check_mapped_name`, `function check_ignored_ctl`.
- 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.