ASoC: SOF: Intel: hda: init NHLT for IPC4
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Thu, 9 Jun 2022 03:26:38 +0000 (20:26 -0700)
committerMark Brown <broonie@kernel.org>
Fri, 10 Jun 2022 12:32:06 +0000 (13:32 +0100)
Init and save the BIOS NHLT as part of the IPC4 FW data.
Add a kernel module param to override the BIOS NHLT with the NHLT from
the topology. Also, add the ops_free callback for all HDA platforms to
free the NHLT.

Co-developed-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220609032643.916882-19-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dai.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/pci-apl.c
sound/soc/sof/intel/pci-cnl.c
sound/soc/sof/intel/pci-icl.c
sound/soc/sof/intel/pci-tgl.c
sound/soc/sof/ipc4-priv.h

index 5423667..228079a 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <sound/pcm_params.h>
 #include <sound/hdaudio_ext.h>
+#include <sound/intel-nhlt.h>
 #include <sound/sof/ipc4/header.h>
 #include <uapi/sound/sof/header.h>
 #include "../ipc4-priv.h"
 #include "../sof-audio.h"
 #include "hda.h"
 
+/*
+ * The default method is to fetch NHLT from BIOS. With this parameter set
+ * it is possible to override that with NHLT in the SOF topology manifest.
+ */
+static bool hda_use_tplg_nhlt;
+module_param_named(sof_use_tplg_nhlt, hda_use_tplg_nhlt, bool, 0444);
+MODULE_PARM_DESC(sof_use_tplg_nhlt, "SOF topology nhlt override");
+
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
 
 struct hda_pipe_params {
@@ -777,6 +786,9 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops)
                }
                break;
        case SOF_INTEL_IPC4:
+       {
+               struct sof_ipc4_fw_data *ipc4_data = sdev->private;
+
                for (i = 0; i < ops->num_drv; i++) {
                        if (strstr(ops->drv[i].name, "DMIC")) {
                                ops->drv[i].ops = &ipc4_dmic_dai_ops;
@@ -793,12 +805,28 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops)
                                ops->drv[i].ops = &ipc4_hda_dai_ops;
 #endif
                }
+
+               if (!hda_use_tplg_nhlt)
+                       ipc4_data->nhlt = intel_nhlt_init(sdev->dev);
+
                break;
+       }
        default:
                break;
        }
 }
 
+void hda_ops_free(struct snd_sof_dev *sdev)
+{
+       if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
+               struct sof_ipc4_fw_data *ipc4_data = sdev->private;
+
+               if (!hda_use_tplg_nhlt)
+                       intel_nhlt_free(ipc4_data->nhlt);
+       }
+}
+EXPORT_SYMBOL_NS(hda_ops_free, SND_SOC_SOF_INTEL_HDA_COMMON);
+
 /*
  * common dai driver for skl+ platforms.
  * some products who use this DAI array only physically have a subset of
index 3e0f7b0..5918146 100644 (file)
@@ -763,6 +763,7 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_f
 extern int sof_hda_position_quirk;
 
 void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops);
+void hda_ops_free(struct snd_sof_dev *sdev);
 
 /* IPC4 */
 irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
index 2de3658..998e219 100644 (file)
@@ -44,6 +44,7 @@ static const struct sof_dev_desc bxt_desc = {
        .nocodec_tplg_filename = "sof-apl-nocodec.tplg",
        .ops = &sof_apl_ops,
        .ops_init = sof_apl_ops_init,
+       .ops_free = hda_ops_free,
 };
 
 static const struct sof_dev_desc glk_desc = {
index 87e587a..c797356 100644 (file)
@@ -73,6 +73,7 @@ static const struct sof_dev_desc cfl_desc = {
        .nocodec_tplg_filename = "sof-cnl-nocodec.tplg",
        .ops = &sof_cnl_ops,
        .ops_init = sof_cnl_ops_init,
+       .ops_free = hda_ops_free,
 };
 
 static const struct sof_dev_desc cml_desc = {
index 1c7f16c..48f24f8 100644 (file)
@@ -45,6 +45,7 @@ static const struct sof_dev_desc icl_desc = {
        .nocodec_tplg_filename = "sof-icl-nocodec.tplg",
        .ops = &sof_icl_ops,
        .ops_init = sof_icl_ops_init,
+       .ops_free = hda_ops_free,
 };
 
 static const struct sof_dev_desc jsl_desc = {
index 58a9bd9..ccc44ba 100644 (file)
@@ -73,6 +73,7 @@ static const struct sof_dev_desc tglh_desc = {
        .nocodec_tplg_filename = "sof-tgl-nocodec.tplg",
        .ops = &sof_tgl_ops,
        .ops_init = sof_tgl_ops_init,
+       .ops_free = hda_ops_free,
 };
 
 static const struct sof_dev_desc ehl_desc = {
index 8dddcea..9492fe1 100644 (file)
  * @manifest_fw_hdr_offset: FW header offset in the manifest
  * @num_fw_modules : Number of modules in base FW
  * @fw_modules: Array of base FW modules
+ * @nhlt: NHLT table either from the BIOS or the topology manifest
  */
 struct sof_ipc4_fw_data {
        u32 manifest_fw_hdr_offset;
        int num_fw_modules;
        void *fw_modules;
+       void *nhlt;
 };
 
 /**