@@ -1279,6 +1279,7 @@ struct sof_sdw_endpoint {
12791279
12801280 u32 link_mask ;
12811281 const char * codec_name ;
1282+ const char * name_prefix ;
12821283
12831284 struct sof_sdw_codec_info * codec_info ;
12841285 const struct sof_sdw_dai_info * dai_info ;
@@ -1340,7 +1341,6 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
13401341 struct mc_private * ctx = snd_soc_card_get_drvdata (card );
13411342 struct snd_soc_acpi_mach * mach = dev_get_platdata (dev );
13421343 struct snd_soc_acpi_mach_params * mach_params = & mach -> mach_params ;
1343- struct snd_soc_codec_conf * codec_conf = card -> codec_conf ;
13441344 const struct snd_soc_acpi_link_adr * adr_link ;
13451345 struct sof_sdw_endpoint * sof_end = sof_ends ;
13461346 int num_dais = 0 ;
@@ -1376,13 +1376,11 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
13761376 if (!codec_name )
13771377 return - ENOMEM ;
13781378
1379- codec_conf -> dlc .name = codec_name ;
1380- codec_conf -> name_prefix = adr_dev -> name_prefix ;
1381- codec_conf ++ ;
1382-
13831379 dev_dbg (dev , "Adding prefix %s for %s\n" ,
13841380 adr_dev -> name_prefix , codec_name );
13851381
1382+ sof_end -> name_prefix = adr_dev -> name_prefix ;
1383+
13861384 for (j = 0 ; j < adr_dev -> num_endpoints ; j ++ ) {
13871385 const struct snd_soc_acpi_endpoint * adr_end ;
13881386 const struct sof_sdw_dai_info * dai_info ;
@@ -1443,21 +1441,27 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
14431441 ctx -> append_dai_type |= (num_link_dailinks > 1 );
14441442 }
14451443
1446- WARN_ON (codec_conf != card -> codec_conf + card -> num_configs );
1447-
14481444 return num_dais ;
14491445}
14501446
14511447static int create_sdw_dailink (struct snd_soc_card * card ,
14521448 struct sof_sdw_dailink * sof_dai ,
14531449 struct snd_soc_dai_link * * dai_links ,
1454- int * be_id )
1450+ int * be_id , struct snd_soc_codec_conf * * codec_conf )
14551451{
14561452 struct device * dev = card -> dev ;
14571453 struct mc_private * ctx = snd_soc_card_get_drvdata (card );
14581454 struct sof_sdw_endpoint * sof_end ;
14591455 int stream ;
14601456
1457+ list_for_each_entry (sof_end , & sof_dai -> endpoints , list ) {
1458+ if (sof_end -> name_prefix ) {
1459+ (* codec_conf )-> dlc .name = sof_end -> codec_name ;
1460+ (* codec_conf )-> name_prefix = sof_end -> name_prefix ;
1461+ (* codec_conf )++ ;
1462+ }
1463+ }
1464+
14611465 for_each_pcm_streams (stream ) {
14621466 static const char * const sdw_stream_name [] = {
14631467 "SDW%d-Playback" ,
@@ -1569,7 +1573,8 @@ static int create_sdw_dailink(struct snd_soc_card *card,
15691573
15701574static int create_sdw_dailinks (struct snd_soc_card * card ,
15711575 struct snd_soc_dai_link * * dai_links , int * be_id ,
1572- struct sof_sdw_dailink * sof_dais )
1576+ struct sof_sdw_dailink * sof_dais ,
1577+ struct snd_soc_codec_conf * * codec_conf )
15731578{
15741579 struct mc_private * ctx = snd_soc_card_get_drvdata (card );
15751580 int ret , i ;
@@ -1581,7 +1586,8 @@ static int create_sdw_dailinks(struct snd_soc_card *card,
15811586 while (sof_dais -> initialised ) {
15821587 int current_be_id ;
15831588
1584- ret = create_sdw_dailink (card , sof_dais , dai_links , & current_be_id );
1589+ ret = create_sdw_dailink (card , sof_dais , dai_links ,
1590+ & current_be_id , codec_conf );
15851591 if (ret )
15861592 return ret ;
15871593
@@ -1751,16 +1757,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
17511757 goto err_dai ;
17521758 }
17531759
1754- /* will be populated when acpi endpoints are parsed */
1755- codec_conf = devm_kcalloc (dev , num_devs , sizeof (* codec_conf ), GFP_KERNEL );
1756- if (!codec_conf ) {
1757- ret = - ENOMEM ;
1758- goto err_end ;
1759- }
1760-
1761- card -> codec_conf = codec_conf ;
1762- card -> num_configs = num_devs ;
1763-
17641760 ret = parse_sdw_endpoints (card , sof_dais , sof_ends );
17651761 if (ret < 0 )
17661762 goto err_end ;
@@ -1798,6 +1794,12 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
17981794 sdw_be_num , ssp_num , dmic_num ,
17991795 ctx -> hdmi .idisp_codec ? hdmi_num : 0 , bt_num );
18001796
1797+ codec_conf = devm_kcalloc (dev , num_devs , sizeof (* codec_conf ), GFP_KERNEL );
1798+ if (!codec_conf ) {
1799+ ret = - ENOMEM ;
1800+ goto err_end ;
1801+ }
1802+
18011803 /* allocate BE dailinks */
18021804 num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num ;
18031805 dai_links = devm_kcalloc (dev , num_links , sizeof (* dai_links ), GFP_KERNEL );
@@ -1806,12 +1808,15 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
18061808 goto err_end ;
18071809 }
18081810
1811+ card -> codec_conf = codec_conf ;
1812+ card -> num_configs = num_devs ;
18091813 card -> dai_link = dai_links ;
18101814 card -> num_links = num_links ;
18111815
18121816 /* SDW */
18131817 if (sdw_be_num ) {
1814- ret = create_sdw_dailinks (card , & dai_links , & be_id , sof_dais );
1818+ ret = create_sdw_dailinks (card , & dai_links , & be_id ,
1819+ sof_dais , & codec_conf );
18151820 if (ret )
18161821 goto err_end ;
18171822 }
@@ -1847,6 +1852,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
18471852 goto err_end ;
18481853 }
18491854
1855+ WARN_ON (codec_conf != card -> codec_conf + card -> num_configs );
18501856 WARN_ON (dai_links != card -> dai_link + card -> num_links );
18511857
18521858err_end :
0 commit comments