forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Intel Skylake I2S Machine Driver for NAU88L25+SSM4567
34 *
....@@ -7,15 +8,6 @@
78 * Intel Skylake I2S Machine Driver for NAU88L25 and SSM4567
89 *
910 * Copyright (C) 2015, Intel Corporation. All rights reserved.
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License version
13
- * 2 as published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
1911 */
2012
2113 #include <linux/module.h>
....@@ -23,11 +15,11 @@
2315 #include <sound/core.h>
2416 #include <sound/pcm.h>
2517 #include <sound/soc.h>
18
+#include <sound/soc-acpi.h>
2619 #include <sound/jack.h>
2720 #include <sound/pcm_params.h>
2821 #include "../../codecs/nau8825.h"
2922 #include "../../codecs/hdac_hdmi.h"
30
-#include "../skylake/skl.h"
3123
3224 #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
3325 #define SKL_SSM_CODEC_DAI "ssm4567-hifi"
....@@ -155,23 +147,12 @@
155147
156148 static struct snd_soc_codec_conf ssm4567_codec_conf[] = {
157149 {
158
- .dev_name = "i2c-INT343B:00",
150
+ .dlc = COMP_CODEC_CONF("i2c-INT343B:00"),
159151 .name_prefix = "Left",
160152 },
161153 {
162
- .dev_name = "i2c-INT343B:01",
154
+ .dlc = COMP_CODEC_CONF("i2c-INT343B:01"),
163155 .name_prefix = "Right",
164
- },
165
-};
166
-
167
-static struct snd_soc_dai_link_component ssm4567_codec_components[] = {
168
- { /* Left */
169
- .name = "i2c-INT343B:00",
170
- .dai_name = SKL_SSM_CODEC_DAI,
171
- },
172
- { /* Right */
173
- .name = "i2c-INT343B:01",
174
- .dai_name = SKL_SSM_CODEC_DAI,
175156 },
176157 };
177158
....@@ -180,12 +161,12 @@
180161 int ret;
181162
182163 /* Slot 1 for left */
183
- ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[0], 0x01, 0x01, 2, 48);
164
+ ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 0), 0x01, 0x01, 2, 48);
184165 if (ret < 0)
185166 return ret;
186167
187168 /* Slot 2 for right */
188
- ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[1], 0x02, 0x02, 2, 48);
169
+ ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 1), 0x02, 0x02, 2, 48);
189170 if (ret < 0)
190171 return ret;
191172
....@@ -195,7 +176,7 @@
195176 static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
196177 {
197178 int ret;
198
- struct snd_soc_component *component = rtd->codec_dai->component;
179
+ struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
199180
200181 /*
201182 * 4 buttons here map to the google Reference headset
....@@ -220,7 +201,7 @@
220201 static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
221202 {
222203 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
223
- struct snd_soc_dai *dai = rtd->codec_dai;
204
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
224205 struct skl_hdmi_pcm *pcm;
225206
226207 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -238,7 +219,7 @@
238219 static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
239220 {
240221 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
241
- struct snd_soc_dai *dai = rtd->codec_dai;
222
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
242223 struct skl_hdmi_pcm *pcm;
243224
244225 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -257,7 +238,7 @@
257238 static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
258239 {
259240 struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
260
- struct snd_soc_dai *dai = rtd->codec_dai;
241
+ struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
261242 struct skl_hdmi_pcm *pcm;
262243
263244 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
....@@ -275,7 +256,7 @@
275256 static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd)
276257 {
277258 struct snd_soc_dapm_context *dapm;
278
- struct snd_soc_component *component = rtd->cpu_dai->component;
259
+ struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
279260
280261 dapm = snd_soc_component_get_dapm(component);
281262 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
....@@ -336,13 +317,13 @@
336317 {
337318 struct snd_interval *rate = hw_param_interval(params,
338319 SNDRV_PCM_HW_PARAM_RATE);
339
- struct snd_interval *channels = hw_param_interval(params,
320
+ struct snd_interval *chan = hw_param_interval(params,
340321 SNDRV_PCM_HW_PARAM_CHANNELS);
341322 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
342323
343324 /* The ADSP will covert the FE rate to 48k, stereo */
344325 rate->min = rate->max = 48000;
345
- channels->min = channels->max = 2;
326
+ chan->min = chan->max = 2;
346327
347328 /* set SSP0 to 24 bit */
348329 snd_mask_none(fmt);
....@@ -353,12 +334,12 @@
353334 static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
354335 struct snd_pcm_hw_params *params)
355336 {
356
- struct snd_interval *channels = hw_param_interval(params,
337
+ struct snd_interval *chan = hw_param_interval(params,
357338 SNDRV_PCM_HW_PARAM_CHANNELS);
358339 if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
359
- channels->min = channels->max = 2;
340
+ chan->min = chan->max = 2;
360341 else
361
- channels->min = channels->max = 4;
342
+ chan->min = chan->max = 4;
362343
363344 return 0;
364345 }
....@@ -366,8 +347,8 @@
366347 static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream,
367348 struct snd_pcm_hw_params *params)
368349 {
369
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
370
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
350
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
351
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
371352 int ret;
372353
373354 ret = snd_soc_dai_set_sysclk(codec_dai,
....@@ -449,9 +430,65 @@
449430 &constraints_16000);
450431 }
451432
452
-static const struct snd_soc_ops skylaye_refcap_ops = {
433
+static const struct snd_soc_ops skylake_refcap_ops = {
453434 .startup = skylake_refcap_startup,
454435 };
436
+
437
+SND_SOC_DAILINK_DEF(dummy,
438
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
439
+
440
+SND_SOC_DAILINK_DEF(system,
441
+ DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
442
+
443
+SND_SOC_DAILINK_DEF(reference,
444
+ DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
445
+
446
+SND_SOC_DAILINK_DEF(dmic,
447
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
448
+
449
+SND_SOC_DAILINK_DEF(hdmi1,
450
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
451
+
452
+SND_SOC_DAILINK_DEF(hdmi2,
453
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
454
+
455
+SND_SOC_DAILINK_DEF(hdmi3,
456
+ DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
457
+
458
+SND_SOC_DAILINK_DEF(ssp0_pin,
459
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
460
+SND_SOC_DAILINK_DEF(ssp0_codec,
461
+ DAILINK_COMP_ARRAY(
462
+ /* Left */ COMP_CODEC("i2c-INT343B:00", SKL_SSM_CODEC_DAI),
463
+ /* Right */ COMP_CODEC("i2c-INT343B:01", SKL_SSM_CODEC_DAI)));
464
+
465
+SND_SOC_DAILINK_DEF(ssp1_pin,
466
+ DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
467
+SND_SOC_DAILINK_DEF(ssp1_codec,
468
+ DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10508825:00", SKL_NUVOTON_CODEC_DAI)));
469
+
470
+SND_SOC_DAILINK_DEF(dmic01_pin,
471
+ DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
472
+SND_SOC_DAILINK_DEF(dmic_codec,
473
+ DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
474
+
475
+SND_SOC_DAILINK_DEF(idisp1_pin,
476
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
477
+SND_SOC_DAILINK_DEF(idisp1_codec,
478
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
479
+
480
+SND_SOC_DAILINK_DEF(idisp2_pin,
481
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
482
+SND_SOC_DAILINK_DEF(idisp2_codec,
483
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
484
+
485
+SND_SOC_DAILINK_DEF(idisp3_pin,
486
+ DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
487
+SND_SOC_DAILINK_DEF(idisp3_codec,
488
+ DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
489
+
490
+SND_SOC_DAILINK_DEF(platform,
491
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
455492
456493 /* skylake digital audio interface glue - connects codec <--> CPU */
457494 static struct snd_soc_dai_link skylake_dais[] = {
....@@ -459,99 +496,78 @@
459496 [SKL_DPCM_AUDIO_PB] = {
460497 .name = "Skl Audio Port",
461498 .stream_name = "Audio",
462
- .cpu_dai_name = "System Pin",
463
- .platform_name = "0000:00:1f.3",
464499 .dynamic = 1,
465
- .codec_name = "snd-soc-dummy",
466
- .codec_dai_name = "snd-soc-dummy-dai",
467500 .nonatomic = 1,
468501 .init = skylake_nau8825_fe_init,
469502 .trigger = {
470503 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
471504 .dpcm_playback = 1,
472505 .ops = &skylake_nau8825_fe_ops,
506
+ SND_SOC_DAILINK_REG(system, dummy, platform),
473507 },
474508 [SKL_DPCM_AUDIO_CP] = {
475509 .name = "Skl Audio Capture Port",
476510 .stream_name = "Audio Record",
477
- .cpu_dai_name = "System Pin",
478
- .platform_name = "0000:00:1f.3",
479511 .dynamic = 1,
480
- .codec_name = "snd-soc-dummy",
481
- .codec_dai_name = "snd-soc-dummy-dai",
482512 .nonatomic = 1,
483513 .trigger = {
484514 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
485515 .dpcm_capture = 1,
486516 .ops = &skylake_nau8825_fe_ops,
517
+ SND_SOC_DAILINK_REG(system, dummy, platform),
487518 },
488519 [SKL_DPCM_AUDIO_REF_CP] = {
489520 .name = "Skl Audio Reference cap",
490521 .stream_name = "Wake on Voice",
491
- .cpu_dai_name = "Reference Pin",
492
- .codec_name = "snd-soc-dummy",
493
- .codec_dai_name = "snd-soc-dummy-dai",
494
- .platform_name = "0000:00:1f.3",
495522 .init = NULL,
496523 .dpcm_capture = 1,
497524 .nonatomic = 1,
498525 .dynamic = 1,
499
- .ops = &skylaye_refcap_ops,
526
+ .ops = &skylake_refcap_ops,
527
+ SND_SOC_DAILINK_REG(reference, dummy, platform),
500528 },
501529 [SKL_DPCM_AUDIO_DMIC_CP] = {
502530 .name = "Skl Audio DMIC cap",
503531 .stream_name = "dmiccap",
504
- .cpu_dai_name = "DMIC Pin",
505
- .codec_name = "snd-soc-dummy",
506
- .codec_dai_name = "snd-soc-dummy-dai",
507
- .platform_name = "0000:00:1f.3",
508532 .init = NULL,
509533 .dpcm_capture = 1,
510534 .nonatomic = 1,
511535 .dynamic = 1,
512536 .ops = &skylake_dmic_ops,
537
+ SND_SOC_DAILINK_REG(dmic, dummy, platform),
513538 },
514539 [SKL_DPCM_AUDIO_HDMI1_PB] = {
515540 .name = "Skl HDMI Port1",
516541 .stream_name = "Hdmi1",
517
- .cpu_dai_name = "HDMI1 Pin",
518
- .codec_name = "snd-soc-dummy",
519
- .codec_dai_name = "snd-soc-dummy-dai",
520
- .platform_name = "0000:00:1f.3",
521542 .dpcm_playback = 1,
522543 .init = NULL,
523544 .trigger = {
524545 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
525546 .nonatomic = 1,
526547 .dynamic = 1,
548
+ SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
527549 },
528550 [SKL_DPCM_AUDIO_HDMI2_PB] = {
529551 .name = "Skl HDMI Port2",
530552 .stream_name = "Hdmi2",
531
- .cpu_dai_name = "HDMI2 Pin",
532
- .codec_name = "snd-soc-dummy",
533
- .codec_dai_name = "snd-soc-dummy-dai",
534
- .platform_name = "0000:00:1f.3",
535553 .dpcm_playback = 1,
536554 .init = NULL,
537555 .trigger = {
538556 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
539557 .nonatomic = 1,
540558 .dynamic = 1,
559
+ SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
541560 },
542561 [SKL_DPCM_AUDIO_HDMI3_PB] = {
543562 .name = "Skl HDMI Port3",
544563 .stream_name = "Hdmi3",
545
- .cpu_dai_name = "HDMI3 Pin",
546
- .codec_name = "snd-soc-dummy",
547
- .codec_dai_name = "snd-soc-dummy-dai",
548
- .platform_name = "0000:00:1f.3",
549564 .trigger = {
550565 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
551566 .dpcm_playback = 1,
552567 .init = NULL,
553568 .nonatomic = 1,
554569 .dynamic = 1,
570
+ SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
555571 },
556572
557573 /* Back End DAI links */
....@@ -559,11 +575,7 @@
559575 /* SSP0 - Codec */
560576 .name = "SSP0-Codec",
561577 .id = 0,
562
- .cpu_dai_name = "SSP0 Pin",
563
- .platform_name = "0000:00:1f.3",
564578 .no_pcm = 1,
565
- .codecs = ssm4567_codec_components,
566
- .num_codecs = ARRAY_SIZE(ssm4567_codec_components),
567579 .dai_fmt = SND_SOC_DAIFMT_DSP_A |
568580 SND_SOC_DAIFMT_IB_NF |
569581 SND_SOC_DAIFMT_CBS_CFS,
....@@ -572,16 +584,13 @@
572584 .be_hw_params_fixup = skylake_ssp_fixup,
573585 .dpcm_playback = 1,
574586 .dpcm_capture = 1,
587
+ SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
575588 },
576589 {
577590 /* SSP1 - Codec */
578591 .name = "SSP1-Codec",
579592 .id = 1,
580
- .cpu_dai_name = "SSP1 Pin",
581
- .platform_name = "0000:00:1f.3",
582593 .no_pcm = 1,
583
- .codec_name = "i2c-10508825:00",
584
- .codec_dai_name = SKL_NUVOTON_CODEC_DAI,
585594 .init = skylake_nau8825_codec_init,
586595 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
587596 SND_SOC_DAIFMT_CBS_CFS,
....@@ -590,51 +599,40 @@
590599 .ops = &skylake_nau8825_ops,
591600 .dpcm_playback = 1,
592601 .dpcm_capture = 1,
602
+ SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
593603 },
594604 {
595605 .name = "dmic01",
596606 .id = 2,
597
- .cpu_dai_name = "DMIC01 Pin",
598
- .codec_name = "dmic-codec",
599
- .codec_dai_name = "dmic-hifi",
600
- .platform_name = "0000:00:1f.3",
601607 .ignore_suspend = 1,
602608 .be_hw_params_fixup = skylake_dmic_fixup,
603609 .dpcm_capture = 1,
604610 .no_pcm = 1,
611
+ SND_SOC_DAILINK_REG(dmic01_pin, dmic_codec, platform),
605612 },
606613 {
607614 .name = "iDisp1",
608615 .id = 3,
609
- .cpu_dai_name = "iDisp1 Pin",
610
- .codec_name = "ehdaudio0D2",
611
- .codec_dai_name = "intel-hdmi-hifi1",
612
- .platform_name = "0000:00:1f.3",
613616 .dpcm_playback = 1,
614617 .init = skylake_hdmi1_init,
615618 .no_pcm = 1,
619
+ SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
616620 },
617621 {
618622 .name = "iDisp2",
619623 .id = 4,
620
- .cpu_dai_name = "iDisp2 Pin",
621
- .codec_name = "ehdaudio0D2",
622
- .codec_dai_name = "intel-hdmi-hifi2",
623
- .platform_name = "0000:00:1f.3",
624624 .init = skylake_hdmi2_init,
625625 .dpcm_playback = 1,
626626 .no_pcm = 1,
627
+ SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
627628 },
628629 {
629630 .name = "iDisp3",
630631 .id = 5,
631
- .cpu_dai_name = "iDisp3 Pin",
632
- .codec_name = "ehdaudio0D2",
633
- .codec_dai_name = "intel-hdmi-hifi3",
634
- .platform_name = "0000:00:1f.3",
635632 .init = skylake_hdmi3_init,
636633 .dpcm_playback = 1,
637634 .no_pcm = 1,
635
+ SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
638636 },
639637 };
640638
....@@ -688,13 +686,14 @@
688686 .codec_conf = ssm4567_codec_conf,
689687 .num_configs = ARRAY_SIZE(ssm4567_codec_conf),
690688 .fully_routed = true,
689
+ .disable_route_checks = true,
691690 .late_probe = skylake_card_late_probe,
692691 };
693692
694693 static int skylake_audio_probe(struct platform_device *pdev)
695694 {
696695 struct skl_nau88125_private *ctx;
697
- struct skl_machine_pdata *pdata;
696
+ struct snd_soc_acpi_mach *mach;
698697
699698 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
700699 if (!ctx)
....@@ -705,9 +704,9 @@
705704 skylake_audio_card.dev = &pdev->dev;
706705 snd_soc_card_set_drvdata(&skylake_audio_card, ctx);
707706
708
- pdata = dev_get_drvdata(&pdev->dev);
709
- if (pdata)
710
- dmic_constraints = pdata->dmic_num == 2 ?
707
+ mach = pdev->dev.platform_data;
708
+ if (mach)
709
+ dmic_constraints = mach->mach_params.dmic_num == 2 ?
711710 &constraints_dmic_2ch : &constraints_dmic_channels;
712711
713712 return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);