sound/soc/codecs/rt1015.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt1015.c
Extension
.c
Size
30273 bytes
Lines
1191
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (rt1015->bypass_boost == RT1015_Enable_Boost) {
			snd_soc_component_write(component,
				RT1015_SYS_RST1, 0x05f7);
			snd_soc_component_write(component,
				RT1015_SYS_RST2, 0x0b0a);
			snd_soc_component_write(component,
				RT1015_GAT_BOOST, 0xacfe);
			snd_soc_component_write(component,
				RT1015_PWR9, 0xaa00);
			snd_soc_component_write(component,
				RT1015_GAT_BOOST, 0xecfe);
		} else {
			snd_soc_component_write(component,
				0x032d, 0xaa60);
			snd_soc_component_write(component,
				RT1015_SYS_RST1, 0x05f7);
			snd_soc_component_write(component,
				RT1015_SYS_RST2, 0x0b0a);
			snd_soc_component_write(component,
				RT1015_PWR_STATE_CTRL, 0x008e);
		}
		break;

	case SND_SOC_DAPM_POST_PMD:
		if (rt1015->bypass_boost == RT1015_Enable_Boost) {
			snd_soc_component_write(component,
				RT1015_PWR9, 0xa800);
			snd_soc_component_write(component,
				RT1015_SYS_RST1, 0x05f5);
			snd_soc_component_write(component,
				RT1015_SYS_RST2, 0x0b9a);
		} else {
			snd_soc_component_write(component,
				0x032d, 0xaa60);
			snd_soc_component_write(component,
				RT1015_PWR_STATE_CTRL, 0x0088);
			snd_soc_component_write(component,
				RT1015_SYS_RST1, 0x05f5);
			snd_soc_component_write(component,
				RT1015_SYS_RST2, 0x0b9a);
		}
		rt1015->dac_is_used = 0;
		break;

	default:
		break;
	}
	return 0;
}

static int rt1015_amp_drv_event(struct snd_soc_dapm_widget *w,
	struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component =
		snd_soc_dapm_to_component(w->dapm);
	struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component);
	unsigned int ret, ret2;

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		ret = snd_soc_component_read(component, RT1015_CLK_DET);
		ret2 = snd_soc_component_read(component, RT1015_SPK_DC_DETECT1);
		if (!((ret >> 15) & 0x1)) {
			snd_soc_component_update_bits(component, RT1015_CLK_DET,
				RT1015_EN_BCLK_DET_MASK, RT1015_EN_BCLK_DET);
			dev_dbg(component->dev, "BCLK Detection Enabled.\n");
		}
		if (!((ret2 >> 12) & 0x1)) {
			snd_soc_component_update_bits(component, RT1015_SPK_DC_DETECT1,
				RT1015_EN_CLA_D_DC_DET_MASK, RT1015_EN_CLA_D_DC_DET);
			dev_dbg(component->dev, "Class-D DC Detection Enabled.\n");
		}
		break;
	case SND_SOC_DAPM_POST_PMU:
		msleep(rt1015->pdata.power_up_delay_ms);
		break;
	default:
		break;
	}
	return 0;
}

static const struct snd_soc_dapm_widget rt1015_dapm_widgets[] = {
	SND_SOC_DAPM_SUPPLY("PLL", RT1015_PWR1, RT1015_PWR_PLL_BIT, 0,
		NULL, 0),
	SND_SOC_DAPM_AIF_IN("AIFRX", "AIF Playback", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0,
		r1015_dac_event, SND_SOC_DAPM_PRE_PMU |
		SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_OUT_DRV_E("Amp Drv", SND_SOC_NOPM, 0, 0, NULL, 0,

Annotation

Implementation Notes