forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
....@@ -60,6 +60,27 @@
6060 { .rate = 352800, .regvalue = 24 },
6161 };
6262
63
+static const unsigned int mt2701_afe_backup_list[] = {
64
+ AUDIO_TOP_CON0,
65
+ AUDIO_TOP_CON4,
66
+ AUDIO_TOP_CON5,
67
+ ASYS_TOP_CON,
68
+ AFE_CONN0,
69
+ AFE_CONN1,
70
+ AFE_CONN2,
71
+ AFE_CONN3,
72
+ AFE_CONN15,
73
+ AFE_CONN16,
74
+ AFE_CONN17,
75
+ AFE_CONN18,
76
+ AFE_CONN19,
77
+ AFE_CONN20,
78
+ AFE_CONN21,
79
+ AFE_CONN22,
80
+ AFE_DAC_CON0,
81
+ AFE_MEMIF_PBUF_SIZE,
82
+};
83
+
6384 static int mt2701_dai_num_to_i2s(struct mtk_base_afe *afe, int num)
6485 {
6586 struct mt2701_afe_private *afe_priv = afe->platform_priv;
....@@ -473,10 +494,10 @@
473494 static int mt2701_memif_fs(struct snd_pcm_substream *substream,
474495 unsigned int rate)
475496 {
476
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
497
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
477498 int fs;
478499
479
- if (rtd->cpu_dai->id != MT2701_MEMIF_ULBT)
500
+ if (asoc_rtd_to_cpu(rtd, 0)->id != MT2701_MEMIF_ULBT)
480501 fs = mt2701_afe_i2s_fs(rate);
481502 else
482503 fs = (rate == 16000 ? 1 : 0);
....@@ -528,8 +549,6 @@
528549 {
529550 .name = "PCMO0",
530551 .id = MT2701_MEMIF_DL1,
531
- .suspend = mtk_afe_dai_suspend,
532
- .resume = mtk_afe_dai_resume,
533552 .playback = {
534553 .stream_name = "DL1",
535554 .channels_min = 1,
....@@ -544,8 +563,6 @@
544563 {
545564 .name = "PCM_multi",
546565 .id = MT2701_MEMIF_DLM,
547
- .suspend = mtk_afe_dai_suspend,
548
- .resume = mtk_afe_dai_resume,
549566 .playback = {
550567 .stream_name = "DLM",
551568 .channels_min = 1,
....@@ -561,8 +578,6 @@
561578 {
562579 .name = "PCM0",
563580 .id = MT2701_MEMIF_UL1,
564
- .suspend = mtk_afe_dai_suspend,
565
- .resume = mtk_afe_dai_resume,
566581 .capture = {
567582 .stream_name = "UL1",
568583 .channels_min = 1,
....@@ -577,8 +592,6 @@
577592 {
578593 .name = "PCM1",
579594 .id = MT2701_MEMIF_UL2,
580
- .suspend = mtk_afe_dai_suspend,
581
- .resume = mtk_afe_dai_resume,
582595 .capture = {
583596 .stream_name = "UL2",
584597 .channels_min = 1,
....@@ -594,8 +607,6 @@
594607 {
595608 .name = "PCM_BT_DL",
596609 .id = MT2701_MEMIF_DLBT,
597
- .suspend = mtk_afe_dai_suspend,
598
- .resume = mtk_afe_dai_resume,
599610 .playback = {
600611 .stream_name = "DLBT",
601612 .channels_min = 1,
....@@ -609,8 +620,6 @@
609620 {
610621 .name = "PCM_BT_UL",
611622 .id = MT2701_MEMIF_ULBT,
612
- .suspend = mtk_afe_dai_suspend,
613
- .resume = mtk_afe_dai_resume,
614623 .capture = {
615624 .stream_name = "ULBT",
616625 .channels_min = 1,
....@@ -796,14 +805,6 @@
796805 SOC_DAPM_SINGLE_AUTODISABLE("I19 Switch", AFE_CONN22, 19, 1, 0),
797806 };
798807
799
-static const struct snd_kcontrol_new mt2701_afe_o23_mix[] = {
800
- SOC_DAPM_SINGLE_AUTODISABLE("I20 Switch", AFE_CONN23, 20, 1, 0),
801
-};
802
-
803
-static const struct snd_kcontrol_new mt2701_afe_o24_mix[] = {
804
- SOC_DAPM_SINGLE_AUTODISABLE("I21 Switch", AFE_CONN24, 21, 1, 0),
805
-};
806
-
807808 static const struct snd_kcontrol_new mt2701_afe_o31_mix[] = {
808809 SOC_DAPM_SINGLE_AUTODISABLE("I35 Switch", AFE_CONN41, 9, 1, 0),
809810 };
....@@ -830,11 +831,6 @@
830831 static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_i2s3[] = {
831832 SOC_DAPM_SINGLE_AUTODISABLE("Multich I2S3 Out Switch",
832833 PWR2_TOP_CON, 18, 1, 0),
833
-};
834
-
835
-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_i2s4[] = {
836
- SOC_DAPM_SINGLE_AUTODISABLE("Multich I2S4 Out Switch",
837
- PWR2_TOP_CON, 19, 1, 0),
838834 };
839835
840836 static const struct snd_soc_dapm_widget mt2701_afe_pcm_widgets[] = {
....@@ -974,6 +970,8 @@
974970 .num_dapm_widgets = ARRAY_SIZE(mt2701_afe_pcm_widgets),
975971 .dapm_routes = mt2701_afe_pcm_routes,
976972 .num_dapm_routes = ARRAY_SIZE(mt2701_afe_pcm_routes),
973
+ .suspend = mtk_afe_suspend,
974
+ .resume = mtk_afe_resume,
977975 };
978976
979977 static const struct mtk_base_memif_data memif_data[MT2701_MEMIF_NUM] = {
....@@ -994,7 +992,6 @@
994992 .agent_disable_reg = AUDIO_TOP_CON5,
995993 .agent_disable_shift = 6,
996994 .msb_reg = -1,
997
- .msb_shift = -1,
998995 },
999996 {
1000997 .name = "DL2",
....@@ -1013,7 +1010,6 @@
10131010 .agent_disable_reg = AUDIO_TOP_CON5,
10141011 .agent_disable_shift = 7,
10151012 .msb_reg = -1,
1016
- .msb_shift = -1,
10171013 },
10181014 {
10191015 .name = "DL3",
....@@ -1032,7 +1028,6 @@
10321028 .agent_disable_reg = AUDIO_TOP_CON5,
10331029 .agent_disable_shift = 8,
10341030 .msb_reg = -1,
1035
- .msb_shift = -1,
10361031 },
10371032 {
10381033 .name = "DL4",
....@@ -1051,7 +1046,6 @@
10511046 .agent_disable_reg = AUDIO_TOP_CON5,
10521047 .agent_disable_shift = 9,
10531048 .msb_reg = -1,
1054
- .msb_shift = -1,
10551049 },
10561050 {
10571051 .name = "DL5",
....@@ -1070,7 +1064,6 @@
10701064 .agent_disable_reg = AUDIO_TOP_CON5,
10711065 .agent_disable_shift = 10,
10721066 .msb_reg = -1,
1073
- .msb_shift = -1,
10741067 },
10751068 {
10761069 .name = "DLM",
....@@ -1089,7 +1082,6 @@
10891082 .agent_disable_reg = AUDIO_TOP_CON5,
10901083 .agent_disable_shift = 12,
10911084 .msb_reg = -1,
1092
- .msb_shift = -1,
10931085 },
10941086 {
10951087 .name = "UL1",
....@@ -1108,7 +1100,6 @@
11081100 .agent_disable_reg = AUDIO_TOP_CON5,
11091101 .agent_disable_shift = 0,
11101102 .msb_reg = -1,
1111
- .msb_shift = -1,
11121103 },
11131104 {
11141105 .name = "UL2",
....@@ -1127,7 +1118,6 @@
11271118 .agent_disable_reg = AUDIO_TOP_CON5,
11281119 .agent_disable_shift = 1,
11291120 .msb_reg = -1,
1130
- .msb_shift = -1,
11311121 },
11321122 {
11331123 .name = "UL3",
....@@ -1146,7 +1136,6 @@
11461136 .agent_disable_reg = AUDIO_TOP_CON5,
11471137 .agent_disable_shift = 2,
11481138 .msb_reg = -1,
1149
- .msb_shift = -1,
11501139 },
11511140 {
11521141 .name = "UL4",
....@@ -1165,7 +1154,6 @@
11651154 .agent_disable_reg = AUDIO_TOP_CON5,
11661155 .agent_disable_shift = 3,
11671156 .msb_reg = -1,
1168
- .msb_shift = -1,
11691157 },
11701158 {
11711159 .name = "UL5",
....@@ -1184,7 +1172,6 @@
11841172 .agent_disable_reg = AUDIO_TOP_CON5,
11851173 .agent_disable_shift = 4,
11861174 .msb_reg = -1,
1187
- .msb_shift = -1,
11881175 },
11891176 {
11901177 .name = "DLBT",
....@@ -1203,7 +1190,6 @@
12031190 .agent_disable_reg = AUDIO_TOP_CON5,
12041191 .agent_disable_shift = 13,
12051192 .msb_reg = -1,
1206
- .msb_shift = -1,
12071193 },
12081194 {
12091195 .name = "ULBT",
....@@ -1222,7 +1208,6 @@
12221208 .agent_disable_reg = AUDIO_TOP_CON5,
12231209 .agent_disable_shift = 16,
12241210 .msb_reg = -1,
1225
- .msb_shift = -1,
12261211 },
12271212 };
12281213
....@@ -1355,10 +1340,8 @@
13551340 return -ENOMEM;
13561341
13571342 irq_id = platform_get_irq_byname(pdev, "asys");
1358
- if (irq_id < 0) {
1359
- dev_err(dev, "unable to get ASYS IRQ\n");
1343
+ if (irq_id < 0)
13601344 return irq_id;
1361
- }
13621345
13631346 ret = devm_request_irq(dev, irq_id, mt2701_asys_isr,
13641347 IRQF_TRIGGER_NONE, "asys-isr", (void *)afe);