@@ -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
8185static 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
@@ -2004,6 +2012,25 @@ sof_ipc4_prepare_dai_copier(struct snd_sof_dev *sdev, struct snd_sof_dai *dai,
20042012 return ret ;
20052013}
20062014
2015+ static void sof_ipc4_host_config (struct snd_sof_dev * sdev , struct snd_sof_widget * swidget ,
2016+ struct snd_sof_platform_stream_params * platform_params )
2017+ {
2018+ struct sof_ipc4_copier * ipc4_copier = (struct sof_ipc4_copier * )swidget -> private ;
2019+ struct snd_sof_widget * pipe_widget = swidget -> spipe -> pipe_widget ;
2020+ struct sof_ipc4_copier_data * copier_data = & ipc4_copier -> data ;
2021+ struct sof_ipc4_pipeline * pipeline = pipe_widget -> private ;
2022+ u32 host_dma_id = platform_params -> stream_tag - 1 ;
2023+
2024+ if (pipeline -> use_chain_dma ) {
2025+ pipeline -> msg .primary &= ~SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK ;
2026+ pipeline -> msg .primary |= SOF_IPC4_GLB_CHAIN_DMA_HOST_ID (host_dma_id );
2027+ return ;
2028+ }
2029+
2030+ copier_data -> gtw_cfg .node_id &= ~SOF_IPC4_NODE_INDEX_MASK ;
2031+ copier_data -> gtw_cfg .node_id |= SOF_IPC4_NODE_INDEX (host_dma_id );
2032+ }
2033+
20072034static int
20082035sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
20092036 struct snd_pcm_hw_params * fe_params ,
@@ -2726,12 +2753,14 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27262753 int input_fmt_index = 0 ;
27272754 int ret ;
27282755
2729- input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
2730- & process -> base_config ,
2731- pipeline_params ,
2732- available_fmt );
2733- if (input_fmt_index < 0 )
2734- return input_fmt_index ;
2756+ if (available_fmt -> num_input_formats ) {
2757+ input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
2758+ & process -> base_config ,
2759+ pipeline_params ,
2760+ available_fmt );
2761+ if (input_fmt_index < 0 )
2762+ return input_fmt_index ;
2763+ }
27352764
27362765 /* Configure output audio format only if the module supports output */
27372766 if (available_fmt -> num_output_formats ) {
@@ -2740,12 +2769,28 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27402769 u32 out_ref_rate , out_ref_channels ;
27412770 int out_ref_valid_bits , out_ref_type ;
27422771
2743- in_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
2772+ if (available_fmt -> num_input_formats ) {
2773+ in_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
27442774
2745- out_ref_rate = in_fmt -> sampling_frequency ;
2746- out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
2747- out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2748- out_ref_type = sof_ipc4_fmt_cfg_to_type (in_fmt -> fmt_cfg );
2775+ out_ref_rate = in_fmt -> sampling_frequency ;
2776+ out_ref_channels =
2777+ SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
2778+ out_ref_valid_bits =
2779+ SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2780+ out_ref_type = sof_ipc4_fmt_cfg_to_type (in_fmt -> fmt_cfg );
2781+ } else {
2782+ /* for modules without input formats, use FE params as reference */
2783+ out_ref_rate = params_rate (fe_params );
2784+ out_ref_channels = params_channels (fe_params );
2785+ ret = sof_ipc4_get_sample_type (sdev , fe_params );
2786+ if (ret < 0 )
2787+ return ret ;
2788+ out_ref_type = (u32 )ret ;
2789+
2790+ out_ref_valid_bits = sof_ipc4_get_valid_bits (sdev , fe_params );
2791+ if (out_ref_valid_bits < 0 )
2792+ return out_ref_valid_bits ;
2793+ }
27492794
27502795 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
27512796 & process -> base_config ,
@@ -2773,6 +2818,16 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27732818 if (ret )
27742819 return ret ;
27752820 }
2821+
2822+ /* set base cfg to match the first output format if there are no input formats */
2823+ if (!available_fmt -> num_input_formats ) {
2824+ struct sof_ipc4_audio_format * out_fmt ;
2825+
2826+ out_fmt = & available_fmt -> output_pin_fmts [0 ].audio_fmt ;
2827+
2828+ /* copy output format */
2829+ memcpy (& process -> base_config .audio_fmt , out_fmt , sizeof (* out_fmt ));
2830+ }
27762831 }
27772832
27782833 sof_ipc4_dbg_module_audio_format (sdev -> dev , swidget , available_fmt ,
@@ -3929,4 +3984,5 @@ const struct sof_ipc_tplg_ops ipc4_tplg_ops = {
39293984 .dai_get_param = sof_ipc4_dai_get_param ,
39303985 .tear_down_all_pipelines = sof_ipc4_tear_down_all_pipelines ,
39313986 .link_setup = sof_ipc4_link_setup ,
3987+ .host_config = sof_ipc4_host_config ,
39323988};
0 commit comments