sound/soc/intel/avs/boards/rt5640.c
Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/boards/rt5640.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/intel/avs/boards/rt5640.c- Extension
.c- Size
- 7710 bytes
- Lines
- 272
- 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/module.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-acpi.h../../../codecs/rt5640.h../utils.h
Detected Declarations
function avs_rt5640_codec_initfunction avs_rt5640_codec_exitfunction avs_rt5640_be_fixupfunction avs_rt5640_hw_paramsfunction avs_create_dai_linkfunction avs_card_suspend_prefunction avs_card_resume_postfunction avs_rt5640_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2022-2025 Intel Corporation
//
// Authors: Cezary Rojewski <cezary.rojewski@intel.com>
// Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
//
#include <linux/module.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../../codecs/rt5640.h"
#include "../utils.h"
#define AVS_RT5640_MCLK_HZ 19200000
#define RT5640_CODEC_DAI "rt5640-aif1"
static const struct snd_soc_dapm_widget card_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Mic Jack", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_soc_dapm_route card_routes[] = {
{ "Headphone Jack", NULL, "HPOR" },
{ "Headphone Jack", NULL, "HPOL" },
{ "IN2P", NULL, "Mic Jack" },
{ "IN2P", NULL, "MICBIAS1" },
{ "Speaker", NULL, "SPOLP" },
{ "Speaker", NULL, "SPOLN" },
{ "Speaker", NULL, "SPORP" },
{ "Speaker", NULL, "SPORN" },
};
static const struct snd_soc_jack_pin card_headset_pins[] = {
{
.pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Mic Jack",
.mask = SND_JACK_MICROPHONE,
},
};
static int avs_rt5640_codec_init(struct snd_soc_pcm_runtime *runtime)
{
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(runtime, 0);
struct snd_soc_card *card = runtime->card;
struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack;
int num_pins, ret;
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
if (!pins)
return -ENOMEM;
ret = snd_soc_card_jack_new_pins(card, "Headset Jack", SND_JACK_HEADSET, jack, pins,
num_pins);
if (ret)
return ret;
snd_soc_component_set_jack(codec_dai->component, jack, NULL);
snd_soc_dapm_set_idle_bias(dapm, false);
return 0;
}
static void avs_rt5640_codec_exit(struct snd_soc_pcm_runtime *runtime)
{
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(runtime, 0);
snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
}
static int avs_rt5640_be_fixup(struct snd_soc_pcm_runtime *runtime,
struct snd_pcm_hw_params *params)
{
struct snd_mask *fmask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
/* Format 24/32 is MSB-aligned for HDAudio and LSB-aligned for I2S. */
if (params_format(params) == SNDRV_PCM_FORMAT_S32_LE)
snd_mask_set_format(fmask, SNDRV_PCM_FORMAT_S24_LE);
Annotation
- Immediate include surface: `linux/module.h`, `sound/jack.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/soc-acpi.h`, `../../../codecs/rt5640.h`, `../utils.h`.
- Detected declarations: `function avs_rt5640_codec_init`, `function avs_rt5640_codec_exit`, `function avs_rt5640_be_fixup`, `function avs_rt5640_hw_params`, `function avs_create_dai_link`, `function avs_card_suspend_pre`, `function avs_card_resume_post`, `function avs_rt5640_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.