@@ -259,29 +259,28 @@ static void *ipc4_pipeline_setup(void)
259259 struct sof * sof = sof_get ();
260260 printk ("DEBUG: Entering ipc4_pipeline_setup\n" );
261261
262- volatile void * refs [] = {
263- sys_comp_module_src_interface_init ,
264- sys_comp_module_copier_interface_init ,
265- sys_comp_module_volume_interface_init ,
266- sys_comp_module_mixin_interface_init ,
267- sys_comp_module_mixout_interface_init ,
262+ sys_comp_init (sof );
263+
264+ sys_comp_module_src_interface_init ();
265+ sys_comp_module_copier_interface_init ();
266+ sys_comp_module_volume_interface_init ();
267+ sys_comp_module_mixin_interface_init ();
268+ sys_comp_module_mixout_interface_init ();
268269#if defined(CONFIG_COMP_EQ_IIR )
269- sys_comp_module_eq_iir_interface_init ,
270+ sys_comp_module_eq_iir_interface_init ();
270271#endif
271272#if defined(CONFIG_COMP_EQ_FIR )
272- sys_comp_module_eq_fir_interface_init ,
273+ sys_comp_module_eq_fir_interface_init ();
273274#endif
274275#if defined(CONFIG_COMP_DRC )
275- sys_comp_module_drc_interface_init ,
276+ sys_comp_module_drc_interface_init ();
276277#endif
277278#if defined(CONFIG_COMP_ARIA )
278- sys_comp_module_aria_interface_init ,
279+ sys_comp_module_aria_interface_init ();
279280#endif
280281#if defined(CONFIG_COMP_MFCC )
281- sys_comp_module_mfcc_interface_init ,
282+ sys_comp_module_mfcc_interface_init ();
282283#endif
283- };
284- (void )refs ;
285284
286285 /* SOF_BOOT_TEST_STANDALONE skips IPC init. We must allocate it manually for testing. */
287286 if (!sof -> ipc ) {
@@ -477,6 +476,8 @@ struct test_pipeline_state {
477476 struct comp_dev * sched_comp ;
478477 struct comp_buffer * source_buf ; /* Mock source buffer for edge */
479478 struct comp_buffer * sink_buf ; /* Mock sink buffer for edge */
479+ uint64_t accumulated_bytes [MAX_PIPELINE_MODULES ];
480+ void * last_wptr [MAX_PIPELINE_MODULES ];
480481};
481482
482483/**
@@ -577,15 +578,33 @@ static void print_module_buffers(struct test_pipeline_state *p_state)
577578{
578579 for (uint32_t i = 0 ; i < p_state -> num_modules ; i ++ ) {
579580 struct comp_dev * mod = p_state -> modules [i ];
580- uint64_t bytes_copied = comp_get_total_data_processed ( mod , 0 , true) ;
581+ uint64_t bytes_copied = 0 ;
581582 uint32_t frames_copied = 0 ;
582583 struct list_item * clist ;
583584 uint32_t frame_bytes = 0 ;
584585
585586 if (!list_is_empty (& mod -> bsink_list )) {
586587 struct comp_buffer * buf = list_first_item (& mod -> bsink_list , struct comp_buffer , source_list );
587588 frame_bytes = audio_stream_frame_bytes (& buf -> stream );
589+
590+ void * current_wptr = audio_stream_get_wptr (& buf -> stream );
591+ void * last_wptr = p_state -> last_wptr [i ];
592+ uint32_t buffer_size = audio_stream_get_size (& buf -> stream );
593+
594+ if (last_wptr && current_wptr != last_wptr ) {
595+ uint32_t diff ;
596+ if (current_wptr >= last_wptr )
597+ diff = (char * )current_wptr - (char * )last_wptr ;
598+ else
599+ diff = buffer_size - ((char * )last_wptr - (char * )current_wptr );
600+
601+ p_state -> accumulated_bytes [i ] += diff ;
602+ }
603+ p_state -> last_wptr [i ] = current_wptr ;
604+ bytes_copied = p_state -> accumulated_bytes [i ];
588605 } else if (!list_is_empty (& mod -> bsource_list )) {
606+ /* If it's a gateway that only has a source but no sink, query its internal counter */
607+ bytes_copied = comp_get_total_data_processed (mod , 0 , false);
589608 struct comp_buffer * buf = list_first_item (& mod -> bsource_list , struct comp_buffer , sink_list );
590609 frame_bytes = audio_stream_frame_bytes (& buf -> stream );
591610 }
@@ -658,7 +677,8 @@ static int test_pipeline_build(struct test_pipeline_state *state,
658677 };
659678 };
660679
661- zassert_not_null (drv , "Driver for module %zu not found" , i );
680+ zassert_not_null (drv , "Driver for module %zu (comp_id 0x%x) not found" ,
681+ i , defs [i ].comp_id );
662682
663683 struct comp_ipc_config cfg = {
664684 .id = defs [i ].comp_id ,
@@ -1394,34 +1414,33 @@ static void multiple_pipelines_thread(void *p1, void *p2, void *p3)
13941414#endif
13951415
13961416#if defined(CONFIG_COMP_MFCC )
1397- struct sof_mfcc_config mfcc_cfg ;
1398- struct ipc4_base_module_cfg mfcc_base ;
1399- memcpy (& mfcc_base , & mfcc_cfg , sizeof (mfcc_base ));
1400- memset (& mfcc_cfg , 0 , sizeof (mfcc_cfg ));
1417+ struct sof_mfcc_config mfcc_init ;
1418+ memset (& mfcc_init , 0 , sizeof (mfcc_init ));
14011419
14021420 /* MFCC implicitly overlays the base configuration over its `size` + `reserved` fields */
1403- mfcc_base = base_cfg ;
1404- mfcc_base .cpc = sizeof (struct sof_mfcc_config ); /* cpc aliases to config->size */
1405-
1406- mfcc_cfg .sample_frequency = 48000 ;
1407- mfcc_cfg .channel = 0 ;
1408- mfcc_cfg .frame_length = 400 ;
1409- mfcc_cfg .frame_shift = 160 ;
1410- mfcc_cfg .num_mel_bins = 23 ;
1411- mfcc_cfg .num_ceps = 13 ;
1412- mfcc_cfg .dct = MFCC_DCT_II ;
1413- mfcc_cfg .window = MFCC_BLACKMAN_WINDOW ;
1414- mfcc_cfg .blackman_coef = MFCC_BLACKMAN_A0 ;
1415- mfcc_cfg .cepstral_lifter = 22 << 9 ;
1416- mfcc_cfg .round_to_power_of_two = true;
1417- mfcc_cfg .snip_edges = true;
1421+ memcpy (& mfcc_init , & base_cfg , sizeof (base_cfg ));
1422+ /* We set cpc (aliasing config->size) so MFCC parses the entire incoming configuration payload */
1423+ mfcc_init .size = sizeof (struct sof_mfcc_config );
1424+
1425+ mfcc_init .sample_frequency = 48000 ;
1426+ mfcc_init .channel = 0 ;
1427+ mfcc_init .frame_length = 400 ;
1428+ mfcc_init .frame_shift = 160 ;
1429+ mfcc_init .num_mel_bins = 23 ;
1430+ mfcc_init .num_ceps = 13 ;
1431+ mfcc_init .dct = MFCC_DCT_II ;
1432+ mfcc_init .window = MFCC_BLACKMAN_WINDOW ;
1433+ mfcc_init .blackman_coef = MFCC_BLACKMAN_A0 ;
1434+ mfcc_init .cepstral_lifter = 22 << 9 ;
1435+ mfcc_init .round_to_power_of_two = true;
1436+ mfcc_init .snip_edges = true;
14181437
14191438 struct test_module_def p3_defs [] = {
14201439 { .uuid = & COPIER_UUID , .comp_id = IPC4_COMP_ID (13 , 0 ), .pipeline_id = 12 ,
14211440 .init_data = & c_cfg , .init_data_size = sizeof (c_cfg ), .is_pipeline_source = true, .is_sched_comp = true,
14221441 .num_sinks = 1 , .sinks = { { .sink_comp_id = IPC4_COMP_ID (14 , 0 ) } } },
14231442 { .uuid = & MFCC_UUID , .comp_id = IPC4_COMP_ID (14 , 0 ), .pipeline_id = 12 ,
1424- .init_data = & mfcc_base , .init_data_size = sizeof (mfcc_base ),
1443+ .init_data = & mfcc_init , .init_data_size = sizeof (mfcc_init ),
14251444 .num_sinks = 1 , .sinks = { { .sink_comp_id = IPC4_COMP_ID (15 , 0 ) } } },
14261445 { .uuid = & COPIER_UUID , .comp_id = IPC4_COMP_ID (15 , 0 ), .pipeline_id = 12 ,
14271446 .init_data = & c_out_cfg , .init_data_size = sizeof (c_out_cfg ), .is_pipeline_sink = true }
@@ -1619,26 +1638,26 @@ static void all_modules_ll_pipeline_thread(void *p1, void *p2, void *p3)
16191638#endif
16201639
16211640#if defined(CONFIG_COMP_MFCC )
1622- struct sof_mfcc_config mfcc_cfg ;
1623- struct ipc4_base_module_cfg mfcc_base ;
1624- memcpy ( & mfcc_base , & mfcc_cfg , sizeof ( mfcc_base ));
1625- memset ( & mfcc_cfg , 0 , sizeof ( mfcc_cfg ));
1626-
1627- mfcc_base = base_cfg ;
1628- mfcc_base . cpc = sizeof (struct sof_mfcc_config );
1629-
1630- mfcc_cfg .sample_frequency = 48000 ;
1631- mfcc_cfg .channel = 0 ;
1632- mfcc_cfg .frame_length = 400 ;
1633- mfcc_cfg .frame_shift = 160 ;
1634- mfcc_cfg .num_mel_bins = 23 ;
1635- mfcc_cfg .num_ceps = 13 ;
1636- mfcc_cfg .dct = MFCC_DCT_II ;
1637- mfcc_cfg .window = MFCC_BLACKMAN_WINDOW ;
1638- mfcc_cfg .blackman_coef = MFCC_BLACKMAN_A0 ;
1639- mfcc_cfg .cepstral_lifter = 22 << 9 ;
1640- mfcc_cfg .round_to_power_of_two = true;
1641- mfcc_cfg .snip_edges = true;
1641+ struct sof_mfcc_config mfcc_init ;
1642+ memset ( & mfcc_init , 0 , sizeof ( mfcc_init )) ;
1643+
1644+ /* MFCC implicitly overlays the base configuration over its `size` + `reserved` fields */
1645+ memcpy ( & mfcc_init , & base_cfg , sizeof ( base_cfg ));
1646+ /* We set cpc (aliasing config->size) so MFCC parses the entire incoming configuration payload */
1647+ mfcc_init . size = sizeof (struct sof_mfcc_config );
1648+
1649+ mfcc_init .sample_frequency = 48000 ;
1650+ mfcc_init .channel = 0 ;
1651+ mfcc_init .frame_length = 400 ;
1652+ mfcc_init .frame_shift = 160 ;
1653+ mfcc_init .num_mel_bins = 23 ;
1654+ mfcc_init .num_ceps = 13 ;
1655+ mfcc_init .dct = MFCC_DCT_II ;
1656+ mfcc_init .window = MFCC_BLACKMAN_WINDOW ;
1657+ mfcc_init .blackman_coef = MFCC_BLACKMAN_A0 ;
1658+ mfcc_init .cepstral_lifter = 22 << 9 ;
1659+ mfcc_init .round_to_power_of_two = true;
1660+ mfcc_init .snip_edges = true;
16421661#endif
16431662
16441663 struct test_module_info modules_to_test [] = {
@@ -1655,7 +1674,7 @@ static void all_modules_ll_pipeline_thread(void *p1, void *p2, void *p3)
16551674 { & ARIA_UUID , & aria_cfg , sizeof (aria_cfg ), "ARIA" },
16561675#endif
16571676#if defined(CONFIG_COMP_MFCC )
1658- { & MFCC_UUID , & mfcc_cfg , sizeof (mfcc_cfg ), "MFCC" },
1677+ { & MFCC_UUID , & mfcc_init , sizeof (mfcc_init ), "MFCC" },
16591678#endif
16601679// Skip testing Volume standalone since test struct isn't fully defined yet
16611680 };
0 commit comments