@@ -328,44 +328,7 @@ static int mt8195_mt6359_init(struct snd_soc_pcm_runtime *rtd)
328328
329329static int mt8195_hdmitx_dptx_startup (struct snd_pcm_substream * substream )
330330{
331- static const unsigned int rates [] = {
332- 48000
333- };
334- static const unsigned int channels [] = {
335- 2 , 4 , 6 , 8
336- };
337- static const struct snd_pcm_hw_constraint_list constraints_rates = {
338- .count = ARRAY_SIZE (rates ),
339- .list = rates ,
340- .mask = 0 ,
341- };
342- static const struct snd_pcm_hw_constraint_list constraints_channels = {
343- .count = ARRAY_SIZE (channels ),
344- .list = channels ,
345- .mask = 0 ,
346- };
347-
348- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
349- struct snd_pcm_runtime * runtime = substream -> runtime ;
350- int ret ;
351-
352- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
353- SNDRV_PCM_HW_PARAM_RATE ,
354- & constraints_rates );
355- if (ret < 0 ) {
356- dev_err (rtd -> dev , "hw_constraint_list rate failed\n" );
357- return ret ;
358- }
359-
360- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
361- SNDRV_PCM_HW_PARAM_CHANNELS ,
362- & constraints_channels );
363- if (ret < 0 ) {
364- dev_err (rtd -> dev , "hw_constraint_list channel failed\n" );
365- return ret ;
366- }
367-
368- return 0 ;
331+ return mtk_soundcard_startup (substream , MTK_CONSTRAINT_HDMIDP );
369332}
370333
371334static const struct snd_soc_ops mt8195_hdmitx_dptx_playback_ops = {
@@ -428,98 +391,6 @@ static int mt8195_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
428391 return 0 ;
429392}
430393
431- static int mt8195_playback_startup (struct snd_pcm_substream * substream )
432- {
433- static const unsigned int rates [] = {
434- 48000
435- };
436- static const unsigned int channels [] = {
437- 2
438- };
439- static const struct snd_pcm_hw_constraint_list constraints_rates = {
440- .count = ARRAY_SIZE (rates ),
441- .list = rates ,
442- .mask = 0 ,
443- };
444- static const struct snd_pcm_hw_constraint_list constraints_channels = {
445- .count = ARRAY_SIZE (channels ),
446- .list = channels ,
447- .mask = 0 ,
448- };
449-
450- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
451- struct snd_pcm_runtime * runtime = substream -> runtime ;
452- int ret ;
453-
454- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
455- SNDRV_PCM_HW_PARAM_RATE ,
456- & constraints_rates );
457- if (ret < 0 ) {
458- dev_err (rtd -> dev , "hw_constraint_list rate failed\n" );
459- return ret ;
460- }
461-
462- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
463- SNDRV_PCM_HW_PARAM_CHANNELS ,
464- & constraints_channels );
465- if (ret < 0 ) {
466- dev_err (rtd -> dev , "hw_constraint_list channel failed\n" );
467- return ret ;
468- }
469-
470- return 0 ;
471- }
472-
473- static const struct snd_soc_ops mt8195_playback_ops = {
474- .startup = mt8195_playback_startup ,
475- };
476-
477- static int mt8195_capture_startup (struct snd_pcm_substream * substream )
478- {
479- static const unsigned int rates [] = {
480- 48000
481- };
482- static const unsigned int channels [] = {
483- 1 , 2
484- };
485- static const struct snd_pcm_hw_constraint_list constraints_rates = {
486- .count = ARRAY_SIZE (rates ),
487- .list = rates ,
488- .mask = 0 ,
489- };
490- static const struct snd_pcm_hw_constraint_list constraints_channels = {
491- .count = ARRAY_SIZE (channels ),
492- .list = channels ,
493- .mask = 0 ,
494- };
495-
496- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
497- struct snd_pcm_runtime * runtime = substream -> runtime ;
498- int ret ;
499-
500- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
501- SNDRV_PCM_HW_PARAM_RATE ,
502- & constraints_rates );
503- if (ret < 0 ) {
504- dev_err (rtd -> dev , "hw_constraint_list rate failed\n" );
505- return ret ;
506- }
507-
508- ret = snd_pcm_hw_constraint_list (runtime , 0 ,
509- SNDRV_PCM_HW_PARAM_CHANNELS ,
510- & constraints_channels );
511- if (ret < 0 ) {
512- dev_err (rtd -> dev , "hw_constraint_list channel failed\n" );
513- return ret ;
514- }
515-
516- return 0 ;
517- }
518-
519- static const struct snd_soc_ops mt8195_capture_ops = {
520- .startup = mt8195_capture_startup ,
521- };
522-
523394static int mt8195_rt5682_etdm_hw_params (struct snd_pcm_substream * substream ,
524395 struct snd_pcm_hw_params * params )
525396{
@@ -1042,7 +913,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
1042913 },
1043914 .dynamic = 1 ,
1044915 .dpcm_playback = 1 ,
1045- .ops = & mt8195_playback_ops ,
916+ .ops = & mtk_soundcard_common_playback_ops ,
1046917 SND_SOC_DAILINK_REG (DL2_FE ),
1047918 },
1048919 [DAI_LINK_DL3_FE ] = {
@@ -1054,7 +925,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
1054925 },
1055926 .dynamic = 1 ,
1056927 .dpcm_playback = 1 ,
1057- .ops = & mt8195_playback_ops ,
928+ .ops = & mtk_soundcard_common_playback_ops ,
1058929 SND_SOC_DAILINK_REG (DL3_FE ),
1059930 },
1060931 [DAI_LINK_DL6_FE ] = {
@@ -1066,7 +937,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
1066937 },
1067938 .dynamic = 1 ,
1068939 .dpcm_playback = 1 ,
1069- .ops = & mt8195_playback_ops ,
940+ .ops = & mtk_soundcard_common_playback_ops ,
1070941 SND_SOC_DAILINK_REG (DL6_FE ),
1071942 },
1072943 [DAI_LINK_DL7_FE ] = {
@@ -1089,7 +960,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
1089960 },
1090961 .dynamic = 1 ,
1091962 .dpcm_playback = 1 ,
1092- .ops = & mt8195_playback_ops ,
963+ .ops = & mtk_soundcard_common_playback_ops ,
1093964 SND_SOC_DAILINK_REG (DL8_FE ),
1094965 },
1095966 [DAI_LINK_DL10_FE ] = {
@@ -1113,7 +984,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
1113984 },
1114985 .dynamic = 1 ,
1115986 .dpcm_playback = 1 ,
1116- .ops = & mt8195_playback_ops ,
987+ .ops = & mtk_soundcard_common_playback_ops ,
1117988 SND_SOC_DAILINK_REG (DL11_FE ),
1118989 },
1119990 [DAI_LINK_UL1_FE ] = {
@@ -1136,7 +1007,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
11361007 },
11371008 .dynamic = 1 ,
11381009 .dpcm_capture = 1 ,
1139- .ops = & mt8195_capture_ops ,
1010+ .ops = & mtk_soundcard_common_capture_ops ,
11401011 SND_SOC_DAILINK_REG (UL2_FE ),
11411012 },
11421013 [DAI_LINK_UL3_FE ] = {
@@ -1148,7 +1019,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
11481019 },
11491020 .dynamic = 1 ,
11501021 .dpcm_capture = 1 ,
1151- .ops = & mt8195_capture_ops ,
1022+ .ops = & mtk_soundcard_common_capture_ops ,
11521023 SND_SOC_DAILINK_REG (UL3_FE ),
11531024 },
11541025 [DAI_LINK_UL4_FE ] = {
@@ -1160,7 +1031,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
11601031 },
11611032 .dynamic = 1 ,
11621033 .dpcm_capture = 1 ,
1163- .ops = & mt8195_capture_ops ,
1034+ .ops = & mtk_soundcard_common_capture_ops ,
11641035 SND_SOC_DAILINK_REG (UL4_FE ),
11651036 },
11661037 [DAI_LINK_UL5_FE ] = {
@@ -1172,7 +1043,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
11721043 },
11731044 .dynamic = 1 ,
11741045 .dpcm_capture = 1 ,
1175- .ops = & mt8195_capture_ops ,
1046+ .ops = & mtk_soundcard_common_capture_ops ,
11761047 SND_SOC_DAILINK_REG (UL5_FE ),
11771048 },
11781049 [DAI_LINK_UL6_FE ] = {
@@ -1195,7 +1066,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
11951066 },
11961067 .dynamic = 1 ,
11971068 .dpcm_capture = 1 ,
1198- .ops = & mt8195_capture_ops ,
1069+ .ops = & mtk_soundcard_common_capture_ops ,
11991070 SND_SOC_DAILINK_REG (UL8_FE ),
12001071 },
12011072 [DAI_LINK_UL9_FE ] = {
@@ -1207,7 +1078,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
12071078 },
12081079 .dynamic = 1 ,
12091080 .dpcm_capture = 1 ,
1210- .ops = & mt8195_capture_ops ,
1081+ .ops = & mtk_soundcard_common_capture_ops ,
12111082 SND_SOC_DAILINK_REG (UL9_FE ),
12121083 },
12131084 [DAI_LINK_UL10_FE ] = {
@@ -1219,7 +1090,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
12191090 },
12201091 .dynamic = 1 ,
12211092 .dpcm_capture = 1 ,
1222- .ops = & mt8195_capture_ops ,
1093+ .ops = & mtk_soundcard_common_capture_ops ,
12231094 SND_SOC_DAILINK_REG (UL10_FE ),
12241095 },
12251096 /* BE */
@@ -1561,6 +1432,40 @@ static int mt8195_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data,
15611432 return 0 ;
15621433}
15631434
1435+ static const unsigned int mt8195_pcm_playback_channels [] = { 2 };
1436+ static const unsigned int mt8195_pcm_capture_channels [] = { 1 , 2 };
1437+ static const unsigned int mt8195_pcm_hdmidp_channels [] = { 2 , 4 , 6 , 8 };
1438+ static const unsigned int mt8195_pcm_rates [] = { 48000 };
1439+
1440+ static const struct snd_pcm_hw_constraint_list mt8195_rate_constraint = {
1441+ .list = mt8195_pcm_rates ,
1442+ .count = ARRAY_SIZE (mt8195_pcm_rates )
1443+ };
1444+
1445+ static const struct mtk_pcm_constraints_data mt8195_pcm_constraints [MTK_CONSTRAINT_HDMIDP + 1 ] = {
1446+ [MTK_CONSTRAINT_PLAYBACK ] = {
1447+ .channels = & (const struct snd_pcm_hw_constraint_list ) {
1448+ .list = mt8195_pcm_playback_channels ,
1449+ .count = ARRAY_SIZE (mt8195_pcm_playback_channels )
1450+ },
1451+ .rates = & mt8195_rate_constraint ,
1452+ },
1453+ [MTK_CONSTRAINT_CAPTURE ] = {
1454+ .channels = & (const struct snd_pcm_hw_constraint_list ) {
1455+ .list = mt8195_pcm_capture_channels ,
1456+ .count = ARRAY_SIZE (mt8195_pcm_capture_channels )
1457+ },
1458+ .rates = & mt8195_rate_constraint ,
1459+ },
1460+ [MTK_CONSTRAINT_HDMIDP ] = {
1461+ .channels = & (const struct snd_pcm_hw_constraint_list ) {
1462+ .list = mt8195_pcm_hdmidp_channels ,
1463+ .count = ARRAY_SIZE (mt8195_pcm_hdmidp_channels )
1464+ },
1465+ .rates = & mt8195_rate_constraint ,
1466+ },
1467+ };
1468+
15641469static const struct mtk_sof_priv mt8195_sof_priv = {
15651470 .conn_streams = g_sof_conn_streams ,
15661471 .num_streams = ARRAY_SIZE (g_sof_conn_streams ),
@@ -1572,6 +1477,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359_rt1019_rt5682_card = {
15721477 .card_data = & (struct mtk_platform_card_data ) {
15731478 .card = & mt8195_mt6359_soc_card ,
15741479 .num_jacks = MT8195_JACK_MAX ,
1480+ .pcm_constraints = mt8195_pcm_constraints ,
1481+ .num_pcm_constraints = ARRAY_SIZE (mt8195_pcm_constraints ),
15751482 .flags = RT1019_SPEAKER_AMP_PRESENT
15761483 },
15771484 .sof_priv = & mt8195_sof_priv ,
@@ -1583,6 +1490,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359_rt1011_rt5682_card = {
15831490 .card_data = & (struct mtk_platform_card_data ) {
15841491 .card = & mt8195_mt6359_soc_card ,
15851492 .num_jacks = MT8195_JACK_MAX ,
1493+ .pcm_constraints = mt8195_pcm_constraints ,
1494+ .num_pcm_constraints = ARRAY_SIZE (mt8195_pcm_constraints ),
15861495 .flags = RT1011_SPEAKER_AMP_PRESENT
15871496 },
15881497 .sof_priv = & mt8195_sof_priv ,
@@ -1594,6 +1503,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359_max98390_rt5682_card = {
15941503 .card_data = & (struct mtk_platform_card_data ) {
15951504 .card = & mt8195_mt6359_soc_card ,
15961505 .num_jacks = MT8195_JACK_MAX ,
1506+ .pcm_constraints = mt8195_pcm_constraints ,
1507+ .num_pcm_constraints = ARRAY_SIZE (mt8195_pcm_constraints ),
15971508 .flags = MAX98390_SPEAKER_AMP_PRESENT
15981509 },
15991510 .sof_priv = & mt8195_sof_priv ,
0 commit comments