sound/soc/codecs/wm2000.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wm2000.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wm2000.c- Extension
.c- Size
- 23189 bytes
- Lines
- 950
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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.hlinux/moduleparam.hlinux/kernel.hlinux/init.hlinux/firmware.hlinux/clk.hlinux/delay.hlinux/pm.hlinux/i2c.hlinux/regmap.hlinux/debugfs.hlinux/regulator/consumer.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/initval.hsound/tlv.hsound/wm2000.hwm2000.h
Detected Declarations
struct wm2000_privenum wm2000_anc_modefunction wm2000_writefunction wm2000_resetfunction wm2000_poll_bitfunction wm2000_power_upfunction wm2000_power_downfunction wm2000_enter_bypassfunction wm2000_exit_bypassfunction wm2000_enter_standbyfunction wm2000_exit_standbyfunction wm2000_anc_transitionfunction wm2000_anc_set_modefunction wm2000_anc_mode_getfunction wm2000_anc_mode_putfunction wm2000_speaker_getfunction wm2000_speaker_putfunction wm2000_anc_power_eventfunction wm2000_suspendfunction wm2000_resumefunction wm2000_readable_regfunction wm2000_probefunction wm2000_removefunction wm2000_i2c_probe
Annotated Snippet
struct wm2000_priv {
struct i2c_client *i2c;
struct regmap *regmap;
struct clk *mclk;
struct regulator_bulk_data supplies[WM2000_NUM_SUPPLIES];
enum wm2000_anc_mode anc_mode;
unsigned int anc_active:1;
unsigned int anc_eng_ena:1;
unsigned int spk_ena:1;
unsigned int speech_clarity:1;
int anc_download_size;
char *anc_download;
struct mutex lock;
};
static int wm2000_write(struct i2c_client *i2c, unsigned int reg,
unsigned int value)
{
struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c);
return regmap_write(wm2000->regmap, reg, value);
}
static void wm2000_reset(struct wm2000_priv *wm2000)
{
struct i2c_client *i2c = wm2000->i2c;
wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_CLR);
wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_CLR);
wm2000_write(i2c, WM2000_REG_ID1, 0);
wm2000->anc_mode = ANC_OFF;
}
static int wm2000_poll_bit(struct i2c_client *i2c,
unsigned int reg, u8 mask)
{
struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c);
int timeout = 4000;
unsigned int val;
regmap_read(wm2000->regmap, reg, &val);
while (!(val & mask) && --timeout) {
msleep(1);
regmap_read(wm2000->regmap, reg, &val);
}
if (timeout == 0)
return 0;
else
return 1;
}
static int wm2000_power_up(struct i2c_client *i2c, int analogue)
{
struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);
unsigned long rate;
unsigned int val;
int ret;
if (WARN_ON(wm2000->anc_mode != ANC_OFF))
return -EINVAL;
dev_dbg(&i2c->dev, "Beginning power up\n");
ret = regulator_bulk_enable(WM2000_NUM_SUPPLIES, wm2000->supplies);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
return ret;
}
rate = clk_get_rate(wm2000->mclk);
if (rate <= 13500000) {
dev_dbg(&i2c->dev, "Disabling MCLK divider\n");
wm2000_write(i2c, WM2000_REG_SYS_CTL2,
WM2000_MCLK_DIV2_ENA_CLR);
} else {
dev_dbg(&i2c->dev, "Enabling MCLK divider\n");
wm2000_write(i2c, WM2000_REG_SYS_CTL2,
WM2000_MCLK_DIV2_ENA_SET);
}
wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_CLR);
wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_SET);
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/init.h`, `linux/firmware.h`, `linux/clk.h`, `linux/delay.h`, `linux/pm.h`.
- Detected declarations: `struct wm2000_priv`, `enum wm2000_anc_mode`, `function wm2000_write`, `function wm2000_reset`, `function wm2000_poll_bit`, `function wm2000_power_up`, `function wm2000_power_down`, `function wm2000_enter_bypass`, `function wm2000_exit_bypass`, `function wm2000_enter_standby`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.