@@ -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 ,
@@ -1043,10 +1043,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
10431043 struct snd_soc_acpi_mach * hda_mach ;
10441044 struct snd_sof_pdata * pdata = sdev -> pdata ;
10451045 const char * tplg_filename ;
1046- const char * idisp_str ;
1047- int dmic_num = 0 ;
10481046 int codec_num = 0 ;
1049- int ret ;
10501047 int i ;
10511048
10521049 /* codec detection */
@@ -1069,33 +1066,30 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
10691066 * - one external HDAudio codec
10701067 */
10711068 if (!* mach && codec_num <= 2 ) {
1072- bool tplg_fixup ;
1069+ bool tplg_fixup = false ;
10731070
10741071 hda_mach = snd_soc_acpi_intel_hda_machines ;
10751072
10761073 dev_info (bus -> dev , "using HDA machine driver %s now\n" ,
10771074 hda_mach -> drv_name );
10781075
1079- if (codec_num == 1 && HDA_IDISP_CODEC (bus -> codec_mask ))
1080- idisp_str = "-idisp" ;
1081- else
1082- idisp_str = "" ;
1083-
1084- /* topology: use the info from hda_machines */
1085- if (pdata -> tplg_filename ) {
1086- tplg_fixup = false;
1087- tplg_filename = pdata -> tplg_filename ;
1088- } else {
1076+ /*
1077+ * topology: use the info from hda_machines since tplg file name
1078+ * is not overwritten
1079+ */
1080+ if (!pdata -> tplg_filename )
10891081 tplg_fixup = true;
1090- tplg_filename = hda_mach -> sof_tplg_filename ;
1091- }
1092- ret = dmic_detect_topology_fixup (sdev , & tplg_filename , idisp_str , & dmic_num ,
1093- tplg_fixup );
1094- if (ret < 0 )
1095- return ;
10961082
1097- hda_mach -> mach_params .dmic_num = dmic_num ;
1098- pdata -> tplg_filename = tplg_filename ;
1083+ if (tplg_fixup &&
1084+ codec_num == 1 && HDA_IDISP_CODEC (bus -> codec_mask )) {
1085+ tplg_filename = devm_kasprintf (sdev -> dev , GFP_KERNEL ,
1086+ "%s-idisp" ,
1087+ hda_mach -> sof_tplg_filename );
1088+ if (!tplg_filename )
1089+ return ;
1090+
1091+ hda_mach -> sof_tplg_filename = tplg_filename ;
1092+ }
10991093
11001094 if (codec_num == 2 ||
11011095 (codec_num == 1 && !HDA_IDISP_CODEC (bus -> codec_mask ))) {
@@ -1309,11 +1303,35 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
13091303 const char * tplg_filename ;
13101304 const char * tplg_suffix ;
13111305 bool amp_name_valid ;
1306+ bool i2s_mach_found = false;
13121307
13131308 /* Try I2S or DMIC if it is supported */
1314- if (interface_mask & (BIT (SOF_DAI_INTEL_SSP ) | BIT (SOF_DAI_INTEL_DMIC )))
1309+ if (interface_mask & (BIT (SOF_DAI_INTEL_SSP ) | BIT (SOF_DAI_INTEL_DMIC ))) {
13151310 mach = snd_soc_acpi_find_machine (desc -> machines );
1311+ if (mach )
1312+ i2s_mach_found = true;
1313+ }
1314+
1315+ /*
1316+ * If I2S fails and no external HDaudio codec is detected,
1317+ * try SoundWire if it is supported
1318+ */
1319+ if (!mach && !HDA_EXT_CODEC (bus -> codec_mask ) &&
1320+ (interface_mask & BIT (SOF_DAI_INTEL_ALH )))
1321+ mach = hda_sdw_machine_select (sdev );
13161322
1323+ /*
1324+ * Choose HDA generic machine driver if mach is NULL.
1325+ * Otherwise, set certain mach params.
1326+ */
1327+ hda_generic_machine_select (sdev , & mach );
1328+ if (!mach )
1329+ dev_warn (sdev -> dev , "warning: No matching ASoC machine driver found\n" );
1330+
1331+ /*
1332+ * Fixup tplg file name by appending dmic num, ssp num, codec/amplifier
1333+ * name string if quirk flag is set.
1334+ */
13171335 if (mach ) {
13181336 bool add_extension = false;
13191337 bool tplg_fixup = false;
@@ -1347,7 +1365,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
13471365 tplg_filename = devm_kasprintf (sdev -> dev , GFP_KERNEL ,
13481366 "%s%s%d%s" ,
13491367 sof_pdata -> tplg_filename ,
1350- "-dmic" ,
1368+ i2s_mach_found ? "-dmic" : "- " ,
13511369 mach -> mach_params .dmic_num ,
13521370 "ch" );
13531371 if (!tplg_filename )
@@ -1477,22 +1495,6 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
14771495 }
14781496 }
14791497
1480- /*
1481- * If I2S fails and no external HDaudio codec is detected,
1482- * try SoundWire if it is supported
1483- */
1484- if (!mach && !HDA_EXT_CODEC (bus -> codec_mask ) &&
1485- (interface_mask & BIT (SOF_DAI_INTEL_ALH )))
1486- mach = hda_sdw_machine_select (sdev );
1487-
1488- /*
1489- * Choose HDA generic machine driver if mach is NULL.
1490- * Otherwise, set certain mach params.
1491- */
1492- hda_generic_machine_select (sdev , & mach );
1493- if (!mach )
1494- dev_warn (sdev -> dev , "warning: No matching ASoC machine driver found\n" );
1495-
14961498 return mach ;
14971499}
14981500
0 commit comments