Skip to content

Commit e52de83

Browse files
ranj063kv2019i
authored andcommitted
ipc4: Set comp direction during module binding
Simplify the direction setting for components to assign the direction for components during module binding. Copier components always have their direction set during init, so use that to set the direction for the other modules. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 82bdd0f commit e52de83

2 files changed

Lines changed: 18 additions & 75 deletions

File tree

src/ipc/ipc4/handler.c

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static bool is_any_ppl_active(void)
209209
* ERROR Stop EOS |______\ SAVE
210210
* /
211211
*/
212-
static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t *ppl_status)
212+
static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed)
213213
{
214214
struct ipc_comp_dev *pcm_dev;
215215
struct ipc_comp_dev *host = NULL;
@@ -227,7 +227,6 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
227227
}
228228

229229
status = pcm_dev->pipeline->status;
230-
*ppl_status = status;
231230
/* source & sink components are set when pipeline is set to COMP_STATE_INIT */
232231
if (status != COMP_STATE_INIT) {
233232
int host_id;
@@ -277,7 +276,6 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
277276
if (ret < 0)
278277
ret = IPC4_INVALID_REQUEST;
279278

280-
*ppl_status = COMP_STATE_READY;
281279
return ret;
282280
case COMP_STATE_READY:
283281
/* initialized -> pause -> reset */
@@ -313,7 +311,6 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
313311
if (ret < 0)
314312
ret = IPC4_INVALID_REQUEST;
315313

316-
*ppl_status = COMP_STATE_READY;
317314
return ret;
318315
case COMP_STATE_READY:
319316
case COMP_STATE_PAUSED:
@@ -344,7 +341,6 @@ static int set_pipeline_state(uint32_t id, uint32_t cmd, bool *delayed, uint32_t
344341
ret = 0;
345342
}
346343

347-
*ppl_status = host->cd->pipeline->status;
348344
return ret;
349345
}
350346

@@ -405,75 +401,10 @@ static int ipc_wait_for_compound_msg(void)
405401
return IPC4_SUCCESS;
406402
}
407403

408-
/* In ipc3 path, host driver sends pcm_hw_param message to fw and
409-
* direction is included. The direction is set to each component
410-
* after pipeline is complete. In ipc4 path, direction is figured out and
411-
* set it to each component after connected pipeline are complete.
412-
*/
413-
static int update_dir_to_pipeline_component(const uint32_t *ppl_id, uint32_t count)
414-
{
415-
struct ipc_comp_dev *icd;
416-
struct ipc_comp_dev *pipe;
417-
struct comp_dev *dir_src = NULL;
418-
struct list_item *clist;
419-
struct ipc *ipc;
420-
uint32_t i;
421-
422-
ipc = ipc_get();
423-
424-
for (i = 0; i < count; i++) {
425-
pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i]);
426-
if (!pipe) {
427-
tr_info(&ipc_tr, "ppl_id %u: no pipeline is found", ppl_id[i]);
428-
continue;
429-
}
430-
431-
if (pipe->pipeline->source_comp->direction_set) {
432-
dir_src = pipe->pipeline->source_comp;
433-
break;
434-
} else if (pipe->pipeline->sink_comp->direction_set) {
435-
dir_src = pipe->pipeline->sink_comp;
436-
break;
437-
}
438-
}
439-
if (!dir_src) {
440-
tr_err(&ipc_tr, "no direction source in pipeline");
441-
return IPC4_INVALID_RESOURCE_STATE;
442-
}
443-
444-
/* set direction to the component in the pipeline array */
445-
list_for_item(clist, &ipc->comp_list) {
446-
icd = container_of(clist, struct ipc_comp_dev, list);
447-
if (icd->type != COMP_TYPE_COMPONENT)
448-
continue;
449-
450-
for (i = 0; i < count; i++) {
451-
if (ipc_comp_pipe_id(icd) == ppl_id[i]) {
452-
struct comp_dev *dev = icd->cd;
453-
454-
/* don't update direction for host & dai since they
455-
* have direction. Especially in dai copier to dai copier
456-
* case the direction can't be modified to single value
457-
* since one of them is for playback and the other one
458-
* is for capture
459-
*/
460-
if (dev->direction_set)
461-
break;
462-
463-
icd->cd->direction = dir_src->direction;
464-
break;
465-
}
466-
}
467-
}
468-
469-
return 0;
470-
}
471-
472404
static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)
473405
{
474406
const struct ipc4_pipeline_set_state_data *ppl_data;
475407
struct ipc4_pipeline_set_state state;
476-
uint32_t status = COMP_STATE_INIT;
477408
uint32_t cmd, ppl_count, id;
478409
const uint32_t *ppl_id;
479410
int ret = 0;
@@ -501,17 +432,13 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)
501432
bool delayed = false;
502433

503434
ipc_compound_pre_start(state.primary.r.type);
504-
ret = set_pipeline_state(ppl_id[i], cmd, &delayed, &status);
435+
ret = set_pipeline_state(ppl_id[i], cmd, &delayed);
505436
ipc_compound_post_start(state.primary.r.type, ret, delayed);
506437

507438
if (ret != 0)
508439
return ret;
509440
}
510441

511-
/* update direction after all connected pipelines are complete */
512-
if (status == COMP_STATE_READY)
513-
ret = update_dir_to_pipeline_component(ppl_id, ppl_count);
514-
515442
return ret;
516443
}
517444

src/ipc/ipc4/helper.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,22 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
318318
if (ret < 0)
319319
return IPC4_INVALID_RESOURCE_ID;
320320

321+
/* update direction for sink component if it is not set already */
322+
if (!sink->direction_set && source->direction_set) {
323+
sink->direction = source->direction;
324+
sink->direction_set = true;
325+
}
326+
327+
/* update direction for source component if it is not set already */
328+
if (!source->direction_set && sink->direction_set) {
329+
source->direction = sink->direction;
330+
source->direction_set = true;
331+
}
332+
333+
/* both sink and source components should have their direction set during module binding */
334+
if (!sink->direction_set || !source->direction_set)
335+
return IPC4_INVALID_RESOURCE_STATE;
336+
321337
return IPC4_SUCCESS;
322338

323339
err:

0 commit comments

Comments
 (0)