forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/intel/boards/skl_nau88l25_max98357a.c
....@@ -1,17 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Intel Skylake I2S Machine Driver with MAXIM98357A
34 * and NAU88L25
45 *
56 * Copyright (C) 2015, Intel Corporation. All rights reserved.
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License version
9
- * 2 as published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
157 */
168
179 #include <linux/module.h>
....@@ -21,9 +13,9 @@
2113 #include <sound/pcm.h>
2214 #include <sound/pcm_params.h>
2315 #include <sound/soc.h>
16
+#include <sound/soc-acpi.h>
2417 #include "../../codecs/nau8825.h"
2518 #include "../../codecs/hdac_hdmi.h"
26
-#include "../skylake/skl.h"
2719
2820 #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
2921 #define SKL_MAXIM_CODEC_DAI "HiFi"
....@@ -147,13 +139,13 @@
147139 {
148140 struct snd_interval *rate = hw_param_interval(params,
149141 SNDRV_PCM_HW_PARAM_RATE);
150
- struct snd_interval *channels = hw_param_interval(params,
142
+ struct snd_interval *chan = hw_param_interval(params,
151143 SNDRV_PCM_HW_PARAM_CHANNELS);
152144 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
153145
154146 /* The ADSP will covert the FE rate to 48k, stereo */
155147 rate->min = rate->max = 48000;
156
- channels->min = channels->max = 2;
148
+ chan->min = chan->max = 2;
157149
158150 /* set SSP0 to 24 bit */
159151 snd_mask_none(fmt);
....@@ -165,7 +157,7 @@
165157 static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
166158 {
167159 int ret;
168
- struct snd_soc_component *component = rtd->codec_dai->component;
160
+ struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
169161
170162 /*
171163 * Headset buttons map to the google Reference headset.
....@@ -190,7 +182,7 @@
190182 static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
191183 {
192184 struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card);
193
- struct snd_soc_dai *dai = rtd->codec_dai;
185
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
194186 struct skl_hdmi_pcm *pcm;
195187
196188 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -208,7 +200,7 @@
208200 static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
209201 {
210202 struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card);
211
- struct snd_soc_dai *dai = rtd->codec_dai;
203
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
212204 struct skl_hdmi_pcm *pcm;
213205
214206 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -226,7 +218,7 @@
226218 static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
227219 {
228220 struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card);
229
- struct snd_soc_dai *dai = rtd->codec_dai;
221
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
230222 struct skl_hdmi_pcm *pcm;
231223
232224 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -244,7 +236,7 @@
244236 static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd)
245237 {
246238 struct snd_soc_dapm_context *dapm;
247
- struct snd_soc_component *component = rtd->cpu_dai->component;
239
+ struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
248240
249241 dapm = snd_soc_component_get_dapm(component);
250242 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
....@@ -303,8 +295,8 @@
303295 static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream,
304296 struct snd_pcm_hw_params *params)
305297 {
306
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
307
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
298
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
299
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
308300 int ret;
309301
310302 ret = snd_soc_dai_set_sysclk(codec_dai,
....@@ -323,13 +315,13 @@
323315 static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
324316 struct snd_pcm_hw_params *params)
325317 {
326
- struct snd_interval *channels = hw_param_interval(params,
318
+ struct snd_interval *chan = hw_param_interval(params,
327319 SNDRV_PCM_HW_PARAM_CHANNELS);
328320
329321 if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
330
- channels->min = channels->max = 2;
322
+ chan->min = chan->max = 2;
331323 else
332
- channels->min = channels->max = 4;
324
+ chan->min = chan->max = 4;
333325
334326 return 0;
335327 }
....@@ -400,9 +392,64 @@
400392 &constraints_16000);
401393 }
402394
403
-static const struct snd_soc_ops skylaye_refcap_ops = {
395
+static const struct snd_soc_ops skylake_refcap_ops = {
404396 .startup = skylake_refcap_startup,
405397 };
398
+
399
+SND_SOC_DAILINK_DEF(dummy,
400
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
401
+
402
+SND_SOC_DAILINK_DEF(system,
403
+ DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
404
+
405
+SND_SOC_DAILINK_DEF(reference,
406
+ DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
407
+
408
+SND_SOC_DAILINK_DEF(dmic,
409
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
410
+
411
+SND_SOC_DAILINK_DEF(hdmi1,
412
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
413
+
414
+SND_SOC_DAILINK_DEF(hdmi2,
415
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
416
+
417
+SND_SOC_DAILINK_DEF(hdmi3,
418
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
419
+
420
+SND_SOC_DAILINK_DEF(ssp0_pin,
421
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
422
+SND_SOC_DAILINK_DEF(ssp0_codec,
423
+ DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00", SKL_MAXIM_CODEC_DAI)));
424
+
425
+SND_SOC_DAILINK_DEF(ssp1_pin,
426
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
427
+SND_SOC_DAILINK_DEF(ssp1_codec,
428
+ DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10508825:00",
429
+ SKL_NUVOTON_CODEC_DAI)));
430
+
431
+SND_SOC_DAILINK_DEF(dmic_pin,
432
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
433
+SND_SOC_DAILINK_DEF(dmic_codec,
434
+ DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
435
+
436
+SND_SOC_DAILINK_DEF(idisp1_pin,
437
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
438
+SND_SOC_DAILINK_DEF(idisp1_codec,
439
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
440
+
441
+SND_SOC_DAILINK_DEF(idisp2_pin,
442
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
443
+SND_SOC_DAILINK_DEF(idisp2_codec,
444
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
445
+
446
+SND_SOC_DAILINK_DEF(idisp3_pin,
447
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
448
+SND_SOC_DAILINK_DEF(idisp3_codec,
449
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
450
+
451
+SND_SOC_DAILINK_DEF(platform,
452
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
406453
407454 /* skylake digital audio interface glue - connects codec <--> CPU */
408455 static struct snd_soc_dai_link skylake_dais[] = {
....@@ -410,99 +457,78 @@
410457 [SKL_DPCM_AUDIO_PB] = {
411458 .name = "Skl Audio Port",
412459 .stream_name = "Audio",
413
- .cpu_dai_name = "System Pin",
414
- .platform_name = "0000:00:1f.3",
415460 .dynamic = 1,
416
- .codec_name = "snd-soc-dummy",
417
- .codec_dai_name = "snd-soc-dummy-dai",
418461 .nonatomic = 1,
419462 .init = skylake_nau8825_fe_init,
420463 .trigger = {
421464 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
422465 .dpcm_playback = 1,
423466 .ops = &skylake_nau8825_fe_ops,
467
+ SND_SOC_DAILINK_REG(system, dummy, platform),
424468 },
425469 [SKL_DPCM_AUDIO_CP] = {
426470 .name = "Skl Audio Capture Port",
427471 .stream_name = "Audio Record",
428
- .cpu_dai_name = "System Pin",
429
- .platform_name = "0000:00:1f.3",
430472 .dynamic = 1,
431
- .codec_name = "snd-soc-dummy",
432
- .codec_dai_name = "snd-soc-dummy-dai",
433473 .nonatomic = 1,
434474 .trigger = {
435475 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
436476 .dpcm_capture = 1,
437477 .ops = &skylake_nau8825_fe_ops,
478
+ SND_SOC_DAILINK_REG(system, dummy, platform),
438479 },
439480 [SKL_DPCM_AUDIO_REF_CP] = {
440481 .name = "Skl Audio Reference cap",
441482 .stream_name = "Wake on Voice",
442
- .cpu_dai_name = "Reference Pin",
443
- .codec_name = "snd-soc-dummy",
444
- .codec_dai_name = "snd-soc-dummy-dai",
445
- .platform_name = "0000:00:1f.3",
446483 .init = NULL,
447484 .dpcm_capture = 1,
448485 .nonatomic = 1,
449486 .dynamic = 1,
450
- .ops = &skylaye_refcap_ops,
487
+ .ops = &skylake_refcap_ops,
488
+ SND_SOC_DAILINK_REG(reference, dummy, platform),
451489 },
452490 [SKL_DPCM_AUDIO_DMIC_CP] = {
453491 .name = "Skl Audio DMIC cap",
454492 .stream_name = "dmiccap",
455
- .cpu_dai_name = "DMIC Pin",
456
- .codec_name = "snd-soc-dummy",
457
- .codec_dai_name = "snd-soc-dummy-dai",
458
- .platform_name = "0000:00:1f.3",
459493 .init = NULL,
460494 .dpcm_capture = 1,
461495 .nonatomic = 1,
462496 .dynamic = 1,
463497 .ops = &skylake_dmic_ops,
498
+ SND_SOC_DAILINK_REG(dmic, dummy, platform),
464499 },
465500 [SKL_DPCM_AUDIO_HDMI1_PB] = {
466501 .name = "Skl HDMI Port1",
467502 .stream_name = "Hdmi1",
468
- .cpu_dai_name = "HDMI1 Pin",
469
- .codec_name = "snd-soc-dummy",
470
- .codec_dai_name = "snd-soc-dummy-dai",
471
- .platform_name = "0000:00:1f.3",
472503 .dpcm_playback = 1,
473504 .init = NULL,
474505 .trigger = {
475506 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
476507 .nonatomic = 1,
477508 .dynamic = 1,
509
+ SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
478510 },
479511 [SKL_DPCM_AUDIO_HDMI2_PB] = {
480512 .name = "Skl HDMI Port2",
481513 .stream_name = "Hdmi2",
482
- .cpu_dai_name = "HDMI2 Pin",
483
- .codec_name = "snd-soc-dummy",
484
- .codec_dai_name = "snd-soc-dummy-dai",
485
- .platform_name = "0000:00:1f.3",
486514 .dpcm_playback = 1,
487515 .init = NULL,
488516 .trigger = {
489517 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
490518 .nonatomic = 1,
491519 .dynamic = 1,
520
+ SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
492521 },
493522 [SKL_DPCM_AUDIO_HDMI3_PB] = {
494523 .name = "Skl HDMI Port3",
495524 .stream_name = "Hdmi3",
496
- .cpu_dai_name = "HDMI3 Pin",
497
- .codec_name = "snd-soc-dummy",
498
- .codec_dai_name = "snd-soc-dummy-dai",
499
- .platform_name = "0000:00:1f.3",
500525 .trigger = {
501526 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
502527 .dpcm_playback = 1,
503528 .init = NULL,
504529 .nonatomic = 1,
505530 .dynamic = 1,
531
+ SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
506532 },
507533
508534 /* Back End DAI links */
....@@ -510,27 +536,20 @@
510536 /* SSP0 - Codec */
511537 .name = "SSP0-Codec",
512538 .id = 0,
513
- .cpu_dai_name = "SSP0 Pin",
514
- .platform_name = "0000:00:1f.3",
515539 .no_pcm = 1,
516
- .codec_name = "MX98357A:00",
517
- .codec_dai_name = SKL_MAXIM_CODEC_DAI,
518540 .dai_fmt = SND_SOC_DAIFMT_I2S |
519541 SND_SOC_DAIFMT_NB_NF |
520542 SND_SOC_DAIFMT_CBS_CFS,
521543 .ignore_pmdown_time = 1,
522544 .be_hw_params_fixup = skylake_ssp_fixup,
523545 .dpcm_playback = 1,
546
+ SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
524547 },
525548 {
526549 /* SSP1 - Codec */
527550 .name = "SSP1-Codec",
528551 .id = 1,
529
- .cpu_dai_name = "SSP1 Pin",
530
- .platform_name = "0000:00:1f.3",
531552 .no_pcm = 1,
532
- .codec_name = "i2c-10508825:00",
533
- .codec_dai_name = SKL_NUVOTON_CODEC_DAI,
534553 .init = skylake_nau8825_codec_init,
535554 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
536555 SND_SOC_DAIFMT_CBS_CFS,
....@@ -539,51 +558,40 @@
539558 .ops = &skylake_nau8825_ops,
540559 .dpcm_playback = 1,
541560 .dpcm_capture = 1,
561
+ SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
542562 },
543563 {
544564 .name = "dmic01",
545565 .id = 2,
546
- .cpu_dai_name = "DMIC01 Pin",
547
- .codec_name = "dmic-codec",
548
- .codec_dai_name = "dmic-hifi",
549
- .platform_name = "0000:00:1f.3",
550566 .be_hw_params_fixup = skylake_dmic_fixup,
551567 .ignore_suspend = 1,
552568 .dpcm_capture = 1,
553569 .no_pcm = 1,
570
+ SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
554571 },
555572 {
556573 .name = "iDisp1",
557574 .id = 3,
558
- .cpu_dai_name = "iDisp1 Pin",
559
- .codec_name = "ehdaudio0D2",
560
- .codec_dai_name = "intel-hdmi-hifi1",
561
- .platform_name = "0000:00:1f.3",
562575 .dpcm_playback = 1,
563576 .init = skylake_hdmi1_init,
564577 .no_pcm = 1,
578
+ SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
565579 },
566580 {
567581 .name = "iDisp2",
568582 .id = 4,
569
- .cpu_dai_name = "iDisp2 Pin",
570
- .codec_name = "ehdaudio0D2",
571
- .codec_dai_name = "intel-hdmi-hifi2",
572
- .platform_name = "0000:00:1f.3",
573583 .init = skylake_hdmi2_init,
574584 .dpcm_playback = 1,
575585 .no_pcm = 1,
586
+ SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
576587 },
577588 {
578589 .name = "iDisp3",
579590 .id = 5,
580
- .cpu_dai_name = "iDisp3 Pin",
581
- .codec_name = "ehdaudio0D2",
582
- .codec_dai_name = "intel-hdmi-hifi3",
583
- .platform_name = "0000:00:1f.3",
584591 .init = skylake_hdmi3_init,
585592 .dpcm_playback = 1,
586593 .no_pcm = 1,
594
+ SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
587595 },
588596 };
589597
....@@ -641,7 +649,7 @@
641649 static int skylake_audio_probe(struct platform_device *pdev)
642650 {
643651 struct skl_nau8825_private *ctx;
644
- struct skl_machine_pdata *pdata;
652
+ struct snd_soc_acpi_mach *mach;
645653
646654 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
647655 if (!ctx)
....@@ -652,9 +660,9 @@
652660 skylake_audio_card.dev = &pdev->dev;
653661 snd_soc_card_set_drvdata(&skylake_audio_card, ctx);
654662
655
- pdata = dev_get_drvdata(&pdev->dev);
656
- if (pdata)
657
- dmic_constraints = pdata->dmic_num == 2 ?
663
+ mach = pdev->dev.platform_data;
664
+ if (mach)
665
+ dmic_constraints = mach->mach_params.dmic_num == 2 ?
658666 &constraints_dmic_2ch : &constraints_dmic_channels;
659667
660668 return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);