sound/soc/codecs/ak5386.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/ak5386.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/ak5386.c- Extension
.c- Size
- 5469 bytes
- Lines
- 204
- 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/device.hlinux/dev_printk.hlinux/err.hlinux/gpio/consumer.hlinux/module.hlinux/regulator/consumer.hlinux/slab.hsound/soc.hsound/pcm.hsound/initval.h
Detected Declarations
struct ak5386_privfunction ak5386_soc_probefunction ak5386_soc_removefunction ak5386_soc_suspendfunction ak5386_soc_resumefunction ak5386_set_dai_fmtfunction ak5386_hw_paramsfunction ak5386_hw_freefunction ak5386_probe
Annotated Snippet
struct ak5386_priv {
struct gpio_desc *reset_gpio;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
};
static const struct snd_soc_dapm_widget ak5386_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("AINL"),
SND_SOC_DAPM_INPUT("AINR"),
};
static const struct snd_soc_dapm_route ak5386_dapm_routes[] = {
{ "Capture", NULL, "AINL" },
{ "Capture", NULL, "AINR" },
};
static int ak5386_soc_probe(struct snd_soc_component *component)
{
struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
}
static void ak5386_soc_remove(struct snd_soc_component *component)
{
struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
}
#ifdef CONFIG_PM
static int ak5386_soc_suspend(struct snd_soc_component *component)
{
struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
return 0;
}
static int ak5386_soc_resume(struct snd_soc_component *component)
{
struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
}
#else
#define ak5386_soc_suspend NULL
#define ak5386_soc_resume NULL
#endif /* CONFIG_PM */
static const struct snd_soc_component_driver soc_component_ak5386 = {
.probe = ak5386_soc_probe,
.remove = ak5386_soc_remove,
.suspend = ak5386_soc_suspend,
.resume = ak5386_soc_resume,
.dapm_widgets = ak5386_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets),
.dapm_routes = ak5386_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(ak5386_dapm_routes),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
};
static int ak5386_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
format &= SND_SOC_DAIFMT_FORMAT_MASK;
if (format != SND_SOC_DAIFMT_LEFT_J &&
format != SND_SOC_DAIFMT_I2S) {
dev_err(component->dev, "Invalid DAI format\n");
return -EINVAL;
}
return 0;
}
static int ak5386_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
/*
* From the datasheet:
*
* All external clocks (MCLK, SCLK and LRCK) must be present unless
* PDN pin = āLā. If these clocks are not provided, the AK5386 may
* draw excess current due to its use of internal dynamically
* refreshed logic. If the external clocks are not present, place
* the AK5386 in power-down mode (PDN pin = āLā).
*/
Annotation
- Immediate include surface: `linux/device.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/regulator/consumer.h`, `linux/slab.h`, `sound/soc.h`.
- Detected declarations: `struct ak5386_priv`, `function ak5386_soc_probe`, `function ak5386_soc_remove`, `function ak5386_soc_suspend`, `function ak5386_soc_resume`, `function ak5386_set_dai_fmt`, `function ak5386_hw_params`, `function ak5386_hw_free`, `function ak5386_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.