27
27
28
28
struct mt8195_mt6359_rt1019_rt5682_priv {
29
29
struct snd_soc_jack headset_jack ;
30
+ struct snd_soc_jack dp_jack ;
30
31
};
31
32
32
33
static const struct snd_soc_dapm_widget
@@ -327,6 +328,52 @@ static int mt8195_etdm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
327
328
return 0 ;
328
329
}
329
330
331
+ static int mt8195_hdmitx_dptx_startup (struct snd_pcm_substream * substream )
332
+ {
333
+ static const unsigned int rates [] = {
334
+ 48000
335
+ };
336
+ static const unsigned int channels [] = {
337
+ 2 , 4 , 6 , 8
338
+ };
339
+ static const struct snd_pcm_hw_constraint_list constraints_rates = {
340
+ .count = ARRAY_SIZE (rates ),
341
+ .list = rates ,
342
+ .mask = 0 ,
343
+ };
344
+ static const struct snd_pcm_hw_constraint_list constraints_channels = {
345
+ .count = ARRAY_SIZE (channels ),
346
+ .list = channels ,
347
+ .mask = 0 ,
348
+ };
349
+
350
+ struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
351
+ struct snd_pcm_runtime * runtime = substream -> runtime ;
352
+ int ret ;
353
+
354
+ ret = snd_pcm_hw_constraint_list (runtime , 0 ,
355
+ SNDRV_PCM_HW_PARAM_RATE ,
356
+ & constraints_rates );
357
+ if (ret < 0 ) {
358
+ dev_err (rtd -> dev , "hw_constraint_list rate failed\n" );
359
+ return ret ;
360
+ }
361
+
362
+ ret = snd_pcm_hw_constraint_list (runtime , 0 ,
363
+ SNDRV_PCM_HW_PARAM_CHANNELS ,
364
+ & constraints_channels );
365
+ if (ret < 0 ) {
366
+ dev_err (rtd -> dev , "hw_constraint_list channel failed\n" );
367
+ return ret ;
368
+ }
369
+
370
+ return 0 ;
371
+ }
372
+
373
+ static const struct snd_soc_ops mt8195_hdmitx_dptx_playback_ops = {
374
+ .startup = mt8195_hdmitx_dptx_startup ,
375
+ };
376
+
330
377
static int mt8195_dptx_hw_params (struct snd_pcm_substream * substream ,
331
378
struct snd_pcm_hw_params * params )
332
379
{
@@ -344,8 +391,25 @@ static struct snd_soc_ops mt8195_dptx_ops = {
344
391
.hw_params = mt8195_dptx_hw_params ,
345
392
};
346
393
347
- static int mt8195_dptx_hw_params_fixup (struct snd_soc_pcm_runtime * rtd ,
348
- struct snd_pcm_hw_params * params )
394
+ static int mt8195_dptx_codec_init (struct snd_soc_pcm_runtime * rtd )
395
+ {
396
+ struct mt8195_mt6359_rt1019_rt5682_priv * priv =
397
+ snd_soc_card_get_drvdata (rtd -> card );
398
+ struct snd_soc_component * cmpnt_codec =
399
+ asoc_rtd_to_codec (rtd , 0 )-> component ;
400
+ int ret = 0 ;
401
+
402
+ ret = snd_soc_card_jack_new (rtd -> card , "DP Jack" , SND_JACK_LINEOUT ,
403
+ & priv -> dp_jack , NULL , 0 );
404
+ if (ret )
405
+ return ret ;
406
+
407
+ return snd_soc_component_set_jack (cmpnt_codec , & priv -> dp_jack , NULL );
408
+ }
409
+
410
+ static int mt8195_hdmitx_dptx_hw_params_fixup (struct snd_soc_pcm_runtime * rtd ,
411
+ struct snd_pcm_hw_params * params )
412
+
349
413
{
350
414
/* fix BE i2s format to 32bit, clean param mask first */
351
415
snd_mask_reset_range (hw_param_mask (params , SNDRV_PCM_HW_PARAM_FORMAT ),
@@ -687,6 +751,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
687
751
},
688
752
.dynamic = 1 ,
689
753
.dpcm_playback = 1 ,
754
+ .ops = & mt8195_hdmitx_dptx_playback_ops ,
690
755
SND_SOC_DAILINK_REG (DL10_FE ),
691
756
},
692
757
[DAI_LINK_DL11_FE ] = {
@@ -820,7 +885,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
820
885
.no_pcm = 1 ,
821
886
.dpcm_playback = 1 ,
822
887
.ops = & mt8195_dptx_ops ,
823
- .be_hw_params_fixup = mt8195_dptx_hw_params_fixup ,
888
+ .be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup ,
824
889
SND_SOC_DAILINK_REG (DPTX_BE ),
825
890
},
826
891
[DAI_LINK_ETDM1_IN_BE ] = {
@@ -915,7 +980,6 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
915
980
struct device_node * platform_node ;
916
981
struct snd_soc_dai_link * dai_link ;
917
982
struct mt8195_mt6359_rt1019_rt5682_priv * priv = NULL ;
918
-
919
983
int ret , i ;
920
984
921
985
card -> dev = & pdev -> dev ;
@@ -930,6 +994,20 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
930
994
for_each_card_prelinks (card , i , dai_link ) {
931
995
if (!dai_link -> platforms -> name )
932
996
dai_link -> platforms -> of_node = platform_node ;
997
+
998
+ if (strcmp (dai_link -> name , "DPTX_BE" ) == 0 ) {
999
+ dai_link -> codecs -> of_node =
1000
+ of_parse_phandle (pdev -> dev .of_node ,
1001
+ "mediatek,dptx-codec" , 0 );
1002
+ if (!dai_link -> codecs -> of_node ) {
1003
+ dev_err (& pdev -> dev , "Property 'dptx-codec' missing or invalid\n" );
1004
+ return - EINVAL ;
1005
+ }
1006
+
1007
+ dai_link -> codecs -> name = NULL ;
1008
+ dai_link -> codecs -> dai_name = "i2s-hifi" ;
1009
+ dai_link -> init = mt8195_dptx_codec_init ;
1010
+ }
933
1011
}
934
1012
935
1013
priv = devm_kzalloc (& pdev -> dev , sizeof (* priv ), GFP_KERNEL );
@@ -940,7 +1018,7 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
940
1018
941
1019
ret = devm_snd_soc_register_card (& pdev -> dev , card );
942
1020
if (ret )
943
- dev_dbg (& pdev -> dev , "%s snd_soc_register_card fail %d\n" ,
1021
+ dev_err (& pdev -> dev , "%s snd_soc_register_card fail %d\n" ,
944
1022
__func__ , ret );
945
1023
return ret ;
946
1024
}
0 commit comments