sound/isa/sb/sb_mixer.c
Source file repositories/reference/linux-study-clean/sound/isa/sb/sb_mixer.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/sb/sb_mixer.c- Extension
.c- Size
- 27126 bytes
- Lines
- 928
- Domain
- Driver Families
- Bucket
- sound/isa
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io.hlinux/delay.hlinux/string.hlinux/time.hsound/core.hsound/sb.hsound/control.h
Detected Declarations
function Copyrightfunction snd_sbmixer_readfunction snd_sbmixer_info_singlefunction snd_sbmixer_get_singlefunction snd_sbmixer_put_singlefunction snd_sbmixer_info_doublefunction snd_sbmixer_get_doublefunction snd_sbmixer_put_doublefunction snd_dt019x_input_sw_infofunction snd_dt019x_input_sw_getfunction scoped_guardfunction snd_dt019x_input_sw_putfunction snd_als4k_mono_capture_route_infofunction snd_als4k_mono_capture_route_getfunction snd_als4k_mono_capture_route_putfunction snd_sb8mixer_info_muxfunction snd_sb8mixer_get_muxfunction snd_sb8mixer_put_muxfunction snd_sb16mixer_info_input_swfunction snd_sb16mixer_get_input_swfunction snd_sb16mixer_put_input_swfunction snd_sbmixer_add_ctlfunction snd_sbmixer_initfunction snd_sbmixer_newfunction save_mixerfunction restore_mixerfunction snd_sbmixer_suspendfunction snd_sbmixer_resume
Annotated Snippet
if (change) {
snd_sbmixer_write(sb, left_reg, left);
snd_sbmixer_write(sb, right_reg, right);
}
}
return change;
}
/*
* DT-019x / ALS-007 capture/input switch
*/
static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static const char * const texts[5] = {
"CD", "Mic", "Line", "Synth", "Master"
};
return snd_ctl_enum_info(uinfo, 1, 5, texts);
}
static int snd_dt019x_input_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
unsigned char oval;
scoped_guard(spinlock_irqsave, &sb->mixer_lock) {
oval = snd_sbmixer_read(sb, SB_DT019X_CAPTURE_SW);
}
switch (oval & 0x07) {
case SB_DT019X_CAP_CD:
ucontrol->value.enumerated.item[0] = 0;
break;
case SB_DT019X_CAP_MIC:
ucontrol->value.enumerated.item[0] = 1;
break;
case SB_DT019X_CAP_LINE:
ucontrol->value.enumerated.item[0] = 2;
break;
case SB_DT019X_CAP_MAIN:
ucontrol->value.enumerated.item[0] = 4;
break;
/* To record the synth on these cards you must record the main. */
/* Thus SB_DT019X_CAP_SYNTH == SB_DT019X_CAP_MAIN and would cause */
/* duplicate case labels if left uncommented. */
/* case SB_DT019X_CAP_SYNTH:
* ucontrol->value.enumerated.item[0] = 3;
* break;
*/
default:
ucontrol->value.enumerated.item[0] = 4;
break;
}
return 0;
}
static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
int change;
unsigned char nval, oval;
if (ucontrol->value.enumerated.item[0] > 4)
return -EINVAL;
switch (ucontrol->value.enumerated.item[0]) {
case 0:
nval = SB_DT019X_CAP_CD;
break;
case 1:
nval = SB_DT019X_CAP_MIC;
break;
case 2:
nval = SB_DT019X_CAP_LINE;
break;
case 3:
nval = SB_DT019X_CAP_SYNTH;
break;
case 4:
nval = SB_DT019X_CAP_MAIN;
break;
default:
nval = SB_DT019X_CAP_MAIN;
}
guard(spinlock_irqsave)(&sb->mixer_lock);
oval = snd_sbmixer_read(sb, SB_DT019X_CAPTURE_SW);
change = nval != oval;
if (change)
snd_sbmixer_write(sb, SB_DT019X_CAPTURE_SW, nval);
return change;
}
Annotation
- Immediate include surface: `linux/io.h`, `linux/delay.h`, `linux/string.h`, `linux/time.h`, `sound/core.h`, `sound/sb.h`, `sound/control.h`.
- Detected declarations: `function Copyright`, `function snd_sbmixer_read`, `function snd_sbmixer_info_single`, `function snd_sbmixer_get_single`, `function snd_sbmixer_put_single`, `function snd_sbmixer_info_double`, `function snd_sbmixer_get_double`, `function snd_sbmixer_put_double`, `function snd_dt019x_input_sw_info`, `function snd_dt019x_input_sw_get`.
- Atlas domain: Driver Families / sound/isa.
- 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.