1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2021 Advanced Micro Devices, Inc.
7 //
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9 //	    Vijendar Mukunda <Vijendar.Mukunda@amd.com>
10 //
11 
12 /*
13  * Machine Driver Interface for ACP HW block
14  */
15 
16 #include <sound/core.h>
17 #include <sound/jack.h>
18 #include <sound/pcm_params.h>
19 #include <sound/soc-dapm.h>
20 #include <sound/soc.h>
21 #include <linux/input.h>
22 #include <linux/module.h>
23 
24 #include "../../codecs/rt5682.h"
25 #include "../../codecs/rt1019.h"
26 #include "../../codecs/rt5682s.h"
27 #include "../../codecs/nau8825.h"
28 #include "../../codecs/nau8821.h"
29 #include "acp-mach.h"
30 
31 #define PCO_PLAT_CLK 48000000
32 #define RT5682_PLL_FREQ (48000 * 512)
33 #define DUAL_CHANNEL	2
34 #define FOUR_CHANNEL	4
35 #define NAU8821_CODEC_DAI	"nau8821-hifi"
36 #define NAU8821_BCLK		1536000
37 #define NAU8821_FREQ_OUT	12288000
38 #define MAX98388_CODEC_DAI	"max98388-aif1"
39 
40 #define TDM_MODE_ENABLE 1
41 
42 const struct dmi_system_id acp_quirk_table[] = {
43 	{
44 		/* Google skyrim proto-0 */
45 		.matches = {
46 			DMI_EXACT_MATCH(DMI_PRODUCT_FAMILY, "Google_Skyrim"),
47 		},
48 		.driver_data = (void *)TDM_MODE_ENABLE,
49 	},
50 	{}
51 };
52 EXPORT_SYMBOL_GPL(acp_quirk_table);
53 
54 static const unsigned int channels[] = {
55 	DUAL_CHANNEL,
56 };
57 
58 static const unsigned int rates[] = {
59 	48000,
60 };
61 
62 static const struct snd_pcm_hw_constraint_list constraints_rates = {
63 	.count = ARRAY_SIZE(rates),
64 	.list  = rates,
65 	.mask = 0,
66 };
67 
68 static const struct snd_pcm_hw_constraint_list constraints_channels = {
69 	.count = ARRAY_SIZE(channels),
70 	.list = channels,
71 	.mask = 0,
72 };
73 
74 static int acp_clk_enable(struct acp_card_drvdata *drvdata,
75 			  unsigned int srate, unsigned int bclk_ratio)
76 {
77 	clk_set_rate(drvdata->wclk, srate);
78 	clk_set_rate(drvdata->bclk, srate * bclk_ratio);
79 
80 	return clk_prepare_enable(drvdata->wclk);
81 }
82 
83 /* Declare RT5682 codec components */
84 SND_SOC_DAILINK_DEF(rt5682,
85 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", "rt5682-aif1")));
86 
87 static struct snd_soc_jack rt5682_jack;
88 static struct snd_soc_jack_pin rt5682_jack_pins[] = {
89 	{
90 		.pin = "Headphone Jack",
91 		.mask = SND_JACK_HEADPHONE,
92 	},
93 	{
94 		.pin = "Headset Mic",
95 		.mask = SND_JACK_MICROPHONE,
96 	},
97 };
98 
99 static const struct snd_kcontrol_new rt5682_controls[] = {
100 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
101 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
102 };
103 
104 static const struct snd_soc_dapm_widget rt5682_widgets[] = {
105 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
106 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
107 };
108 
109 static const struct snd_soc_dapm_route rt5682_map[] = {
110 	{ "Headphone Jack", NULL, "HPOL" },
111 	{ "Headphone Jack", NULL, "HPOR" },
112 	{ "IN1P", NULL, "Headset Mic" },
113 };
114 
115 /* Define card ops for RT5682 CODEC */
116 static int acp_card_rt5682_init(struct snd_soc_pcm_runtime *rtd)
117 {
118 	struct snd_soc_card *card = rtd->card;
119 	struct acp_card_drvdata *drvdata = card->drvdata;
120 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
121 	struct snd_soc_component *component = codec_dai->component;
122 	int ret;
123 
124 	dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
125 
126 	if (drvdata->hs_codec_id != RT5682)
127 		return -EINVAL;
128 
129 	drvdata->wclk = clk_get(component->dev, "rt5682-dai-wclk");
130 	drvdata->bclk = clk_get(component->dev, "rt5682-dai-bclk");
131 
132 	ret = snd_soc_dapm_new_controls(&card->dapm, rt5682_widgets,
133 					ARRAY_SIZE(rt5682_widgets));
134 	if (ret) {
135 		dev_err(rtd->dev, "unable to add widget dapm controls, ret %d\n", ret);
136 		return ret;
137 	}
138 
139 	ret = snd_soc_add_card_controls(card, rt5682_controls,
140 					ARRAY_SIZE(rt5682_controls));
141 	if (ret) {
142 		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
143 		return ret;
144 	}
145 
146 	ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
147 					 SND_JACK_HEADSET | SND_JACK_LINEOUT |
148 					 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
149 					 SND_JACK_BTN_2 | SND_JACK_BTN_3,
150 					 &rt5682_jack,
151 					 rt5682_jack_pins,
152 					 ARRAY_SIZE(rt5682_jack_pins));
153 	if (ret) {
154 		dev_err(card->dev, "HP jack creation failed %d\n", ret);
155 		return ret;
156 	}
157 
158 	snd_jack_set_key(rt5682_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
159 	snd_jack_set_key(rt5682_jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
160 	snd_jack_set_key(rt5682_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
161 	snd_jack_set_key(rt5682_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
162 
163 	ret = snd_soc_component_set_jack(component, &rt5682_jack, NULL);
164 	if (ret) {
165 		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
166 		return ret;
167 	}
168 
169 	return snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map));
170 }
171 
172 static int acp_card_hs_startup(struct snd_pcm_substream *substream)
173 {
174 	struct snd_pcm_runtime *runtime = substream->runtime;
175 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
176 	struct snd_soc_card *card = rtd->card;
177 	struct acp_card_drvdata *drvdata = card->drvdata;
178 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
179 	int ret;
180 	unsigned int fmt;
181 
182 	if (drvdata->tdm_mode)
183 		fmt = SND_SOC_DAIFMT_DSP_A;
184 	else
185 		fmt = SND_SOC_DAIFMT_I2S;
186 
187 	if (drvdata->soc_mclk)
188 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
189 	else
190 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
191 
192 	ret =  snd_soc_dai_set_fmt(codec_dai, fmt);
193 	if (ret < 0) {
194 		dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
195 		return ret;
196 	}
197 
198 	runtime->hw.channels_max = DUAL_CHANNEL;
199 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
200 				      &constraints_channels);
201 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
202 				      &constraints_rates);
203 
204 	return ret;
205 }
206 
207 static void acp_card_shutdown(struct snd_pcm_substream *substream)
208 {
209 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
210 	struct snd_soc_card *card = rtd->card;
211 	struct acp_card_drvdata *drvdata = card->drvdata;
212 
213 	if (!drvdata->soc_mclk)
214 		clk_disable_unprepare(drvdata->wclk);
215 }
216 
217 static int acp_card_rt5682_hw_params(struct snd_pcm_substream *substream,
218 				      struct snd_pcm_hw_params *params)
219 {
220 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
221 	struct snd_soc_card *card = rtd->card;
222 	struct acp_card_drvdata *drvdata = card->drvdata;
223 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
224 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
225 	int ret;
226 	unsigned int fmt, srate, ch, format;
227 
228 	srate = params_rate(params);
229 	ch = params_channels(params);
230 	format = params_physical_width(params);
231 
232 	if (drvdata->tdm_mode)
233 		fmt = SND_SOC_DAIFMT_DSP_A;
234 	else
235 		fmt = SND_SOC_DAIFMT_I2S;
236 
237 	if (drvdata->soc_mclk)
238 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
239 	else
240 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
241 
242 	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
243 	if (ret && ret != -ENOTSUPP) {
244 		dev_err(rtd->dev, "Failed to set dai fmt: %d\n", ret);
245 		return ret;
246 	}
247 
248 	ret =  snd_soc_dai_set_fmt(codec_dai, fmt);
249 	if (ret < 0) {
250 		dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
251 		return ret;
252 	}
253 
254 	if (drvdata->tdm_mode) {
255 		/**
256 		 * As codec supports slot 0 and slot 1 for playback and capture.
257 		 */
258 		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 8, 16);
259 		if (ret && ret != -ENOTSUPP) {
260 			dev_err(rtd->dev, "set TDM slot err: %d\n", ret);
261 			return ret;
262 		}
263 
264 		ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 8, 16);
265 		if (ret < 0) {
266 			dev_warn(rtd->dev, "set TDM slot err:%d\n", ret);
267 			return ret;
268 		}
269 	}
270 
271 	ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL2, RT5682_PLL2_S_MCLK,
272 				  PCO_PLAT_CLK, RT5682_PLL_FREQ);
273 	if (ret < 0) {
274 		dev_err(rtd->dev, "Failed to set codec PLL: %d\n", ret);
275 		return ret;
276 	}
277 
278 	ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL2,
279 				     RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
280 	if (ret < 0) {
281 		dev_err(rtd->dev, "Failed to set codec SYSCLK: %d\n", ret);
282 		return ret;
283 	}
284 
285 	/* Set tdm/i2s1 master bclk ratio */
286 	ret = snd_soc_dai_set_bclk_ratio(codec_dai, ch * format);
287 	if (ret < 0) {
288 		dev_err(rtd->dev, "Failed to set rt5682 tdm bclk ratio: %d\n", ret);
289 		return ret;
290 	}
291 
292 	if (!drvdata->soc_mclk) {
293 		ret = acp_clk_enable(drvdata, srate, ch * format);
294 		if (ret < 0) {
295 			dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret);
296 			return ret;
297 		}
298 	}
299 
300 	return 0;
301 }
302 
303 static const struct snd_soc_ops acp_card_rt5682_ops = {
304 	.startup = acp_card_hs_startup,
305 	.shutdown = acp_card_shutdown,
306 	.hw_params = acp_card_rt5682_hw_params,
307 };
308 
309 /* Define RT5682S CODEC component*/
310 SND_SOC_DAILINK_DEF(rt5682s,
311 		    DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RTL5682:00", "rt5682s-aif1")));
312 
313 static struct snd_soc_jack rt5682s_jack;
314 static struct snd_soc_jack_pin rt5682s_jack_pins[] = {
315 	{
316 		.pin = "Headphone Jack",
317 		.mask = SND_JACK_HEADPHONE,
318 	},
319 	{
320 		.pin = "Headset Mic",
321 		.mask = SND_JACK_MICROPHONE,
322 	},
323 };
324 
325 static const struct snd_kcontrol_new rt5682s_controls[] = {
326 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
327 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
328 };
329 
330 static const struct snd_soc_dapm_widget rt5682s_widgets[] = {
331 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
332 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
333 };
334 
335 static const struct snd_soc_dapm_route rt5682s_map[] = {
336 	{ "Headphone Jack", NULL, "HPOL" },
337 	{ "Headphone Jack", NULL, "HPOR" },
338 	{ "IN1P", NULL, "Headset Mic" },
339 };
340 
341 static int acp_card_rt5682s_init(struct snd_soc_pcm_runtime *rtd)
342 {
343 	struct snd_soc_card *card = rtd->card;
344 	struct acp_card_drvdata *drvdata = card->drvdata;
345 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
346 	struct snd_soc_component *component = codec_dai->component;
347 	int ret;
348 
349 	dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
350 
351 	if (drvdata->hs_codec_id != RT5682S)
352 		return -EINVAL;
353 
354 	if (!drvdata->soc_mclk) {
355 		drvdata->wclk = clk_get(component->dev, "rt5682-dai-wclk");
356 		drvdata->bclk = clk_get(component->dev, "rt5682-dai-bclk");
357 	}
358 
359 	ret = snd_soc_dapm_new_controls(&card->dapm, rt5682s_widgets,
360 					ARRAY_SIZE(rt5682s_widgets));
361 	if (ret) {
362 		dev_err(rtd->dev, "unable to add widget dapm controls, ret %d\n", ret);
363 		return ret;
364 	}
365 
366 	ret = snd_soc_add_card_controls(card, rt5682s_controls,
367 					ARRAY_SIZE(rt5682s_controls));
368 	if (ret) {
369 		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
370 		return ret;
371 	}
372 
373 	ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
374 					 SND_JACK_HEADSET | SND_JACK_LINEOUT |
375 					 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
376 					 SND_JACK_BTN_2 | SND_JACK_BTN_3,
377 					 &rt5682s_jack,
378 					 rt5682s_jack_pins,
379 					 ARRAY_SIZE(rt5682s_jack_pins));
380 	if (ret) {
381 		dev_err(card->dev, "HP jack creation failed %d\n", ret);
382 		return ret;
383 	}
384 
385 	snd_jack_set_key(rt5682s_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
386 	snd_jack_set_key(rt5682s_jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
387 	snd_jack_set_key(rt5682s_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
388 	snd_jack_set_key(rt5682s_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
389 
390 	ret = snd_soc_component_set_jack(component, &rt5682s_jack, NULL);
391 	if (ret) {
392 		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
393 		return ret;
394 	}
395 
396 	return snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682s_map, ARRAY_SIZE(rt5682s_map));
397 }
398 
399 static int acp_card_rt5682s_hw_params(struct snd_pcm_substream *substream,
400 				      struct snd_pcm_hw_params *params)
401 {
402 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
403 	struct snd_soc_card *card = rtd->card;
404 	struct acp_card_drvdata *drvdata = card->drvdata;
405 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
406 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
407 	int ret;
408 	unsigned int fmt, srate, ch, format;
409 
410 	srate = params_rate(params);
411 	ch = params_channels(params);
412 	format = params_physical_width(params);
413 
414 	if (drvdata->tdm_mode)
415 		fmt = SND_SOC_DAIFMT_DSP_A;
416 	else
417 		fmt = SND_SOC_DAIFMT_I2S;
418 
419 	if (drvdata->soc_mclk)
420 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
421 	else
422 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
423 
424 	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
425 	if (ret && ret != -ENOTSUPP) {
426 		dev_err(rtd->dev, "Failed to set dai fmt: %d\n", ret);
427 		return ret;
428 	}
429 
430 	ret =  snd_soc_dai_set_fmt(codec_dai, fmt);
431 	if (ret < 0) {
432 		dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
433 		return ret;
434 	}
435 
436 	if (drvdata->tdm_mode) {
437 		/**
438 		 * As codec supports slot 0 and slot 1 for playback and capture.
439 		 */
440 		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 8, 16);
441 		if (ret && ret != -ENOTSUPP) {
442 			dev_err(rtd->dev, "set TDM slot err: %d\n", ret);
443 			return ret;
444 		}
445 
446 		ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 8, 16);
447 		if (ret < 0) {
448 			dev_warn(rtd->dev, "set TDM slot err:%d\n", ret);
449 			return ret;
450 		}
451 	}
452 
453 	ret = snd_soc_dai_set_pll(codec_dai, RT5682S_PLL2, RT5682S_PLL_S_MCLK,
454 				  PCO_PLAT_CLK, RT5682_PLL_FREQ);
455 	if (ret < 0) {
456 		dev_err(rtd->dev, "Failed to set codec PLL: %d\n", ret);
457 		return ret;
458 	}
459 
460 	ret = snd_soc_dai_set_sysclk(codec_dai, RT5682S_SCLK_S_PLL2,
461 				     RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
462 	if (ret < 0) {
463 		dev_err(rtd->dev, "Failed to set codec SYSCLK: %d\n", ret);
464 		return ret;
465 	}
466 
467 	/* Set tdm/i2s1 master bclk ratio */
468 	ret = snd_soc_dai_set_bclk_ratio(codec_dai, ch * format);
469 	if (ret < 0) {
470 		dev_err(rtd->dev, "Failed to set rt5682 tdm bclk ratio: %d\n", ret);
471 		return ret;
472 	}
473 
474 	clk_set_rate(drvdata->wclk, srate);
475 	clk_set_rate(drvdata->bclk, srate * ch * format);
476 
477 	return 0;
478 }
479 
480 static const struct snd_soc_ops acp_card_rt5682s_ops = {
481 	.startup = acp_card_hs_startup,
482 	.hw_params = acp_card_rt5682s_hw_params,
483 };
484 
485 static const unsigned int dmic_channels[] = {
486 	DUAL_CHANNEL, FOUR_CHANNEL,
487 };
488 
489 static const struct snd_pcm_hw_constraint_list dmic_constraints_channels = {
490 	.count = ARRAY_SIZE(dmic_channels),
491 	.list = dmic_channels,
492 	.mask = 0,
493 };
494 
495 static int acp_card_dmic_startup(struct snd_pcm_substream *substream)
496 {
497 	struct snd_pcm_runtime *runtime = substream->runtime;
498 
499 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
500 				   &dmic_constraints_channels);
501 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
502 				   &constraints_rates);
503 
504 	return 0;
505 }
506 
507 static const struct snd_soc_ops acp_card_dmic_ops = {
508 	.startup = acp_card_dmic_startup,
509 };
510 
511 /* Declare RT1019 codec components */
512 SND_SOC_DAILINK_DEF(rt1019,
513 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC1019:00", "rt1019-aif"),
514 			  COMP_CODEC("i2c-10EC1019:01", "rt1019-aif")));
515 
516 static const struct snd_soc_dapm_route rt1019_map_lr[] = {
517 	{ "Left Spk", NULL, "Left SPO" },
518 	{ "Right Spk", NULL, "Right SPO" },
519 };
520 
521 static struct snd_soc_codec_conf rt1019_conf[] = {
522 	{
523 		 .dlc = COMP_CODEC_CONF("i2c-10EC1019:01"),
524 		 .name_prefix = "Left",
525 	},
526 	{
527 		 .dlc = COMP_CODEC_CONF("i2c-10EC1019:00"),
528 		 .name_prefix = "Right",
529 	},
530 };
531 
532 static int acp_card_rt1019_init(struct snd_soc_pcm_runtime *rtd)
533 {
534 	struct snd_soc_card *card = rtd->card;
535 	struct acp_card_drvdata *drvdata = card->drvdata;
536 
537 	if (drvdata->amp_codec_id != RT1019)
538 		return -EINVAL;
539 
540 	return snd_soc_dapm_add_routes(&rtd->card->dapm, rt1019_map_lr,
541 				       ARRAY_SIZE(rt1019_map_lr));
542 }
543 
544 static int acp_card_rt1019_hw_params(struct snd_pcm_substream *substream,
545 				     struct snd_pcm_hw_params *params)
546 {
547 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
548 	struct snd_soc_card *card = rtd->card;
549 	struct acp_card_drvdata *drvdata = card->drvdata;
550 	struct snd_soc_dai *codec_dai;
551 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
552 	int i, ret = 0;
553 	unsigned int fmt, srate, ch, format;
554 
555 	srate = params_rate(params);
556 	ch = params_channels(params);
557 	format = params_physical_width(params);
558 
559 	if (drvdata->amp_codec_id != RT1019)
560 		return -EINVAL;
561 
562 	if (drvdata->tdm_mode)
563 		fmt = SND_SOC_DAIFMT_DSP_A;
564 	else
565 		fmt = SND_SOC_DAIFMT_I2S;
566 
567 	if (drvdata->soc_mclk)
568 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
569 	else
570 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
571 
572 	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
573 	if (ret && ret != -ENOTSUPP) {
574 		dev_err(rtd->dev, "Failed to set dai fmt: %d\n", ret);
575 		return ret;
576 	}
577 
578 	if (drvdata->tdm_mode) {
579 		/**
580 		 * As codec supports slot 2 and slot 3 for playback.
581 		 */
582 		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xC, 0, 8, 16);
583 		if (ret && ret != -ENOTSUPP) {
584 			dev_err(rtd->dev, "set TDM slot err: %d\n", ret);
585 			return ret;
586 		}
587 	}
588 
589 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
590 		if (strcmp(codec_dai->name, "rt1019-aif"))
591 			continue;
592 
593 		if (drvdata->tdm_mode)
594 			ret = snd_soc_dai_set_pll(codec_dai, 0, RT1019_PLL_S_BCLK,
595 						  TDM_CHANNELS * format * srate, 256 * srate);
596 		else
597 			ret = snd_soc_dai_set_pll(codec_dai, 0, RT1019_PLL_S_BCLK,
598 						  ch * format * srate, 256 * srate);
599 
600 		if (ret < 0)
601 			return ret;
602 
603 		ret = snd_soc_dai_set_sysclk(codec_dai, RT1019_SCLK_S_PLL,
604 					     256 * srate, SND_SOC_CLOCK_IN);
605 		if (ret < 0)
606 			return ret;
607 
608 		if (drvdata->tdm_mode) {
609 			ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A
610 							| SND_SOC_DAIFMT_NB_NF);
611 			if (ret < 0) {
612 				dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
613 				return ret;
614 			}
615 
616 			/**
617 			 * As codec supports slot 2 for left channel playback.
618 			 */
619 			if (!strcmp(codec_dai->component->name, "i2c-10EC1019:00")) {
620 				ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x4, 0x4, 8, 16);
621 				if (ret < 0)
622 					break;
623 			}
624 
625 			/**
626 			 * As codec supports slot 3 for right channel playback.
627 			 */
628 			if (!strcmp(codec_dai->component->name, "i2c-10EC1019:01")) {
629 				ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x8, 0x8, 8, 16);
630 				if (ret < 0)
631 					break;
632 			}
633 		}
634 	}
635 
636 	if (!drvdata->soc_mclk) {
637 		ret = acp_clk_enable(drvdata, srate, ch * format);
638 		if (ret < 0) {
639 			dev_err(rtd->card->dev, "Failed to enable AMP clk: %d\n", ret);
640 			return ret;
641 		}
642 	}
643 
644 	return 0;
645 }
646 
647 static int acp_card_amp_startup(struct snd_pcm_substream *substream)
648 {
649 	struct snd_pcm_runtime *runtime = substream->runtime;
650 
651 	runtime->hw.channels_max = DUAL_CHANNEL;
652 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
653 				      &constraints_channels);
654 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
655 				      &constraints_rates);
656 
657 	return 0;
658 }
659 
660 static const struct snd_soc_ops acp_card_rt1019_ops = {
661 	.startup = acp_card_amp_startup,
662 	.shutdown = acp_card_shutdown,
663 	.hw_params = acp_card_rt1019_hw_params,
664 };
665 
666 /* Declare Maxim codec components */
667 SND_SOC_DAILINK_DEF(max98360a,
668 	DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi")));
669 
670 static const struct snd_soc_dapm_route max98360a_map[] = {
671 	{"Spk", NULL, "Speaker"},
672 };
673 
674 static int acp_card_maxim_init(struct snd_soc_pcm_runtime *rtd)
675 {
676 	struct snd_soc_card *card = rtd->card;
677 	struct acp_card_drvdata *drvdata = card->drvdata;
678 
679 	if (drvdata->amp_codec_id != MAX98360A)
680 		return -EINVAL;
681 
682 	return snd_soc_dapm_add_routes(&rtd->card->dapm, max98360a_map,
683 				       ARRAY_SIZE(max98360a_map));
684 }
685 
686 static int acp_card_maxim_hw_params(struct snd_pcm_substream *substream,
687 				    struct snd_pcm_hw_params *params)
688 {
689 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
690 	struct snd_soc_card *card = rtd->card;
691 	struct acp_card_drvdata *drvdata = card->drvdata;
692 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
693 	unsigned int fmt, srate, ch, format;
694 	int ret;
695 
696 	srate = params_rate(params);
697 	ch = params_channels(params);
698 	format = params_physical_width(params);
699 
700 	if (drvdata->tdm_mode)
701 		fmt = SND_SOC_DAIFMT_DSP_A;
702 	else
703 		fmt = SND_SOC_DAIFMT_I2S;
704 
705 	if (drvdata->soc_mclk)
706 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
707 	else
708 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
709 
710 	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
711 	if (ret && ret != -ENOTSUPP) {
712 		dev_err(rtd->dev, "Failed to set dai fmt: %d\n", ret);
713 		return ret;
714 	}
715 
716 	if (drvdata->tdm_mode) {
717 		/**
718 		 * As codec supports slot 2 and slot 3 for playback.
719 		 */
720 		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xC, 0, 8, 16);
721 		if (ret && ret != -ENOTSUPP) {
722 			dev_err(rtd->dev, "set TDM slot err: %d\n", ret);
723 			return ret;
724 		}
725 	}
726 
727 	if (!drvdata->soc_mclk) {
728 		ret = acp_clk_enable(drvdata, srate, ch * format);
729 		if (ret < 0) {
730 			dev_err(rtd->card->dev, "Failed to enable AMP clk: %d\n", ret);
731 			return ret;
732 		}
733 	}
734 	return 0;
735 }
736 
737 static const struct snd_soc_ops acp_card_maxim_ops = {
738 	.startup = acp_card_amp_startup,
739 	.shutdown = acp_card_shutdown,
740 	.hw_params = acp_card_maxim_hw_params,
741 };
742 
743 SND_SOC_DAILINK_DEF(max98388,
744 		    DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ADS8388:00", "max98388-aif1"),
745 				       COMP_CODEC("i2c-ADS8388:01", "max98388-aif1")));
746 
747 static const struct snd_soc_dapm_widget max98388_widgets[] = {
748 	SND_SOC_DAPM_SPK("SPK", NULL),
749 };
750 
751 static const struct snd_soc_dapm_route max98388_map[] = {
752 	{ "SPK", NULL, "Left BE_OUT" },
753 	{ "SPK", NULL, "Right BE_OUT" },
754 };
755 
756 static struct snd_soc_codec_conf max98388_conf[] = {
757 	{
758 		.dlc = COMP_CODEC_CONF("i2c-ADS8388:00"),
759 		.name_prefix = "Left",
760 	},
761 	{
762 		.dlc = COMP_CODEC_CONF("i2c-ADS8388:01"),
763 		.name_prefix = "Right",
764 	},
765 };
766 
767 static const unsigned int max98388_format[] = {16};
768 
769 static struct snd_pcm_hw_constraint_list constraints_sample_bits_max = {
770 	.list = max98388_format,
771 	.count = ARRAY_SIZE(max98388_format),
772 };
773 
774 static int acp_card_max98388_startup(struct snd_pcm_substream *substream)
775 {
776 	struct snd_pcm_runtime *runtime = substream->runtime;
777 
778 	runtime->hw.channels_max = DUAL_CHANNEL;
779 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
780 				   &constraints_channels);
781 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
782 				   &constraints_rates);
783 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
784 				   &constraints_sample_bits_max);
785 
786 	return 0;
787 }
788 
789 static int acp_card_max98388_init(struct snd_soc_pcm_runtime *rtd)
790 {
791 	struct snd_soc_card *card = rtd->card;
792 	struct acp_card_drvdata *drvdata = card->drvdata;
793 	int ret;
794 
795 	if (drvdata->amp_codec_id != MAX98388)
796 		return -EINVAL;
797 
798 	ret = snd_soc_dapm_new_controls(&card->dapm, max98388_widgets,
799 					ARRAY_SIZE(max98388_widgets));
800 
801 	if (ret) {
802 		dev_err(rtd->dev, "unable to add widget dapm controls, ret %d\n", ret);
803 		/* Don't need to add routes if widget addition failed */
804 		return ret;
805 	}
806 	return snd_soc_dapm_add_routes(&rtd->card->dapm, max98388_map,
807 				       ARRAY_SIZE(max98388_map));
808 }
809 
810 static int acp_max98388_hw_params(struct snd_pcm_substream *substream,
811 				  struct snd_pcm_hw_params *params)
812 {
813 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
814 	struct snd_soc_card *card = rtd->card;
815 	struct snd_soc_dai *codec_dai =
816 			snd_soc_card_get_codec_dai(card,
817 						   MAX98388_CODEC_DAI);
818 	int ret;
819 
820 	ret = snd_soc_dai_set_fmt(codec_dai,
821 				  SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S |
822 				  SND_SOC_DAIFMT_NB_NF);
823 	if (ret < 0)
824 		return ret;
825 
826 	return ret;
827 }
828 
829 static const struct snd_soc_ops acp_max98388_ops = {
830 	.startup = acp_card_max98388_startup,
831 	.hw_params = acp_max98388_hw_params,
832 };
833 
834 /* Declare nau8825 codec components */
835 SND_SOC_DAILINK_DEF(nau8825,
836 		    DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10508825:00", "nau8825-hifi")));
837 
838 static struct snd_soc_jack nau8825_jack;
839 static struct snd_soc_jack_pin nau8825_jack_pins[] = {
840 	{
841 		.pin = "Headphone Jack",
842 		.mask = SND_JACK_HEADPHONE,
843 	},
844 	{
845 		.pin = "Headset Mic",
846 		.mask = SND_JACK_MICROPHONE,
847 	},
848 };
849 
850 static const struct snd_kcontrol_new nau8825_controls[] = {
851 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
852 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
853 };
854 
855 static const struct snd_soc_dapm_widget nau8825_widgets[] = {
856 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
857 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
858 };
859 
860 static const struct snd_soc_dapm_route nau8825_map[] = {
861 	{ "Headphone Jack", NULL, "HPOL" },
862 	{ "Headphone Jack", NULL, "HPOR" },
863 };
864 
865 static int acp_card_nau8825_init(struct snd_soc_pcm_runtime *rtd)
866 {
867 	struct snd_soc_card *card = rtd->card;
868 	struct acp_card_drvdata *drvdata = card->drvdata;
869 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
870 	struct snd_soc_component *component = codec_dai->component;
871 	int ret;
872 
873 	dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
874 
875 	if (drvdata->hs_codec_id != NAU8825)
876 		return -EINVAL;
877 
878 	ret = snd_soc_dapm_new_controls(&card->dapm, nau8825_widgets,
879 					ARRAY_SIZE(nau8825_widgets));
880 	if (ret) {
881 		dev_err(rtd->dev, "unable to add widget dapm controls, ret %d\n", ret);
882 		return ret;
883 	}
884 
885 	ret = snd_soc_add_card_controls(card, nau8825_controls,
886 					ARRAY_SIZE(nau8825_controls));
887 	if (ret) {
888 		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
889 		return ret;
890 	}
891 
892 	ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
893 					 SND_JACK_HEADSET | SND_JACK_LINEOUT |
894 					 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
895 					 SND_JACK_BTN_2 | SND_JACK_BTN_3,
896 					 &nau8825_jack,
897 					 nau8825_jack_pins,
898 					 ARRAY_SIZE(nau8825_jack_pins));
899 	if (ret) {
900 		dev_err(card->dev, "HP jack creation failed %d\n", ret);
901 		return ret;
902 	}
903 
904 	snd_jack_set_key(nau8825_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
905 	snd_jack_set_key(nau8825_jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
906 	snd_jack_set_key(nau8825_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
907 	snd_jack_set_key(nau8825_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
908 
909 	ret = snd_soc_component_set_jack(component, &nau8825_jack, NULL);
910 	if (ret) {
911 		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
912 		return ret;
913 	}
914 
915 	return snd_soc_dapm_add_routes(&rtd->card->dapm, nau8825_map, ARRAY_SIZE(nau8825_map));
916 }
917 
918 static int acp_nau8825_hw_params(struct snd_pcm_substream *substream,
919 				 struct snd_pcm_hw_params *params)
920 {
921 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
922 	struct snd_soc_card *card = rtd->card;
923 	struct acp_card_drvdata *drvdata = card->drvdata;
924 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
925 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
926 	int ret;
927 	unsigned int fmt;
928 
929 	ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS,
930 				     (48000 * 256), SND_SOC_CLOCK_IN);
931 	if (ret < 0)
932 		dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
933 
934 	ret = snd_soc_dai_set_pll(codec_dai, 0, 0, params_rate(params),
935 				  params_rate(params) * 256);
936 	if (ret < 0) {
937 		dev_err(rtd->dev, "can't set FLL: %d\n", ret);
938 		return ret;
939 	}
940 
941 	if (drvdata->tdm_mode)
942 		fmt = SND_SOC_DAIFMT_DSP_A;
943 	else
944 		fmt = SND_SOC_DAIFMT_I2S;
945 
946 	if (drvdata->soc_mclk)
947 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
948 	else
949 		fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
950 
951 	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
952 	if (ret && ret != -ENOTSUPP) {
953 		dev_err(rtd->dev, "Failed to set dai fmt: %d\n", ret);
954 		return ret;
955 	}
956 
957 	ret =  snd_soc_dai_set_fmt(codec_dai, fmt);
958 	if (ret < 0) {
959 		dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
960 		return ret;
961 	}
962 
963 	if (drvdata->tdm_mode) {
964 		/**
965 		 * As codec supports slot 4 and slot 5 for playback and slot 6 for capture.
966 		 */
967 		ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x30, 0xC0, 8, 16);
968 		if (ret && ret != -ENOTSUPP) {
969 			dev_err(rtd->dev, "set TDM slot err: %d\n", ret);
970 			return ret;
971 		}
972 
973 		ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x40, 0x30, 8, 16);
974 		if (ret < 0) {
975 			dev_warn(rtd->dev, "set TDM slot err:%d\n", ret);
976 			return ret;
977 		}
978 	}
979 	return ret;
980 }
981 
982 static int acp_nau8825_startup(struct snd_pcm_substream *substream)
983 {
984 	struct snd_pcm_runtime *runtime = substream->runtime;
985 
986 	runtime->hw.channels_max = 2;
987 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
988 				   &constraints_channels);
989 
990 	runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
991 	snd_pcm_hw_constraint_list(runtime, 0,
992 				   SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
993 	return 0;
994 }
995 
996 static const struct snd_soc_ops acp_card_nau8825_ops = {
997 	.startup =  acp_nau8825_startup,
998 	.hw_params = acp_nau8825_hw_params,
999 };
1000 
1001 static int platform_clock_control(struct snd_soc_dapm_widget *w,
1002 				  struct snd_kcontrol *k, int  event)
1003 {
1004 	struct snd_soc_dapm_context *dapm = w->dapm;
1005 	struct snd_soc_card *card = dapm->card;
1006 	struct snd_soc_dai *codec_dai;
1007 	int ret = 0;
1008 
1009 	codec_dai = snd_soc_card_get_codec_dai(card, NAU8821_CODEC_DAI);
1010 	if (!codec_dai) {
1011 		dev_err(card->dev, "Codec dai not found\n");
1012 		return -EIO;
1013 	}
1014 
1015 	if (SND_SOC_DAPM_EVENT_OFF(event)) {
1016 		ret = snd_soc_dai_set_sysclk(codec_dai, NAU8821_CLK_INTERNAL,
1017 					     0, SND_SOC_CLOCK_IN);
1018 		if (ret < 0) {
1019 			dev_err(card->dev, "set sysclk err = %d\n", ret);
1020 			return -EIO;
1021 		}
1022 	} else {
1023 		ret = snd_soc_dai_set_sysclk(codec_dai, NAU8821_CLK_FLL_BLK, 0,
1024 					     SND_SOC_CLOCK_IN);
1025 		if (ret < 0)
1026 			dev_err(codec_dai->dev, "can't set FS clock %d\n", ret);
1027 		ret = snd_soc_dai_set_pll(codec_dai, 0, 0, NAU8821_BCLK,
1028 					  NAU8821_FREQ_OUT);
1029 		if (ret < 0)
1030 			dev_err(codec_dai->dev, "can't set FLL: %d\n", ret);
1031 	}
1032 	return ret;
1033 }
1034 
1035 static struct snd_soc_jack nau8821_jack;
1036 static struct snd_soc_jack_pin nau8821_jack_pins[] = {
1037 	{
1038 		.pin = "Headphone Jack",
1039 		.mask = SND_JACK_HEADPHONE,
1040 	},
1041 	{
1042 		.pin = "Headset Mic",
1043 		.mask = SND_JACK_MICROPHONE,
1044 	},
1045 };
1046 
1047 static const struct snd_kcontrol_new nau8821_controls[] = {
1048 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
1049 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
1050 };
1051 
1052 static const struct snd_soc_dapm_widget nau8821_widgets[] = {
1053 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
1054 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
1055 	SND_SOC_DAPM_MIC("Int Mic", NULL),
1056 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
1057 			    platform_clock_control, SND_SOC_DAPM_PRE_PMU |
1058 			    SND_SOC_DAPM_POST_PMD),
1059 };
1060 
1061 static const struct snd_soc_dapm_route nau8821_audio_route[] = {
1062 	/* HP jack connectors - unknown if we have jack detection */
1063 	{ "Headphone Jack", NULL, "HPOL" },
1064 	{ "Headphone Jack", NULL, "HPOR" },
1065 	{ "MICL", NULL, "Headset Mic" },
1066 	{ "MICR", NULL, "Headset Mic" },
1067 	{ "DMIC", NULL, "Int Mic" },
1068 	{ "Headphone Jack", NULL, "Platform Clock" },
1069 	{ "Headset Mic", NULL, "Platform Clock" },
1070 	{ "Int Mic", NULL, "Platform Clock" },
1071 };
1072 
1073 static const unsigned int nau8821_format[] = {16};
1074 
1075 static struct snd_pcm_hw_constraint_list constraints_sample_bits = {
1076 	.list = nau8821_format,
1077 	.count = ARRAY_SIZE(nau8821_format),
1078 };
1079 
1080 static int acp_8821_init(struct snd_soc_pcm_runtime *rtd)
1081 {
1082 	struct snd_soc_card *card = rtd->card;
1083 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1084 	struct snd_soc_component *component = codec_dai->component;
1085 	int ret;
1086 
1087 	dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
1088 
1089 	ret = snd_soc_dapm_new_controls(&card->dapm, nau8821_widgets,
1090 					ARRAY_SIZE(nau8821_widgets));
1091 	if (ret) {
1092 		dev_err(rtd->dev, "unable to add widget dapm controls, ret %d\n", ret);
1093 		// Don't need to add routes if widget addition failed
1094 		return ret;
1095 	}
1096 
1097 	ret = snd_soc_add_card_controls(card, nau8821_controls,
1098 					ARRAY_SIZE(nau8821_controls));
1099 	if (ret) {
1100 		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
1101 		return ret;
1102 	}
1103 
1104 	ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
1105 					 SND_JACK_HEADSET | SND_JACK_LINEOUT |
1106 					 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1107 					 SND_JACK_BTN_2 | SND_JACK_BTN_3,
1108 					 &nau8821_jack,
1109 					 nau8821_jack_pins,
1110 					 ARRAY_SIZE(nau8821_jack_pins));
1111 	if (ret) {
1112 		dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
1113 		return ret;
1114 	}
1115 
1116 	snd_jack_set_key(nau8821_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
1117 	snd_jack_set_key(nau8821_jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
1118 	snd_jack_set_key(nau8821_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
1119 	snd_jack_set_key(nau8821_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
1120 
1121 	nau8821_enable_jack_detect(component, &nau8821_jack);
1122 
1123 	return snd_soc_dapm_add_routes(&rtd->card->dapm, nau8821_audio_route,
1124 				       ARRAY_SIZE(nau8821_audio_route));
1125 }
1126 
1127 static int acp_8821_startup(struct snd_pcm_substream *substream)
1128 {
1129 	struct snd_pcm_runtime *runtime = substream->runtime;
1130 
1131 	runtime->hw.channels_max = DUAL_CHANNEL;
1132 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1133 				   &constraints_channels);
1134 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
1135 				   &constraints_rates);
1136 	snd_pcm_hw_constraint_list(substream->runtime, 0,
1137 				   SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
1138 				   &constraints_sample_bits);
1139 	return 0;
1140 }
1141 
1142 static int acp_nau8821_hw_params(struct snd_pcm_substream *substream,
1143 				 struct snd_pcm_hw_params *params)
1144 {
1145 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1146 	struct snd_soc_card *card = rtd->card;
1147 	struct acp_card_drvdata *drvdata = card->drvdata;
1148 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1149 	int ret;
1150 	unsigned int fmt;
1151 
1152 	if (drvdata->soc_mclk)
1153 		fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
1154 	else
1155 		fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP;
1156 
1157 	ret =  snd_soc_dai_set_fmt(codec_dai, fmt);
1158 	if (ret < 0) {
1159 		dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret);
1160 		return ret;
1161 	}
1162 
1163 	ret = snd_soc_dai_set_sysclk(codec_dai, NAU8821_CLK_FLL_BLK, 0,
1164 				     SND_SOC_CLOCK_IN);
1165 	if (ret < 0)
1166 		dev_err(card->dev, "can't set FS clock %d\n", ret);
1167 	ret = snd_soc_dai_set_pll(codec_dai, 0, 0, snd_soc_params_to_bclk(params),
1168 				  params_rate(params) * 256);
1169 	if (ret < 0)
1170 		dev_err(card->dev, "can't set FLL: %d\n", ret);
1171 
1172 	return ret;
1173 }
1174 
1175 static const struct snd_soc_ops acp_8821_ops = {
1176 	.startup = acp_8821_startup,
1177 	.hw_params = acp_nau8821_hw_params,
1178 };
1179 
1180 SND_SOC_DAILINK_DEF(nau8821,
1181 		    DAILINK_COMP_ARRAY(COMP_CODEC("i2c-NVTN2020:00",
1182 						  "nau8821-hifi")));
1183 
1184 /* Declare DMIC codec components */
1185 SND_SOC_DAILINK_DEF(dmic_codec,
1186 		DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
1187 
1188 /* Declare ACP CPU components */
1189 static struct snd_soc_dai_link_component platform_component[] = {
1190 	{
1191 		 .name = "acp_asoc_renoir.0",
1192 	}
1193 };
1194 
1195 static struct snd_soc_dai_link_component platform_rmb_component[] = {
1196 	{
1197 		.name = "acp_asoc_rembrandt.0",
1198 	}
1199 };
1200 
1201 static struct snd_soc_dai_link_component sof_component[] = {
1202 	{
1203 		 .name = "0000:04:00.5",
1204 	}
1205 };
1206 
1207 SND_SOC_DAILINK_DEF(i2s_sp,
1208 	DAILINK_COMP_ARRAY(COMP_CPU("acp-i2s-sp")));
1209 SND_SOC_DAILINK_DEF(i2s_hs,
1210 		    DAILINK_COMP_ARRAY(COMP_CPU("acp-i2s-hs")));
1211 SND_SOC_DAILINK_DEF(sof_sp,
1212 	DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-sp")));
1213 SND_SOC_DAILINK_DEF(sof_sp_virtual,
1214 	DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-sp-virtual")));
1215 SND_SOC_DAILINK_DEF(sof_hs,
1216 		    DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-hs")));
1217 SND_SOC_DAILINK_DEF(sof_hs_virtual,
1218 	DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-hs-virtual")));
1219 SND_SOC_DAILINK_DEF(sof_dmic,
1220 	DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-dmic")));
1221 SND_SOC_DAILINK_DEF(pdm_dmic,
1222 	DAILINK_COMP_ARRAY(COMP_CPU("acp-pdm-dmic")));
1223 
1224 static int acp_rtk_set_bias_level(struct snd_soc_card *card,
1225 				  struct snd_soc_dapm_context *dapm,
1226 				  enum snd_soc_bias_level level)
1227 {
1228 	struct snd_soc_component *component = dapm->component;
1229 	struct acp_card_drvdata *drvdata = card->drvdata;
1230 	int ret = 0;
1231 
1232 	if (!component)
1233 		return 0;
1234 
1235 	if (strncmp(component->name, "i2c-RTL5682", 11) &&
1236 	    strncmp(component->name, "i2c-10EC1019", 12))
1237 		return 0;
1238 
1239 	/*
1240 	 * For Realtek's codec and amplifier components,
1241 	 * the lrck and bclk must be enabled brfore their all dapms be powered on,
1242 	 * and must be disabled after their all dapms be powered down
1243 	 * to avoid any pop.
1244 	 */
1245 	switch (level) {
1246 	case SND_SOC_BIAS_STANDBY:
1247 		if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) {
1248 
1249 			/* Increase bclk's enable_count */
1250 			ret = clk_prepare_enable(drvdata->bclk);
1251 			if (ret < 0)
1252 				dev_err(component->dev, "Failed to enable bclk %d\n", ret);
1253 		} else {
1254 			/*
1255 			 * Decrease bclk's enable_count.
1256 			 * While the enable_count is 0, the bclk would be closed.
1257 			 */
1258 			clk_disable_unprepare(drvdata->bclk);
1259 		}
1260 		break;
1261 	default:
1262 		break;
1263 	}
1264 
1265 	return ret;
1266 }
1267 
1268 int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
1269 {
1270 	struct snd_soc_dai_link *links;
1271 	struct device *dev = card->dev;
1272 	struct acp_card_drvdata *drv_data = card->drvdata;
1273 	int i = 0, num_links = 0;
1274 
1275 	if (drv_data->hs_cpu_id)
1276 		num_links++;
1277 	if (drv_data->amp_cpu_id)
1278 		num_links++;
1279 	if (drv_data->dmic_cpu_id)
1280 		num_links++;
1281 
1282 	links = devm_kcalloc(dev, num_links, sizeof(struct snd_soc_dai_link), GFP_KERNEL);
1283 	if (!links)
1284 		return -ENOMEM;
1285 
1286 	if (drv_data->hs_cpu_id == I2S_SP) {
1287 		links[i].name = "acp-headset-codec";
1288 		links[i].id = HEADSET_BE_ID;
1289 		links[i].cpus = sof_sp;
1290 		links[i].num_cpus = ARRAY_SIZE(sof_sp);
1291 		links[i].platforms = sof_component;
1292 		links[i].num_platforms = ARRAY_SIZE(sof_component);
1293 		links[i].dpcm_playback = 1;
1294 		links[i].dpcm_capture = 1;
1295 		links[i].nonatomic = true;
1296 		links[i].no_pcm = 1;
1297 		if (!drv_data->hs_codec_id) {
1298 			/* Use dummy codec if codec id not specified */
1299 			links[i].codecs = &asoc_dummy_dlc;
1300 			links[i].num_codecs = 1;
1301 		}
1302 		if (drv_data->hs_codec_id == RT5682) {
1303 			links[i].codecs = rt5682;
1304 			links[i].num_codecs = ARRAY_SIZE(rt5682);
1305 			links[i].init = acp_card_rt5682_init;
1306 			links[i].ops = &acp_card_rt5682_ops;
1307 		}
1308 		if (drv_data->hs_codec_id == RT5682S) {
1309 			links[i].codecs = rt5682s;
1310 			links[i].num_codecs = ARRAY_SIZE(rt5682s);
1311 			links[i].init = acp_card_rt5682s_init;
1312 			links[i].ops = &acp_card_rt5682s_ops;
1313 		}
1314 		if (drv_data->hs_codec_id == NAU8821) {
1315 			links[i].codecs = nau8821;
1316 			links[i].num_codecs = ARRAY_SIZE(nau8821);
1317 			links[i].init = acp_8821_init;
1318 			links[i].ops = &acp_8821_ops;
1319 		}
1320 		i++;
1321 	}
1322 
1323 	if (drv_data->hs_cpu_id == I2S_HS) {
1324 		links[i].name = "acp-headset-codec";
1325 		links[i].id = HEADSET_BE_ID;
1326 		links[i].cpus = sof_hs;
1327 		links[i].num_cpus = ARRAY_SIZE(sof_hs);
1328 		links[i].platforms = sof_component;
1329 		links[i].num_platforms = ARRAY_SIZE(sof_component);
1330 		links[i].dpcm_playback = 1;
1331 		links[i].dpcm_capture = 1;
1332 		links[i].nonatomic = true;
1333 		links[i].no_pcm = 1;
1334 		if (!drv_data->hs_codec_id) {
1335 			/* Use dummy codec if codec id not specified */
1336 			links[i].codecs = &asoc_dummy_dlc;
1337 			links[i].num_codecs = 1;
1338 		}
1339 		if (drv_data->hs_codec_id == NAU8825) {
1340 			links[i].codecs = nau8825;
1341 			links[i].num_codecs = ARRAY_SIZE(nau8825);
1342 			links[i].init = acp_card_nau8825_init;
1343 			links[i].ops = &acp_card_nau8825_ops;
1344 		}
1345 		if (drv_data->hs_codec_id == RT5682S) {
1346 			links[i].codecs = rt5682s;
1347 			links[i].num_codecs = ARRAY_SIZE(rt5682s);
1348 			links[i].init = acp_card_rt5682s_init;
1349 			links[i].ops = &acp_card_rt5682s_ops;
1350 		}
1351 		i++;
1352 	}
1353 
1354 	if (drv_data->amp_cpu_id == I2S_SP) {
1355 		links[i].name = "acp-amp-codec";
1356 		links[i].id = AMP_BE_ID;
1357 		links[i].cpus = sof_sp_virtual;
1358 		links[i].num_cpus = ARRAY_SIZE(sof_sp_virtual);
1359 		links[i].platforms = sof_component;
1360 		links[i].num_platforms = ARRAY_SIZE(sof_component);
1361 		links[i].dpcm_playback = 1;
1362 		links[i].nonatomic = true;
1363 		links[i].no_pcm = 1;
1364 		if (!drv_data->amp_codec_id) {
1365 			/* Use dummy codec if codec id not specified */
1366 			links[i].codecs = &asoc_dummy_dlc;
1367 			links[i].num_codecs = 1;
1368 		}
1369 		if (drv_data->amp_codec_id == RT1019) {
1370 			links[i].codecs = rt1019;
1371 			links[i].num_codecs = ARRAY_SIZE(rt1019);
1372 			links[i].ops = &acp_card_rt1019_ops;
1373 			links[i].init = acp_card_rt1019_init;
1374 			card->codec_conf = rt1019_conf;
1375 			card->num_configs = ARRAY_SIZE(rt1019_conf);
1376 		}
1377 		if (drv_data->amp_codec_id == MAX98360A) {
1378 			links[i].codecs = max98360a;
1379 			links[i].num_codecs = ARRAY_SIZE(max98360a);
1380 			links[i].ops = &acp_card_maxim_ops;
1381 			links[i].init = acp_card_maxim_init;
1382 		}
1383 		i++;
1384 	}
1385 
1386 	if (drv_data->amp_cpu_id == I2S_HS) {
1387 		links[i].name = "acp-amp-codec";
1388 		links[i].id = AMP_BE_ID;
1389 		links[i].cpus = sof_hs_virtual;
1390 		links[i].num_cpus = ARRAY_SIZE(sof_hs_virtual);
1391 		links[i].platforms = sof_component;
1392 		links[i].num_platforms = ARRAY_SIZE(sof_component);
1393 		links[i].dpcm_playback = 1;
1394 		links[i].nonatomic = true;
1395 		links[i].no_pcm = 1;
1396 		if (!drv_data->amp_codec_id) {
1397 			/* Use dummy codec if codec id not specified */
1398 			links[i].codecs = &asoc_dummy_dlc;
1399 			links[i].num_codecs = 1;
1400 		}
1401 		if (drv_data->amp_codec_id == MAX98360A) {
1402 			links[i].codecs = max98360a;
1403 			links[i].num_codecs = ARRAY_SIZE(max98360a);
1404 			links[i].ops = &acp_card_maxim_ops;
1405 			links[i].init = acp_card_maxim_init;
1406 		}
1407 		if (drv_data->amp_codec_id == MAX98388) {
1408 			links[i].codecs = max98388;
1409 			links[i].num_codecs = ARRAY_SIZE(max98388);
1410 			links[i].ops = &acp_max98388_ops;
1411 			links[i].init = acp_card_max98388_init;
1412 			card->codec_conf = max98388_conf;
1413 			card->num_configs = ARRAY_SIZE(max98388_conf);
1414 		}
1415 		if (drv_data->amp_codec_id == RT1019) {
1416 			links[i].codecs = rt1019;
1417 			links[i].num_codecs = ARRAY_SIZE(rt1019);
1418 			links[i].ops = &acp_card_rt1019_ops;
1419 			links[i].init = acp_card_rt1019_init;
1420 			card->codec_conf = rt1019_conf;
1421 			card->num_configs = ARRAY_SIZE(rt1019_conf);
1422 		}
1423 		i++;
1424 	}
1425 
1426 	if (drv_data->dmic_cpu_id == DMIC) {
1427 		links[i].name = "acp-dmic-codec";
1428 		links[i].id = DMIC_BE_ID;
1429 		links[i].codecs = dmic_codec;
1430 		links[i].num_codecs = ARRAY_SIZE(dmic_codec);
1431 		links[i].cpus = sof_dmic;
1432 		links[i].num_cpus = ARRAY_SIZE(sof_dmic);
1433 		links[i].platforms = sof_component;
1434 		links[i].num_platforms = ARRAY_SIZE(sof_component);
1435 		links[i].dpcm_capture = 1;
1436 		links[i].nonatomic = true;
1437 		links[i].no_pcm = 1;
1438 	}
1439 
1440 	card->dai_link = links;
1441 	card->num_links = num_links;
1442 	card->set_bias_level = acp_rtk_set_bias_level;
1443 
1444 	return 0;
1445 }
1446 EXPORT_SYMBOL_NS_GPL(acp_sofdsp_dai_links_create, SND_SOC_AMD_MACH);
1447 
1448 int acp_legacy_dai_links_create(struct snd_soc_card *card)
1449 {
1450 	struct snd_soc_dai_link *links;
1451 	struct device *dev = card->dev;
1452 	struct acp_card_drvdata *drv_data = card->drvdata;
1453 	int i = 0, num_links = 0;
1454 
1455 	if (drv_data->hs_cpu_id)
1456 		num_links++;
1457 	if (drv_data->amp_cpu_id)
1458 		num_links++;
1459 	if (drv_data->dmic_cpu_id)
1460 		num_links++;
1461 
1462 	links = devm_kcalloc(dev, num_links, sizeof(struct snd_soc_dai_link), GFP_KERNEL);
1463 	if (!links)
1464 		return -ENOMEM;
1465 
1466 	if (drv_data->hs_cpu_id == I2S_SP) {
1467 		links[i].name = "acp-headset-codec";
1468 		links[i].id = HEADSET_BE_ID;
1469 		links[i].cpus = i2s_sp;
1470 		links[i].num_cpus = ARRAY_SIZE(i2s_sp);
1471 		links[i].platforms = platform_component;
1472 		links[i].num_platforms = ARRAY_SIZE(platform_component);
1473 		links[i].dpcm_playback = 1;
1474 		links[i].dpcm_capture = 1;
1475 		if (!drv_data->hs_codec_id) {
1476 			/* Use dummy codec if codec id not specified */
1477 			links[i].codecs = &asoc_dummy_dlc;
1478 			links[i].num_codecs = 1;
1479 		}
1480 		if (drv_data->hs_codec_id == RT5682) {
1481 			links[i].codecs = rt5682;
1482 			links[i].num_codecs = ARRAY_SIZE(rt5682);
1483 			links[i].init = acp_card_rt5682_init;
1484 			links[i].ops = &acp_card_rt5682_ops;
1485 		}
1486 		if (drv_data->hs_codec_id == RT5682S) {
1487 			links[i].codecs = rt5682s;
1488 			links[i].num_codecs = ARRAY_SIZE(rt5682s);
1489 			links[i].init = acp_card_rt5682s_init;
1490 			links[i].ops = &acp_card_rt5682s_ops;
1491 		}
1492 		i++;
1493 	}
1494 
1495 	if (drv_data->hs_cpu_id == I2S_HS) {
1496 		links[i].name = "acp-headset-codec";
1497 		links[i].id = HEADSET_BE_ID;
1498 		links[i].cpus = i2s_hs;
1499 		links[i].num_cpus = ARRAY_SIZE(i2s_hs);
1500 		if (drv_data->platform == REMBRANDT) {
1501 			links[i].platforms = platform_rmb_component;
1502 			links[i].num_platforms = ARRAY_SIZE(platform_rmb_component);
1503 		} else {
1504 			links[i].platforms = platform_component;
1505 			links[i].num_platforms = ARRAY_SIZE(platform_component);
1506 		}
1507 		links[i].dpcm_playback = 1;
1508 		links[i].dpcm_capture = 1;
1509 		if (!drv_data->hs_codec_id) {
1510 			/* Use dummy codec if codec id not specified */
1511 			links[i].codecs = &asoc_dummy_dlc;
1512 			links[i].num_codecs = 1;
1513 		}
1514 		if (drv_data->hs_codec_id == NAU8825) {
1515 			links[i].codecs = nau8825;
1516 			links[i].num_codecs = ARRAY_SIZE(nau8825);
1517 			links[i].init = acp_card_nau8825_init;
1518 			links[i].ops = &acp_card_nau8825_ops;
1519 		}
1520 		if (drv_data->hs_codec_id == RT5682S) {
1521 			links[i].codecs = rt5682s;
1522 			links[i].num_codecs = ARRAY_SIZE(rt5682s);
1523 			links[i].init = acp_card_rt5682s_init;
1524 			links[i].ops = &acp_card_rt5682s_ops;
1525 		}
1526 		i++;
1527 	}
1528 
1529 	if (drv_data->amp_cpu_id == I2S_SP) {
1530 		links[i].name = "acp-amp-codec";
1531 		links[i].id = AMP_BE_ID;
1532 		links[i].cpus = i2s_sp;
1533 		links[i].num_cpus = ARRAY_SIZE(i2s_sp);
1534 		links[i].platforms = platform_component;
1535 		links[i].num_platforms = ARRAY_SIZE(platform_component);
1536 		links[i].dpcm_playback = 1;
1537 		if (!drv_data->amp_codec_id) {
1538 			/* Use dummy codec if codec id not specified */
1539 			links[i].codecs = &asoc_dummy_dlc;
1540 			links[i].num_codecs = 1;
1541 		}
1542 		if (drv_data->amp_codec_id == RT1019) {
1543 			links[i].codecs = rt1019;
1544 			links[i].num_codecs = ARRAY_SIZE(rt1019);
1545 			links[i].ops = &acp_card_rt1019_ops;
1546 			links[i].init = acp_card_rt1019_init;
1547 			card->codec_conf = rt1019_conf;
1548 			card->num_configs = ARRAY_SIZE(rt1019_conf);
1549 		}
1550 		if (drv_data->amp_codec_id == MAX98360A) {
1551 			links[i].codecs = max98360a;
1552 			links[i].num_codecs = ARRAY_SIZE(max98360a);
1553 			links[i].ops = &acp_card_maxim_ops;
1554 			links[i].init = acp_card_maxim_init;
1555 		}
1556 		i++;
1557 	}
1558 
1559 	if (drv_data->amp_cpu_id == I2S_HS) {
1560 		links[i].name = "acp-amp-codec";
1561 		links[i].id = AMP_BE_ID;
1562 		links[i].cpus = i2s_hs;
1563 		links[i].num_cpus = ARRAY_SIZE(i2s_hs);
1564 		if (drv_data->platform == REMBRANDT) {
1565 			links[i].platforms = platform_rmb_component;
1566 			links[i].num_platforms = ARRAY_SIZE(platform_rmb_component);
1567 		} else {
1568 			links[i].platforms = platform_component;
1569 			links[i].num_platforms = ARRAY_SIZE(platform_component);
1570 		}
1571 		links[i].dpcm_playback = 1;
1572 		if (!drv_data->amp_codec_id) {
1573 			/* Use dummy codec if codec id not specified */
1574 			links[i].codecs = &asoc_dummy_dlc;
1575 			links[i].num_codecs = 1;
1576 		}
1577 		if (drv_data->amp_codec_id == MAX98360A) {
1578 			links[i].codecs = max98360a;
1579 			links[i].num_codecs = ARRAY_SIZE(max98360a);
1580 			links[i].ops = &acp_card_maxim_ops;
1581 			links[i].init = acp_card_maxim_init;
1582 		}
1583 		if (drv_data->amp_codec_id == RT1019) {
1584 			links[i].codecs = rt1019;
1585 			links[i].num_codecs = ARRAY_SIZE(rt1019);
1586 			links[i].ops = &acp_card_rt1019_ops;
1587 			links[i].init = acp_card_rt1019_init;
1588 			card->codec_conf = rt1019_conf;
1589 			card->num_configs = ARRAY_SIZE(rt1019_conf);
1590 		}
1591 		i++;
1592 	}
1593 
1594 	if (drv_data->dmic_cpu_id == DMIC) {
1595 		links[i].name = "acp-dmic-codec";
1596 		links[i].id = DMIC_BE_ID;
1597 		if (drv_data->dmic_codec_id == DMIC) {
1598 			links[i].codecs = dmic_codec;
1599 			links[i].num_codecs = ARRAY_SIZE(dmic_codec);
1600 		} else {
1601 			/* Use dummy codec if codec id not specified */
1602 			links[i].codecs = &asoc_dummy_dlc;
1603 			links[i].num_codecs = 1;
1604 		}
1605 		links[i].cpus = pdm_dmic;
1606 		links[i].num_cpus = ARRAY_SIZE(pdm_dmic);
1607 		if (drv_data->platform == REMBRANDT) {
1608 			links[i].platforms = platform_rmb_component;
1609 			links[i].num_platforms = ARRAY_SIZE(platform_rmb_component);
1610 		} else {
1611 			links[i].platforms = platform_component;
1612 			links[i].num_platforms = ARRAY_SIZE(platform_component);
1613 		}
1614 		links[i].ops = &acp_card_dmic_ops;
1615 		links[i].dpcm_capture = 1;
1616 	}
1617 
1618 	card->dai_link = links;
1619 	card->num_links = num_links;
1620 	card->set_bias_level = acp_rtk_set_bias_level;
1621 
1622 	return 0;
1623 }
1624 EXPORT_SYMBOL_NS_GPL(acp_legacy_dai_links_create, SND_SOC_AMD_MACH);
1625 
1626 MODULE_LICENSE("GPL v2");
1627