@@ -1279,6 +1279,7 @@ struct sof_sdw_endpoint {
1279
1279
1280
1280
u32 link_mask ;
1281
1281
const char * codec_name ;
1282
+ const char * name_prefix ;
1282
1283
1283
1284
struct sof_sdw_codec_info * codec_info ;
1284
1285
const struct sof_sdw_dai_info * dai_info ;
@@ -1340,7 +1341,6 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
1340
1341
struct mc_private * ctx = snd_soc_card_get_drvdata (card );
1341
1342
struct snd_soc_acpi_mach * mach = dev_get_platdata (dev );
1342
1343
struct snd_soc_acpi_mach_params * mach_params = & mach -> mach_params ;
1343
- struct snd_soc_codec_conf * codec_conf = card -> codec_conf ;
1344
1344
const struct snd_soc_acpi_link_adr * adr_link ;
1345
1345
struct sof_sdw_endpoint * sof_end = sof_ends ;
1346
1346
int num_dais = 0 ;
@@ -1376,13 +1376,11 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
1376
1376
if (!codec_name )
1377
1377
return - ENOMEM ;
1378
1378
1379
- codec_conf -> dlc .name = codec_name ;
1380
- codec_conf -> name_prefix = adr_dev -> name_prefix ;
1381
- codec_conf ++ ;
1382
-
1383
1379
dev_dbg (dev , "Adding prefix %s for %s\n" ,
1384
1380
adr_dev -> name_prefix , codec_name );
1385
1381
1382
+ sof_end -> name_prefix = adr_dev -> name_prefix ;
1383
+
1386
1384
for (j = 0 ; j < adr_dev -> num_endpoints ; j ++ ) {
1387
1385
const struct snd_soc_acpi_endpoint * adr_end ;
1388
1386
const struct sof_sdw_dai_info * dai_info ;
@@ -1443,21 +1441,27 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
1443
1441
ctx -> append_dai_type |= (num_link_dailinks > 1 );
1444
1442
}
1445
1443
1446
- WARN_ON (codec_conf != card -> codec_conf + card -> num_configs );
1447
-
1448
1444
return num_dais ;
1449
1445
}
1450
1446
1451
1447
static int create_sdw_dailink (struct snd_soc_card * card ,
1452
1448
struct sof_sdw_dailink * sof_dai ,
1453
1449
struct snd_soc_dai_link * * dai_links ,
1454
- int * be_id )
1450
+ int * be_id , struct snd_soc_codec_conf * * codec_conf )
1455
1451
{
1456
1452
struct device * dev = card -> dev ;
1457
1453
struct mc_private * ctx = snd_soc_card_get_drvdata (card );
1458
1454
struct sof_sdw_endpoint * sof_end ;
1459
1455
int stream ;
1460
1456
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
+
1461
1465
for_each_pcm_streams (stream ) {
1462
1466
static const char * const sdw_stream_name [] = {
1463
1467
"SDW%d-Playback" ,
@@ -1569,7 +1573,8 @@ static int create_sdw_dailink(struct snd_soc_card *card,
1569
1573
1570
1574
static int create_sdw_dailinks (struct snd_soc_card * card ,
1571
1575
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 )
1573
1578
{
1574
1579
struct mc_private * ctx = snd_soc_card_get_drvdata (card );
1575
1580
int ret , i ;
@@ -1581,7 +1586,8 @@ static int create_sdw_dailinks(struct snd_soc_card *card,
1581
1586
while (sof_dais -> initialised ) {
1582
1587
int current_be_id ;
1583
1588
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 );
1585
1591
if (ret )
1586
1592
return ret ;
1587
1593
@@ -1751,16 +1757,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
1751
1757
goto err_dai ;
1752
1758
}
1753
1759
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
-
1764
1760
ret = parse_sdw_endpoints (card , sof_dais , sof_ends );
1765
1761
if (ret < 0 )
1766
1762
goto err_end ;
@@ -1798,6 +1794,12 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
1798
1794
sdw_be_num , ssp_num , dmic_num ,
1799
1795
ctx -> hdmi .idisp_codec ? hdmi_num : 0 , bt_num );
1800
1796
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
+
1801
1803
/* allocate BE dailinks */
1802
1804
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num ;
1803
1805
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)
1806
1808
goto err_end ;
1807
1809
}
1808
1810
1811
+ card -> codec_conf = codec_conf ;
1812
+ card -> num_configs = num_devs ;
1809
1813
card -> dai_link = dai_links ;
1810
1814
card -> num_links = num_links ;
1811
1815
1812
1816
/* SDW */
1813
1817
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 );
1815
1820
if (ret )
1816
1821
goto err_end ;
1817
1822
}
@@ -1847,6 +1852,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
1847
1852
goto err_end ;
1848
1853
}
1849
1854
1855
+ WARN_ON (codec_conf != card -> codec_conf + card -> num_configs );
1850
1856
WARN_ON (dai_links != card -> dai_link + card -> num_links );
1851
1857
1852
1858
err_end :
0 commit comments