ASoC: SOF: Intel: hda: simplify NHLT handling
The existing code does an init/free for each piece of information needed. We can instead initialize the NHLT table in the .probe() and free it in the .remove() callback. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20220421201946.1547041-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
14bdc7b2f9
commit
95fa7a62e1
@ -599,14 +599,13 @@ static int hda_init(struct snd_sof_dev *sdev)
|
|||||||
|
|
||||||
static int check_dmic_num(struct snd_sof_dev *sdev)
|
static int check_dmic_num(struct snd_sof_dev *sdev)
|
||||||
{
|
{
|
||||||
|
struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
|
||||||
struct nhlt_acpi_table *nhlt;
|
struct nhlt_acpi_table *nhlt;
|
||||||
int dmic_num = 0;
|
int dmic_num = 0;
|
||||||
|
|
||||||
nhlt = intel_nhlt_init(sdev->dev);
|
nhlt = hdev->nhlt;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allow for module parameter override */
|
/* allow for module parameter override */
|
||||||
if (dmic_num_override != -1) {
|
if (dmic_num_override != -1) {
|
||||||
@ -626,10 +625,11 @@ static int check_dmic_num(struct snd_sof_dev *sdev)
|
|||||||
|
|
||||||
static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev)
|
static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev)
|
||||||
{
|
{
|
||||||
|
struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
|
||||||
struct nhlt_acpi_table *nhlt;
|
struct nhlt_acpi_table *nhlt;
|
||||||
int ssp_mask = 0;
|
int ssp_mask = 0;
|
||||||
|
|
||||||
nhlt = intel_nhlt_init(sdev->dev);
|
nhlt = hdev->nhlt;
|
||||||
if (!nhlt)
|
if (!nhlt)
|
||||||
return ssp_mask;
|
return ssp_mask;
|
||||||
|
|
||||||
@ -638,7 +638,6 @@ static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev)
|
|||||||
if (ssp_mask)
|
if (ssp_mask)
|
||||||
dev_info(sdev->dev, "NHLT_DEVICE_I2S detected, ssp_mask %#x\n", ssp_mask);
|
dev_info(sdev->dev, "NHLT_DEVICE_I2S detected, ssp_mask %#x\n", ssp_mask);
|
||||||
}
|
}
|
||||||
intel_nhlt_free(nhlt);
|
|
||||||
|
|
||||||
return ssp_mask;
|
return ssp_mask;
|
||||||
}
|
}
|
||||||
@ -999,6 +998,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
|
|||||||
|
|
||||||
INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work);
|
INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work);
|
||||||
|
|
||||||
|
hdev->nhlt = intel_nhlt_init(sdev->dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
free_ipc_irq:
|
free_ipc_irq:
|
||||||
@ -1024,6 +1025,10 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
|
|||||||
const struct sof_intel_dsp_desc *chip = hda->desc;
|
const struct sof_intel_dsp_desc *chip = hda->desc;
|
||||||
struct hdac_bus *bus = sof_to_bus(sdev);
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
||||||
struct pci_dev *pci = to_pci_dev(sdev->dev);
|
struct pci_dev *pci = to_pci_dev(sdev->dev);
|
||||||
|
struct nhlt_acpi_table *nhlt = hda->nhlt;
|
||||||
|
|
||||||
|
if (nhlt)
|
||||||
|
intel_nhlt_free(nhlt);
|
||||||
|
|
||||||
/* cancel any attempt for DSP D0I3 */
|
/* cancel any attempt for DSP D0I3 */
|
||||||
cancel_delayed_work_sync(&hda->d0i3_work);
|
cancel_delayed_work_sync(&hda->d0i3_work);
|
||||||
|
@ -449,6 +449,9 @@ struct sof_intel_hda_dev {
|
|||||||
|
|
||||||
/* FW clock config, 0:HPRO, 1:LPRO */
|
/* FW clock config, 0:HPRO, 1:LPRO */
|
||||||
bool clk_config_lpro;
|
bool clk_config_lpro;
|
||||||
|
|
||||||
|
/* Intel NHLT information */
|
||||||
|
struct nhlt_acpi_table *nhlt;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
|
static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user