Skip to content

Commit 21bcf73

Browse files
iganakovkv2019i
authored andcommitted
ipc4: add helper function to parse dma config
Add helper function to parse muiltiple DMA config tlv structures added to copier Init Instance IPC in case of SNDW FW aggregation. To be able to find correct config we need to iterate over the sequence of DMA tlv with the same tlv type. Thus, we need to check if device_address value (which contains PDI) is equal to device_id parameter (passed with alh_id value). Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
1 parent b6cdc75 commit 21bcf73

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/include/sof/ipc/topology.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id, uint32_t cmd);
6060
int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size);
6161
int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd);
6262
int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed);
63+
int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer,
64+
uint32_t size, uint32_t device_id, int dma_cfg_idx);
6365
#else
6466
#error "No or invalid IPC MAJOR version selected."
6567
#endif

src/ipc/ipc4/helper.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <ipc4/module.h>
4545
#include <ipc4/error_status.h>
4646
#include <sof/lib_manager.h>
47+
#include <sof/tlv.h>
4748

4849
#include <errno.h>
4950
#include <stdbool.h>
@@ -1048,6 +1049,35 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3
10481049
return IPC4_SUCCESS;
10491050
}
10501051

1052+
int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer,
1053+
uint32_t size, uint32_t device_id, int dma_cfg_idx)
1054+
{
1055+
uint32_t end_addr = (uint32_t)data_buffer + size;
1056+
struct ipc_dma_config *dma_cfg;
1057+
struct sof_tlv *tlvs;
1058+
1059+
for (tlvs = (struct sof_tlv *)data_buffer; (uint32_t)tlvs < end_addr;
1060+
tlvs = tlv_next(tlvs)) {
1061+
dma_cfg = tlv_value_ptr_get(tlvs, GTW_DMA_CONFIG_ID);
1062+
if (!dma_cfg)
1063+
continue;
1064+
1065+
/* To be able to retrieve proper DMA config we need to check if
1066+
* device_id value (which is alh_id) is equal to device_address.
1067+
* They both contain SNDW master id and PDI. If they match then
1068+
* proper config is found.
1069+
*/
1070+
for (uint32_t i = 0; i < dma_cfg->channel_map.device_count; i++) {
1071+
if (dma_cfg->channel_map.map[i].device_address == device_id) {
1072+
dai->host_dma_config[dma_cfg_idx] = dma_cfg;
1073+
return IPC4_SUCCESS;
1074+
}
1075+
}
1076+
}
1077+
1078+
return IPC4_INVALID_REQUEST;
1079+
}
1080+
10511081
void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg,
10521082
struct sof_ipc_stream_params *params)
10531083
{

0 commit comments

Comments
 (0)