Skip to content

Commit dccc6a5

Browse files
committed
ASoC: SOF: ipc4-topology: Add new tokens for pipeline direction
Parse the pipeline direction from topology. The direction_valid token is required for backward-compatibility with older topologies that may not have the direction set for pipelines. This will be used when setting up pipelines to check if a pipeline is in the same direction as the requested params and skip those in the opposite direction like in the case of echo reference capture pipelines during playback. Signed-off-by: Ranjani Sridharan <[email protected]>
1 parent c5bfd63 commit dccc6a5

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

include/uapi/sound/sof/tokens.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define SOF_TKN_SCHED_MEM_USAGE 208
5858
#define SOF_TKN_SCHED_USE_CHAIN_DMA 209
5959
#define SOF_TKN_SCHED_KCPS 210
60+
#define SOF_TKN_SCHED_DIRECTION 211
61+
#define SOF_TKN_SCHED_DIRECTION_VALID 212
6062

6163
/* volume */
6264
#define SOF_TKN_VOLUME_RAMP_STEP_TYPE 250

sound/soc/sof/ipc4-topology.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ static const struct sof_topology_token ipc4_sched_tokens[] = {
7676
offsetof(struct sof_ipc4_pipeline, core_id)},
7777
{SOF_TKN_SCHED_PRIORITY, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
7878
offsetof(struct sof_ipc4_pipeline, priority)},
79+
{SOF_TKN_SCHED_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
80+
offsetof(struct sof_ipc4_pipeline, direction)},
81+
{SOF_TKN_SCHED_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
82+
offsetof(struct sof_ipc4_pipeline, direction_valid)},
7983
};
8084

8185
static const struct sof_topology_token pipeline_tokens[] = {
@@ -939,6 +943,10 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
939943

940944
swidget->core = pipeline->core_id;
941945
spipe->core_mask |= BIT(pipeline->core_id);
946+
if (pipeline->direction_valid) {
947+
spipe->direction = pipeline->direction;
948+
spipe->direction_valid = true;
949+
}
942950

943951
if (pipeline->use_chain_dma) {
944952
dev_dbg(scomp->dev, "Set up chain DMA for %s\n", swidget->widget->name);
@@ -954,9 +962,9 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
954962
goto err;
955963
}
956964

957-
dev_dbg(scomp->dev, "pipeline '%s': id %d, pri %d, core_id %u, lp mode %d\n",
965+
dev_dbg(scomp->dev, "pipeline '%s': id %d, pri %d, core_id %u, lp mode %d direction %d\n",
958966
swidget->widget->name, swidget->pipeline_id,
959-
pipeline->priority, pipeline->core_id, pipeline->lp_mode);
967+
pipeline->priority, pipeline->core_id, pipeline->lp_mode, pipeline->direction);
960968

961969
swidget->private = pipeline;
962970

sound/soc/sof/ipc4-topology.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ struct sof_ipc4_copier_config_set_sink_format {
150150
* @use_chain_dma: flag to indicate if the firmware shall use chained DMA
151151
* @msg: message structure for pipeline
152152
* @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger
153+
* @direction_valid: flag indicating if valid direction is set in topology
154+
* @direction: pipeline direction set in topology if direction_valid is true
153155
*/
154156
struct sof_ipc4_pipeline {
155157
uint32_t priority;
@@ -160,6 +162,8 @@ struct sof_ipc4_pipeline {
160162
bool use_chain_dma;
161163
struct sof_ipc4_msg msg;
162164
bool skip_during_fe_trigger;
165+
bool direction_valid;
166+
u32 direction;
163167
};
164168

165169
/**

sound/soc/sof/sof-audio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ struct snd_sof_widget {
512512
* @complete: flag used to indicate that pipeline set up is complete.
513513
* @core_mask: Mask containing target cores for all modules in the pipeline
514514
* @list: List item in sdev pipeline_list
515+
* @direction_valid: flag indicating if the direction is set in topology
516+
* @direction: pipeline direction set in topology, valid is direction_valid is true
517+
*
515518
*/
516519
struct snd_sof_pipeline {
517520
struct snd_sof_widget *pipe_widget;
@@ -520,6 +523,8 @@ struct snd_sof_pipeline {
520523
int complete;
521524
unsigned long core_mask;
522525
struct list_head list;
526+
bool direction_valid;
527+
u32 direction;
523528
};
524529

525530
/* ASoC SOF DAPM route */

0 commit comments

Comments
 (0)