Lines Matching +full:headset +full:- +full:detect +full:- +full:gpios

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 "../atom/sst-atom-controls.h"
31 #include "../common/soc-intel-quirks.h"
33 /* jd-inv + terminating entry */
55 static int quirk_override = -1;
57 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
76 struct snd_soc_card *card = w->dapm->card; in byt_cht_es8316_speaker_power_event()
80 priv->speaker_en = true; in byt_cht_es8316_speaker_power_event()
82 priv->speaker_en = false; in byt_cht_es8316_speaker_power_event()
84 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_speaker_power_event()
92 SND_SOC_DAPM_MIC("Headset Mic", NULL),
115 {"MIC2", NULL, "Headset Mic"},
120 {"MIC1", NULL, "Headset Mic"},
142 SOC_DAPM_PIN_SWITCH("Headset Mic"),
152 .pin = "Headset Mic",
159 struct snd_soc_component *codec = asoc_rtd_to_codec(runtime, 0)->component; in byt_cht_es8316_init()
160 struct snd_soc_card *card = runtime->card; in byt_cht_es8316_init()
166 card->dapm.idle_bias_off = true; in byt_cht_es8316_init()
179 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
190 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
202 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
204 clk_disable_unprepare(priv->mclk); in byt_cht_es8316_init()
206 ret = clk_set_rate(priv->mclk, 19200000); in byt_cht_es8316_init()
208 dev_err(card->dev, "unable to set MCLK rate\n"); in byt_cht_es8316_init()
210 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
212 dev_err(card->dev, "unable to enable MCLK\n"); in byt_cht_es8316_init()
217 dev_err(card->dev, "can't set codec clock %d\n", ret); in byt_cht_es8316_init()
221 ret = snd_soc_card_jack_new(card, "Headset", in byt_cht_es8316_init()
223 &priv->jack, byt_cht_es8316_jack_pins, in byt_cht_es8316_init()
226 dev_err(card->dev, "jack creation failed %d\n", ret); in byt_cht_es8316_init()
230 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in byt_cht_es8316_init()
231 snd_soc_component_set_jack(codec, &priv->jack, NULL); in byt_cht_es8316_init()
246 rate->min = rate->max = 48000; in byt_cht_es8316_codec_fixup()
247 channels->min = channels->max = 2; in byt_cht_es8316_codec_fixup()
250 /* set SSP0 to 16-bit */ in byt_cht_es8316_codec_fixup()
254 /* set SSP2 to 24-bit */ in byt_cht_es8316_codec_fixup()
261 * with explicit setting to I2S 2ch 24-bit. The word length is set with in byt_cht_es8316_codec_fixup()
270 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in byt_cht_es8316_codec_fixup()
276 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in byt_cht_es8316_codec_fixup()
285 return snd_pcm_hw_constraint_single(substream->runtime, in byt_cht_es8316_aif1_startup()
297 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
300 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
303 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
305 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8316:00", "ES8316 HiFi")));
308 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
323 .name = "Deep-Buffer Audio Port",
324 .stream_name = "Deep-Buffer Audio",
334 /* Only SSP2 has been tested here, so BYT-CR platforms that
337 .name = "SSP2-Codec",
355 static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
357 static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */
364 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_suspend()
365 dev_dbg(component->dev, "disabling jack detect before suspend\n"); in byt_cht_es8316_suspend()
380 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_resume()
381 dev_dbg(component->dev, "re-enabling jack detect after resume\n"); in byt_cht_es8316_resume()
382 snd_soc_component_set_jack(component, &priv->jack, NULL); in byt_cht_es8316_resume()
390 * wrongly also set the speaker-enable GPIO to 1/0. Testing has shown in byt_cht_es8316_resume()
397 * is guaranteed to run after the touchscreen driver/ACPI-subsys has in byt_cht_es8316_resume()
404 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_resume()
411 #define CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
414 #define CARD_NAME "bytcht-es8316"
438 { "speaker-enable-gpios", &first_gpio, 1 },
470 struct device *dev = &pdev->dev; in snd_byt_cht_es8316_mc_probe()
482 return -ENOMEM; in snd_byt_cht_es8316_mc_probe()
484 mach = dev->platform_data; in snd_byt_cht_es8316_mc_probe()
487 if (!strcmp(byt_cht_es8316_dais[i].codecs->name, in snd_byt_cht_es8316_mc_probe()
488 "i2c-ESSX8316:00")) { in snd_byt_cht_es8316_mc_probe()
495 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_cht_es8316_mc_probe()
498 "i2c-%s", acpi_dev_name(adev)); in snd_byt_cht_es8316_mc_probe()
499 put_device(&adev->dev); in snd_byt_cht_es8316_mc_probe()
500 byt_cht_es8316_dais[dai_index].codecs->name = codec_name; in snd_byt_cht_es8316_mc_probe()
505 platform_name = mach->mach_params.platform; in snd_byt_cht_es8316_mc_probe()
515 quirk = (unsigned long)dmi_id->driver_data; in snd_byt_cht_es8316_mc_probe()
517 mach->mach_params.acpi_ipc_irq_index == 0) { in snd_byt_cht_es8316_mc_probe()
518 /* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */ in snd_byt_cht_es8316_mc_probe()
522 /* Others default to internal-mic-in1-map, mono-speaker */ in snd_byt_cht_es8316_mc_probe()
526 if (quirk_override != -1) { in snd_byt_cht_es8316_mc_probe()
534 byt_cht_es8316_dais[dai_index].cpus->dai_name = "ssp0-port"; in snd_byt_cht_es8316_mc_probe()
537 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_cht_es8316_mc_probe()
538 if (IS_ERR(priv->mclk)) { in snd_byt_cht_es8316_mc_probe()
539 ret = PTR_ERR(priv->mclk); in snd_byt_cht_es8316_mc_probe()
547 return -EPROBE_DEFER; in snd_byt_cht_es8316_mc_probe()
550 props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); in snd_byt_cht_es8316_mc_probe()
561 priv->speaker_en_gpio = in snd_byt_cht_es8316_mc_probe()
562 gpiod_get_index(codec_dev, "speaker-enable", 0, in snd_byt_cht_es8316_mc_probe()
567 if (IS_ERR(priv->speaker_en_gpio)) { in snd_byt_cht_es8316_mc_probe()
568 ret = PTR_ERR(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_probe()
570 case -ENOENT: in snd_byt_cht_es8316_mc_probe()
571 priv->speaker_en_gpio = NULL; in snd_byt_cht_es8316_mc_probe()
576 case -EPROBE_DEFER: in snd_byt_cht_es8316_mc_probe()
582 "cfg-spk:%s cfg-mic:%s", in snd_byt_cht_es8316_mc_probe()
587 snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic", in snd_byt_cht_es8316_mc_probe()
598 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_probe()
611 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_remove()
628 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");