sound/soc/fsl/imx-es8328.c

Source file repositories/reference/linux-study-clean/sound/soc/fsl/imx-es8328.c

File Facts

System
Linux kernel
Corpus path
sound/soc/fsl/imx-es8328.c
Extension
.c
Size
6450 bytes
Lines
256
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 imx_es8328_data {
	struct device *dev;
	struct snd_soc_dai_link dai;
	struct snd_soc_card card;
	char codec_dai_name[DAI_NAME_SIZE];
	char platform_name[DAI_NAME_SIZE];
	struct gpio_desc *jack_gpiod;
};

static struct snd_soc_jack_gpio headset_jack_gpios[] = {
	{
		.name = "headset-gpio",
		.report = SND_JACK_HEADSET,
		.invert = 0,
		.debounce_time = 200,
	},
};

static struct snd_soc_jack headset_jack;
static struct snd_soc_jack_pin headset_jack_pins[] = {
	{
		.pin = "Headphone",
		.mask = SND_JACK_HEADPHONE,
	},
	{
		.pin = "Mic Jack",
		.mask = SND_JACK_MICROPHONE,
	},
};

static int imx_es8328_dai_init(struct snd_soc_pcm_runtime *rtd)
{
	struct imx_es8328_data *data = container_of(rtd->card,
					struct imx_es8328_data, card);
	int ret = 0;

	if (data->jack_gpiod) {
		/* Headphone jack detection */
		ret = snd_soc_card_jack_new_pins(rtd->card, "Headphone",
						 SND_JACK_HEADSET | SND_JACK_BTN_0,
						 &headset_jack,
						 headset_jack_pins,
						 ARRAY_SIZE(headset_jack_pins));
		if (ret)
			return ret;

		headset_jack_gpios[0].desc = data->jack_gpiod;
		ret = snd_soc_jack_add_gpios(&headset_jack,
					     ARRAY_SIZE(headset_jack_gpios),
					     headset_jack_gpios);
	}

	return ret;
}

static const struct snd_soc_dapm_widget imx_es8328_dapm_widgets[] = {
	SND_SOC_DAPM_MIC("Mic Jack", NULL),
	SND_SOC_DAPM_HP("Headphone", NULL),
	SND_SOC_DAPM_SPK("Speaker", NULL),
	SND_SOC_DAPM_REGULATOR_SUPPLY("audio-amp", 1, 0),
};

static const struct snd_kcontrol_new imx_es8328_controls[] = {
	SOC_DAPM_PIN_SWITCH("Headphone"),
	SOC_DAPM_PIN_SWITCH("Mic Jack"),
};

static int imx_es8328_probe(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct device_node *ssi_np = NULL, *codec_np = NULL;
	struct platform_device *ssi_pdev;
	struct imx_es8328_data *data;
	struct snd_soc_dai_link_component *comp;
	u32 int_port, ext_port;
	int ret;
	struct device *dev = &pdev->dev;

	ret = of_property_read_u32(np, "mux-int-port", &int_port);
	if (ret) {
		dev_err(dev, "mux-int-port missing or invalid\n");
		goto fail;
	}
	if (int_port > MUX_PORT_MAX || int_port == 0) {
		dev_err(dev, "mux-int-port: hardware only has %d mux ports\n",
			MUX_PORT_MAX);
		ret = -EINVAL;
		goto fail;
	}

Annotation

Implementation Notes