sound/soc/codecs/rt5682.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5682.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt5682.c
Extension
.c
Size
92382 bytes
Lines
3186
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

while (val == 0 && count < 50) {
			usleep_range(10000, 15000);
			val = snd_soc_component_read(component,
				RT5682_CBJ_CTRL_2) & RT5682_JACK_TYPE_MASK;
			count++;
		}

		switch (val) {
		case 0x1:
		case 0x2:
			rt5682->jack_type = SND_JACK_HEADSET;
			snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
				RT5682_FAST_OFF_MASK, RT5682_FAST_OFF_EN);
			rt5682_enable_push_button_irq(component, true);
			break;
		default:
			rt5682->jack_type = SND_JACK_HEADPHONE;
			break;
		}

		snd_soc_component_update_bits(component,
			RT5682_HP_CHARGE_PUMP_1,
			RT5682_OSW_L_MASK | RT5682_OSW_R_MASK,
			RT5682_OSW_L_EN | RT5682_OSW_R_EN);
		snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
			RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
			RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
	} else {
		rt5682_enable_push_button_irq(component, false);
		snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
			RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
		if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS") &&
			!snd_soc_dapm_get_pin_status(dapm, "PLL1") &&
			!snd_soc_dapm_get_pin_status(dapm, "PLL2B"))
			snd_soc_component_update_bits(component,
				RT5682_PWR_ANLG_1, RT5682_PWR_MB, 0);
		if (!snd_soc_dapm_get_pin_status(dapm, "Vref2") &&
			!snd_soc_dapm_get_pin_status(dapm, "PLL1") &&
			!snd_soc_dapm_get_pin_status(dapm, "PLL2B"))
			snd_soc_component_update_bits(component,
				RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
		snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
			RT5682_PWR_CBJ, 0);
		snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
			RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
			RT5682_PWR_CLK25M_PD | RT5682_PWR_CLK1M_PD);
		snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
			RT5682_FAST_OFF_MASK, RT5682_FAST_OFF_DIS);

		rt5682->jack_type = 0;
	}

	dev_dbg(component->dev, "jack_type = %d\n", rt5682->jack_type);
	return rt5682->jack_type;
}

static int rt5682_set_jack_detect(struct snd_soc_component *component,
		struct snd_soc_jack *hs_jack, void *data)
{
	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);

	rt5682->hs_jack = hs_jack;

	if (rt5682->is_sdw && !rt5682->first_hw_init)
		return 0;

	if (!hs_jack) {
		regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
			RT5682_JD1_EN_MASK, RT5682_JD1_DIS);
		regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL,
			RT5682_POW_JDH | RT5682_POW_JDL, 0);
		cancel_delayed_work_sync(&rt5682->jack_detect_work);

		return 0;
	}

	if (!rt5682->is_sdw) {
		switch (rt5682->pdata.jd_src) {
		case RT5682_JD1:
			snd_soc_component_update_bits(component,
				RT5682_CBJ_CTRL_5, 0x0700, 0x0600);
			snd_soc_component_update_bits(component,
				RT5682_CBJ_CTRL_2, RT5682_EXT_JD_SRC,
				RT5682_EXT_JD_SRC_MANUAL);
			snd_soc_component_write(component, RT5682_CBJ_CTRL_1,
				0xd142);
			snd_soc_component_update_bits(component,
				RT5682_CBJ_CTRL_3, RT5682_CBJ_IN_BUF_EN,
				RT5682_CBJ_IN_BUF_EN);
			snd_soc_component_update_bits(component,

Annotation

Implementation Notes