sound/soc/codecs/cs42l51.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs42l51.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs42l51.c- Extension
.c- Size
- 23243 bytes
- Lines
- 832
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/clk.hlinux/module.hlinux/slab.hsound/core.hsound/soc.hsound/tlv.hsound/initval.hsound/pcm_params.hsound/pcm.hlinux/gpio/consumer.hlinux/regmap.hlinux/regulator/consumer.hcs42l51.h
Detected Declarations
struct cs42l51_privatestruct cs42l51_ratiosenum master_slave_modefunction cs42l51_get_chan_mixfunction cs42l51_set_chan_mixfunction cs42l51_pdn_eventfunction mclk_eventfunction cs42l51_set_dai_fmtfunction cs42l51_set_dai_sysclkfunction cs42l51_hw_paramsfunction cs42l51_dai_mutefunction cs42l51_of_xlate_dai_idfunction cs42l51_component_probefunction cs42l51_writeable_regfunction cs42l51_volatile_regfunction cs42l51_readable_regfunction cs42l51_probefunction cs42l51_removefunction cs42l51_suspendfunction cs42l51_resumeexport cs42l51_regmapexport cs42l51_probeexport cs42l51_removeexport cs42l51_suspendexport cs42l51_resume
Annotated Snippet
struct cs42l51_private {
unsigned int mclk;
struct clk *mclk_handle;
unsigned int audio_mode; /* The mode (I2S or left-justified) */
enum master_slave_mode func;
struct regulator_bulk_data supplies[ARRAY_SIZE(cs42l51_supply_names)];
struct gpio_desc *reset_gpio;
struct regmap *regmap;
};
#define CS42L51_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE | \
SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE)
static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
unsigned long value = snd_soc_component_read(component, CS42L51_PCM_MIXER)&3;
switch (value) {
default:
case 0:
ucontrol->value.enumerated.item[0] = 0;
break;
/* same value : (L+R)/2 and (R+L)/2 */
case 1:
case 2:
ucontrol->value.enumerated.item[0] = 1;
break;
case 3:
ucontrol->value.enumerated.item[0] = 2;
break;
}
return 0;
}
#define CHAN_MIX_NORMAL 0x00
#define CHAN_MIX_BOTH 0x55
#define CHAN_MIX_SWAP 0xFF
static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
unsigned char val;
switch (ucontrol->value.enumerated.item[0]) {
default:
case 0:
val = CHAN_MIX_NORMAL;
break;
case 1:
val = CHAN_MIX_BOTH;
break;
case 2:
val = CHAN_MIX_SWAP;
break;
}
snd_soc_component_write(component, CS42L51_PCM_MIXER, val);
return 1;
}
static const DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -5150, 50, 0);
static const DECLARE_TLV_DB_SCALE(tone_tlv, -1050, 150, 0);
static const DECLARE_TLV_DB_SCALE(aout_tlv, -10200, 50, 0);
static const DECLARE_TLV_DB_SCALE(boost_tlv, 1600, 1600, 0);
static const DECLARE_TLV_DB_SCALE(adc_boost_tlv, 2000, 2000, 0);
static const char *chan_mix[] = {
"L R",
"L+R",
"R L",
};
static const DECLARE_TLV_DB_SCALE(pga_tlv, -300, 50, 0);
static const DECLARE_TLV_DB_SCALE(adc_att_tlv, -9600, 100, 0);
static SOC_ENUM_SINGLE_EXT_DECL(cs42l51_chan_mix, chan_mix);
static const struct snd_kcontrol_new cs42l51_snd_controls[] = {
SOC_DOUBLE_R_SX_TLV("PCM Playback Volume",
CS42L51_PCMA_VOL, CS42L51_PCMB_VOL,
0, 0x19, 0x7F, adc_pcm_tlv),
SOC_DOUBLE_R("PCM Playback Switch",
CS42L51_PCMA_VOL, CS42L51_PCMB_VOL, 7, 1, 1),
SOC_DOUBLE_R_SX_TLV("Analog Playback Volume",
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/slab.h`, `sound/core.h`, `sound/soc.h`, `sound/tlv.h`, `sound/initval.h`, `sound/pcm_params.h`.
- Detected declarations: `struct cs42l51_private`, `struct cs42l51_ratios`, `enum master_slave_mode`, `function cs42l51_get_chan_mix`, `function cs42l51_set_chan_mix`, `function cs42l51_pdn_event`, `function mclk_event`, `function cs42l51_set_dai_fmt`, `function cs42l51_set_dai_sysclk`, `function cs42l51_hw_params`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.