ASoC: SOF: ipc4-topology: Save the ALH DAI index during hw_params
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Tue, 2 Apr 2024 15:18:28 +0000 (10:18 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 2 Apr 2024 16:14:58 +0000 (17:14 +0100)
The node_id for multi-gateway ALH DAI's get overwritten with the
group_id during the DAI copier's ipc_prepare op. So, save the ALH
dai_index during the BE DAI hw_params in the dai_index field of struct
ipc4_copier and use that to set the device ID in the configuration blob.
This will avoid errors during copier init after an xrun.

Note that the dai_index is typically set in topology for DMIC/SSP, but
it's not used for ALH. Reclaiming this dai_index field to store the
node_id does not generate a conflict with topology-defined values.

Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240402151828.175002-18-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda.c
sound/soc/sof/ipc4-topology.c
sound/soc/sof/ipc4-topology.h

index 2c64c25d6f3b154dc6c36edb079150f1dfe44d93..d38dc43c2f1c929184179c8e9a42a598fd6305d4 100644 (file)
@@ -164,6 +164,7 @@ static int sdw_params_free(struct device *dev, struct sdw_intel_stream_free_data
                struct sof_ipc4_copier *ipc4_copier;
 
                ipc4_copier = dai->private;
+               ipc4_copier->dai_index = 0;
                copier_data = &ipc4_copier->data;
 
                /* clear the node ID */
index e8a5e9fbd7968a64bdd1307b6ee99d255c5a6d1a..793bca09bbf417585eccb446f92e52e744ca20f0 100644 (file)
@@ -1700,6 +1700,8 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
                         */
                        i = 0;
                        list_for_each_entry(w, &sdev->widget_list, list) {
+                               u32 node_type;
+
                                if (w->widget->sname &&
                                    strcmp(w->widget->sname, swidget->widget->sname))
                                        continue;
@@ -1707,7 +1709,10 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
                                dai = w->private;
                                alh_copier = (struct sof_ipc4_copier *)dai->private;
                                alh_data = &alh_copier->data;
-                               blob->alh_cfg.mapping[i].device = alh_data->gtw_cfg.node_id;
+                               node_type = SOF_IPC4_GET_NODE_TYPE(alh_data->gtw_cfg.node_id);
+                               blob->alh_cfg.mapping[i].device = SOF_IPC4_NODE_TYPE(node_type);
+                               blob->alh_cfg.mapping[i].device |=
+                                       SOF_IPC4_NODE_INDEX(alh_copier->dai_index);
 
                                /*
                                 * The mapping[i] device in ALH blob should be the same as the
@@ -2830,12 +2835,15 @@ static int sof_ipc4_dai_config(struct snd_sof_dev *sdev, struct snd_sof_widget *
                /*
                 * Do not clear the node ID when this op is invoked with
                 * SOF_DAI_CONFIG_FLAGS_HW_FREE. It is needed to free the group_ida during
-                * unprepare.
+                * unprepare. The node_id for multi-gateway DAI's will be overwritten with the
+                * group_id during copier's ipc_prepare op.
                 */
                if (flags & SOF_DAI_CONFIG_FLAGS_HW_PARAMS) {
+                       ipc4_copier->dai_index = data->dai_node_id;
                        copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK;
                        copier_data->gtw_cfg.node_id |= SOF_IPC4_NODE_INDEX(data->dai_node_id);
                }
+
                break;
        case SOF_DAI_INTEL_DMIC:
        case SOF_DAI_INTEL_SSP:
index aa5122c3721d3a7d7ea72408fe81ea2a5a9a24d9..6e33208a357f5d0d80407b5bd1006432ce1d7476 100644 (file)
@@ -45,6 +45,7 @@
 #define SOF_IPC4_NODE_INDEX_MASK       0xFF
 #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK)
 #define SOF_IPC4_NODE_TYPE(x)  ((x) << 8)
+#define SOF_IPC4_GET_NODE_TYPE(node_id) ((node_id) >> 8)
 
 /* Node ID for SSP type DAI copiers */
 #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4)