ASoC: SOF: Intel: Switch to use the generic pm_ops.set_core_state
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Fri, 10 Jun 2022 08:35:48 +0000 (11:35 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 10 Jun 2022 12:31:42 +0000 (13:31 +0100)
Instead of craft and send an IPC(3) message in hda_dsp_core_get(),
tgl_dsp_core_get() and tgl_dsp_core_put(), use the generic ops for handling
the IPC dependent implementation of core power on/off.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220610083549.16773-6-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dsp.c
sound/soc/sof/intel/tgl.c

index 000ea906670cbc320047878795518949519469d1..3a70f441a8d5a7936f81addef0a2df289d5ae36a 100644 (file)
@@ -932,13 +932,7 @@ void hda_dsp_d0i3_work(struct work_struct *work)
 
 int hda_dsp_core_get(struct snd_sof_dev *sdev, int core)
 {
-       struct sof_ipc_pm_core_config pm_core_config = {
-               .hdr = {
-                       .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE,
-                       .size = sizeof(pm_core_config),
-               },
-               .enable_mask = sdev->enabled_cores_mask | BIT(core),
-       };
+       const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm;
        int ret, ret1;
 
        /* power up core */
@@ -953,9 +947,12 @@ int hda_dsp_core_get(struct snd_sof_dev *sdev, int core)
        if (sdev->fw_state != SOF_FW_BOOT_COMPLETE || core == SOF_DSP_PRIMARY_CORE)
                return 0;
 
+       /* No need to continue the set_core_state ops is not available */
+       if (!pm_ops->set_core_state)
+               return 0;
+
        /* Now notify DSP for secondary cores */
-       ret = sof_ipc_tx_message(sdev->ipc, &pm_core_config, sizeof(pm_core_config),
-                                &pm_core_config, sizeof(pm_core_config));
+       ret = pm_ops->set_core_state(sdev, core, true);
        if (ret < 0) {
                dev_err(sdev->dev, "failed to enable secondary core '%d' failed with %d\n",
                        core, ret);
index 1ddc492f1b13a9365dbbc3a338b1419af32fbb0b..dcad7c382de69df9edae92add483fef98de43df2 100644 (file)
@@ -24,40 +24,30 @@ static const struct snd_sof_debugfs_map tgl_dsp_debugfs[] = {
 
 static int tgl_dsp_core_get(struct snd_sof_dev *sdev, int core)
 {
-       struct sof_ipc_pm_core_config pm_core_config = {
-               .hdr = {
-                       .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE,
-                       .size = sizeof(pm_core_config),
-               },
-               .enable_mask = sdev->enabled_cores_mask | BIT(core),
-       };
+       const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm;
 
        /* power up primary core if not already powered up and return */
        if (core == SOF_DSP_PRIMARY_CORE)
                return hda_dsp_enable_core(sdev, BIT(core));
 
-       /* notify DSP for secondary cores */
-       return sof_ipc_tx_message(sdev->ipc, &pm_core_config, sizeof(pm_core_config),
-                                &pm_core_config, sizeof(pm_core_config));
+       if (pm_ops->set_core_state)
+               return pm_ops->set_core_state(sdev, core, true);
+
+       return 0;
 }
 
 static int tgl_dsp_core_put(struct snd_sof_dev *sdev, int core)
 {
-       struct sof_ipc_pm_core_config pm_core_config = {
-               .hdr = {
-                       .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE,
-                       .size = sizeof(pm_core_config),
-               },
-               .enable_mask = sdev->enabled_cores_mask & ~BIT(core),
-       };
+       const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm;
 
        /* power down primary core and return */
        if (core == SOF_DSP_PRIMARY_CORE)
                return hda_dsp_core_reset_power_down(sdev, BIT(core));
 
-       /* notify DSP for secondary cores */
-       return sof_ipc_tx_message(sdev->ipc, &pm_core_config, sizeof(pm_core_config),
-                                &pm_core_config, sizeof(pm_core_config));
+       if (pm_ops->set_core_state)
+               return pm_ops->set_core_state(sdev, core, false);
+
+       return 0;
 }
 
 /* Tigerlake ops */