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 */
56 static int quirk_override = -1;
58 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
77 struct snd_soc_card *card = w->dapm->card; in byt_cht_es8316_speaker_power_event()
81 priv->speaker_en = true; in byt_cht_es8316_speaker_power_event()
83 priv->speaker_en = false; in byt_cht_es8316_speaker_power_event()
85 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_speaker_power_event()
93 SND_SOC_DAPM_MIC("Headset Mic", NULL),
116 {"MIC2", NULL, "Headset Mic"},
121 {"MIC1", NULL, "Headset Mic"},
143 SOC_DAPM_PIN_SWITCH("Headset Mic"),
153 .pin = "Headset Mic",
160 struct snd_soc_component *codec = asoc_rtd_to_codec(runtime, 0)->component; in byt_cht_es8316_init()
161 struct snd_soc_card *card = runtime->card; in byt_cht_es8316_init()
167 card->dapm.idle_bias_off = true; in byt_cht_es8316_init()
180 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
191 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_cht_es8316_init()
203 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
205 clk_disable_unprepare(priv->mclk); in byt_cht_es8316_init()
207 ret = clk_set_rate(priv->mclk, 19200000); in byt_cht_es8316_init()
209 dev_err(card->dev, "unable to set MCLK rate\n"); in byt_cht_es8316_init()
211 ret = clk_prepare_enable(priv->mclk); in byt_cht_es8316_init()
213 dev_err(card->dev, "unable to enable MCLK\n"); in byt_cht_es8316_init()
218 dev_err(card->dev, "can't set codec clock %d\n", ret); in byt_cht_es8316_init()
222 ret = snd_soc_card_jack_new_pins(card, "Headset", in byt_cht_es8316_init()
224 &priv->jack, byt_cht_es8316_jack_pins, in byt_cht_es8316_init()
227 dev_err(card->dev, "jack creation failed %d\n", ret); in byt_cht_es8316_init()
231 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in byt_cht_es8316_init()
232 snd_soc_component_set_jack(codec, &priv->jack, NULL); in byt_cht_es8316_init()
247 rate->min = rate->max = 48000; in byt_cht_es8316_codec_fixup()
248 channels->min = channels->max = 2; in byt_cht_es8316_codec_fixup()
251 /* set SSP0 to 16-bit */ in byt_cht_es8316_codec_fixup()
255 /* set SSP2 to 24-bit */ in byt_cht_es8316_codec_fixup()
262 * with explicit setting to I2S 2ch 24-bit. The word length is set with in byt_cht_es8316_codec_fixup()
271 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in byt_cht_es8316_codec_fixup()
277 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in byt_cht_es8316_codec_fixup()
286 return snd_pcm_hw_constraint_single(substream->runtime, in byt_cht_es8316_aif1_startup()
298 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
301 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
304 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
306 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8316:00", "ES8316 HiFi")));
309 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
324 .name = "Deep-Buffer Audio Port",
325 .stream_name = "Deep-Buffer Audio",
335 .name = "SSP2-Codec",
352 static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */
354 static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */
361 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_suspend()
362 dev_dbg(component->dev, "disabling jack detect before suspend\n"); in byt_cht_es8316_suspend()
377 if (!strcmp(component->name, codec_name)) { in byt_cht_es8316_resume()
378 dev_dbg(component->dev, "re-enabling jack detect after resume\n"); in byt_cht_es8316_resume()
379 snd_soc_component_set_jack(component, &priv->jack, NULL); in byt_cht_es8316_resume()
387 * wrongly also set the speaker-enable GPIO to 1/0. Testing has shown in byt_cht_es8316_resume()
394 * is guaranteed to run after the touchscreen driver/ACPI-subsys has in byt_cht_es8316_resume()
401 gpiod_set_value_cansleep(priv->speaker_en_gpio, priv->speaker_en); in byt_cht_es8316_resume()
407 #define SOF_CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
410 #define CARD_NAME "bytcht-es8316"
431 { "speaker-enable-gpios", &first_gpio, 1 },
446 { /* Nanote UMPC-01 */
449 DMI_MATCH(DMI_PRODUCT_NAME, "UMPC-01"),
466 struct device *dev = &pdev->dev; in snd_byt_cht_es8316_mc_probe()
484 return -ENOMEM; in snd_byt_cht_es8316_mc_probe()
488 if (!strcmp(byt_cht_es8316_dais[i].codecs->name, in snd_byt_cht_es8316_mc_probe()
489 "i2c-ESSX8316:00")) { in snd_byt_cht_es8316_mc_probe()
496 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_cht_es8316_mc_probe()
499 "i2c-%s", acpi_dev_name(adev)); in snd_byt_cht_es8316_mc_probe()
500 put_device(&adev->dev); in snd_byt_cht_es8316_mc_probe()
501 byt_cht_es8316_dais[dai_index].codecs->name = codec_name; in snd_byt_cht_es8316_mc_probe()
503 dev_err(dev, "Error cannot find '%s' dev\n", mach->id); in snd_byt_cht_es8316_mc_probe()
504 return -ENXIO; in snd_byt_cht_es8316_mc_probe()
509 platform_name = mach->mach_params.platform; in snd_byt_cht_es8316_mc_probe()
519 quirk = (unsigned long)dmi_id->driver_data; in snd_byt_cht_es8316_mc_probe()
521 mach->mach_params.acpi_ipc_irq_index == 0) { in snd_byt_cht_es8316_mc_probe()
522 /* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */ in snd_byt_cht_es8316_mc_probe()
526 /* Others default to internal-mic-in1-map, mono-speaker */ in snd_byt_cht_es8316_mc_probe()
530 if (quirk_override != -1) { in snd_byt_cht_es8316_mc_probe()
538 byt_cht_es8316_dais[dai_index].cpus->dai_name = "ssp0-port"; in snd_byt_cht_es8316_mc_probe()
541 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_cht_es8316_mc_probe()
542 if (IS_ERR(priv->mclk)) in snd_byt_cht_es8316_mc_probe()
543 return dev_err_probe(dev, PTR_ERR(priv->mclk), "clk_get pmc_plt_clk_3 failed\n"); in snd_byt_cht_es8316_mc_probe()
547 return -EPROBE_DEFER; in snd_byt_cht_es8316_mc_probe()
548 priv->codec_dev = get_device(codec_dev); in snd_byt_cht_es8316_mc_probe()
551 props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); in snd_byt_cht_es8316_mc_probe()
572 priv->speaker_en_gpio = in snd_byt_cht_es8316_mc_probe()
573 gpiod_get_optional(codec_dev, "speaker-enable", in snd_byt_cht_es8316_mc_probe()
576 if (IS_ERR(priv->speaker_en_gpio)) { in snd_byt_cht_es8316_mc_probe()
577 ret = dev_err_probe(dev, PTR_ERR(priv->speaker_en_gpio), in snd_byt_cht_es8316_mc_probe()
583 "cfg-spk:%s cfg-mic:%s", in snd_byt_cht_es8316_mc_probe()
588 snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic", in snd_byt_cht_es8316_mc_probe()
607 dev->driver->pm = &snd_soc_pm_ops; in snd_byt_cht_es8316_mc_probe()
614 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_probe()
622 device_remove_software_node(priv->codec_dev); in snd_byt_cht_es8316_mc_probe()
623 put_device(priv->codec_dev); in snd_byt_cht_es8316_mc_probe()
632 gpiod_put(priv->speaker_en_gpio); in snd_byt_cht_es8316_mc_remove()
633 device_remove_software_node(priv->codec_dev); in snd_byt_cht_es8316_mc_remove()
634 put_device(priv->codec_dev); in snd_byt_cht_es8316_mc_remove()
648 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");