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.
- 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.
- 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/device.hlinux/gpio/consumer.hlinux/input.hlinux/module.hlinux/platform_device.hlinux/processor.hlinux/slab.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-acpi.hasm/cpu_device_id.h../utils.h
Detected Declarations
struct avs_card_drvdatafunction avs_es8336_speaker_power_eventfunction avs_es8336_codec_initfunction avs_es8336_codec_exitfunction avs_es8336_hw_paramsfunction avs_es8336_be_fixupfunction avs_create_dai_linkfunction avs_card_suspend_prefunction avs_card_resume_postfunction avs_es8336_probe
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
- Immediate include surface: `linux/device.h`, `linux/gpio/consumer.h`, `linux/input.h`, `linux/module.h`, `linux/platform_device.h`, `linux/processor.h`, `linux/slab.h`, `sound/jack.h`.
- Detected declarations: `struct avs_card_drvdata`, `function avs_es8336_speaker_power_event`, `function avs_es8336_codec_init`, `function avs_es8336_codec_exit`, `function avs_es8336_hw_params`, `function avs_es8336_be_fixup`, `function avs_create_dai_link`, `function avs_card_suspend_pre`, `function avs_card_resume_post`, `function avs_es8336_probe`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
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.