sound/soc/codecs/rtq9124.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rtq9124.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rtq9124.c- Extension
.c- Size
- 15768 bytes
- Lines
- 544
- 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/bitfield.hlinux/bits.hlinux/byteorder/generic.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dai.hsound/soc-dapm.hsound/tlv.h
Detected Declarations
struct rtq9124_privfunction rtq9124_enable_eventfunction rtq9124_comp_probefunction rtq9124_dai_set_formatfunction rtq9124_dai_set_tdm_slotfunction rtq9124_dai_hw_paramsfunction rtq9124_readable_regfunction rtq9124_writeable_regfunction rtq9124_volatile_regfunction rtq9124_get_reg_lenfunction rtq9124_regmap_readfunction rtq9124_regmap_writefunction rtq9124_probefunction rtq9124_runtime_suspendfunction rtq9124_runtime_resume
Annotated Snippet
struct rtq9124_priv {
struct gpio_desc *enable;
unsigned int dai_fmt;
int tdm_slots;
int tdm_slot_width;
};
static int rtq9124_enable_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);
unsigned int i, chan_state;
switch (event) {
case SND_SOC_DAPM_POST_PMU:
/* Change state to normal */
chan_state = 0;
break;
case SND_SOC_DAPM_POST_PMD:
/* Change state to HiZ */
chan_state = 1;
break;
default:
return -EINVAL;
}
/* Before amp turn on, clear old events first */
for (i = 0; !chan_state && i < 8; i++)
snd_soc_component_write(comp, RTQ9124_REG_ERR_INT_0 + i, 0xffff);
snd_soc_component_write_field(comp, RTQ9124_REG_STATE_CTRL, RTQ9124_MASK_CH_STATE,
chan_state);
return 0;
}
static const struct snd_soc_dapm_widget rtq9124_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("SPK"),
SND_SOC_DAPM_OUT_DRV_E("Amp Drv", SND_SOC_NOPM, 0, 0, NULL, 0, rtq9124_enable_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
};
static const struct snd_soc_dapm_route rtq9124_dapm_routes[] = {
{ "Amp Drv", NULL, "HiFi Playback" },
{ "SPK", NULL, "Amp Drv" },
};
static const DECLARE_TLV_DB_SCALE(dig_tlv, -10375, 25, 0);
static const DECLARE_TLV_DB_RANGE(ana_tlv,
0, 3, TLV_DB_SCALE_ITEM(-600, 600, 0),
4, 6, TLV_DB_SCALE_ITEM(1400, 200, 0));
static const char * const i2sch_text[] = { "(L+R)/2", "LCH", "RCH", "(L+R)/2" };
static const struct soc_enum rtq9124_i2sch_select_enum =
SOC_ENUM_SINGLE(RTQ9124_REG_SDI_SEL, 0, ARRAY_SIZE(i2sch_text), i2sch_text);
static const char * const sdo_vsel_text[] = { "1.8V", "3.3V" };
static const struct soc_enum rtq9124_sdo_vselect_enum =
SOC_ENUM_SINGLE(RTQ9124_REG_SDO_SEL, 8, ARRAY_SIZE(sdo_vsel_text), sdo_vsel_text);
static const char * const pwmfreq_text[] = { "8*fs", "10*fs", "40*fs", "44*fs", "48*fs" };
static const struct soc_enum rtq9124_pwm_freq_enum =
SOC_ENUM_SINGLE(RTQ9124_REG_AMP_OPT, 4, ARRAY_SIZE(pwmfreq_text), pwmfreq_text);
static const char * const out_angle_text[] = { "0", "45", "90", "135", "180", "225", "270", "315" };
static const struct soc_enum rtq9124_out_angle_enum =
SOC_ENUM_SINGLE(RTQ9124_REG_PWM_PHASE, 0, ARRAY_SIZE(out_angle_text), out_angle_text);
static const char * const sdo_select_text[] = {
"None", "I2S DataI", "Interface", "DSP", "DF", "ISense", "ACLoad Cos", "ACLoad Sin",
"DCR",
};
static const struct soc_enum rtq9124_sdo_select_enum =
SOC_ENUM_DOUBLE(RTQ9124_REG_SDO_SEL, 4, 0, ARRAY_SIZE(sdo_select_text), sdo_select_text);
static const char * const ulqm_dcvt_text[] = { "Disable", "DC", "VT", "DC+VT" };
static const struct soc_enum rtq9124_ulqm_dcvt_select_enum =
SOC_ENUM_SINGLE(RTQ9124_REG_STATE_CTRL, 10, ARRAY_SIZE(ulqm_dcvt_text), ulqm_dcvt_text);
static const struct snd_kcontrol_new rtq9124_controls[] = {
SOC_SINGLE_TLV("Master Volume", RTQ9124_REG_VOL_OPT, 2, 511, 1, dig_tlv),
SOC_SINGLE_TLV("Speaker Volume", RTQ9124_REG_AMP_OPT, 0, 6, 0, ana_tlv),
SOC_ENUM("I2S CH Select", rtq9124_i2sch_select_enum),
SOC_ENUM("SDO VDDIO Select", rtq9124_sdo_vselect_enum),
SOC_ENUM("PWM Frequency Select", rtq9124_pwm_freq_enum),
SOC_ENUM("PWM Output Phase Select", rtq9124_out_angle_enum),
SOC_ENUM("SDO Select", rtq9124_sdo_select_enum),
SOC_ENUM("ULQM DCVT Select", rtq9124_ulqm_dcvt_select_enum),
SOC_SINGLE("Silence Detect Enable Switch", RTQ9124_REG_SIL_CTRL, 7, 1, 0),
SOC_SINGLE("Spread Spectrum Enable Switch", RTQ9124_REG_PWM_SS_OPT, 7, 1, 0),
};
static int rtq9124_comp_probe(struct snd_soc_component *comp)
{
/* CS Data INV */
snd_soc_component_write_field(comp, RTQ9124_REG_SDO_SEL, RTQ9124_MASK_CS_DATA_INV, 1);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/byteorder/generic.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`.
- Detected declarations: `struct rtq9124_priv`, `function rtq9124_enable_event`, `function rtq9124_comp_probe`, `function rtq9124_dai_set_format`, `function rtq9124_dai_set_tdm_slot`, `function rtq9124_dai_hw_params`, `function rtq9124_readable_reg`, `function rtq9124_writeable_reg`, `function rtq9124_volatile_reg`, `function rtq9124_get_reg_len`.
- 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.