sound/soc/codecs/wcd939x.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wcd939x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wcd939x.c- Extension
.c- Size
- 118328 bytes
- Lines
- 3618
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/slab.hlinux/platform_device.hlinux/device.hlinux/delay.hlinux/gpio/consumer.hlinux/kernel.hlinux/pm_runtime.hlinux/component.hsound/tlv.hlinux/of_graph.hlinux/of.hsound/jack.hsound/pcm.hsound/pcm_params.hlinux/regmap.hsound/soc.hsound/soc-dapm.hlinux/regulator/consumer.hlinux/usb/typec_mux.hlinux/usb/typec_altmode.hwcd-clsh-v2.hwcd-common.hwcd-mbhc-v2.hwcd939x.h
Detected Declarations
struct zdet_paramstruct wcd939x_privfunction wcd939x_get_clk_ratefunction wcd939x_set_swr_clk_ratefunction wcd939x_io_initfunction wcd939x_sdw_connect_portfunction wcd939x_connect_portfunction wcd939x_codec_enable_rxclkfunction wcd939x_codec_hphl_dac_eventfunction wcd939x_codec_hphr_dac_eventfunction wcd939x_codec_ear_dac_eventfunction wcd939x_codec_enable_hphr_pafunction wcd939x_codec_enable_hphl_pafunction wcd939x_codec_enable_ear_pafunction wcd939x_codec_enable_dmicfunction wcd939x_tx_swr_ctrlfunction wcd939x_get_adc_modefunction wcd939x_codec_enable_adcfunction wcd939x_tx_channel_configfunction wcd939x_adc_enable_reqfunction wcd939x_micbias_controlfunction wcd939x_codec_enable_micbiasfunction wcd939x_codec_enable_micbias_pullupfunction wcd939x_tx_mode_getfunction wcd939x_tx_mode_putfunction wcd939x_rx_hph_mode_getfunction wcd939x_rx_hph_mode_putfunction wcd939x_get_companderfunction wcd939x_set_companderfunction wcd939x_ldoh_getfunction wcd939x_ldoh_putfunction wcd939x_get_swr_portfunction wcd939x_set_swr_portfunction wcd939x_mbhc_clk_setupfunction wcd939x_mbhc_mbhc_bias_controlfunction wcd939x_mbhc_program_btn_thrfunction wcd939x_mbhc_micb_en_statusfunction wcd939x_mbhc_hph_l_pull_up_controlfunction wcd939x_mbhc_request_micbiasfunction wcd939x_mbhc_micb_ramp_controlfunction wcd939x_mbhc_micb_adjust_voltagefunction wcd939x_mbhc_micb_ctrl_threshold_micfunction wcd939x_mbhc_get_result_paramsfunction wcd939x_mbhc_zdet_rampfunction wcd939x_wcd_mbhc_qfuse_calfunction wcd939x_wcd_mbhc_calc_impedancefunction wcd939x_mbhc_gnd_det_ctrlfunction wcd939x_mbhc_hph_pull_down_ctrl
Annotated Snippet
struct zdet_param {
u16 ldo_ctl;
u16 noff;
u16 nshift;
u16 btn5;
u16 btn6;
u16 btn7;
};
struct wcd939x_priv {
struct sdw_slave *tx_sdw_dev;
struct wcd939x_sdw_priv *sdw_priv[NUM_CODEC_DAIS];
struct device *txdev;
struct device *rxdev;
struct device_node *rxnode, *txnode;
struct regmap *regmap;
struct snd_soc_component *component;
/* micb setup lock */
struct mutex micb_lock;
/* typec handling */
bool typec_analog_mux;
#if IS_ENABLED(CONFIG_TYPEC)
enum typec_orientation typec_orientation;
unsigned long typec_mode;
struct typec_switch *typec_switch;
#endif /* CONFIG_TYPEC */
/* mbhc module */
struct wcd_mbhc *wcd_mbhc;
struct wcd_mbhc_config mbhc_cfg;
struct wcd_mbhc_intr intr_ids;
struct wcd_clsh_ctrl *clsh_info;
struct wcd_common common;
struct irq_domain *virq;
struct regmap_irq_chip_data *irq_chip;
struct snd_soc_jack *jack;
unsigned long status_mask;
s32 micb_ref[WCD939X_MAX_MICBIAS];
s32 pullup_ref[WCD939X_MAX_MICBIAS];
u32 hph_mode;
u32 tx_mode[TX_ADC_MAX];
int variant;
struct gpio_desc *reset_gpio;
int hphr_pdm_wd_int;
int hphl_pdm_wd_int;
int ear_pdm_wd_int;
bool comp1_enable;
bool comp2_enable;
bool ldoh;
};
static const char * const wcd939x_supplies[] = {
"vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", "vdd-px",
};
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
static const struct wcd_mbhc_field wcd_mbhc_fields[WCD_MBHC_REG_FUNC_MAX] = {
WCD_MBHC_FIELD(WCD_MBHC_L_DET_EN, WCD939X_ANA_MBHC_MECH, 0x80),
WCD_MBHC_FIELD(WCD_MBHC_GND_DET_EN, WCD939X_ANA_MBHC_MECH, 0x40),
WCD_MBHC_FIELD(WCD_MBHC_MECH_DETECTION_TYPE, WCD939X_ANA_MBHC_MECH, 0x20),
WCD_MBHC_FIELD(WCD_MBHC_MIC_CLAMP_CTL, WCD939X_MBHC_NEW_PLUG_DETECT_CTL, 0x30),
WCD_MBHC_FIELD(WCD_MBHC_ELECT_DETECTION_TYPE, WCD939X_ANA_MBHC_ELECT, 0x08),
WCD_MBHC_FIELD(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, WCD939X_MBHC_NEW_INT_MECH_DET_CURRENT, 0x1F),
WCD_MBHC_FIELD(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, WCD939X_ANA_MBHC_MECH, 0x04),
WCD_MBHC_FIELD(WCD_MBHC_HPHL_PLUG_TYPE, WCD939X_ANA_MBHC_MECH, 0x10),
WCD_MBHC_FIELD(WCD_MBHC_GND_PLUG_TYPE, WCD939X_ANA_MBHC_MECH, 0x08),
WCD_MBHC_FIELD(WCD_MBHC_SW_HPH_LP_100K_TO_GND, WCD939X_ANA_MBHC_MECH, 0x01),
WCD_MBHC_FIELD(WCD_MBHC_ELECT_SCHMT_ISRC, WCD939X_ANA_MBHC_ELECT, 0x06),
WCD_MBHC_FIELD(WCD_MBHC_FSM_EN, WCD939X_ANA_MBHC_ELECT, 0x80),
WCD_MBHC_FIELD(WCD_MBHC_INSREM_DBNC, WCD939X_MBHC_NEW_PLUG_DETECT_CTL, 0x0F),
WCD_MBHC_FIELD(WCD_MBHC_BTN_DBNC, WCD939X_MBHC_NEW_CTL_1, 0x03),
WCD_MBHC_FIELD(WCD_MBHC_HS_VREF, WCD939X_MBHC_NEW_CTL_2, 0x03),
WCD_MBHC_FIELD(WCD_MBHC_HS_COMP_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0x08),
WCD_MBHC_FIELD(WCD_MBHC_IN2P_CLAMP_STATE, WCD939X_ANA_MBHC_RESULT_3, 0x10),
WCD_MBHC_FIELD(WCD_MBHC_MIC_SCHMT_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0x20),
WCD_MBHC_FIELD(WCD_MBHC_HPHL_SCHMT_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0x80),
WCD_MBHC_FIELD(WCD_MBHC_HPHR_SCHMT_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0x40),
WCD_MBHC_FIELD(WCD_MBHC_OCP_FSM_EN, WCD939X_HPH_OCP_CTL, 0x10),
WCD_MBHC_FIELD(WCD_MBHC_BTN_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0x07),
WCD_MBHC_FIELD(WCD_MBHC_BTN_ISRC_CTL, WCD939X_ANA_MBHC_ELECT, 0x70),
WCD_MBHC_FIELD(WCD_MBHC_ELECT_RESULT, WCD939X_ANA_MBHC_RESULT_3, 0xFF),
WCD_MBHC_FIELD(WCD_MBHC_MICB_CTRL, WCD939X_ANA_MICB2, 0xC0),
WCD_MBHC_FIELD(WCD_MBHC_HPH_CNP_WG_TIME, WCD939X_HPH_CNP_WG_TIME, 0xFF),
WCD_MBHC_FIELD(WCD_MBHC_HPHR_PA_EN, WCD939X_ANA_HPH, 0x40),
WCD_MBHC_FIELD(WCD_MBHC_HPHL_PA_EN, WCD939X_ANA_HPH, 0x80),
WCD_MBHC_FIELD(WCD_MBHC_HPH_PA_EN, WCD939X_ANA_HPH, 0xC0),
WCD_MBHC_FIELD(WCD_MBHC_SWCH_LEVEL_REMOVE, WCD939X_ANA_MBHC_RESULT_3, 0x10),
WCD_MBHC_FIELD(WCD_MBHC_ANC_DET_EN, WCD939X_MBHC_CTL_BCS, 0x02),
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/platform_device.h`, `linux/device.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/kernel.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct zdet_param`, `struct wcd939x_priv`, `function wcd939x_get_clk_rate`, `function wcd939x_set_swr_clk_rate`, `function wcd939x_io_init`, `function wcd939x_sdw_connect_port`, `function wcd939x_connect_port`, `function wcd939x_codec_enable_rxclk`, `function wcd939x_codec_hphl_dac_event`, `function wcd939x_codec_hphr_dac_event`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.