sound/soc/intel/avs/boards/es8336.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/boards/es8336.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/avs/boards/es8336.c
Extension
.c
Size
9430 bytes
Lines
332
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 avs_card_drvdata {
	struct snd_soc_jack jack;
	struct gpio_desc *gpiod;
};

static const struct acpi_gpio_params enable_gpio = { 0, 0, true };

static const struct acpi_gpio_mapping speaker_gpios[] = {
	{ "speaker-enable-gpios", &enable_gpio, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
	{ }
};

static int avs_es8336_speaker_power_event(struct snd_soc_dapm_widget *w,
					  struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_card *card = snd_soc_dapm_to_card(w->dapm);
	struct avs_card_drvdata *data;
	bool speaker_en;

	data = snd_soc_card_get_drvdata(card);
	/* As enable_gpio has active_low=true, logic is inverted. */
	speaker_en = !SND_SOC_DAPM_EVENT_ON(event);

	gpiod_set_value_cansleep(data->gpiod, speaker_en);
	return 0;
}

static const struct snd_soc_dapm_widget card_widgets[] = {
	SND_SOC_DAPM_SPK("Speaker", NULL),
	SND_SOC_DAPM_HP("Headphone", NULL),
	SND_SOC_DAPM_MIC("Headset Mic", NULL),
	SND_SOC_DAPM_MIC("Internal Mic", NULL),

	SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
			    avs_es8336_speaker_power_event,
			    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
};

static const struct snd_soc_dapm_route card_routes[] = {
	{"Headphone", NULL, "HPOL"},
	{"Headphone", NULL, "HPOR"},

	/*
	 * There is no separate speaker output instead the speakers are muxed to
	 * the HP outputs. The mux is controlled by the "Speaker Power" widget.
	 */
	{"Speaker", NULL, "HPOL"},
	{"Speaker", NULL, "HPOR"},
	{"Speaker", NULL, "Speaker Power"},

	/* Mic route map */
	{"MIC1", NULL, "Internal Mic"},
	{"MIC2", NULL, "Headset Mic"},
};

static const struct snd_kcontrol_new card_controls[] = {
	SOC_DAPM_PIN_SWITCH("Speaker"),
	SOC_DAPM_PIN_SWITCH("Headphone"),
	SOC_DAPM_PIN_SWITCH("Headset Mic"),
	SOC_DAPM_PIN_SWITCH("Internal Mic"),
};

static const struct snd_soc_jack_pin card_headset_pins[] = {
	{
		.pin = "Headphone",
		.mask = SND_JACK_HEADPHONE,
	},
	{
		.pin = "Headset Mic",
		.mask = SND_JACK_MICROPHONE,
	},
};

static int avs_es8336_codec_init(struct snd_soc_pcm_runtime *runtime)
{
	struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(runtime, 0);
	struct snd_soc_component *component = codec_dai->component;
	struct snd_soc_card *card = runtime->card;
	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
	struct snd_soc_jack_pin *pins;
	struct avs_card_drvdata *data;
	struct gpio_desc *gpiod;
	int num_pins, ret;

	data = snd_soc_card_get_drvdata(card);
	num_pins = ARRAY_SIZE(card_headset_pins);

	pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
				  sizeof(card_headset_pins[0]), GFP_KERNEL);
	if (!pins)

Annotation

Implementation Notes