Lines Matching +full:dmic +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-only
5 // sc7180.c -- ALSA SoC Machine driver for SC7180
7 #include <dt-bindings/sound/sc7180-lpass.h>
8 #include <dt-bindings/sound/qcom,q6afe.h>
17 #include <uapi/linux/input-event-codes.h>
41 struct snd_soc_component *component = jack->private_data; in sc7180_jack_free()
59 struct snd_soc_card *card = rtd->card; in sc7180_headset_init()
62 struct snd_soc_component *component = codec_dai->component; in sc7180_headset_init()
71 &pdata->hs_jack, in sc7180_headset_init()
76 dev_err(card->dev, "Unable to add Headset Jack\n"); in sc7180_headset_init()
80 jack = pdata->hs_jack.jack; in sc7180_headset_init()
87 jack->private_data = component; in sc7180_headset_init()
88 jack->private_free = sc7180_jack_free; in sc7180_headset_init()
90 return snd_soc_component_set_jack(component, &pdata->hs_jack, NULL); in sc7180_headset_init()
95 struct snd_soc_card *card = rtd->card; in sc7180_hdmi_init()
98 struct snd_soc_component *component = codec_dai->component; in sc7180_hdmi_init()
105 &pdata->hdmi_jack); in sc7180_hdmi_init()
108 dev_err(card->dev, "Unable to add HDMI Jack\n"); in sc7180_hdmi_init()
112 jack = pdata->hdmi_jack.jack; in sc7180_hdmi_init()
113 jack->private_data = component; in sc7180_hdmi_init()
114 jack->private_free = sc7180_jack_free; in sc7180_hdmi_init()
116 return snd_soc_component_set_jack(component, &pdata->hdmi_jack, NULL); in sc7180_hdmi_init()
123 switch (cpu_dai->id) { in sc7180_init()
131 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_init()
132 cpu_dai->id); in sc7180_init()
133 return -EINVAL; in sc7180_init()
142 switch (cpu_dai->id) { in sc7180_qdsp_init()
151 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_qdsp_init()
152 cpu_dai->id); in sc7180_qdsp_init()
153 return -EINVAL; in sc7180_qdsp_init()
163 if (!strcmp(codec_dai->name, "rt5682-aif1")) { in sc7180_startup_realtek_codec()
169 } else if (!strcmp(codec_dai->name, "rt5682s-aif1")) { in sc7180_startup_realtek_codec()
187 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in sc7180_startup_realtek_codec()
195 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", in sc7180_startup_realtek_codec()
204 struct snd_soc_card *card = rtd->card; in sc7180_snd_startup()
209 switch (cpu_dai->id) { in sc7180_snd_startup()
211 if (++data->pri_mi2s_clk_count == 1) { in sc7180_snd_startup()
228 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_snd_startup()
229 cpu_dai->id); in sc7180_snd_startup()
230 return -EINVAL; in sc7180_snd_startup()
238 struct snd_soc_card *card = rtd->card; in sc7180_qdsp_snd_startup()
244 switch (cpu_dai->id) { in sc7180_qdsp_snd_startup()
247 if (++data->pri_mi2s_clk_count == 1) { in sc7180_qdsp_snd_startup()
280 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_qdsp_snd_startup()
281 cpu_dai->id); in sc7180_qdsp_snd_startup()
282 return -EINVAL; in sc7180_qdsp_snd_startup()
291 struct sc7180_snd_data *data = snd_soc_card_get_drvdata(dapm->card); in dmic_get()
293 ucontrol->value.integer.value[0] = data->dmic_switch; in dmic_get()
301 struct sc7180_snd_data *data = snd_soc_card_get_drvdata(dapm->card); in dmic_set()
303 data->dmic_switch = ucontrol->value.integer.value[0]; in dmic_set()
304 gpiod_set_value(data->dmic_sel, data->dmic_switch); in dmic_set()
311 struct snd_soc_card *card = rtd->card; in sc7180_snd_shutdown()
315 switch (cpu_dai->id) { in sc7180_snd_shutdown()
317 if (--data->pri_mi2s_clk_count == 0) { in sc7180_snd_shutdown()
329 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_snd_shutdown()
330 cpu_dai->id); in sc7180_snd_shutdown()
338 struct snd_soc_card *card = rtd->card; in sc7180_qdsp_snd_shutdown()
342 switch (cpu_dai->id) { in sc7180_qdsp_snd_shutdown()
345 if (--data->pri_mi2s_clk_count == 0) { in sc7180_qdsp_snd_shutdown()
365 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_qdsp_snd_shutdown()
366 cpu_dai->id); in sc7180_qdsp_snd_shutdown()
375 switch (cpu_dai->id) { in sc7180_adau7002_init()
383 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_adau7002_init()
384 cpu_dai->id); in sc7180_adau7002_init()
385 return -EINVAL; in sc7180_adau7002_init()
395 struct snd_pcm_runtime *runtime = substream->runtime; in sc7180_adau7002_snd_startup()
397 switch (cpu_dai->id) { in sc7180_adau7002_snd_startup()
403 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; in sc7180_adau7002_snd_startup()
412 dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, in sc7180_adau7002_snd_startup()
413 cpu_dai->id); in sc7180_adau7002_snd_startup()
414 return -EINVAL; in sc7180_adau7002_snd_startup()
427 rate->min = rate->max = 48000; in sc7180_qdsp_be_hw_params_fixup()
428 channels->min = channels->max = 2; in sc7180_qdsp_be_hw_params_fixup()
458 SND_SOC_DAPM_MIC("DMIC", NULL),
470 SOC_DAPM_ENUM_EXT("DMIC Select Mux", sc7180_dmic_enum,
476 SND_SOC_DAPM_MIC("DMIC", NULL),
477 SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &sc7180_dmic_mux_control),
486 {"Dmic Mux", "Front Mic", "DMIC"},
487 {"Dmic Mux", "Rear Mic", "DMIC"},
494 struct device *dev = &pdev->dev; in sc7180_snd_platform_probe()
503 return -ENOMEM; in sc7180_snd_platform_probe()
505 card = &data->card; in sc7180_snd_platform_probe()
508 card->owner = THIS_MODULE; in sc7180_snd_platform_probe()
509 card->driver_name = DRIVER_NAME; in sc7180_snd_platform_probe()
510 card->dev = dev; in sc7180_snd_platform_probe()
511 card->dapm_widgets = sc7180_snd_widgets; in sc7180_snd_platform_probe()
512 card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_widgets); in sc7180_snd_platform_probe()
513 card->controls = sc7180_snd_controls; in sc7180_snd_platform_probe()
514 card->num_controls = ARRAY_SIZE(sc7180_snd_controls); in sc7180_snd_platform_probe()
516 if (of_property_read_bool(dev->of_node, "dmic-gpios")) { in sc7180_snd_platform_probe()
517 card->dapm_widgets = sc7180_snd_dual_mic_widgets, in sc7180_snd_platform_probe()
518 card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_dual_mic_widgets), in sc7180_snd_platform_probe()
519 card->controls = sc7180_snd_dual_mic_controls, in sc7180_snd_platform_probe()
520 card->num_controls = ARRAY_SIZE(sc7180_snd_dual_mic_controls), in sc7180_snd_platform_probe()
521 card->dapm_routes = sc7180_snd_dual_mic_audio_route, in sc7180_snd_platform_probe()
522 card->num_dapm_routes = ARRAY_SIZE(sc7180_snd_dual_mic_audio_route), in sc7180_snd_platform_probe()
523 data->dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW); in sc7180_snd_platform_probe()
524 if (IS_ERR(data->dmic_sel)) { in sc7180_snd_platform_probe()
525 dev_err(&pdev->dev, "DMIC gpio failed err=%ld\n", PTR_ERR(data->dmic_sel)); in sc7180_snd_platform_probe()
526 return PTR_ERR(data->dmic_sel); in sc7180_snd_platform_probe()
530 if (of_device_is_compatible(dev->of_node, "google,sc7180-coachz")) { in sc7180_snd_platform_probe()
532 card->dapm_widgets = sc7180_adau7002_snd_widgets; in sc7180_snd_platform_probe()
533 card->num_dapm_widgets = ARRAY_SIZE(sc7180_adau7002_snd_widgets); in sc7180_snd_platform_probe()
534 } else if (of_device_is_compatible(dev->of_node, "qcom,sc7180-qdsp6-sndcard")) { in sc7180_snd_platform_probe()
544 link->ops = &sc7180_adau7002_ops; in sc7180_snd_platform_probe()
545 link->init = sc7180_adau7002_init; in sc7180_snd_platform_probe()
547 if (link->no_pcm == 1) { in sc7180_snd_platform_probe()
548 link->ops = &sc7180_qdsp_ops; in sc7180_snd_platform_probe()
549 link->be_hw_params_fixup = sc7180_qdsp_be_hw_params_fixup; in sc7180_snd_platform_probe()
550 link->init = sc7180_qdsp_init; in sc7180_snd_platform_probe()
553 link->ops = &sc7180_ops; in sc7180_snd_platform_probe()
554 link->init = sc7180_init; in sc7180_snd_platform_probe()
562 {.compatible = "google,sc7180-trogdor"},
563 {.compatible = "google,sc7180-coachz"},
564 {.compatible = "qcom,sc7180-qdsp6-sndcard"},
572 .name = "msm-snd-sc7180",