sound/soc/codecs/wm8770.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wm8770.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wm8770.c- Extension
.c- Size
- 19503 bytes
- Lines
- 702
- 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/mod_devicetable.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/delay.hlinux/pm.hlinux/spi/spi.hlinux/regmap.hlinux/regulator/consumer.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/initval.hsound/tlv.hwm8770.h
Detected Declarations
struct wm8770_privfunction wm8770_volatile_regfunction vout12supply_eventfunction vout34supply_eventfunction wm8770_resetfunction wm8770_set_fmtfunction wm8770_hw_paramsfunction wm8770_mutefunction wm8770_set_sysclkfunction wm8770_set_bias_levelfunction wm8770_probefunction wm8770_spi_probe
Annotated Snippet
struct wm8770_priv {
struct regmap *regmap;
struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES];
struct notifier_block disable_nb[WM8770_NUM_SUPPLIES];
struct snd_soc_component *component;
int sysclk;
};
static int vout12supply_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event);
static int vout34supply_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event);
/*
* We can't use the same notifier block for more than one supply and
* there's no way I can see to get from a callback to the caller
* except container_of().
*/
#define WM8770_REGULATOR_EVENT(n) \
static int wm8770_regulator_event_##n(struct notifier_block *nb, \
unsigned long event, void *data) \
{ \
struct wm8770_priv *wm8770 = container_of(nb, struct wm8770_priv, \
disable_nb[n]); \
if (event & REGULATOR_EVENT_DISABLE) { \
regcache_mark_dirty(wm8770->regmap); \
} \
return 0; \
}
WM8770_REGULATOR_EVENT(0)
WM8770_REGULATOR_EVENT(1)
WM8770_REGULATOR_EVENT(2)
static const DECLARE_TLV_DB_SCALE(adc_tlv, -1200, 100, 0);
static const DECLARE_TLV_DB_SCALE(dac_dig_tlv, -12750, 50, 1);
static const DECLARE_TLV_DB_SCALE(dac_alg_tlv, -12700, 100, 1);
static const char *dac_phase_text[][2] = {
{ "DAC1 Normal", "DAC1 Inverted" },
{ "DAC2 Normal", "DAC2 Inverted" },
{ "DAC3 Normal", "DAC3 Inverted" },
{ "DAC4 Normal", "DAC4 Inverted" },
};
static const struct soc_enum dac_phase[] = {
SOC_ENUM_DOUBLE(WM8770_DACPHASE, 0, 1, 2, dac_phase_text[0]),
SOC_ENUM_DOUBLE(WM8770_DACPHASE, 2, 3, 2, dac_phase_text[1]),
SOC_ENUM_DOUBLE(WM8770_DACPHASE, 4, 5, 2, dac_phase_text[2]),
SOC_ENUM_DOUBLE(WM8770_DACPHASE, 6, 7, 2, dac_phase_text[3]),
};
static const struct snd_kcontrol_new wm8770_snd_controls[] = {
/* global DAC playback controls */
SOC_SINGLE_TLV("DAC Playback Volume", WM8770_MSDIGVOL, 0, 255, 0,
dac_dig_tlv),
SOC_SINGLE("DAC Playback Switch", WM8770_DACMUTE, 4, 1, 1),
SOC_SINGLE("DAC Playback ZC Switch", WM8770_DACCTRL1, 0, 1, 0),
/* global VOUT playback controls */
SOC_SINGLE_TLV("VOUT Playback Volume", WM8770_MSALGVOL, 0, 127, 0,
dac_alg_tlv),
SOC_SINGLE("VOUT Playback ZC Switch", WM8770_MSALGVOL, 7, 1, 0),
/* VOUT1/2/3/4 specific controls */
SOC_DOUBLE_R_TLV("VOUT1 Playback Volume", WM8770_VOUT1LVOL,
WM8770_VOUT1RVOL, 0, 127, 0, dac_alg_tlv),
SOC_DOUBLE_R("VOUT1 Playback ZC Switch", WM8770_VOUT1LVOL,
WM8770_VOUT1RVOL, 7, 1, 0),
SOC_DOUBLE_R_TLV("VOUT2 Playback Volume", WM8770_VOUT2LVOL,
WM8770_VOUT2RVOL, 0, 127, 0, dac_alg_tlv),
SOC_DOUBLE_R("VOUT2 Playback ZC Switch", WM8770_VOUT2LVOL,
WM8770_VOUT2RVOL, 7, 1, 0),
SOC_DOUBLE_R_TLV("VOUT3 Playback Volume", WM8770_VOUT3LVOL,
WM8770_VOUT3RVOL, 0, 127, 0, dac_alg_tlv),
SOC_DOUBLE_R("VOUT3 Playback ZC Switch", WM8770_VOUT3LVOL,
WM8770_VOUT3RVOL, 7, 1, 0),
SOC_DOUBLE_R_TLV("VOUT4 Playback Volume", WM8770_VOUT4LVOL,
WM8770_VOUT4RVOL, 0, 127, 0, dac_alg_tlv),
SOC_DOUBLE_R("VOUT4 Playback ZC Switch", WM8770_VOUT4LVOL,
WM8770_VOUT4RVOL, 7, 1, 0),
/* DAC1/2/3/4 specific controls */
SOC_DOUBLE_R_TLV("DAC1 Playback Volume", WM8770_DAC1LVOL,
WM8770_DAC1RVOL, 0, 255, 0, dac_dig_tlv),
SOC_SINGLE("DAC1 Deemphasis Switch", WM8770_DACCTRL2, 0, 1, 0),
SOC_ENUM("DAC1 Phase", dac_phase[0]),
SOC_DOUBLE_R_TLV("DAC2 Playback Volume", WM8770_DAC2LVOL,
WM8770_DAC2RVOL, 0, 255, 0, dac_dig_tlv),
SOC_SINGLE("DAC2 Deemphasis Switch", WM8770_DACCTRL2, 1, 1, 0),
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/spi/spi.h`, `linux/regmap.h`.
- Detected declarations: `struct wm8770_priv`, `function wm8770_volatile_reg`, `function vout12supply_event`, `function vout34supply_event`, `function wm8770_reset`, `function wm8770_set_fmt`, `function wm8770_hw_params`, `function wm8770_mute`, `function wm8770_set_sysclk`, `function wm8770_set_bias_level`.
- 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.