sound/soc/ti/omap-twl4030.c

Source file repositories/reference/linux-study-clean/sound/soc/ti/omap-twl4030.c

File Facts

System
Linux kernel
Corpus path
sound/soc/ti/omap-twl4030.c
Extension
.c
Size
9792 bytes
Lines
340
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

struct omap_twl4030 {
	struct snd_soc_jack hs_jack;
};

static int omap_twl4030_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	unsigned int fmt;

	switch (params_channels(params)) {
	case 2: /* Stereo I2S mode */
		fmt =	SND_SOC_DAIFMT_I2S |
			SND_SOC_DAIFMT_NB_NF |
			SND_SOC_DAIFMT_CBP_CFP;
		break;
	case 4: /* Four channel TDM mode */
		fmt =	SND_SOC_DAIFMT_DSP_A |
			SND_SOC_DAIFMT_IB_NF |
			SND_SOC_DAIFMT_CBP_CFP;
		break;
	default:
		return -EINVAL;
	}

	return snd_soc_runtime_set_dai_fmt(rtd, fmt);
}

static const struct snd_soc_ops omap_twl4030_ops = {
	.hw_params = omap_twl4030_hw_params,
};

static const struct snd_soc_dapm_widget dapm_widgets[] = {
	SND_SOC_DAPM_SPK("Earpiece Spk", NULL),
	SND_SOC_DAPM_SPK("Handsfree Spk", NULL),
	SND_SOC_DAPM_HP("Headset Stereophone", NULL),
	SND_SOC_DAPM_SPK("Ext Spk", NULL),
	SND_SOC_DAPM_SPK("Carkit Spk", NULL),

	SND_SOC_DAPM_MIC("Main Mic", NULL),
	SND_SOC_DAPM_MIC("Sub Mic", NULL),
	SND_SOC_DAPM_MIC("Headset Mic", NULL),
	SND_SOC_DAPM_MIC("Carkit Mic", NULL),
	SND_SOC_DAPM_MIC("Digital0 Mic", NULL),
	SND_SOC_DAPM_MIC("Digital1 Mic", NULL),
	SND_SOC_DAPM_LINE("Line In", NULL),
};

static const struct snd_soc_dapm_route audio_map[] = {
	/* Headset Stereophone:  HSOL, HSOR */
	{"Headset Stereophone", NULL, "HSOL"},
	{"Headset Stereophone", NULL, "HSOR"},
	/* External Speakers: HFL, HFR */
	{"Handsfree Spk", NULL, "HFL"},
	{"Handsfree Spk", NULL, "HFR"},
	/* External Speakers: PredrivL, PredrivR */
	{"Ext Spk", NULL, "PREDRIVEL"},
	{"Ext Spk", NULL, "PREDRIVER"},
	/* Carkit speakers:  CARKITL, CARKITR */
	{"Carkit Spk", NULL, "CARKITL"},
	{"Carkit Spk", NULL, "CARKITR"},
	/* Earpiece */
	{"Earpiece Spk", NULL, "EARPIECE"},

	/* External Mics: MAINMIC, SUBMIC with bias */
	{"MAINMIC", NULL, "Main Mic"},
	{"Main Mic", NULL, "Mic Bias 1"},
	{"SUBMIC", NULL, "Sub Mic"},
	{"Sub Mic", NULL, "Mic Bias 2"},
	/* Headset Mic: HSMIC with bias */
	{"HSMIC", NULL, "Headset Mic"},
	{"Headset Mic", NULL, "Headset Mic Bias"},
	/* Digital Mics: DIGIMIC0, DIGIMIC1 with bias */
	{"DIGIMIC0", NULL, "Digital0 Mic"},
	{"Digital0 Mic", NULL, "Mic Bias 1"},
	{"DIGIMIC1", NULL, "Digital1 Mic"},
	{"Digital1 Mic", NULL, "Mic Bias 2"},
	/* Carkit In: CARKITMIC */
	{"CARKITMIC", NULL, "Carkit Mic"},
	/* Aux In: AUXL, AUXR */
	{"AUXL", NULL, "Line In"},
	{"AUXR", NULL, "Line In"},
};

/* Headset jack detection DAPM pins */
static struct snd_soc_jack_pin hs_jack_pins[] = {
	{
		.pin = "Headset Mic",
		.mask = SND_JACK_MICROPHONE,
	},

Annotation

Implementation Notes