Commit 92c1b7c0 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: Intel: hda: retrieve DMIC number for I2S boards

We currently extract the DMIC number only for HDaudio or SoundWire
platforms. For I2S/TDM platforms, this wasn't necessary until now, but
with devices with ES8336 we need to find a solution to detect dmics
more reliably than with a DMI quirk.
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/20220308192610.392950-4-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 679aa83a
...@@ -432,11 +432,9 @@ static char *hda_model; ...@@ -432,11 +432,9 @@ static char *hda_model;
module_param(hda_model, charp, 0444); module_param(hda_model, charp, 0444);
MODULE_PARM_DESC(hda_model, "Use the given HDA board model."); MODULE_PARM_DESC(hda_model, "Use the given HDA board model.");
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) static int dmic_num_override = -1;
static int hda_dmic_num = -1; module_param_named(dmic_num, dmic_num_override, int, 0444);
module_param_named(dmic_num, hda_dmic_num, int, 0444);
MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number"); MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number");
#endif
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
static bool hda_codec_use_common_hdmi = IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI); static bool hda_codec_use_common_hdmi = IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI);
...@@ -644,24 +642,35 @@ static int hda_init(struct snd_sof_dev *sdev) ...@@ -644,24 +642,35 @@ static int hda_init(struct snd_sof_dev *sdev)
return ret; return ret;
} }
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) static int check_dmic_num(struct snd_sof_dev *sdev)
static int check_nhlt_dmic(struct snd_sof_dev *sdev)
{ {
struct nhlt_acpi_table *nhlt; struct nhlt_acpi_table *nhlt;
int dmic_num; int dmic_num = 0;
nhlt = intel_nhlt_init(sdev->dev); nhlt = intel_nhlt_init(sdev->dev);
if (nhlt) { if (nhlt) {
dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt);
intel_nhlt_free(nhlt); intel_nhlt_free(nhlt);
if (dmic_num >= 1 && dmic_num <= 4)
return dmic_num;
} }
return 0; /* allow for module parameter override */
if (dmic_num_override != -1) {
dev_dbg(sdev->dev,
"overriding DMICs detected in NHLT tables %d by kernel param %d\n",
dmic_num, dmic_num_override);
dmic_num = dmic_num_override;
}
if (dmic_num < 0 || dmic_num > 4) {
dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num);
dmic_num = 0;
}
return dmic_num;
} }
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
static const char *fixup_tplg_name(struct snd_sof_dev *sdev, static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
const char *sof_tplg_filename, const char *sof_tplg_filename,
const char *idisp_str, const char *idisp_str,
...@@ -697,16 +706,8 @@ static int dmic_topology_fixup(struct snd_sof_dev *sdev, ...@@ -697,16 +706,8 @@ static int dmic_topology_fixup(struct snd_sof_dev *sdev,
const char *dmic_str; const char *dmic_str;
int dmic_num; int dmic_num;
/* first check NHLT for DMICs */ /* first check for DMICs (using NHLT or module parameter) */
dmic_num = check_nhlt_dmic(sdev); dmic_num = check_dmic_num(sdev);
/* allow for module parameter override */
if (hda_dmic_num != -1) {
dev_dbg(sdev->dev,
"overriding DMICs detected in NHLT tables %d by kernel param %d\n",
dmic_num, hda_dmic_num);
dmic_num = hda_dmic_num;
}
switch (dmic_num) { switch (dmic_num) {
case 1: case 1:
...@@ -1383,6 +1384,9 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) ...@@ -1383,6 +1384,9 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
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;
/* report to machine driver if any DMICs are found */
mach->mach_params.dmic_num = check_dmic_num(sdev);
if (mach->link_mask) { if (mach->link_mask) {
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;
......
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