sound/hda/codecs/cirrus/cs8409.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/cirrus/cs8409.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/cirrus/cs8409.c- Extension
.c- Size
- 48071 bytes
- Lines
- 1638
- Domain
- Driver Families
- Bucket
- sound/hda
- 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/acpi.hlinux/cleanup.hlinux/i2c.hlinux/init.hlinux/slab.hlinux/module.hlinux/spi/spi.hsound/core.hlinux/mutex.hlinux/iopoll.hcs8409.h../side-codecs/hda_component.h
Detected Declarations
function Copyrightfunction cs8409_vendor_coef_getfunction cs8409_vendor_coef_setfunction cs8409_disable_i2c_clockfunction cs8409_disable_i2c_clock_workerfunction cs8409_enable_i2c_clockfunction cs8409_i2c_wait_completefunction cs8409_set_i2c_dev_addrfunction cs8409_i2c_set_pagefunction cs8409_i2c_readfunction cs8409_i2c_bulk_readfunction cs8409_i2c_writefunction cs8409_i2c_bulk_writefunction cs8409_initfunction cs8409_build_controlsfunction cs8409_enable_urfunction cs8409_fix_capsfunction cs8409_spk_sw_gpio_getfunction cs8409_spk_sw_gpio_putfunction cs42l42_volume_infofunction cs42l42_volume_getfunction cs42l42_mutefunction cs42l42_volume_putfunction cs42l42_playback_pcm_hookfunction cs42l42_capture_pcm_hookfunction cs42l42_enable_jack_detectfunction cs42l42_run_jack_detectfunction cs42l42_manual_hs_detfunction cs42l42_handle_tip_sensefunction cs42l42_jack_unsol_eventfunction cs42l42_resumefunction cs42l42_suspendfunction cs8409_removefunction snd_hda_jack_unsol_eventfunction cs8409_unsol_eventfunction cs8409_cs42l42_suspendfunction cs8409_cs42l42_hw_initfunction cs8409_cs42l42_exec_verbfunction read_pin_sensefunction cs8409_cs42l42_fixupsfunction cs8409_comp_bindfunction cs8409_comp_unbindfunction cs8409_comp_playback_hookfunction cs8409_cdb35l56_four_hw_initfunction cs8409_spk_sw_getfunction cs8409_spk_sw_putfunction cs8409_cdb35l56_four_autodet_fixupfunction snd_hda_jack_unsol_event
Annotated Snippet
if (vol_type == CS42L42_VOL_DAC) {
if (chs & BIT(0))
cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHA_VOL, 0x3f);
if (chs & BIT(1))
cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHB_VOL, 0x3f);
} else if (vol_type == CS42L42_VOL_ADC) {
if (chs & BIT(0))
cs8409_i2c_write(cs42l42, CS42L42_ADC_VOLUME, 0x9f);
}
} else {
if (vol_type == CS42L42_VOL_DAC) {
if (chs & BIT(0))
cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHA_VOL,
-(cs42l42->vol[CS42L42_DAC_CH0_VOL_OFFSET])
& CS42L42_MIXER_CH_VOL_MASK);
if (chs & BIT(1))
cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHB_VOL,
-(cs42l42->vol[CS42L42_DAC_CH1_VOL_OFFSET])
& CS42L42_MIXER_CH_VOL_MASK);
} else if (vol_type == CS42L42_VOL_ADC) {
if (chs & BIT(0))
cs8409_i2c_write(cs42l42, CS42L42_ADC_VOLUME,
cs42l42->vol[CS42L42_ADC_VOL_OFFSET]
& CS42L42_REG_AMIC_VOL_MASK);
}
}
}
int cs42l42_volume_put(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *uctrl)
{
struct hda_codec *codec = snd_kcontrol_chip(kctrl);
struct cs8409_spec *spec = codec->spec;
struct sub_codec *cs42l42 = spec->scodecs[get_amp_index(kctrl)];
int chs = get_amp_channels(kctrl);
unsigned int ofs = get_amp_offset(kctrl);
long *valp = uctrl->value.integer.value;
switch (ofs) {
case CS42L42_VOL_DAC:
if (chs & BIT(0))
cs42l42->vol[ofs] = *valp;
if (chs & BIT(1)) {
valp++;
cs42l42->vol[ofs + 1] = *valp;
}
if (spec->playback_started)
cs42l42_mute(cs42l42, CS42L42_VOL_DAC, chs, false);
break;
case CS42L42_VOL_ADC:
if (chs & BIT(0))
cs42l42->vol[ofs] = *valp;
if (spec->capture_started)
cs42l42_mute(cs42l42, CS42L42_VOL_ADC, chs, false);
break;
default:
break;
}
return 0;
}
static void cs42l42_playback_pcm_hook(struct hda_pcm_stream *hinfo,
struct hda_codec *codec,
struct snd_pcm_substream *substream,
int action)
{
struct cs8409_spec *spec = codec->spec;
struct sub_codec *cs42l42;
int i;
bool mute;
switch (action) {
case HDA_GEN_PCM_ACT_PREPARE:
mute = false;
spec->playback_started = 1;
break;
case HDA_GEN_PCM_ACT_CLEANUP:
mute = true;
spec->playback_started = 0;
break;
default:
return;
}
for (i = 0; i < spec->num_scodecs; i++) {
cs42l42 = spec->scodecs[i];
cs42l42_mute(cs42l42, CS42L42_VOL_DAC, 0x3, mute);
}
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/cleanup.h`, `linux/i2c.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/spi/spi.h`, `sound/core.h`.
- Detected declarations: `function Copyright`, `function cs8409_vendor_coef_get`, `function cs8409_vendor_coef_set`, `function cs8409_disable_i2c_clock`, `function cs8409_disable_i2c_clock_worker`, `function cs8409_enable_i2c_clock`, `function cs8409_i2c_wait_complete`, `function cs8409_set_i2c_dev_addr`, `function cs8409_i2c_set_page`, `function cs8409_i2c_read`.
- Atlas domain: Driver Families / sound/hda.
- 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.