Lines Matching +full:dsp +full:- +full:aif1
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"
24 #include "../common/soc-intel-quirks.h"
29 #define CHT_CODEC_DAI "rt5670-aif1"
53 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
54 struct snd_soc_card *card = dapm->card; in platform_clock_control()
61 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); in platform_clock_control()
62 return -EIO; in platform_clock_control()
66 if (ctx->mclk) { in platform_clock_control()
67 ret = clk_prepare_enable(ctx->mclk); in platform_clock_control()
69 dev_err(card->dev, in platform_clock_control()
79 dev_err(card->dev, "can't set codec pll: %d\n", ret); in platform_clock_control()
87 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
99 dev_err(card->dev, "failed to set codec sysclk: %d\n", ret); in platform_clock_control()
103 if (ctx->mclk) in platform_clock_control()
104 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
137 {"AIF1 Playback", NULL, "ssp0 Tx"},
140 {"ssp0 Rx", NULL, "AIF1 Capture"},
144 {"AIF1 Playback", NULL, "ssp2 Tx"},
149 {"ssp2 Rx", NULL, "AIF1 Capture"},
170 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
179 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
188 { "headset-gpios", &headset_gpios, 1 },
196 struct snd_soc_component *component = codec_dai->component; in cht_codec_init()
197 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
199 if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) in cht_codec_init()
200 dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); in cht_codec_init()
216 if (ctx->use_ssp0) { in cht_codec_init()
217 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
221 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
228 ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", in cht_codec_init()
231 &ctx->headset, in cht_codec_init()
237 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in cht_codec_init()
238 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in cht_codec_init()
239 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in cht_codec_init()
241 rt5670_set_jack_detect(component, &ctx->headset); in cht_codec_init()
242 if (ctx->mclk) { in cht_codec_init()
253 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
255 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
257 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
260 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
270 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card); in cht_codec_fixup()
277 /* The DSP will convert the FE rate to 48k, stereo, 24bits */ in cht_codec_fixup()
278 rate->min = rate->max = 48000; in cht_codec_fixup()
279 channels->min = channels->max = 2; in cht_codec_fixup()
281 if (ctx->use_ssp0) { in cht_codec_fixup()
282 /* set SSP0 to 16-bit */ in cht_codec_fixup()
286 /* set SSP2 to 24-bit */ in cht_codec_fixup()
292 * The default mode for the cpu-dai is TDM 4 slot. The default mode in cht_codec_fixup()
293 * for the codec-dai is I2S. So we need to either set the cpu-dai to in cht_codec_fixup()
294 * I2S mode to match the codec-dai, or set the codec-dai to TDM 4 slot in cht_codec_fixup()
297 * to SSP2. The second piggy-backed, output-only codec is inside the in cht_codec_fixup()
298 * keyboard-dock (which has extra speakers). Unlike the main rt5672 in cht_codec_fixup()
302 * for TDM on any cht-bsw-rt5672 designs. So we use I2S 2ch everywhere. in cht_codec_fixup()
309 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
315 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in cht_codec_fixup()
324 return snd_pcm_hw_constraint_single(substream->runtime, in cht_aif1_startup()
340 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
343 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
346 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
348 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5670:00",
349 "rt5670-aif1")));
352 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
365 .name = "Deep-Buffer Audio Port",
366 .stream_name = "Deep-Buffer Audio",
376 /* SSP2 - Codec */
377 .name = "SSP2-Codec",
393 if (!strncmp(component->name, in cht_suspend_pre()
394 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_suspend_pre()
396 dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); in cht_suspend_pre()
410 if (!strncmp(component->name, in cht_resume_post()
411 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_resume_post()
413 dev_dbg(component->dev, "enabling jack detect for resume.\n"); in cht_resume_post()
423 #define SOF_CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
426 #define CARD_NAME "cht-bsw-rt5672"
444 #define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
450 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in snd_cht_mc_probe()
457 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
459 return -ENOMEM; in snd_cht_mc_probe()
461 strcpy(drv->codec_name, RT5672_I2C_DEFAULT); in snd_cht_mc_probe()
466 !strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) { in snd_cht_mc_probe()
473 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
475 snprintf(drv->codec_name, sizeof(drv->codec_name), in snd_cht_mc_probe()
476 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
477 cht_dailink[dai_index].codecs->name = drv->codec_name; in snd_cht_mc_probe()
479 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); in snd_cht_mc_probe()
480 return -ENOENT; in snd_cht_mc_probe()
486 if (soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0) { in snd_cht_mc_probe()
487 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
488 drv->use_ssp0 = true; in snd_cht_mc_probe()
492 snd_soc_card_cht.dev = &pdev->dev; in snd_cht_mc_probe()
493 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
502 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); in snd_cht_mc_probe()
503 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
504 dev_err(&pdev->dev, in snd_cht_mc_probe()
506 PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
507 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
511 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
524 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
527 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); in snd_cht_mc_probe()
529 dev_err(&pdev->dev, in snd_cht_mc_probe()
539 .name = "cht-bsw-rt5672",
549 MODULE_ALIAS("platform:cht-bsw-rt5672");