Commit 054d1fd1 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: Intel: hda: only fixup topology name if not set already

We do all kinds of renaming tricks that get in the way of kernel
parameter and DMI quirk overrides at a higher level.

Tested on UpExtreme board with

options snd-sof-pci tplg_filename=sof-hda-generic.tplg
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220715145216.277003-10-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ef05eb57
...@@ -776,13 +776,12 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev, ...@@ -776,13 +776,12 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
return tplg_filename; return tplg_filename;
} }
static int dmic_topology_fixup(struct snd_sof_dev *sdev, static int dmic_detect_topology_fixup(struct snd_sof_dev *sdev,
const char **tplg_filename, const char **tplg_filename,
const char *idisp_str, const char *idisp_str,
int *dmic_found) int *dmic_found,
bool tplg_fixup)
{ {
const char *default_tplg_filename = *tplg_filename;
const char *fixed_tplg_filename;
const char *dmic_str; const char *dmic_str;
int dmic_num; int dmic_num;
...@@ -808,14 +807,19 @@ static int dmic_topology_fixup(struct snd_sof_dev *sdev, ...@@ -808,14 +807,19 @@ static int dmic_topology_fixup(struct snd_sof_dev *sdev,
break; break;
} }
fixed_tplg_filename = fixup_tplg_name(sdev, default_tplg_filename, if (tplg_fixup) {
idisp_str, dmic_str); const char *default_tplg_filename = *tplg_filename;
if (!fixed_tplg_filename) const char *fixed_tplg_filename;
return -ENOMEM;
fixed_tplg_filename = fixup_tplg_name(sdev, default_tplg_filename,
idisp_str, dmic_str);
if (!fixed_tplg_filename)
return -ENOMEM;
*tplg_filename = fixed_tplg_filename;
}
dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num); dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num);
*dmic_found = dmic_num; *dmic_found = dmic_num;
*tplg_filename = fixed_tplg_filename;
return 0; return 0;
} }
...@@ -1221,6 +1225,8 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev, ...@@ -1221,6 +1225,8 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
* - one external HDAudio codec * - one external HDAudio codec
*/ */
if (!*mach && codec_num <= 2) { if (!*mach && codec_num <= 2) {
bool tplg_fixup;
hda_mach = snd_soc_acpi_intel_hda_machines; hda_mach = snd_soc_acpi_intel_hda_machines;
dev_info(bus->dev, "using HDA machine driver %s now\n", dev_info(bus->dev, "using HDA machine driver %s now\n",
...@@ -1232,8 +1238,15 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev, ...@@ -1232,8 +1238,15 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
idisp_str = ""; idisp_str = "";
/* topology: use the info from hda_machines */ /* topology: use the info from hda_machines */
tplg_filename = hda_mach->sof_tplg_filename; if (pdata->tplg_filename) {
ret = dmic_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num); tplg_fixup = false;
tplg_filename = pdata->tplg_filename;
} else {
tplg_fixup = true;
tplg_filename = hda_mach->sof_tplg_filename;
}
ret = dmic_detect_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num,
tplg_fixup);
if (ret < 0) if (ret < 0)
return; return;
...@@ -1397,11 +1410,19 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev ...@@ -1397,11 +1410,19 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
} }
if (mach && mach->link_mask) { if (mach && mach->link_mask) {
int dmic_num = 0; int dmic_num = 0;
bool tplg_fixup;
const char *tplg_filename;
mach->mach_params.links = mach->links; mach->mach_params.links = mach->links;
mach->mach_params.link_mask = mach->link_mask; mach->mach_params.link_mask = mach->link_mask;
mach->mach_params.platform = dev_name(sdev->dev); mach->mach_params.platform = dev_name(sdev->dev);
pdata->tplg_filename = mach->sof_tplg_filename;
if (pdata->tplg_filename) {
tplg_fixup = false;
} else {
tplg_fixup = true;
tplg_filename = mach->sof_tplg_filename;
}
/* /*
* DMICs use up to 4 pins and are typically pin-muxed with SoundWire * DMICs use up to 4 pins and are typically pin-muxed with SoundWire
...@@ -1411,15 +1432,15 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev ...@@ -1411,15 +1432,15 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
* b) the NHLT table reports the presence of microphones * b) the NHLT table reports the presence of microphones
*/ */
if (hweight_long(mach->link_mask) <= 2) { if (hweight_long(mach->link_mask) <= 2) {
const char *tplg_filename = mach->sof_tplg_filename;
int ret; int ret;
ret = dmic_topology_fixup(sdev, &tplg_filename, "", &dmic_num); ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
&dmic_num, tplg_fixup);
if (ret < 0) if (ret < 0)
return NULL; return NULL;
pdata->tplg_filename = tplg_filename;
} }
if (tplg_fixup)
pdata->tplg_filename = tplg_filename;
mach->mach_params.dmic_num = dmic_num; mach->mach_params.dmic_num = dmic_num;
dev_dbg(sdev->dev, dev_dbg(sdev->dev,
...@@ -1465,18 +1486,22 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) ...@@ -1465,18 +1486,22 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
mach = snd_soc_acpi_find_machine(desc->machines); mach = snd_soc_acpi_find_machine(desc->machines);
if (mach) { if (mach) {
bool add_extension = false; bool add_extension = false;
bool tplg_fixup = false;
/* /*
* If tplg file name is overridden, use it instead of * If tplg file name is overridden, use it instead of
* the one set in mach table * the one set in mach table
*/ */
if (!sof_pdata->tplg_filename) if (!sof_pdata->tplg_filename) {
sof_pdata->tplg_filename = mach->sof_tplg_filename; sof_pdata->tplg_filename = mach->sof_tplg_filename;
tplg_fixup = true;
}
/* report to machine driver if any DMICs are found */ /* report to machine driver if any DMICs are found */
mach->mach_params.dmic_num = check_dmic_num(sdev); mach->mach_params.dmic_num = check_dmic_num(sdev);
if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER && if (tplg_fixup &&
mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER &&
mach->mach_params.dmic_num) { mach->mach_params.dmic_num) {
tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
"%s%s%d%s", "%s%s%d%s",
...@@ -1499,7 +1524,8 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) ...@@ -1499,7 +1524,8 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
/* report SSP link mask to machine driver */ /* report SSP link mask to machine driver */
mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev); mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev);
if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && if (tplg_fixup &&
mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER &&
mach->mach_params.i2s_link_mask) { mach->mach_params.i2s_link_mask) {
int ssp_num; int ssp_num;
...@@ -1522,7 +1548,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) ...@@ -1522,7 +1548,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
add_extension = true; add_extension = true;
} }
if (add_extension) { if (tplg_fixup && add_extension) {
tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
"%s%s", "%s%s",
sof_pdata->tplg_filename, sof_pdata->tplg_filename,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment