sound/soc/codecs/wm8524.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wm8524.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wm8524.c- Extension
.c- Size
- 7038 bytes
- Lines
- 283
- Domain
- Driver Families
- Bucket
- sound/soc
- 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/mod_devicetable.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/delay.hlinux/slab.hlinux/gpio/consumer.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/initval.h
Detected Declarations
struct wm8524_privfunction wm8524_startupfunction wm8524_shutdownfunction wm8524_set_dai_sysclkfunction wm8524_set_fmtfunction wm8524_mute_streamfunction wm8524_hw_paramsfunction wm8524_probefunction wm8524_codec_probe
Annotated Snippet
struct wm8524_priv {
struct gpio_desc *mute;
unsigned int sysclk;
unsigned int rate_constraint_list[WM8524_NUM_RATES];
struct snd_pcm_hw_constraint_list rate_constraint;
};
static const struct snd_soc_dapm_widget wm8524_dapm_widgets[] = {
SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_OUTPUT("LINEVOUTL"),
SND_SOC_DAPM_OUTPUT("LINEVOUTR"),
};
static const struct snd_soc_dapm_route wm8524_dapm_routes[] = {
{ "LINEVOUTL", NULL, "DAC" },
{ "LINEVOUTR", NULL, "DAC" },
};
static const struct {
int value;
int ratio;
} lrclk_ratios[] = {
{ 1, 128 },
{ 2, 192 },
{ 3, 256 },
{ 4, 384 },
{ 5, 512 },
{ 6, 768 },
{ 7, 1152 },
};
static int wm8524_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
/* The set of sample rates that can be supported depends on the
* MCLK supplied to the CODEC.
*/
if (wm8524->sysclk)
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&wm8524->rate_constraint);
gpiod_set_value_cansleep(wm8524->mute, 1);
return 0;
}
static void wm8524_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
gpiod_set_value_cansleep(wm8524->mute, 0);
}
static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_component *component = codec_dai->component;
struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
unsigned int val;
int i, j = 0;
wm8524->rate_constraint.count = 0;
wm8524->sysclk = freq;
if (!wm8524->sysclk)
return 0;
for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
val = freq / lrclk_ratios[i].ratio;
/* Check that it's a standard rate since core can't
* cope with others and having the odd rates confuses
* constraint matching.
*/
switch (val) {
case 8000:
case 11025:
case 16000:
case 22050:
case 32000:
case 44100:
case 48000:
case 64000:
case 88200:
case 96000:
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/slab.h`, `linux/gpio/consumer.h`, `sound/core.h`.
- Detected declarations: `struct wm8524_priv`, `function wm8524_startup`, `function wm8524_shutdown`, `function wm8524_set_dai_sysclk`, `function wm8524_set_fmt`, `function wm8524_mute_stream`, `function wm8524_hw_params`, `function wm8524_probe`, `function wm8524_codec_probe`.
- Atlas domain: Driver Families / sound/soc.
- 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.