Skip to content

Commit

Permalink
Add some trace
Browse files Browse the repository at this point in the history
Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao committed Jan 10, 2024
1 parent 17aa03a commit f76d4f4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
32 changes: 27 additions & 5 deletions src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,35 +94,57 @@ static int copier_alh_assign_dai_index(struct comp_dev *dev,
* in other words do we need to create multiple dai or not
*/
if (!is_multi_gateway(node_id)) {
comp_err(mod->dev, "bard: !is_multi_gateway");
/* Find DMA config in blob and retrieve stream_id */
ret = ipc4_find_dma_config_multiple(dai, dma_config, dma_config_length,
alh_blob->alh_cfg.mapping[0].alh_id);
alh_blob->alh_cfg.mapping[0].alh_id,
0);
if (ret != 0) {
comp_err(mod->dev, "No sndw dma_config found in blob!");
comp_err(mod->dev, "No sndw dma_config found in blob! alh_id 0x%x",
alh_blob->alh_cfg.mapping[0].alh_id);
return -EINVAL;
}
dai_index[0] = dai->host_dma_config[0]->stream_id;
return 0;
}

comp_err(mod->dev, "bard: copier_alh_assign_dai_index 1");
dai_num = alh_blob->alh_cfg.count;
if (dai_num > IPC4_ALH_MAX_NUMBER_OF_GTW || dai_num < 0) {
comp_err(mod->dev, "Invalid dai_count: %d", dai_num);
return -EINVAL;
}

comp_err(mod->dev, "bard: copier_alh_assign_dai_index 2 dai_num %d", dai_num);
for (i = 0; i < dai_num; i++) {
comp_err(mod->dev, "bard: i %d", i);
ret = ipc4_find_dma_config_multiple(dai, dma_config,
dma_config_length,
alh_blob->alh_cfg.mapping[i].alh_id);
alh_blob->alh_cfg.mapping[i].alh_id,
i);
comp_err(mod->dev, "bard: copier_alh_assign_dai_index after ipc4_find_dma_config_multiple");
if (ret != 0) {
comp_err(mod->dev, "No sndw dma_config found in blob!");
comp_err(mod->dev, "No sndw dma_config found in blob! mapping[%d].alh_id 0x%x",
i, alh_blob->alh_cfg.mapping[i].alh_id);
return -EINVAL;
}
dai_index[i] = dai->host_dma_config[i]->stream_id;
if (dai->host_dma_config[i]) {
comp_err(mod->dev, "bard: copier_alh_assign_dai_index 3 stream_id 0x%x", dai->host_dma_config[i]->stream_id);
} else {
comp_err(mod->dev, "bard: dai->host_dma_config[%d] is null", i);
return -EINVAL;
}
if (dai_index[i])
dai_index[i] = dai->host_dma_config[i]->stream_id;
else {
comp_err(mod->dev, "bard: dai_index[%d] is null", i);
return -EINVAL;
}
comp_err(mod->dev, "bard: copier_alh_assign_dai_index 4");
}

*dai_count = dai_num;
comp_err(mod->dev, "bard: copier_alh_assign_dai_index 5 *dai_count %d", *dai_count);
break;
case SOF_DAI_INTEL_ALH:
/* Use DAI_INTEL_ALH for ACE 1.0 and older */
Expand Down
2 changes: 1 addition & 1 deletion src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
}

channel = dai_config_dma_channel(dd, dev, dd->dai_spec_config);
comp_dbg(dev, "dai_common_config_prepare(), channel = %d", channel);
comp_info(dev, "dai_common_config_prepare(), channel = %d", channel);

/* do nothing for asking for channel free, for compatibility. */
if (channel == DMA_CHAN_INVALID) {
Expand Down
2 changes: 1 addition & 1 deletion src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3
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);
uint32_t size, uint32_t device_id, int dma_cfg_index);
#else
#error "No or invalid IPC MAJOR version selected."
#endif
Expand Down
24 changes: 17 additions & 7 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,11 @@ int ipc4_add_comp_dev(struct comp_dev *dev)

int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size)
{
tr_err(&comp_tr, "bard: ipc4_find_dma_config");
#if defined(CONFIG_ACE_VERSION_2_0)
uint32_t *dma_config_id = GET_IPC_DMA_CONFIG_ID(data_buffer, size);

tr_err(&comp_tr, "bard: dma_config_id 0x%x", *dma_config_id);
if (*dma_config_id != GTW_DMA_CONFIG_ID)
return IPC4_INVALID_REQUEST;

Expand All @@ -1038,33 +1040,41 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3
}

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

tr_err(&ipc_tr, "bard: ipc4_find_dma_config_multiple device_id 0x%x", device_id);
for (tlvs = (struct sof_tlv *)data_buffer; (uint32_t)tlvs < end_addr;
tlvs = tlv_next(tlvs)) {

if ((uintptr_t)tlvs % sizeof(uint32_t) != 0)
tr_err(&comp_tr, "bard: tlv size in incorrect");
else
tr_err(&comp_tr, "bard: tlv->type 0x%x", tlvs->type);
dma_cfg = tlv_value_ptr_get(tlvs, GTW_DMA_CONFIG_ID);
if (!dma_cfg)
if (!dma_cfg) {
tr_err(&ipc_tr, "bard: !dma_cfg");
continue;
}

tr_err(&ipc_tr, "bard: device_count %d dma_cfg_index %d", dma_cfg->channel_map.device_count, dma_cfg_index);
if (dma_cfg->channel_map.device_count == 0) {
dai->host_dma_config[dma_cfg_count] = dma_cfg;
dai->host_dma_config[dma_cfg_index] = dma_cfg;
return IPC4_SUCCESS;
}

for (uint32_t i = 0; i < dma_cfg->channel_map.device_count; i++) {
tr_err(&ipc_tr, "bard: map[%d].device_address = 0x%x device_id 0x%x",
i, dma_cfg->channel_map.map[i].device_address, device_id);
if (dma_cfg->channel_map.map[i].device_address == device_id) {
dai->host_dma_config[dma_cfg_count] = dma_cfg;
dai->host_dma_config[dma_cfg_index] = dma_cfg;
tr_err(&ipc_tr, "bard: set ai->host_dma_config[%d] return success", dma_cfg_index);
return IPC4_SUCCESS;
}
}

dma_cfg_count++;
}

return IPC4_INVALID_REQUEST;
Expand Down

0 comments on commit f76d4f4

Please sign in to comment.