@@ -66,8 +66,8 @@ static void crossover_reset_state(struct comp_data *cd)
6666 * \return the position at which pipe_id is found in config->assign_sink.
6767 * -EINVAL if not found.
6868 */
69- static int crossover_get_stream_index (struct processing_module * mod ,
70- struct sof_crossover_config * config , uint32_t pipe_id )
69+ int crossover_get_stream_index (struct processing_module * mod ,
70+ struct sof_crossover_config * config , uint32_t pipe_id )
7171{
7272 int i ;
7373 uint32_t * assign_sink = config -> assign_sink ;
@@ -111,11 +111,7 @@ static int crossover_assign_sinks(struct processing_module *mod,
111111 unsigned int sink_id , state ;
112112
113113 sink = container_of (sink_list , struct comp_buffer , source_list );
114- #if CONFIG_IPC_MAJOR_4
115- sink_id = cd -> output_pin_index [j ];
116- #else
117- sink_id = sink -> pipeline_id ;
118- #endif
114+ sink_id = crossover_get_sink_id (cd , sink -> pipeline_id , j );
119115 state = sink -> sink -> state ;
120116 if (state != dev -> state ) {
121117 j ++ ;
@@ -295,42 +291,6 @@ static int crossover_setup(struct processing_module *mod, int nch)
295291 return ret ;
296292}
297293
298- #if CONFIG_IPC_MAJOR_4
299- /* Note: Crossover needs to have in the rimage manifest the init_config set to 1 to let
300- * kernel know that the base_cfg_ext needs to be appended to the IPC payload. The
301- * Extension is needed to know the output pin indices.
302- */
303- static int crossover_init_output_pins (struct processing_module * mod )
304- {
305- struct comp_data * cd = module_get_private_data (mod );
306- struct comp_dev * dev = mod -> dev ;
307- const struct ipc4_base_module_extended_cfg * base_cfg = mod -> priv .cfg .init_data ;
308- uint16_t num_input_pins = base_cfg -> base_cfg_ext .nb_input_pins ;
309- uint16_t num_output_pins = base_cfg -> base_cfg_ext .nb_output_pins ;
310- struct ipc4_input_pin_format * input_pin ;
311- struct ipc4_output_pin_format * output_pin ;
312- int i ;
313-
314- comp_dbg (dev , "Number of input pins %u, output pins %u" , num_input_pins , num_output_pins );
315-
316- if (num_input_pins != 1 || num_output_pins > SOF_CROSSOVER_MAX_STREAMS ) {
317- comp_err (dev , "Illegal number of pins %u %u" , num_input_pins , num_output_pins );
318- return - EINVAL ;
319- }
320-
321- input_pin = (struct ipc4_input_pin_format * )base_cfg -> base_cfg_ext .pin_formats ;
322- output_pin = (struct ipc4_output_pin_format * )(input_pin + 1 );
323- cd -> num_output_pins = num_output_pins ;
324- comp_dbg (dev , "input pin index = %u" , input_pin -> pin_index );
325- for (i = 0 ; i < num_output_pins ; i ++ ) {
326- comp_dbg (dev , "output pin %d index = %u" , i , output_pin [i ].pin_index );
327- cd -> output_pin_index [i ] = output_pin [i ].pin_index ;
328- }
329-
330- return 0 ;
331- }
332- #endif
333-
334294/**
335295 * \brief Creates a Crossover Filter component.
336296 * \return Pointer to Crossover Filter component device.
@@ -374,13 +334,11 @@ static int crossover_init(struct processing_module *mod)
374334 goto cd_fail ;
375335 }
376336
377- #if CONFIG_IPC_MAJOR_4
378- ret = crossover_init_output_pins (mod );
337+ ret = crossover_output_pin_init (mod );
379338 if (ret < 0 ) {
380339 comp_err (dev , "crossover_init(): crossover_init_output_pins() failed." );
381340 goto cd_fail ;
382341 }
383- #endif
384342
385343 crossover_reset_state (cd );
386344 return 0 ;
@@ -408,82 +366,6 @@ static int crossover_free(struct processing_module *mod)
408366 return 0 ;
409367}
410368
411- #if CONFIG_IPC_MAJOR_4
412- /**
413- * \brief Check sink streams configuration for matching pin index for output pins
414- */
415- static int crossover_check_sink_assign (struct processing_module * mod ,
416- struct sof_crossover_config * config )
417- {
418- struct comp_data * cd = module_get_private_data (mod );
419- struct comp_dev * dev = mod -> dev ;
420- uint32_t pin_index ;
421- int num_assigned_sinks = 0 ;
422- int i , j ;
423- uint8_t assigned_sinks [SOF_CROSSOVER_MAX_STREAMS ] = {0 };
424-
425- for (j = 0 ; j < cd -> num_output_pins ; j ++ ) {
426- pin_index = cd -> output_pin_index [j ];
427- i = crossover_get_stream_index (mod , config , pin_index );
428- if (i < 0 ) {
429- comp_warn (dev , "crossover_check_sink_assign(), could not assign sink %u" ,
430- pin_index );
431- break ;
432- }
433-
434- if (assigned_sinks [i ]) {
435- comp_warn (dev , "crossover_check_sink_assign(), multiple sinks from pin %u are assigned" ,
436- pin_index );
437- break ;
438- }
439-
440- assigned_sinks [i ] = true;
441- num_assigned_sinks ++ ;
442- }
443-
444- return num_assigned_sinks ;
445- }
446- #else
447- /**
448- * \brief Check sink streams configuration for matching pipeline IDs
449- */
450- static int crossover_check_sink_assign (struct processing_module * mod ,
451- struct sof_crossover_config * config )
452- {
453- struct comp_dev * dev = mod -> dev ;
454- struct comp_buffer * sink ;
455- struct list_item * sink_list ;
456- int num_assigned_sinks = 0 ;
457- uint8_t assigned_sinks [SOF_CROSSOVER_MAX_STREAMS ] = {0 };
458- int i ;
459-
460- list_for_item (sink_list , & dev -> bsink_list ) {
461- unsigned int pipeline_id ;
462-
463- sink = container_of (sink_list , struct comp_buffer , source_list );
464- pipeline_id = sink -> pipeline_id ;
465-
466- i = crossover_get_stream_index (mod , config , pipeline_id );
467- if (i < 0 ) {
468- comp_warn (dev , "crossover_check_sink_assign(), could not assign sink %d" ,
469- pipeline_id );
470- break ;
471- }
472-
473- if (assigned_sinks [i ]) {
474- comp_warn (dev , "crossover_check_sink_assign(), multiple sinks from pipeline %d are assigned" ,
475- pipeline_id );
476- break ;
477- }
478-
479- assigned_sinks [i ] = true;
480- num_assigned_sinks ++ ;
481- }
482-
483- return num_assigned_sinks ;
484- }
485- #endif
486-
487369/**
488370 * \brief Verifies that the config is formatted correctly.
489371 *
@@ -532,20 +414,13 @@ static int crossover_set_config(struct processing_module *mod, uint32_t config_i
532414 size_t response_size )
533415{
534416 struct comp_data * cd = module_get_private_data (mod );
417+ int ret ;
535418
536419 comp_info (mod -> dev , "crossover_set_config()" );
537420
538- #if CONFIG_IPC_MAJOR_3
539- /* TODO: This check seems to work only for IPC3, FW crash happens from reject from
540- * topology embedded blob.
541- */
542- struct sof_ipc_ctrl_data * cdata = (struct sof_ipc_ctrl_data * )fragment ;
543-
544- if (cdata -> cmd != SOF_CTRL_CMD_BINARY ) {
545- comp_err (mod -> dev , "crossover_set_config(), invalid command" );
546- return - EINVAL ;
547- }
548- #endif
421+ ret = crossover_check_config (mod , fragment );
422+ if (ret < 0 )
423+ return ret ;
549424
550425 return comp_data_blob_set (cd -> model_handler , pos , data_offset_size , fragment ,
551426 fragment_size );
@@ -557,16 +432,13 @@ static int crossover_get_config(struct processing_module *mod,
557432{
558433 struct comp_data * cd = module_get_private_data (mod );
559434 struct sof_ipc_ctrl_data * cdata = (struct sof_ipc_ctrl_data * )fragment ;
435+ int ret ;
560436
561437 comp_info (mod -> dev , "crossover_get_config()" );
562438
563- #if CONFIG_IPC_MAJOR_3
564-
565- if (cdata -> cmd != SOF_CTRL_CMD_BINARY ) {
566- comp_err (mod -> dev , "crossover_get_config(), invalid command" );
567- return - EINVAL ;
568- }
569- #endif
439+ ret = crossover_check_config (mod , fragment );
440+ if (ret < 0 )
441+ return ret ;
570442
571443 return comp_data_blob_get_cmd (cd -> model_handler , cdata , fragment_size );
572444}
@@ -647,32 +519,6 @@ static int crossover_process_audio_stream(struct processing_module *mod,
647519 return 0 ;
648520}
649521
650- #if CONFIG_IPC_MAJOR_4
651- /**
652- * \brief IPC4 specific component prepare, updates source and sink buffers formats from base_cfg
653- */
654- static void crossover_params (struct processing_module * mod )
655- {
656- struct sof_ipc_stream_params * params = mod -> stream_params ;
657- struct comp_buffer * sinkb , * sourceb ;
658- struct list_item * sink_list ;
659- struct comp_dev * dev = mod -> dev ;
660-
661- comp_dbg (dev , "crossover_params()" );
662-
663- ipc4_base_module_cfg_to_stream_params (& mod -> priv .cfg .base_cfg , params );
664- component_set_nearest_period_frames (dev , params -> rate );
665-
666- sourceb = list_first_item (& dev -> bsource_list , struct comp_buffer , sink_list );
667- ipc4_update_buffer_format (sourceb , & mod -> priv .cfg .base_cfg .audio_fmt );
668-
669- list_for_item (sink_list , & dev -> bsink_list ) {
670- sinkb = container_of (sink_list , struct comp_buffer , source_list );
671- ipc4_update_buffer_format (sinkb , & mod -> priv .cfg .base_cfg .audio_fmt );
672- }
673- }
674- #endif
675-
676522/**
677523 * \brief Prepares Crossover Filter component for processing.
678524 * \param[in,out] dev Crossover Filter base component device.
@@ -691,9 +537,7 @@ static int crossover_prepare(struct processing_module *mod,
691537
692538 comp_info (dev , "crossover_prepare()" );
693539
694- #if CONFIG_IPC_MAJOR_4
695540 crossover_params (mod );
696- #endif
697541
698542 /* Crossover has a variable number of sinks */
699543 mod -> max_sinks = SOF_CROSSOVER_MAX_STREAMS ;
0 commit comments