forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/soc/intel/boards/glk_rt5682_max98357a.c
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+// SPDX-License-Identifier: GPL-2.0-only
22 // Copyright(c) 2018 Intel Corporation.
33
44 /*
....@@ -16,9 +16,10 @@
1616 #include <sound/pcm.h>
1717 #include <sound/pcm_params.h>
1818 #include <sound/soc.h>
19
-#include "../skylake/skl.h"
19
+#include <sound/soc-acpi.h>
2020 #include "../../codecs/rt5682.h"
2121 #include "../../codecs/hdac_hdmi.h"
22
+#include "hda_dsp_common.h"
2223
2324 /* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */
2425 #define GLK_PLAT_CLK_FREQ 19200000
....@@ -41,6 +42,7 @@
4142 struct glk_card_private {
4243 struct snd_soc_jack geminilake_headset;
4344 struct list_head hdmi_pcm_list;
45
+ bool common_hdmi_codec_drv;
4446 };
4547
4648 enum {
....@@ -54,39 +56,6 @@
5456 GLK_DPCM_AUDIO_HDMI2_PB,
5557 GLK_DPCM_AUDIO_HDMI3_PB,
5658 };
57
-
58
-static int platform_clock_control(struct snd_soc_dapm_widget *w,
59
- struct snd_kcontrol *k, int event)
60
-{
61
- struct snd_soc_dapm_context *dapm = w->dapm;
62
- struct snd_soc_card *card = dapm->card;
63
- struct snd_soc_dai *codec_dai;
64
- int ret = 0;
65
-
66
- codec_dai = snd_soc_card_get_codec_dai(card, GLK_REALTEK_CODEC_DAI);
67
- if (!codec_dai) {
68
- dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
69
- return -EIO;
70
- }
71
-
72
- if (SND_SOC_DAPM_EVENT_OFF(event)) {
73
- ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
74
- if (ret)
75
- dev_err(card->dev, "failed to stop sysclk: %d\n", ret);
76
- } else if (SND_SOC_DAPM_EVENT_ON(event)) {
77
- ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
78
- GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
79
- if (ret < 0) {
80
- dev_err(card->dev, "can't set codec pll: %d\n", ret);
81
- return ret;
82
- }
83
- }
84
-
85
- if (ret)
86
- dev_err(card->dev, "failed to start internal clk: %d\n", ret);
87
-
88
- return ret;
89
-}
9059
9160 static const struct snd_kcontrol_new geminilake_controls[] = {
9261 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
....@@ -102,14 +71,10 @@
10271 SND_SOC_DAPM_SPK("HDMI1", NULL),
10372 SND_SOC_DAPM_SPK("HDMI2", NULL),
10473 SND_SOC_DAPM_SPK("HDMI3", NULL),
105
- SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
106
- platform_clock_control, SND_SOC_DAPM_PRE_PMU |
107
- SND_SOC_DAPM_POST_PMD),
10874 };
10975
11076 static const struct snd_soc_dapm_route geminilake_map[] = {
11177 /* HP jack connectors - unknown if we have jack detection */
112
- { "Headphone Jack", NULL, "Platform Clock" },
11378 { "Headphone Jack", NULL, "HPOL" },
11479 { "Headphone Jack", NULL, "HPOR" },
11580
....@@ -117,7 +82,6 @@
11782 { "Spk", NULL, "Speaker" },
11883
11984 /* other jacks */
120
- { "Headset Mic", NULL, "Platform Clock" },
12185 { "IN1P", NULL, "Headset Mic" },
12286
12387 /* digital mics */
....@@ -154,17 +118,17 @@
154118 {
155119 struct snd_interval *rate = hw_param_interval(params,
156120 SNDRV_PCM_HW_PARAM_RATE);
157
- struct snd_interval *channels = hw_param_interval(params,
121
+ struct snd_interval *chan = hw_param_interval(params,
158122 SNDRV_PCM_HW_PARAM_CHANNELS);
159123 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
160124
161125 /* The ADSP will convert the FE rate to 48k, stereo */
162126 rate->min = rate->max = 48000;
163
- channels->min = channels->max = DUAL_CHANNEL;
127
+ chan->min = chan->max = DUAL_CHANNEL;
164128
165129 /* set SSP to 24 bit */
166130 snd_mask_none(fmt);
167
- snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
131
+ snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
168132
169133 return 0;
170134 }
....@@ -172,10 +136,17 @@
172136 static int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
173137 {
174138 struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
175
- struct snd_soc_component *component = rtd->codec_dai->component;
176
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
139
+ struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
140
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
177141 struct snd_soc_jack *jack;
178142 int ret;
143
+
144
+ ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
145
+ GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
146
+ if (ret < 0) {
147
+ dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
148
+ return ret;
149
+ }
179150
180151 /* Configure sysclk for codec */
181152 ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1,
....@@ -199,9 +170,10 @@
199170 jack = &ctx->geminilake_headset;
200171
201172 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
202
- snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
203
- snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
204
- snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
173
+ snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
174
+ snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
175
+ snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
176
+
205177 ret = snd_soc_component_set_jack(component, jack, NULL);
206178
207179 if (ret) {
....@@ -215,8 +187,8 @@
215187 static int geminilake_rt5682_hw_params(struct snd_pcm_substream *substream,
216188 struct snd_pcm_hw_params *params)
217189 {
218
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
219
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
190
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
191
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
220192 int ret;
221193
222194 /* Set valid bitmask & configuration for I2S in 24 bit */
....@@ -236,7 +208,7 @@
236208 static int geminilake_hdmi_init(struct snd_soc_pcm_runtime *rtd)
237209 {
238210 struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
239
- struct snd_soc_dai *dai = rtd->codec_dai;
211
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
240212 struct glk_hdmi_pcm *pcm;
241213
242214 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -253,7 +225,7 @@
253225
254226 static int geminilake_rt5682_fe_init(struct snd_soc_pcm_runtime *rtd)
255227 {
256
- struct snd_soc_component *component = rtd->cpu_dai->component;
228
+ struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
257229 struct snd_soc_dapm_context *dapm;
258230 int ret;
259231
....@@ -277,16 +249,6 @@
277249 .mask = 0,
278250 };
279251
280
-static const unsigned int channels[] = {
281
- DUAL_CHANNEL,
282
-};
283
-
284
-static const struct snd_pcm_hw_constraint_list constraints_channels = {
285
- .count = ARRAY_SIZE(channels),
286
- .list = channels,
287
- .mask = 0,
288
-};
289
-
290252 static unsigned int channels_quad[] = {
291253 QUAD_CHANNEL,
292254 };
....@@ -300,13 +262,13 @@
300262 static int geminilake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
301263 struct snd_pcm_hw_params *params)
302264 {
303
- struct snd_interval *channels = hw_param_interval(params,
265
+ struct snd_interval *chan = hw_param_interval(params,
304266 SNDRV_PCM_HW_PARAM_CHANNELS);
305267
306268 /*
307269 * set BE channel constraint as user FE channels
308270 */
309
- channels->min = channels->max = 4;
271
+ chan->min = chan->max = 4;
310272
311273 return 0;
312274 }
....@@ -347,152 +309,181 @@
347309 .startup = geminilake_refcap_startup,
348310 };
349311
312
+SND_SOC_DAILINK_DEF(dummy,
313
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
314
+
315
+SND_SOC_DAILINK_DEF(system,
316
+ DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
317
+
318
+SND_SOC_DAILINK_DEF(system2,
319
+ DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
320
+
321
+SND_SOC_DAILINK_DEF(echoref,
322
+ DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
323
+
324
+SND_SOC_DAILINK_DEF(reference,
325
+ DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
326
+
327
+SND_SOC_DAILINK_DEF(dmic,
328
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
329
+
330
+SND_SOC_DAILINK_DEF(hdmi1,
331
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
332
+
333
+SND_SOC_DAILINK_DEF(hdmi2,
334
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
335
+
336
+SND_SOC_DAILINK_DEF(hdmi3,
337
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
338
+
339
+SND_SOC_DAILINK_DEF(ssp1_pin,
340
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
341
+SND_SOC_DAILINK_DEF(ssp1_codec,
342
+ DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME,
343
+ GLK_MAXIM_CODEC_DAI)));
344
+
345
+SND_SOC_DAILINK_DEF(ssp2_pin,
346
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin")));
347
+SND_SOC_DAILINK_DEF(ssp2_codec,
348
+ DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00",
349
+ GLK_REALTEK_CODEC_DAI)));
350
+
351
+SND_SOC_DAILINK_DEF(dmic_pin,
352
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
353
+SND_SOC_DAILINK_DEF(dmic_codec,
354
+ DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
355
+
356
+SND_SOC_DAILINK_DEF(idisp1_pin,
357
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
358
+SND_SOC_DAILINK_DEF(idisp1_codec,
359
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
360
+
361
+SND_SOC_DAILINK_DEF(idisp2_pin,
362
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
363
+SND_SOC_DAILINK_DEF(idisp2_codec,
364
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
365
+
366
+SND_SOC_DAILINK_DEF(idisp3_pin,
367
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
368
+SND_SOC_DAILINK_DEF(idisp3_codec,
369
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
370
+
371
+SND_SOC_DAILINK_DEF(platform,
372
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
373
+
350374 /* geminilake digital audio interface glue - connects codec <--> CPU */
351375 static struct snd_soc_dai_link geminilake_dais[] = {
352376 /* Front End DAI links */
353377 [GLK_DPCM_AUDIO_PB] = {
354378 .name = "Glk Audio Port",
355379 .stream_name = "Audio",
356
- .cpu_dai_name = "System Pin",
357
- .platform_name = "0000:00:0e.0",
358380 .dynamic = 1,
359
- .codec_name = "snd-soc-dummy",
360
- .codec_dai_name = "snd-soc-dummy-dai",
361381 .nonatomic = 1,
362382 .init = geminilake_rt5682_fe_init,
363383 .trigger = {
364384 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
365385 .dpcm_playback = 1,
386
+ SND_SOC_DAILINK_REG(system, dummy, platform),
366387 },
367388 [GLK_DPCM_AUDIO_CP] = {
368389 .name = "Glk Audio Capture Port",
369390 .stream_name = "Audio Record",
370
- .cpu_dai_name = "System Pin",
371
- .platform_name = "0000:00:0e.0",
372391 .dynamic = 1,
373
- .codec_name = "snd-soc-dummy",
374
- .codec_dai_name = "snd-soc-dummy-dai",
375392 .nonatomic = 1,
376393 .trigger = {
377394 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
378395 .dpcm_capture = 1,
396
+ SND_SOC_DAILINK_REG(system, dummy, platform),
379397 },
380398 [GLK_DPCM_AUDIO_HS_PB] = {
381399 .name = "Glk Audio Headset Playback",
382400 .stream_name = "Headset Audio",
383
- .cpu_dai_name = "System Pin2",
384
- .platform_name = "0000:00:0e.0",
385
- .codec_name = "snd-soc-dummy",
386
- .codec_dai_name = "snd-soc-dummy-dai",
387401 .dpcm_playback = 1,
388402 .nonatomic = 1,
389403 .dynamic = 1,
404
+ SND_SOC_DAILINK_REG(system2, dummy, platform),
390405 },
391406 [GLK_DPCM_AUDIO_ECHO_REF_CP] = {
392407 .name = "Glk Audio Echo Reference cap",
393408 .stream_name = "Echoreference Capture",
394
- .cpu_dai_name = "Echoref Pin",
395
- .platform_name = "0000:00:0e.0",
396
- .codec_name = "snd-soc-dummy",
397
- .codec_dai_name = "snd-soc-dummy-dai",
398409 .init = NULL,
399
- .capture_only = 1,
410
+ .dpcm_capture = 1,
400411 .nonatomic = 1,
412
+ .dynamic = 1,
413
+ SND_SOC_DAILINK_REG(echoref, dummy, platform),
401414 },
402415 [GLK_DPCM_AUDIO_REF_CP] = {
403416 .name = "Glk Audio Reference cap",
404417 .stream_name = "Refcap",
405
- .cpu_dai_name = "Reference Pin",
406
- .codec_name = "snd-soc-dummy",
407
- .codec_dai_name = "snd-soc-dummy-dai",
408
- .platform_name = "0000:00:0e.0",
409418 .init = NULL,
410419 .dpcm_capture = 1,
411420 .nonatomic = 1,
412421 .dynamic = 1,
413422 .ops = &geminilake_refcap_ops,
423
+ SND_SOC_DAILINK_REG(reference, dummy, platform),
414424 },
415425 [GLK_DPCM_AUDIO_DMIC_CP] = {
416426 .name = "Glk Audio DMIC cap",
417427 .stream_name = "dmiccap",
418
- .cpu_dai_name = "DMIC Pin",
419
- .codec_name = "snd-soc-dummy",
420
- .codec_dai_name = "snd-soc-dummy-dai",
421
- .platform_name = "0000:00:0e.0",
422428 .init = NULL,
423429 .dpcm_capture = 1,
424430 .nonatomic = 1,
425431 .dynamic = 1,
426432 .ops = &geminilake_dmic_ops,
433
+ SND_SOC_DAILINK_REG(dmic, dummy, platform),
427434 },
428435 [GLK_DPCM_AUDIO_HDMI1_PB] = {
429436 .name = "Glk HDMI Port1",
430437 .stream_name = "Hdmi1",
431
- .cpu_dai_name = "HDMI1 Pin",
432
- .codec_name = "snd-soc-dummy",
433
- .codec_dai_name = "snd-soc-dummy-dai",
434
- .platform_name = "0000:00:0e.0",
435438 .dpcm_playback = 1,
436439 .init = NULL,
437440 .trigger = {
438441 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
439442 .nonatomic = 1,
440443 .dynamic = 1,
444
+ SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
441445 },
442446 [GLK_DPCM_AUDIO_HDMI2_PB] = {
443447 .name = "Glk HDMI Port2",
444448 .stream_name = "Hdmi2",
445
- .cpu_dai_name = "HDMI2 Pin",
446
- .codec_name = "snd-soc-dummy",
447
- .codec_dai_name = "snd-soc-dummy-dai",
448
- .platform_name = "0000:00:0e.0",
449449 .dpcm_playback = 1,
450450 .init = NULL,
451451 .trigger = {
452452 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
453453 .nonatomic = 1,
454454 .dynamic = 1,
455
+ SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
455456 },
456457 [GLK_DPCM_AUDIO_HDMI3_PB] = {
457458 .name = "Glk HDMI Port3",
458459 .stream_name = "Hdmi3",
459
- .cpu_dai_name = "HDMI3 Pin",
460
- .codec_name = "snd-soc-dummy",
461
- .codec_dai_name = "snd-soc-dummy-dai",
462
- .platform_name = "0000:00:0e.0",
463460 .trigger = {
464461 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
465462 .dpcm_playback = 1,
466463 .init = NULL,
467464 .nonatomic = 1,
468465 .dynamic = 1,
466
+ SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
469467 },
470468 /* Back End DAI links */
471469 {
472470 /* SSP1 - Codec */
473471 .name = "SSP1-Codec",
474472 .id = 0,
475
- .cpu_dai_name = "SSP1 Pin",
476
- .platform_name = "0000:00:0e.0",
477473 .no_pcm = 1,
478
- .codec_name = MAXIM_DEV0_NAME,
479
- .codec_dai_name = GLK_MAXIM_CODEC_DAI,
480474 .dai_fmt = SND_SOC_DAIFMT_I2S |
481475 SND_SOC_DAIFMT_NB_NF |
482476 SND_SOC_DAIFMT_CBS_CFS,
483477 .ignore_pmdown_time = 1,
484478 .be_hw_params_fixup = geminilake_ssp_fixup,
485479 .dpcm_playback = 1,
480
+ SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
486481 },
487482 {
488483 /* SSP2 - Codec */
489484 .name = "SSP2-Codec",
490485 .id = 1,
491
- .cpu_dai_name = "SSP2 Pin",
492
- .platform_name = "0000:00:0e.0",
493486 .no_pcm = 1,
494
- .codec_name = "i2c-10EC5682:00",
495
- .codec_dai_name = GLK_REALTEK_CODEC_DAI,
496487 .init = geminilake_rt5682_codec_init,
497488 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
498489 SND_SOC_DAIFMT_CBS_CFS,
....@@ -501,51 +492,40 @@
501492 .ops = &geminilake_rt5682_ops,
502493 .dpcm_playback = 1,
503494 .dpcm_capture = 1,
495
+ SND_SOC_DAILINK_REG(ssp2_pin, ssp2_codec, platform),
504496 },
505497 {
506498 .name = "dmic01",
507499 .id = 2,
508
- .cpu_dai_name = "DMIC01 Pin",
509
- .codec_name = "dmic-codec",
510
- .codec_dai_name = "dmic-hifi",
511
- .platform_name = "0000:00:0e.0",
512500 .ignore_suspend = 1,
513501 .be_hw_params_fixup = geminilake_dmic_fixup,
514502 .dpcm_capture = 1,
515503 .no_pcm = 1,
504
+ SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
516505 },
517506 {
518507 .name = "iDisp1",
519508 .id = 3,
520
- .cpu_dai_name = "iDisp1 Pin",
521
- .codec_name = "ehdaudio0D2",
522
- .codec_dai_name = "intel-hdmi-hifi1",
523
- .platform_name = "0000:00:0e.0",
524509 .init = geminilake_hdmi_init,
525510 .dpcm_playback = 1,
526511 .no_pcm = 1,
512
+ SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
527513 },
528514 {
529515 .name = "iDisp2",
530516 .id = 4,
531
- .cpu_dai_name = "iDisp2 Pin",
532
- .codec_name = "ehdaudio0D2",
533
- .codec_dai_name = "intel-hdmi-hifi2",
534
- .platform_name = "0000:00:0e.0",
535517 .init = geminilake_hdmi_init,
536518 .dpcm_playback = 1,
537519 .no_pcm = 1,
520
+ SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
538521 },
539522 {
540523 .name = "iDisp3",
541524 .id = 5,
542
- .cpu_dai_name = "iDisp3 Pin",
543
- .codec_name = "ehdaudio0D2",
544
- .codec_dai_name = "intel-hdmi-hifi3",
545
- .platform_name = "0000:00:0e.0",
546525 .init = geminilake_hdmi_init,
547526 .dpcm_playback = 1,
548527 .no_pcm = 1,
528
+ SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
549529 },
550530 };
551531
....@@ -555,8 +535,18 @@
555535 struct snd_soc_component *component = NULL;
556536 char jack_name[NAME_SIZE];
557537 struct glk_hdmi_pcm *pcm;
558
- int err = 0;
538
+ int err;
559539 int i = 0;
540
+
541
+ if (list_empty(&ctx->hdmi_pcm_list))
542
+ return -EINVAL;
543
+
544
+ if (ctx->common_hdmi_codec_drv) {
545
+ pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
546
+ head);
547
+ component = pcm->codec_dai->component;
548
+ return hda_dsp_hdmi_build_controls(card, component);
549
+ }
560550
561551 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
562552 component = pcm->codec_dai->component;
....@@ -576,9 +566,6 @@
576566
577567 i++;
578568 }
579
-
580
- if (!component)
581
- return -EINVAL;
582569
583570 return hdac_hdmi_jack_port_init(component, &card->dapm);
584571 }
....@@ -602,18 +589,32 @@
602589 static int geminilake_audio_probe(struct platform_device *pdev)
603590 {
604591 struct glk_card_private *ctx;
592
+ struct snd_soc_acpi_mach *mach;
593
+ const char *platform_name;
594
+ struct snd_soc_card *card;
595
+ int ret;
605596
606
- ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
597
+ ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
607598 if (!ctx)
608599 return -ENOMEM;
609600
610601 INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
611602
612
- glk_audio_card_rt5682_m98357a.dev = &pdev->dev;
613
- snd_soc_card_set_drvdata(&glk_audio_card_rt5682_m98357a, ctx);
603
+ card = &glk_audio_card_rt5682_m98357a;
604
+ card->dev = &pdev->dev;
605
+ snd_soc_card_set_drvdata(card, ctx);
614606
615
- return devm_snd_soc_register_card(&pdev->dev,
616
- &glk_audio_card_rt5682_m98357a);
607
+ /* override plaform name, if required */
608
+ mach = pdev->dev.platform_data;
609
+ platform_name = mach->mach_params.platform;
610
+
611
+ ret = snd_soc_fixup_dai_links_platform_name(card, platform_name);
612
+ if (ret)
613
+ return ret;
614
+
615
+ ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
616
+
617
+ return devm_snd_soc_register_card(&pdev->dev, card);
617618 }
618619
619620 static const struct platform_device_id glk_board_ids[] = {