Skip to content

Commit

Permalink
ipc4: add helper function to parse dma config
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
iganakov authored and kv2019i committed Jan 29, 2024
1 parent b6cdc75 commit 21bcf73
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id, uint32_t cmd);
int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size);
int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd);
int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed);
int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer,
uint32_t size, uint32_t device_id, int dma_cfg_idx);
#else
#error "No or invalid IPC MAJOR version selected."
#endif
Expand Down
30 changes: 30 additions & 0 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <ipc4/module.h>
#include <ipc4/error_status.h>
#include <sof/lib_manager.h>
#include <sof/tlv.h>

#include <errno.h>
#include <stdbool.h>
Expand Down Expand Up @@ -1048,6 +1049,35 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3
return IPC4_SUCCESS;
}

int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer,
uint32_t size, uint32_t device_id, int dma_cfg_idx)
{
uint32_t end_addr = (uint32_t)data_buffer + size;
struct ipc_dma_config *dma_cfg;
struct sof_tlv *tlvs;

for (tlvs = (struct sof_tlv *)data_buffer; (uint32_t)tlvs < end_addr;
tlvs = tlv_next(tlvs)) {
dma_cfg = tlv_value_ptr_get(tlvs, GTW_DMA_CONFIG_ID);
if (!dma_cfg)
continue;

/* To be able to retrieve proper DMA config we need to check if
* device_id value (which is alh_id) is equal to device_address.
* They both contain SNDW master id and PDI. If they match then
* proper config is found.
*/
for (uint32_t i = 0; i < dma_cfg->channel_map.device_count; i++) {
if (dma_cfg->channel_map.map[i].device_address == device_id) {
dai->host_dma_config[dma_cfg_idx] = dma_cfg;
return IPC4_SUCCESS;
}
}
}

return IPC4_INVALID_REQUEST;
}

void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg,
struct sof_ipc_stream_params *params)
{
Expand Down

0 comments on commit 21bcf73

Please sign in to comment.