Lines Matching +full:asrc +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0-only
3 * cht_bsw_rt5672.c - ASoc Machine driver for Intel Cherryview-based platforms
22 #include <sound/soc-acpi.h>
24 #include "../atom/sst-atom-controls.h"
25 #include "../common/soc-intel-quirks.h"
30 #define CHT_CODEC_DAI "rt5670-aif1"
54 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
55 struct snd_soc_card *card = dapm->card; in platform_clock_control()
62 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); in platform_clock_control()
63 return -EIO; in platform_clock_control()
67 if (ctx->mclk) { in platform_clock_control()
68 ret = clk_prepare_enable(ctx->mclk); in platform_clock_control()
70 dev_err(card->dev, in platform_clock_control()
80 dev_err(card->dev, "can't set codec pll: %d\n", ret); in platform_clock_control()
88 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
100 dev_err(card->dev, "failed to set codec sysclk: %d\n", ret); in platform_clock_control()
104 if (ctx->mclk) in platform_clock_control()
105 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
171 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
180 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
189 { "headset-gpios", &headset_gpios, 1 },
197 struct snd_soc_component *component = codec_dai->component; in cht_codec_init()
198 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
200 if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) in cht_codec_init()
201 dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); in cht_codec_init()
203 /* Select codec ASRC clock source to track I2S1 clock, because codec in cht_codec_init()
205 * be supported by RT5672. Otherwise, ASRC will be disabled and cause in cht_codec_init()
217 if (ctx->use_ssp0) { in cht_codec_init()
218 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
222 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
229 ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", in cht_codec_init()
232 &ctx->headset, in cht_codec_init()
238 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in cht_codec_init()
239 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in cht_codec_init()
240 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in cht_codec_init()
242 rt5670_set_jack_detect(component, &ctx->headset); in cht_codec_init()
243 if (ctx->mclk) { in cht_codec_init()
248 * To change the rate we must disable the clock in cht_codec_init()
254 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
256 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
258 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
261 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
271 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card); in cht_codec_fixup()
272 struct snd_interval *rate = hw_param_interval(params, in cht_codec_fixup() local
278 /* The DSP will convert the FE rate to 48k, stereo, 24bits */ in cht_codec_fixup()
279 rate->min = rate->max = 48000; in cht_codec_fixup()
280 channels->min = channels->max = 2; in cht_codec_fixup()
282 if (ctx->use_ssp0) { in cht_codec_fixup()
283 /* set SSP0 to 16-bit */ in cht_codec_fixup()
287 /* set SSP2 to 24-bit */ in cht_codec_fixup()
293 * The default mode for the cpu-dai is TDM 4 slot. The default mode in cht_codec_fixup()
294 * for the codec-dai is I2S. So we need to either set the cpu-dai to in cht_codec_fixup()
295 * I2S mode to match the codec-dai, or set the codec-dai to TDM 4 slot in cht_codec_fixup()
298 * to SSP2. The second piggy-backed, output-only codec is inside the in cht_codec_fixup()
299 * keyboard-dock (which has extra speakers). Unlike the main rt5672 in cht_codec_fixup()
303 * for TDM on any cht-bsw-rt5672 designs. So we use I2S 2ch everywhere. in cht_codec_fixup()
310 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
316 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in cht_codec_fixup()
325 return snd_pcm_hw_constraint_single(substream->runtime, in cht_aif1_startup()
341 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
344 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
347 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
349 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5670:00",
350 "rt5670-aif1")));
353 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
366 .name = "Deep-Buffer Audio Port",
367 .stream_name = "Deep-Buffer Audio",
377 /* SSP2 - Codec */
378 .name = "SSP2-Codec",
394 if (!strncmp(component->name, in cht_suspend_pre()
395 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_suspend_pre()
397 dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); in cht_suspend_pre()
411 if (!strncmp(component->name, in cht_resume_post()
412 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_resume_post()
414 dev_dbg(component->dev, "enabling jack detect for resume.\n"); in cht_resume_post()
424 #define SOF_CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
427 #define CARD_NAME "cht-bsw-rt5672"
445 #define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
451 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in snd_cht_mc_probe()
458 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
460 return -ENOMEM; in snd_cht_mc_probe()
462 strscpy(drv->codec_name, RT5672_I2C_DEFAULT, sizeof(drv->codec_name)); in snd_cht_mc_probe()
467 !strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) { in snd_cht_mc_probe()
474 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
476 snprintf(drv->codec_name, sizeof(drv->codec_name), in snd_cht_mc_probe()
477 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
478 cht_dailink[dai_index].codecs->name = drv->codec_name; in snd_cht_mc_probe()
480 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); in snd_cht_mc_probe()
481 return -ENOENT; in snd_cht_mc_probe()
487 if (soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0) { in snd_cht_mc_probe()
488 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
489 drv->use_ssp0 = true; in snd_cht_mc_probe()
493 snd_soc_card_cht.dev = &pdev->dev; in snd_cht_mc_probe()
494 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
503 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); in snd_cht_mc_probe()
504 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
505 dev_err(&pdev->dev, in snd_cht_mc_probe()
507 PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
508 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
512 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
525 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
528 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); in snd_cht_mc_probe()
530 dev_err(&pdev->dev, in snd_cht_mc_probe()
540 .name = "cht-bsw-rt5672",
550 MODULE_ALIAS("platform:cht-bsw-rt5672");