Lines Matching +full:codec +full:- +full:mclk1

1 // SPDX-License-Identifier: GPL-2.0+
12 #include <linux/input-event-codes.h>
17 #include <sound/soc-dapm.h>
23 * The MCLK1 clock source is XCLKOUT with its mux set to the external fixed rate
75 struct snd_soc_component *codec = data; in headset_jack_check() local
76 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); in headset_jack_check()
77 struct midas_priv *priv = snd_soc_card_get_drvdata(codec->card); in headset_jack_check()
81 if (!gpiod_get_value_cansleep(priv->gpio_headset_detect)) in headset_jack_check()
85 ret = snd_soc_dapm_force_enable_pin(dapm, "headset-mic-bias"); in headset_jack_check()
96 ret = iio_read_channel_processed(priv->adc_headset_detect, &adc); in headset_jack_check()
105 jack_type = snd_soc_jack_get_type(&priv->headset_jack, adc); in headset_jack_check()
108 ret = snd_soc_dapm_disable_pin(dapm, "headset-mic-bias"); in headset_jack_check()
119 struct snd_soc_component *codec = data; in headset_key_check() local
120 struct midas_priv *priv = snd_soc_card_get_drvdata(codec->card); in headset_key_check()
123 if (!gpiod_get_value_cansleep(priv->gpio_headset_key)) in headset_key_check()
127 if (!(priv->headset_jack.status & SND_JACK_MICROPHONE)) in headset_key_check()
130 ret = iio_read_channel_processed(priv->adc_headset_detect, &adc); in headset_key_check()
165 struct snd_soc_card *card = rtd->card; in midas_start_fll1()
172 rate = priv->fll1_rate; in midas_start_fll1()
180 if (rate != priv->fll1_rate && priv->fll1_rate) { in midas_start_fll1()
185 dev_err(card->dev, "Unable to switch to MCLK2: %d\n", ret); in midas_start_fll1()
193 dev_err(card->dev, "Failed to set FLL1 rate: %d\n", ret); in midas_start_fll1()
196 priv->fll1_rate = rate; in midas_start_fll1()
199 priv->fll1_rate, SND_SOC_CLOCK_IN); in midas_start_fll1()
201 dev_err(card->dev, "Failed to set SYSCLK source: %d\n", ret); in midas_start_fll1()
208 dev_err(card->dev, "Failed to set OPCLK source: %d\n", ret); in midas_start_fll1()
217 struct snd_soc_card *card = rtd->card; in midas_stop_fll1()
225 dev_err(card->dev, "Unable to switch to MCLK2: %d\n", ret); in midas_stop_fll1()
231 dev_err(card->dev, "Unable to stop FLL1: %d\n", ret); in midas_stop_fll1()
235 priv->fll1_rate = 0; in midas_stop_fll1()
266 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); in midas_ext_spkmode() local
271 ret = snd_soc_component_update_bits(codec, WM8994_SPKOUT_MIXERS, in midas_ext_spkmode()
276 ret = snd_soc_component_update_bits(codec, WM8994_SPKOUT_MIXERS, in midas_ext_spkmode()
288 struct snd_soc_card *card = w->dapm->card; in midas_fm_set()
291 if (!priv->gpio_fm_sel) in midas_fm_set()
296 gpiod_set_value_cansleep(priv->gpio_fm_sel, 1); in midas_fm_set()
299 gpiod_set_value_cansleep(priv->gpio_fm_sel, 0); in midas_fm_set()
309 struct snd_soc_card *card = w->dapm->card; in midas_line_set()
312 if (!priv->gpio_lineout_sel) in midas_line_set()
317 gpiod_set_value_cansleep(priv->gpio_lineout_sel, 1); in midas_line_set()
320 gpiod_set_value_cansleep(priv->gpio_lineout_sel, 0); in midas_line_set()
356 SND_SOC_DAPM_REGULATOR_SUPPLY("headset-mic-bias", 0, 0),
358 SND_SOC_DAPM_REGULATOR_SUPPLY("mic-bias", 0, 0),
360 SND_SOC_DAPM_REGULATOR_SUPPLY("submic-bias", 0, 0),
363 /* Default routing; supplemented by audio-routing DT property */
366 {"Main Mic", NULL, "mic-bias"},
367 {"Sub Mic", NULL, "submic-bias"},
368 {"Headset Mic", NULL, "headset-mic-bias"},
376 &card->dai_link[0]); in midas_set_bias_level()
379 if (dapm->dev != aif1_dai->dev) in midas_set_bias_level()
397 &card->dai_link[0]); in midas_late_probe()
406 dev_err(aif1_dai->dev, "Failed to switch to MCLK2: %d\n", ret); in midas_late_probe()
410 if (!priv->gpio_headset_detect) { in midas_late_probe()
416 &priv->headset_jack, in midas_late_probe()
422 wm8958_mic_detect(aif1_dai->component, &priv->headset_jack, in midas_late_probe()
429 &priv->headset_jack, in midas_late_probe()
433 dev_err(card->dev, in midas_late_probe()
438 ret = snd_soc_jack_add_zones(&priv->headset_jack, in midas_late_probe()
442 dev_err(card->dev, in midas_late_probe()
447 headset_gpio[0].data = aif1_dai->component; in midas_late_probe()
448 headset_gpio[0].desc = priv->gpio_headset_detect; in midas_late_probe()
450 headset_gpio[1].data = aif1_dai->component; in midas_late_probe()
451 headset_gpio[1].desc = priv->gpio_headset_key; in midas_late_probe()
453 snd_jack_set_key(priv->headset_jack.jack, in midas_late_probe()
455 snd_jack_set_key(priv->headset_jack.jack, in midas_late_probe()
457 snd_jack_set_key(priv->headset_jack.jack, in midas_late_probe()
460 ret = snd_soc_jack_add_gpios(&priv->headset_jack, in midas_late_probe()
464 dev_err(card->dev, in midas_late_probe()
516 .name = "midas-audio",
521 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif1")),
526 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif2")),
531 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif3")),
575 struct device_node *cpu = NULL, *codec = NULL; in midas_probe() local
577 struct device *dev = &pdev->dev; in midas_probe()
587 return -ENOMEM; in midas_probe()
590 card->dev = dev; in midas_probe()
592 priv->gpio_fm_sel = devm_gpiod_get_optional(dev, "fm-sel", GPIOD_OUT_HIGH); in midas_probe()
593 if (IS_ERR(priv->gpio_fm_sel)) in midas_probe()
594 return dev_err_probe(dev, PTR_ERR(priv->gpio_fm_sel), in midas_probe()
597 priv->gpio_lineout_sel = devm_gpiod_get_optional(dev, "lineout-sel", in midas_probe()
599 if (IS_ERR(priv->gpio_lineout_sel)) in midas_probe()
600 return dev_err_probe(dev, PTR_ERR(priv->gpio_lineout_sel), in midas_probe()
603 priv->gpio_headset_detect = devm_gpiod_get_optional(dev, in midas_probe()
604 "headset-detect", GPIOD_IN); in midas_probe()
605 if (IS_ERR(priv->gpio_headset_detect)) in midas_probe()
606 return dev_err_probe(dev, PTR_ERR(priv->gpio_headset_detect), in midas_probe()
609 if (priv->gpio_headset_detect) { in midas_probe()
610 priv->adc_headset_detect = devm_iio_channel_get(dev, in midas_probe()
611 "headset-detect"); in midas_probe()
612 if (IS_ERR(priv->adc_headset_detect)) in midas_probe()
614 PTR_ERR(priv->adc_headset_detect), in midas_probe()
617 ret = iio_get_channel_type(priv->adc_headset_detect, in midas_probe()
626 return -EINVAL; in midas_probe()
629 priv->gpio_headset_key = devm_gpiod_get(dev, "headset-key", in midas_probe()
631 if (IS_ERR(priv->gpio_headset_key)) in midas_probe()
633 PTR_ERR(priv->gpio_headset_key), in midas_probe()
636 ret = of_property_read_u32_array(dev->of_node, in midas_probe()
637 "samsung,headset-4pole-threshold-microvolt", in midas_probe()
641 dev_err(dev, "Failed to get 4-pole jack detection threshold\n"); in midas_probe()
646 dev_err(dev, "Invalid 4-pole jack detection threshold value\n"); in midas_probe()
647 return -EINVAL; in midas_probe()
656 ret = of_property_read_u32_array(dev->of_node, in midas_probe()
657 "samsung,headset-button-threshold-microvolt", in midas_probe()
668 return -EINVAL; in midas_probe()
674 return -EINVAL; in midas_probe()
683 (button_threshold[i+1] - 1); in midas_probe()
693 ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); in midas_probe()
696 ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); in midas_probe()
703 cpu = of_get_child_by_name(dev->of_node, "cpu"); in midas_probe()
705 return -EINVAL; in midas_probe()
707 codec = of_get_child_by_name(dev->of_node, "codec"); in midas_probe()
708 if (!codec) { in midas_probe()
710 return -EINVAL; in midas_probe()
713 cpu_dai_node = of_parse_phandle(cpu, "sound-dai", 0); in midas_probe()
716 dev_err(dev, "parsing cpu/sound-dai failed\n"); in midas_probe()
717 of_node_put(codec); in midas_probe()
718 return -EINVAL; in midas_probe()
721 codec_dai_node = of_parse_phandle(codec, "sound-dai", 0); in midas_probe()
722 of_node_put(codec); in midas_probe()
724 dev_err(dev, "audio-codec property invalid/missing\n"); in midas_probe()
725 ret = -EINVAL; in midas_probe()
730 dai_link->codecs->of_node = codec_dai_node; in midas_probe()
731 dai_link->cpus->of_node = cpu_dai_node; in midas_probe()
732 dai_link->platforms->of_node = cpu_dai_node; in midas_probe()
758 { .compatible = "samsung,midas-audio" },
765 .name = "midas-audio",