Lines Matching +full:mic +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0-only
3 * bytcht_es8316.c - ASoc Machine driver for Intel Baytrail/Cherrytrail
7 * Authors: David Yang <yangxiaohua@everest-semi.com>,
29 #include <sound/soc-acpi.h>
30 #include "../../codecs/es83xx-dsm-common.h"
31 #include "../atom/sst-atom-controls.h"
32 #include "../common/soc-intel-quirks.h"
34 /* jd-inv + terminating entry */
57 static int quirk_override = -1;
59 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
78 struct snd_soc_card *card = w->dapm->card; in byt_cht_es8316_speaker_power_event()
82 priv->speaker_en = true; in byt_cht_es8316_speaker_power_event()
84 priv->speaker_en = false; in byt_cht_es8316_speaker_power_event()
86 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_speaker_power_event()
94 SND_SOC_DAPM_MIC("Headset Mic", NULL),
95 SND_SOC_DAPM_MIC("Internal Mic", NULL),
116 {"MIC1", NULL, "Internal Mic"},
117 {"MIC2", NULL, "Headset Mic"},
121 {"MIC2", NULL, "Internal Mic"},
122 {"MIC1", NULL, "Headset Mic"},
144 SOC_DAPM_PIN_SWITCH("Headset Mic"),
145 SOC_DAPM_PIN_SWITCH("Internal Mic"),
154 .pin = "Headset Mic",
161 struct snd_soc_component *codec = snd_soc_rtd_to_codec(runtime, 0)->component; in byt_cht_es8316_init()
162 struct snd_soc_card *card = runtime->card; in byt_cht_es8316_init()
168 card->dapm.idle_bias_off = true; in byt_cht_es8316_init()
181 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
192 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
204 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
206 clk_disable_unprepare(priv->mclk); in byt_cht_es8316_init()
208 ret = clk_set_rate(priv->mclk, 19200000); in byt_cht_es8316_init()
210 dev_err(card->dev, "unable to set MCLK rate\n"); in byt_cht_es8316_init()
212 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
214 dev_err(card->dev, "unable to enable MCLK\n"); in byt_cht_es8316_init()
219 dev_err(card->dev, "can't set codec clock %d\n", ret); in byt_cht_es8316_init()
225 &priv->jack, byt_cht_es8316_jack_pins, in byt_cht_es8316_init()
228 dev_err(card->dev, "jack creation failed %d\n", ret); in byt_cht_es8316_init()
232 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in byt_cht_es8316_init()
233 snd_soc_component_set_jack(codec, &priv->jack, NULL); in byt_cht_es8316_init()
248 rate->min = rate->max = 48000; in byt_cht_es8316_codec_fixup()
249 channels->min = channels->max = 2; in byt_cht_es8316_codec_fixup()
252 /* set SSP0 to 16-bit */ in byt_cht_es8316_codec_fixup()
256 /* set SSP2 to 24-bit */ in byt_cht_es8316_codec_fixup()
263 * with explicit setting to I2S 2ch 24-bit. The word length is set with in byt_cht_es8316_codec_fixup()
272 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in byt_cht_es8316_codec_fixup()
278 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in byt_cht_es8316_codec_fixup()
287 return snd_pcm_hw_constraint_single(substream->runtime, in byt_cht_es8316_aif1_startup()
299 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
302 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
305 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
307 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8316:00", "ES8316 HiFi")));
310 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
325 .name = "Deep-Buffer Audio Port",
326 .stream_name = "Deep-Buffer Audio",
336 .name = "SSP2-Codec",
353 static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
355 static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */
362 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_suspend()
363 dev_dbg(component->dev, "disabling jack detect before suspend\n"); in byt_cht_es8316_suspend()
378 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_resume()
379 dev_dbg(component->dev, "re-enabling jack detect after resume\n"); in byt_cht_es8316_resume()
380 snd_soc_component_set_jack(component, &priv->jack, NULL); in byt_cht_es8316_resume()
388 * wrongly also set the speaker-enable GPIO to 1/0. Testing has shown in byt_cht_es8316_resume()
395 * is guaranteed to run after the touchscreen driver/ACPI-subsys has in byt_cht_es8316_resume()
402 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_resume()
408 #define SOF_CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
411 #define CARD_NAME "bytcht-es8316"
432 { "speaker-enable-gpios", &first_gpio, 1 },
447 { /* Nanote UMPC-01 */
450 DMI_MATCH(DMI_PRODUCT_NAME, "UMPC-01"),
473 ret = es83xx_dsm(priv->codec_dev, PLATFORM_MAINMIC_TYPE_ARG, &val1); in byt_cht_es8316_get_quirks_from_dsm()
477 ret = es83xx_dsm(priv->codec_dev, PLATFORM_HPMIC_TYPE_ARG, &val2); in byt_cht_es8316_get_quirks_from_dsm()
486 dev_warn(priv->codec_dev, "Unknown mic settings mainmic 0x%02x hpmic 0x%02x\n", in byt_cht_es8316_get_quirks_from_dsm()
488 return -EINVAL; in byt_cht_es8316_get_quirks_from_dsm()
491 ret = es83xx_dsm(priv->codec_dev, PLATFORM_SPK_TYPE_ARG, &val1); in byt_cht_es8316_get_quirks_from_dsm()
502 dev_warn(priv->codec_dev, "Unknown speaker setting 0x%02x\n", val1); in byt_cht_es8316_get_quirks_from_dsm()
503 return -EINVAL; in byt_cht_es8316_get_quirks_from_dsm()
506 ret = es83xx_dsm(priv->codec_dev, PLATFORM_HPDET_INV_ARG, &val1); in byt_cht_es8316_get_quirks_from_dsm()
517 dev_warn(priv->codec_dev, "Unknown hpdet-inv setting 0x%02x\n", val1); in byt_cht_es8316_get_quirks_from_dsm()
518 return -EINVAL; in byt_cht_es8316_get_quirks_from_dsm()
527 struct device *dev = &pdev->dev; in snd_byt_cht_es8316_mc_probe()
545 return -ENOMEM; in snd_byt_cht_es8316_mc_probe()
550 !strcmp(byt_cht_es8316_dais[i].codecs->name, in snd_byt_cht_es8316_mc_probe()
551 "i2c-ESSX8316:00")) { in snd_byt_cht_es8316_mc_probe()
558 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_cht_es8316_mc_probe()
561 "i2c-%s", acpi_dev_name(adev)); in snd_byt_cht_es8316_mc_probe()
562 byt_cht_es8316_dais[dai_index].codecs->name = codec_name; in snd_byt_cht_es8316_mc_probe()
564 dev_err(dev, "Error cannot find '%s' dev\n", mach->id); in snd_byt_cht_es8316_mc_probe()
565 return -ENOENT; in snd_byt_cht_es8316_mc_probe()
571 return -EPROBE_DEFER; in snd_byt_cht_es8316_mc_probe()
572 priv->codec_dev = get_device(codec_dev); in snd_byt_cht_es8316_mc_probe()
576 platform_name = mach->mach_params.platform; in snd_byt_cht_es8316_mc_probe()
585 es83xx_dsm_dump(priv->codec_dev); in snd_byt_cht_es8316_mc_probe()
588 is_bytcr = soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0; in snd_byt_cht_es8316_mc_probe()
591 quirk = (unsigned long)dmi_id->driver_data; in snd_byt_cht_es8316_mc_probe()
595 /* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */ in snd_byt_cht_es8316_mc_probe()
599 /* Others default to internal-mic-in1-map, mono-speaker */ in snd_byt_cht_es8316_mc_probe()
603 if (quirk_override != -1) { in snd_byt_cht_es8316_mc_probe()
611 byt_cht_es8316_dais[dai_index].cpus->dai_name = "ssp0-port"; in snd_byt_cht_es8316_mc_probe()
614 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_cht_es8316_mc_probe()
615 if (IS_ERR(priv->mclk)) { in snd_byt_cht_es8316_mc_probe()
617 return dev_err_probe(dev, PTR_ERR(priv->mclk), "clk_get pmc_plt_clk_3 failed\n"); in snd_byt_cht_es8316_mc_probe()
621 props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); in snd_byt_cht_es8316_mc_probe()
642 priv->speaker_en_gpio = in snd_byt_cht_es8316_mc_probe()
643 gpiod_get_optional(codec_dev, "speaker-enable", in snd_byt_cht_es8316_mc_probe()
646 if (IS_ERR(priv->speaker_en_gpio)) { in snd_byt_cht_es8316_mc_probe()
647 ret = dev_err_probe(dev, PTR_ERR(priv->speaker_en_gpio), in snd_byt_cht_es8316_mc_probe()
653 "cfg-spk:%s cfg-mic:%s", in snd_byt_cht_es8316_mc_probe()
658 snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic", in snd_byt_cht_es8316_mc_probe()
677 dev->driver->pm = &snd_soc_pm_ops; in snd_byt_cht_es8316_mc_probe()
684 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_probe()
692 device_remove_software_node(priv->codec_dev); in snd_byt_cht_es8316_mc_probe()
693 put_device(priv->codec_dev); in snd_byt_cht_es8316_mc_probe()
702 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_remove()
703 device_remove_software_node(priv->codec_dev); in snd_byt_cht_es8316_mc_remove()
704 put_device(priv->codec_dev); in snd_byt_cht_es8316_mc_remove()
717 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");