@@ -558,7 +558,7 @@ static int check_nhlt_ssp_mclk_mask(struct snd_sof_dev *sdev, int ssp_num)
558558 return intel_nhlt_ssp_mclk_mask (nhlt , ssp_num );
559559}
560560
561- #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) || IS_ENABLED ( CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE )
561+ #if IS_ENABLED (CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE )
562562
563563static const char * fixup_tplg_name (struct snd_sof_dev * sdev ,
564564 const char * sof_tplg_filename ,
@@ -1045,10 +1045,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
10451045 struct snd_soc_acpi_mach * hda_mach ;
10461046 struct snd_sof_pdata * pdata = sdev -> pdata ;
10471047 const char * tplg_filename ;
1048- const char * idisp_str ;
1049- int dmic_num = 0 ;
10501048 int codec_num = 0 ;
1051- int ret ;
10521049 int i ;
10531050
10541051 /* codec detection */
@@ -1071,33 +1068,30 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
10711068 * - one external HDAudio codec
10721069 */
10731070 if (!* mach && codec_num <= 2 ) {
1074- bool tplg_fixup ;
1071+ bool tplg_fixup = false ;
10751072
10761073 hda_mach = snd_soc_acpi_intel_hda_machines ;
10771074
10781075 dev_info (bus -> dev , "using HDA machine driver %s now\n" ,
10791076 hda_mach -> drv_name );
10801077
1081- if (codec_num == 1 && HDA_IDISP_CODEC (bus -> codec_mask ))
1082- idisp_str = "-idisp" ;
1083- else
1084- idisp_str = "" ;
1085-
1086- /* topology: use the info from hda_machines */
1087- if (pdata -> tplg_filename ) {
1088- tplg_fixup = false;
1089- tplg_filename = pdata -> tplg_filename ;
1090- } else {
1078+ /*
1079+ * topology: use the info from hda_machines since tplg file name
1080+ * is not overwritten
1081+ */
1082+ if (!pdata -> tplg_filename )
10911083 tplg_fixup = true;
1092- tplg_filename = hda_mach -> sof_tplg_filename ;
1093- }
1094- ret = dmic_detect_topology_fixup (sdev , & tplg_filename , idisp_str , & dmic_num ,
1095- tplg_fixup );
1096- if (ret < 0 )
1097- return ;
10981084
1099- hda_mach -> mach_params .dmic_num = dmic_num ;
1100- pdata -> tplg_filename = tplg_filename ;
1085+ if (tplg_fixup &&
1086+ codec_num == 1 && HDA_IDISP_CODEC (bus -> codec_mask )) {
1087+ tplg_filename = devm_kasprintf (sdev -> dev , GFP_KERNEL ,
1088+ "%s-idisp" ,
1089+ hda_mach -> sof_tplg_filename );
1090+ if (!tplg_filename )
1091+ return ;
1092+
1093+ hda_mach -> sof_tplg_filename = tplg_filename ;
1094+ }
11011095
11021096 if (codec_num == 2 ||
11031097 (codec_num == 1 && !HDA_IDISP_CODEC (bus -> codec_mask ))) {
@@ -1311,11 +1305,35 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
13111305 const char * tplg_filename ;
13121306 const char * tplg_suffix ;
13131307 bool amp_name_valid ;
1308+ bool i2s_mach_found = false;
13141309
13151310 /* Try I2S or DMIC if it is supported */
1316- if (interface_mask & (BIT (SOF_DAI_INTEL_SSP ) | BIT (SOF_DAI_INTEL_DMIC )))
1311+ if (interface_mask & (BIT (SOF_DAI_INTEL_SSP ) | BIT (SOF_DAI_INTEL_DMIC ))) {
13171312 mach = snd_soc_acpi_find_machine (desc -> machines );
1313+ if (mach )
1314+ i2s_mach_found = true;
1315+ }
1316+
1317+ /*
1318+ * If I2S fails and no external HDaudio codec is detected,
1319+ * try SoundWire if it is supported
1320+ */
1321+ if (!mach && !HDA_EXT_CODEC (bus -> codec_mask ) &&
1322+ (interface_mask & BIT (SOF_DAI_INTEL_ALH )))
1323+ mach = hda_sdw_machine_select (sdev );
13181324
1325+ /*
1326+ * Choose HDA generic machine driver if mach is NULL.
1327+ * Otherwise, set certain mach params.
1328+ */
1329+ hda_generic_machine_select (sdev , & mach );
1330+ if (!mach )
1331+ dev_warn (sdev -> dev , "warning: No matching ASoC machine driver found\n" );
1332+
1333+ /*
1334+ * Fixup tplg file name by appending dmic num, ssp num, codec/amplifier
1335+ * name string if quirk flag is set.
1336+ */
13191337 if (mach ) {
13201338 bool add_extension = false;
13211339 bool tplg_fixup = false;
@@ -1349,7 +1367,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
13491367 tplg_filename = devm_kasprintf (sdev -> dev , GFP_KERNEL ,
13501368 "%s%s%d%s" ,
13511369 sof_pdata -> tplg_filename ,
1352- "-dmic" ,
1370+ i2s_mach_found ? "-dmic" : "- " ,
13531371 mach -> mach_params .dmic_num ,
13541372 "ch" );
13551373 if (!tplg_filename )
@@ -1479,22 +1497,6 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
14791497 }
14801498 }
14811499
1482- /*
1483- * If I2S fails and no external HDaudio codec is detected,
1484- * try SoundWire if it is supported
1485- */
1486- if (!mach && !HDA_EXT_CODEC (bus -> codec_mask ) &&
1487- (interface_mask & BIT (SOF_DAI_INTEL_ALH )))
1488- mach = hda_sdw_machine_select (sdev );
1489-
1490- /*
1491- * Choose HDA generic machine driver if mach is NULL.
1492- * Otherwise, set certain mach params.
1493- */
1494- hda_generic_machine_select (sdev , & mach );
1495- if (!mach )
1496- dev_warn (sdev -> dev , "warning: No matching ASoC machine driver found\n" );
1497-
14981500 return mach ;
14991501}
15001502
0 commit comments