sound/soc/amd/acp3x-rt5682-max9836.c
Source file repositories/reference/linux-study-clean/sound/soc/amd/acp3x-rt5682-max9836.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/amd/acp3x-rt5682-max9836.c- Extension
.c- Size
- 15622 bytes
- Lines
- 561
- 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
sound/core.hsound/soc.hsound/pcm.hsound/pcm_params.hsound/soc-dapm.hsound/jack.hlinux/clk.hlinux/gpio/consumer.hlinux/module.hlinux/i2c.hlinux/input.hlinux/io.hlinux/acpi.hraven/acp3x.h../codecs/rt5682.h../codecs/rt1015.h
Detected Declarations
function acp3x_5682_initfunction rt5682_clk_enablefunction acp3x_1015_hw_paramsfunction for_each_rtd_codec_daisfunction rt5682_clk_disablefunction acp3x_5682_startupfunction acp3x_max_startupfunction acp3x_ec_dmic0_startupfunction dmic_getfunction dmic_setfunction rt5682_shutdownfunction card_spk_dai_link_presentfunction acp3x_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
//
// Machine driver for AMD ACP Audio engine using DA7219 & MAX98357 codec.
//
//Copyright 2016 Advanced Micro Devices, Inc.
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <linux/clk.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/io.h>
#include <linux/acpi.h>
#include "raven/acp3x.h"
#include "../codecs/rt5682.h"
#include "../codecs/rt1015.h"
#define PCO_PLAT_CLK 48000000
#define RT5682_PLL_FREQ (48000 * 512)
#define DUAL_CHANNEL 2
static struct snd_soc_jack pco_jack;
static struct snd_soc_jack_pin pco_jack_pins[] = {
{
.pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
};
static struct clk *rt5682_dai_wclk;
static struct clk *rt5682_dai_bclk;
static struct gpio_desc *dmic_sel;
void *soc_is_rltk_max(struct device *dev);
enum {
RT5682 = 0,
MAX,
EC,
};
static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd)
{
int ret;
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
struct snd_soc_component *component = codec_dai->component;
dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
/* set rt5682 dai fmt */
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBP_CFP);
if (ret < 0) {
dev_err(rtd->card->dev,
"Failed to set rt5682 dai fmt: %d\n", ret);
return ret;
}
/* set codec PLL */
ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL2, RT5682_PLL2_S_MCLK,
PCO_PLAT_CLK, RT5682_PLL_FREQ);
if (ret < 0) {
dev_err(rtd->dev, "can't set rt5682 PLL: %d\n", ret);
return ret;
}
/* Set codec sysclk */
ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL2,
RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
if (ret < 0) {
dev_err(rtd->dev,
"Failed to set rt5682 SYSCLK: %d\n", ret);
return ret;
}
/* Set tdm/i2s1 master bclk ratio */
ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
if (ret < 0) {
Annotation
- Immediate include surface: `sound/core.h`, `sound/soc.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc-dapm.h`, `sound/jack.h`, `linux/clk.h`, `linux/gpio/consumer.h`.
- Detected declarations: `function acp3x_5682_init`, `function rt5682_clk_enable`, `function acp3x_1015_hw_params`, `function for_each_rtd_codec_dais`, `function rt5682_clk_disable`, `function acp3x_5682_startup`, `function acp3x_max_startup`, `function acp3x_ec_dmic0_startup`, `function dmic_get`, `function dmic_set`.
- 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.