Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/drivers/intel/cavs/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static int idc_pipeline_trigger(uint32_t cmd)
dcache_invalidate_region(data, sizeof(*data));

/* check whether component exists */
pcm_dev = ipc_get_comp(ipc, data->comp_id);
pcm_dev = ipc_get_comp_by_id(ipc, data->comp_id);
if (!pcm_dev)
return -ENODEV;

Expand Down Expand Up @@ -246,7 +246,7 @@ static int idc_component_command(uint32_t cmd)
data->rhdr.hdr.size - sizeof(*data));

/* check whether component exists */
comp_dev = ipc_get_comp(ipc, data->comp_id);
comp_dev = ipc_get_comp_by_id(ipc, data->comp_id);
if (!comp_dev)
return -ENODEV;

Expand Down
8 changes: 7 additions & 1 deletion src/include/sof/drivers/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ int ipc_comp_connect(struct ipc *ipc,
/*
* Get component by ID.
*/
struct ipc_comp_dev *ipc_get_comp(struct ipc *ipc, uint32_t id);
struct ipc_comp_dev *ipc_get_comp_by_id(struct ipc *ipc, uint32_t id);

/*
* Get component by pipeline ID.
*/
struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id);

/*
* Configure all DAI components attached to DAI.
Expand Down
10 changes: 5 additions & 5 deletions src/ipc/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int ipc_stream_pcm_params(uint32_t stream)
trace_ipc("ipc: comp %d -> params", pcm_params.comp_id);

/* get the pcm_dev */
pcm_dev = ipc_get_comp(_ipc, pcm_params.comp_id);
pcm_dev = ipc_get_comp_by_id(_ipc, pcm_params.comp_id);
if (pcm_dev == NULL) {
trace_ipc_error("ipc: comp %d not found", pcm_params.comp_id);
return -ENODEV;
Expand Down Expand Up @@ -344,7 +344,7 @@ static int ipc_stream_pcm_free(uint32_t header)
trace_ipc("ipc: comp %d -> free", free_req.comp_id);

/* get the pcm_dev */
pcm_dev = ipc_get_comp(_ipc, free_req.comp_id);
pcm_dev = ipc_get_comp_by_id(_ipc, free_req.comp_id);
if (pcm_dev == NULL) {
trace_ipc_error("ipc: comp %d not found", free_req.comp_id);
return -ENODEV;
Expand Down Expand Up @@ -376,7 +376,7 @@ static int ipc_stream_position(uint32_t header)
memset(&posn, 0, sizeof(posn));

/* get the pcm_dev */
pcm_dev = ipc_get_comp(_ipc, stream.comp_id);
pcm_dev = ipc_get_comp_by_id(_ipc, stream.comp_id);
if (pcm_dev == NULL) {
trace_ipc_error("ipc: comp %d not found", stream.comp_id);
return -ENODEV;
Expand Down Expand Up @@ -455,7 +455,7 @@ static int ipc_stream_trigger(uint32_t header)
trace_ipc("ipc: comp %d -> trigger cmd 0x%x", stream.comp_id, ipc_cmd);

/* get the pcm_dev */
pcm_dev = ipc_get_comp(_ipc, stream.comp_id);
pcm_dev = ipc_get_comp_by_id(_ipc, stream.comp_id);
if (pcm_dev == NULL) {
trace_ipc_error("ipc: comp %d not found", stream.comp_id);
return -ENODEV;
Expand Down Expand Up @@ -842,7 +842,7 @@ static int ipc_comp_value(uint32_t header, uint32_t cmd)
trace_ipc("ipc: comp %d -> cmd %d", data.comp_id, data.cmd);

/* get the component */
comp_dev = ipc_get_comp(_ipc, data.comp_id);
comp_dev = ipc_get_comp_by_id(_ipc, data.comp_id);
if (!comp_dev) {
trace_ipc_error("ipc: comp %d not found", data.comp_id);
return -ENODEV;
Expand Down
62 changes: 51 additions & 11 deletions src/ipc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* more than 1 list may need to be searched for the corresponding component.
*/

struct ipc_comp_dev *ipc_get_comp(struct ipc *ipc, uint32_t id)
struct ipc_comp_dev *ipc_get_comp_by_id(struct ipc *ipc, uint32_t id)
{
struct ipc_comp_dev *icd;
struct list_item *clist;
Expand Down Expand Up @@ -66,6 +66,36 @@ struct ipc_comp_dev *ipc_get_comp(struct ipc *ipc, uint32_t id)
return NULL;
}

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id)
{
struct ipc_comp_dev *icd;
struct list_item *clist;

list_for_item(clist, &ipc->shared_ctx->comp_list) {
icd = container_of(clist, struct ipc_comp_dev, list);
if (icd->type != type)
continue;

switch (icd->type) {
case COMP_TYPE_COMPONENT:
if (icd->cd->comp.pipeline_id == ppl_id)
return icd;
break;
case COMP_TYPE_BUFFER:
if (icd->cb->ipc_buffer.comp.pipeline_id == ppl_id)
return icd;
break;
case COMP_TYPE_PIPELINE:
if (icd->pipeline->ipc_pipe.pipeline_id == ppl_id)
return icd;
break;
}
}

return NULL;
}

static struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc,
uint32_t pipeline_id, int dir)
{
Expand Down Expand Up @@ -129,7 +159,7 @@ int ipc_comp_new(struct ipc *ipc, struct sof_ipc_comp *comp)
int ret = 0;

/* check whether component already exists */
icd = ipc_get_comp(ipc, comp->id);
icd = ipc_get_comp_by_id(ipc, comp->id);
if (icd != NULL) {
trace_ipc_error("ipc_comp_new() error: comp->id = %u",
comp->id);
Expand Down Expand Up @@ -164,7 +194,7 @@ int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
struct ipc_comp_dev *icd;

/* check whether component exists */
icd = ipc_get_comp(ipc, comp_id);
icd = ipc_get_comp_by_id(ipc, comp_id);
if (icd == NULL)
return -ENODEV;

Expand Down Expand Up @@ -196,7 +226,7 @@ int ipc_buffer_new(struct ipc *ipc, struct sof_ipc_buffer *desc)
int ret = 0;

/* check whether buffer already exists */
ibd = ipc_get_comp(ipc, desc->comp.id);
ibd = ipc_get_comp_by_id(ipc, desc->comp.id);
if (ibd != NULL) {
trace_ipc_error("ipc_buffer_new() error: "
"buffer already exists, desc->comp.id = %u",
Expand Down Expand Up @@ -231,7 +261,7 @@ int ipc_buffer_free(struct ipc *ipc, uint32_t buffer_id)
struct ipc_comp_dev *ibd;

/* check whether buffer exists */
ibd = ipc_get_comp(ipc, buffer_id);
ibd = ipc_get_comp_by_id(ipc, buffer_id);
if (ibd == NULL)
return -ENODEV;

Expand All @@ -250,15 +280,15 @@ int ipc_comp_connect(struct ipc *ipc,
struct ipc_comp_dev *icd_sink;

/* check whether the components already exist */
icd_source = ipc_get_comp(ipc, connect->source_id);
icd_source = ipc_get_comp_by_id(ipc, connect->source_id);
if (icd_source == NULL) {
trace_ipc_error("ipc_comp_connect() error: components already"
" exist, connect->source_id = %u",
connect->source_id);
return -EINVAL;
}

icd_sink = ipc_get_comp(ipc, connect->sink_id);
icd_sink = ipc_get_comp_by_id(ipc, connect->sink_id);
if (icd_sink == NULL) {
trace_ipc_error("ipc_comp_connect() error: components already"
" exist, connect->sink_id = %u",
Expand Down Expand Up @@ -293,16 +323,26 @@ int ipc_pipeline_new(struct ipc *ipc,
struct ipc_comp_dev *icd;

/* check whether the pipeline already exists */
ipc_pipe = ipc_get_comp(ipc, pipe_desc->comp_id);
ipc_pipe = ipc_get_comp_by_id(ipc, pipe_desc->comp_id);
if (ipc_pipe != NULL) {
trace_ipc_error("ipc_pipeline_new() error: pipeline already"
" exists, pipe_desc->comp_id = %u",
pipe_desc->comp_id);
return -EINVAL;
}

/* check whether pipeline id is already taken */
ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE,
pipe_desc->pipeline_id);
if (ipc_pipe) {
trace_ipc_error("ipc_pipeline_new() error: pipeline id is "
"already taken, pipe_desc->pipeline_id = %u",
pipe_desc->pipeline_id);
return -EINVAL;
}

/* find the scheduling component */
icd = ipc_get_comp(ipc, pipe_desc->sched_id);
icd = ipc_get_comp_by_id(ipc, pipe_desc->sched_id);
if (icd == NULL) {
trace_ipc_error("ipc_pipeline_new() error: cannot find the "
"scheduling component, pipe_desc->sched_id"
Expand Down Expand Up @@ -345,7 +385,7 @@ int ipc_pipeline_free(struct ipc *ipc, uint32_t comp_id)
int ret;

/* check whether pipeline exists */
ipc_pipe = ipc_get_comp(ipc, comp_id);
ipc_pipe = ipc_get_comp_by_id(ipc, comp_id);
if (ipc_pipe == NULL)
return -ENODEV;

Expand All @@ -371,7 +411,7 @@ int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
struct ipc_comp_dev *ipc_ppl_sink;

/* check whether pipeline exists */
ipc_pipe = ipc_get_comp(ipc, comp_id);
ipc_pipe = ipc_get_comp_by_id(ipc, comp_id);
if (!ipc_pipe)
return -EINVAL;

Expand Down
12 changes: 11 additions & 1 deletion test/cmocka/src/audio/pipeline/pipeline_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,24 @@ void cpu_power_down_core(void) { }

void notifier_notify(void) { }

struct ipc_comp_dev *ipc_get_comp(struct ipc *ipc, uint32_t id)
struct ipc_comp_dev *ipc_get_comp_by_id(struct ipc *ipc, uint32_t id)
{
(void)ipc;
(void)id;

return NULL;
}

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id)
{
(void)ipc;
(void)type;
(void)ppl_id;

return NULL;
}

void heap_trace_all(int force)
{
(void)force;
Expand Down
5 changes: 4 additions & 1 deletion test/cmocka/src/audio/pipeline/pipeline_mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ int arch_cpu_is_core_enabled(int id);

void cpu_power_down_core(void);

struct ipc_comp_dev *ipc_get_comp(struct ipc *ipc, uint32_t id);
struct ipc_comp_dev *ipc_get_comp_by_id(struct ipc *ipc, uint32_t id);

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id);

void notifier_notify(void);

Expand Down
4 changes: 2 additions & 2 deletions tools/testbench/common_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int tb_pipeline_start(struct ipc *ipc, int nch,
}

/* Get IPC component device for pipeline */
pcm_dev = ipc_get_comp(ipc, ipc_pipe->sched_id);
pcm_dev = ipc_get_comp_by_id(ipc, ipc_pipe->sched_id);
if (!pcm_dev) {
fprintf(stderr, "error: ipc get comp\n");
return -EINVAL;
Expand Down Expand Up @@ -136,7 +136,7 @@ int tb_pipeline_params(struct ipc *ipc, int nch,
}

/* get scheduling component device for pipeline*/
pcm_dev = ipc_get_comp(ipc, ipc_pipe->sched_id);
pcm_dev = ipc_get_comp_by_id(ipc, ipc_pipe->sched_id);
if (!pcm_dev) {
fprintf(stderr, "error: ipc get comp\n");
return -EINVAL;
Expand Down
6 changes: 3 additions & 3 deletions tools/testbench/testbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ int main(int argc, char **argv)
}

/* Get pointers to fileread and filewrite */
pcm_dev = ipc_get_comp(sof.ipc, fw_id);
pcm_dev = ipc_get_comp_by_id(sof.ipc, fw_id);
fwcd = comp_get_drvdata(pcm_dev->cd);
pcm_dev = ipc_get_comp(sof.ipc, fr_id);
pcm_dev = ipc_get_comp_by_id(sof.ipc, fr_id);
frcd = comp_get_drvdata(pcm_dev->cd);

/* Run pipeline until EOF from fileread */
pcm_dev = ipc_get_comp(sof.ipc, sched_id);
pcm_dev = ipc_get_comp_by_id(sof.ipc, sched_id);
p = pcm_dev->cd->pipeline;
ipc_pipe = &p->ipc_pipe;

Expand Down