sound/soc/codecs/wsa881x.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wsa881x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wsa881x.c- Extension
.c- Size
- 40063 bytes
- Lines
- 1210
- 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/bitops.hlinux/gpio/consumer.hlinux/module.hlinux/regmap.hlinux/slab.hlinux/pm_runtime.hlinux/soundwire/sdw.hlinux/soundwire/sdw_registers.hlinux/soundwire/sdw_type.hsound/soc.hsound/tlv.h
Detected Declarations
struct wsa881x_privenum wsa_port_idsfunction wsa881x_readable_registerfunction wsa881x_volatile_registerfunction wsa881x_initfunction wsa881x_component_probefunction wsa881x_put_pa_gainfunction wsa881x_get_portfunction wsa881x_boost_ctrlfunction wsa881x_set_portfunction wsa881x_visense_txfe_ctrlfunction wsa881x_visense_adc_ctrlfunction wsa881x_spkr_pa_eventfunction wsa881x_hw_paramsfunction wsa881x_hw_freefunction wsa881x_set_sdw_streamfunction wsa881x_digital_mutefunction wsa881x_update_statusfunction wsa881x_port_prepfunction wsa881x_bus_configfunction wsa881x_probefunction wsa881x_runtime_suspendfunction wsa881x_runtime_resume
Annotated Snippet
struct wsa881x_priv {
struct regmap *regmap;
struct device *dev;
struct sdw_slave *slave;
struct sdw_stream_config sconfig;
struct sdw_stream_runtime *sruntime;
struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS];
struct gpio_desc *sd_n;
int active_ports;
bool hw_init;
bool port_prepared[WSA881X_MAX_SWR_PORTS];
bool port_enable[WSA881X_MAX_SWR_PORTS];
};
static void wsa881x_init(struct wsa881x_priv *wsa881x)
{
struct regmap *rm = wsa881x->regmap;
unsigned int val = 0;
if (wsa881x->hw_init)
return;
regmap_register_patch(wsa881x->regmap, wsa881x_rev_2_0,
ARRAY_SIZE(wsa881x_rev_2_0));
/* Enable software reset output from soundwire slave */
regmap_update_bits(rm, WSA881X_SWR_RESET_EN, 0x07, 0x07);
/* Bring out of analog reset */
regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x02, 0x02);
/* Bring out of digital reset */
regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x01, 0x01);
regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, 0x10, 0x10);
regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x02, 0x02);
regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80);
regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06);
regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00);
regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0xF0, 0x40);
regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0x0E, 0x0E);
regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, 0x03, 0x03);
regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14);
regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x80, 0x80);
regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x03, 0x00);
regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x0C, 0x04);
regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x03, 0x00);
regmap_read(rm, WSA881X_OTP_REG_0, &val);
if (val)
regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT1, 0xF0, 0x70);
regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, 0xF0, 0x30);
regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, 0x08, 0x08);
regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, 0x0F, 0x08);
regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x30, 0x30);
regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00);
regmap_update_bits(rm, WSA881X_OTP_REG_28, 0x3F, 0x3A);
regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, 0xFF, 0xB2);
regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, 0xFF, 0x05);
wsa881x->hw_init = true;
}
static int wsa881x_component_probe(struct snd_soc_component *comp)
{
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp);
snd_soc_component_init_regmap(comp, wsa881x->regmap);
return 0;
}
static int wsa881x_put_pa_gain(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *comp = snd_kcontrol_chip(kc);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kc->private_value;
int max = mc->max;
unsigned int mask = (1 << fls(max)) - 1;
int val, ret, min_gain, max_gain;
ret = pm_runtime_resume_and_get(comp->dev);
if (ret < 0 && ret != -EACCES)
return ret;
max_gain = (max - ucontrol->value.integer.value[0]) & mask;
/*
* Gain has to set incrementally in 4 steps
* as per HW sequence
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/regmap.h`, `linux/slab.h`, `linux/pm_runtime.h`, `linux/soundwire/sdw.h`, `linux/soundwire/sdw_registers.h`.
- Detected declarations: `struct wsa881x_priv`, `enum wsa_port_ids`, `function wsa881x_readable_register`, `function wsa881x_volatile_register`, `function wsa881x_init`, `function wsa881x_component_probe`, `function wsa881x_put_pa_gain`, `function wsa881x_get_port`, `function wsa881x_boost_ctrl`, `function wsa881x_set_port`.
- 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.