sound/soc/meson/aiu-acodec-ctrl.c
Source file repositories/reference/linux-study-clean/sound/soc/meson/aiu-acodec-ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/meson/aiu-acodec-ctrl.c- Extension
.c- Size
- 6607 bytes
- Lines
- 207
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hsound/pcm_params.hsound/soc.hsound/soc-dai.hdt-bindings/sound/meson-aiu.haiu.hmeson-codec-glue.h
Detected Declarations
function aiu_acodec_ctrl_mux_put_enumfunction aiu_acodec_ctrl_input_hw_paramsfunction aiu_acodec_of_xlate_dai_namefunction aiu_acodec_ctrl_component_probefunction aiu_acodec_ctrl_register_component
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2020 BayLibre, SAS.
// Author: Jerome Brunet <jbrunet@baylibre.com>
#include <linux/bitfield.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dai.h>
#include <dt-bindings/sound/meson-aiu.h>
#include "aiu.h"
#include "meson-codec-glue.h"
#define CTRL_DIN_EN 15
#define CTRL_CLK_INV BIT(14)
#define CTRL_LRCLK_INV BIT(13)
#define CTRL_I2S_IN_BCLK_SRC BIT(11)
#define CTRL_DIN_LRCLK_SRC_SHIFT 6
#define CTRL_DIN_LRCLK_SRC (0x3 << CTRL_DIN_LRCLK_SRC_SHIFT)
#define CTRL_BCLK_MCLK_SRC GENMASK(5, 4)
#define CTRL_DIN_SKEW GENMASK(3, 2)
#define CTRL_I2S_OUT_LANE_SRC 0
#define AIU_ACODEC_OUT_CHMAX 2
static const char * const aiu_acodec_ctrl_mux_texts[] = {
"DISABLED", "I2S", "PCM",
};
static int aiu_acodec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol);
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int mux, changed;
if (ucontrol->value.enumerated.item[0] >= e->items)
return -EINVAL;
mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
changed = snd_soc_component_test_bits(component, e->reg,
CTRL_DIN_LRCLK_SRC,
FIELD_PREP(CTRL_DIN_LRCLK_SRC,
mux));
if (!changed)
return 0;
/* Force disconnect of the mux while updating */
snd_soc_dapm_mux_update_power(dapm, kcontrol, 0, NULL, NULL);
snd_soc_component_update_bits(component, e->reg,
CTRL_DIN_LRCLK_SRC |
CTRL_BCLK_MCLK_SRC,
FIELD_PREP(CTRL_DIN_LRCLK_SRC, mux) |
FIELD_PREP(CTRL_BCLK_MCLK_SRC, mux));
snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
return 1;
}
static SOC_ENUM_SINGLE_DECL(aiu_acodec_ctrl_mux_enum, AIU_ACODEC_CTRL,
CTRL_DIN_LRCLK_SRC_SHIFT,
aiu_acodec_ctrl_mux_texts);
static const struct snd_kcontrol_new aiu_acodec_ctrl_mux =
SOC_DAPM_ENUM_EXT("ACodec Source", aiu_acodec_ctrl_mux_enum,
snd_soc_dapm_get_enum_double,
aiu_acodec_ctrl_mux_put_enum);
static const struct snd_kcontrol_new aiu_acodec_ctrl_out_enable =
SOC_DAPM_SINGLE_AUTODISABLE("Switch", AIU_ACODEC_CTRL,
CTRL_DIN_EN, 1, 0);
static const struct snd_soc_dapm_widget aiu_acodec_ctrl_widgets[] = {
SND_SOC_DAPM_MUX("ACODEC SRC", SND_SOC_NOPM, 0, 0,
&aiu_acodec_ctrl_mux),
SND_SOC_DAPM_SWITCH("ACODEC OUT EN", SND_SOC_NOPM, 0, 0,
&aiu_acodec_ctrl_out_enable),
};
static int aiu_acodec_ctrl_input_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct meson_codec_glue_input *data;
int ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/soc-dai.h`, `dt-bindings/sound/meson-aiu.h`, `aiu.h`, `meson-codec-glue.h`.
- Detected declarations: `function aiu_acodec_ctrl_mux_put_enum`, `function aiu_acodec_ctrl_input_hw_params`, `function aiu_acodec_of_xlate_dai_name`, `function aiu_acodec_ctrl_component_probe`, `function aiu_acodec_ctrl_register_component`.
- 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.