Lines Matching +full:event +full:- +full:deep

1 // SPDX-License-Identifier: GPL-2.0-only
3 * cht_bsw_rt5672.c - ASoc Machine driver for Intel Cherryview-based platforms
21 #include <sound/soc-acpi.h>
23 #include "../atom/sst-atom-controls.h"
28 #define CHT_CODEC_DAI "rt5670-aif1"
49 struct snd_kcontrol *k, int event) in platform_clock_control() argument
51 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
52 struct snd_soc_card *card = dapm->card; in platform_clock_control()
59 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); in platform_clock_control()
60 return -EIO; in platform_clock_control()
63 if (SND_SOC_DAPM_EVENT_ON(event)) { in platform_clock_control()
64 if (ctx->mclk) { in platform_clock_control()
65 ret = clk_prepare_enable(ctx->mclk); in platform_clock_control()
67 dev_err(card->dev, in platform_clock_control()
77 dev_err(card->dev, "can't set codec pll: %d\n", ret); in platform_clock_control()
85 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
97 if (ctx->mclk) in platform_clock_control()
98 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
154 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
163 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
172 { "headset-gpios", &headset_gpios, 1 },
180 struct snd_soc_component *component = codec_dai->component; in cht_codec_init()
181 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
183 if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) in cht_codec_init()
184 dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); in cht_codec_init()
200 ret = snd_soc_card_jack_new(runtime->card, "Headset", in cht_codec_init()
203 &ctx->headset, in cht_codec_init()
209 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in cht_codec_init()
210 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in cht_codec_init()
211 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in cht_codec_init()
213 rt5670_set_jack_detect(component, &ctx->headset); in cht_codec_init()
214 if (ctx->mclk) { in cht_codec_init()
225 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
227 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
229 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
232 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
249 rate->min = rate->max = 48000; in cht_codec_fixup()
250 channels->min = channels->max = 2; in cht_codec_fixup()
252 /* set SSP2 to 24-bit */ in cht_codec_fixup()
256 * The default mode for the cpu-dai is TDM 4 slot. The default mode in cht_codec_fixup()
257 * for the codec-dai is I2S. So we need to either set the cpu-dai to in cht_codec_fixup()
258 * I2S mode to match the codec-dai, or set the codec-dai to TDM 4 slot in cht_codec_fixup()
261 * to SSP2. The second piggy-backed, output-only codec is inside the in cht_codec_fixup()
262 * keyboard-dock (which has extra speakers). Unlike the main rt5672 in cht_codec_fixup()
266 * for TDM on any cht-bsw-rt5672 designs. So we use I2S 2ch everywhere. in cht_codec_fixup()
273 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
282 return snd_pcm_hw_constraint_single(substream->runtime, in cht_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-10EC5670:00",
307 "rt5670-aif1")));
310 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
325 .name = "Deep-Buffer Audio Port",
326 .stream_name = "Deep-Buffer Audio",
336 /* SSP2 - Codec */
337 .name = "SSP2-Codec",
356 if (!strncmp(component->name, in cht_suspend_pre()
357 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_suspend_pre()
359 dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); in cht_suspend_pre()
373 if (!strncmp(component->name, in cht_resume_post()
374 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_resume_post()
376 dev_dbg(component->dev, "enabling jack detect for resume.\n"); in cht_resume_post()
387 #define CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
390 #define CARD_NAME "cht-bsw-rt5672"
411 #define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
417 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in snd_cht_mc_probe()
422 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
424 return -ENOMEM; in snd_cht_mc_probe()
426 strcpy(drv->codec_name, RT5672_I2C_DEFAULT); in snd_cht_mc_probe()
429 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
431 snprintf(drv->codec_name, sizeof(drv->codec_name), in snd_cht_mc_probe()
432 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
433 put_device(&adev->dev); in snd_cht_mc_probe()
435 if (!strcmp(cht_dailink[i].codecs->name, in snd_cht_mc_probe()
437 cht_dailink[i].codecs->name = drv->codec_name; in snd_cht_mc_probe()
444 snd_soc_card_cht.dev = &pdev->dev; in snd_cht_mc_probe()
445 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
452 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); in snd_cht_mc_probe()
453 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
454 dev_err(&pdev->dev, in snd_cht_mc_probe()
456 PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
457 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
462 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); in snd_cht_mc_probe()
464 dev_err(&pdev->dev, in snd_cht_mc_probe()
474 .name = "cht-bsw-rt5672",
487 MODULE_ALIAS("platform:cht-bsw-rt5672");