sound/soc/codecs/rt9120.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt9120.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt9120.c- Extension
.c- Size
- 16456 bytes
- Lines
- 644
- 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/bits.hlinux/bitfield.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/tlv.h
Detected Declarations
struct rt9120_datafunction internal_power_eventfunction rt9120_codec_probefunction rt9120_codec_suspendfunction rt9120_codec_resumefunction rt9120_set_fmtfunction rt9120_hw_paramsfunction rt9120_volatile_regfunction rt9120_get_reg_sizefunction rt9120_reg_readfunction rt9120_reg_writefunction rt9120_check_vendor_infofunction rt9120_do_register_resetfunction rt9120_probefunction rt9120_removefunction rt9120_runtime_suspendfunction rt9120_runtime_resume
Annotated Snippet
struct rt9120_data {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *pwdnn_gpio;
int chip_idx;
};
/* 11bit [min,max,step] = [-103.9375dB, 24dB, 0.0625dB] */
static const DECLARE_TLV_DB_SCALE(digital_tlv, -1039375, 625, 1);
/* {6, 8, 10, 12, 13, 14, 15, 16}dB */
static const DECLARE_TLV_DB_RANGE(classd_tlv,
0, 3, TLV_DB_SCALE_ITEM(600, 200, 0),
4, 7, TLV_DB_SCALE_ITEM(1300, 100, 0)
);
static const char * const sdo_select_text[] = {
"None", "INTF", "Final", "RMS Detect"
};
static const struct soc_enum sdo_select_enum =
SOC_ENUM_SINGLE(RT9120_REG_SDIOSEL, 4, ARRAY_SIZE(sdo_select_text),
sdo_select_text);
static const struct snd_kcontrol_new rt9120_snd_controls[] = {
SOC_SINGLE_TLV("MS Volume", RT9120_REG_MSVOL, 0, 2047, 1, digital_tlv),
SOC_SINGLE_TLV("SPK Gain Volume", RT9120_REG_SPKGAIN, 0, 7, 0, classd_tlv),
SOC_SINGLE("PBTL Switch", RT9120_REG_SYSCTL, 3, 1, 0),
SOC_ENUM("SDO Select", sdo_select_enum),
};
static int internal_power_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
snd_soc_component_write(comp, RT9120_REG_ERRRPT, 0);
break;
case SND_SOC_DAPM_POST_PMU:
msleep(RT9120_AMPON_WAITMS);
break;
case SND_SOC_DAPM_POST_PMD:
msleep(RT9120_AMPOFF_WAITMS);
break;
default:
break;
}
return 0;
}
static const struct snd_soc_dapm_widget rt9120_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("DMIX", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_DAC("LDAC", NULL, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_DAC("RDAC", NULL, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_SUPPLY("PWND", RT9120_REG_SYSCTL, 6, 1,
internal_power_event, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA("SPKL PA", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_PGA("SPKR PA", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_OUTPUT("SPKL"),
SND_SOC_DAPM_OUTPUT("SPKR"),
};
static const struct snd_soc_dapm_route rt9120_dapm_routes[] = {
{ "DMIX", NULL, "AIF Playback" },
/* SPKL */
{ "LDAC", NULL, "PWND" },
{ "LDAC", NULL, "DMIX" },
{ "SPKL PA", NULL, "LDAC" },
{ "SPKL", NULL, "SPKL PA" },
/* SPKR */
{ "RDAC", NULL, "PWND" },
{ "RDAC", NULL, "DMIX" },
{ "SPKR PA", NULL, "RDAC" },
{ "SPKR", NULL, "SPKR PA" },
/* Cap */
{ "AIF Capture", NULL, "LDAC" },
{ "AIF Capture", NULL, "RDAC" },
};
static int rt9120_codec_probe(struct snd_soc_component *comp)
{
struct rt9120_data *data = snd_soc_component_get_drvdata(comp);
snd_soc_component_init_regmap(comp, data->regmap);
pm_runtime_get_sync(comp->dev);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct rt9120_data`, `function internal_power_event`, `function rt9120_codec_probe`, `function rt9120_codec_suspend`, `function rt9120_codec_resume`, `function rt9120_set_fmt`, `function rt9120_hw_params`, `function rt9120_volatile_reg`, `function rt9120_get_reg_size`, `function rt9120_reg_read`.
- 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.