sound/hda/codecs/cirrus/cs421x.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/cirrus/cs421x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/cirrus/cs421x.c- Extension
.c- Size
- 15156 bytes
- Lines
- 586
- 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/init.hlinux/slab.hlinux/module.hsound/core.hlinux/pci.hsound/tlv.hsound/hda_codec.hhda_local.hhda_auto_parser.hhda_jack.h../generic.h
Detected Declarations
struct cs_specfunction cs_vendor_coef_getfunction cs_vendor_coef_setfunction cs_automutefunction is_active_pinfunction cs421x_fixup_sense_bfunction cs421x_boost_vol_infofunction cs421x_boost_vol_getfunction cs421x_boost_vol_putfunction cs4210_pinmux_initfunction cs4210_spdif_automutefunction parse_cs421x_digitalfunction cs421x_initfunction fix_volume_capsfunction cs421x_parse_auto_configfunction cs421x_suspendfunction cs421x_probe
Annotated Snippet
struct cs_spec {
struct hda_gen_spec gen;
unsigned int gpio_mask;
unsigned int gpio_dir;
unsigned int gpio_data;
unsigned int gpio_eapd_hp; /* EAPD GPIO bit for headphones */
unsigned int gpio_eapd_speaker; /* EAPD GPIO bit for speakers */
/* CS421x */
unsigned int spdif_detect:1;
unsigned int spdif_present:1;
unsigned int sense_b:1;
hda_nid_t vendor_nid;
/* for MBP SPDIF control */
int (*spdif_sw_put)(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
};
/* CS421x boards */
enum {
CS421X_CDB4210,
CS421X_SENSE_B,
CS421X_STUMPY,
};
/* Vendor-specific processing widget */
#define CS_DIG_OUT1_PIN_NID 0x10
#define CS_DIG_OUT2_PIN_NID 0x15
#define CS_DMIC1_PIN_NID 0x0e
#define CS_DMIC2_PIN_NID 0x12
/* coef indices */
#define IDX_SPDIF_STAT 0x0000
#define IDX_SPDIF_CTL 0x0001
#define IDX_ADC_CFG 0x0002
/* SZC bitmask, 4 modes below:
* 0 = immediate,
* 1 = digital immediate, analog zero-cross
* 2 = digtail & analog soft-ramp
* 3 = digital soft-ramp, analog zero-cross
*/
#define CS_COEF_ADC_SZC_MASK (3 << 0)
#define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */
#define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */
/* PGA mode: 0 = differential, 1 = signle-ended */
#define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */
#define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */
#define IDX_DAC_CFG 0x0003
/* SZC bitmask, 4 modes below:
* 0 = Immediate
* 1 = zero-cross
* 2 = soft-ramp
* 3 = soft-ramp on zero-cross
*/
#define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */
#define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */
#define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */
#define IDX_BEEP_CFG 0x0004
/* 0x0008 - test reg key */
/* 0x0009 - 0x0014 -> 12 test regs */
/* 0x0015 - visibility reg */
/*
* Cirrus Logic CS4210
*
* 1 DAC => HP(sense) / Speakers,
* 1 ADC <= LineIn(sense) / MicIn / DMicIn,
* 1 SPDIF OUT => SPDIF Transmitter(sense)
*/
#define CS4210_DAC_NID 0x02
#define CS4210_ADC_NID 0x03
#define CS4210_VENDOR_NID 0x0B
#define CS421X_DMIC_PIN_NID 0x09 /* Port E */
#define CS421X_SPDIF_PIN_NID 0x0A /* Port H */
#define CS421X_IDX_DEV_CFG 0x01
#define CS421X_IDX_ADC_CFG 0x02
#define CS421X_IDX_DAC_CFG 0x03
#define CS421X_IDX_SPK_CTL 0x04
/* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */
#define CS4213_VENDOR_NID 0x09
static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
{
struct cs_spec *spec = codec->spec;
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `linux/pci.h`, `sound/tlv.h`, `sound/hda_codec.h`, `hda_local.h`.
- Detected declarations: `struct cs_spec`, `function cs_vendor_coef_get`, `function cs_vendor_coef_set`, `function cs_automute`, `function is_active_pin`, `function cs421x_fixup_sense_b`, `function cs421x_boost_vol_info`, `function cs421x_boost_vol_get`, `function cs421x_boost_vol_put`, `function cs4210_pinmux_init`.
- 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.