1111#include <rtos/string.h>
1212#include <sof/trace/trace.h>
1313#include <sof/audio/format.h>
14+ #include <sof/lib/fast-get.h>
15+ #include <sof/lib/memory.h>
1416#include <user/trace.h>
1517#include "asrc_farrow.h"
1618
@@ -506,6 +508,31 @@ enum asrc_error_code asrc_set_output_format(struct comp_dev *dev,
506508 return ASRC_EC_OK ;
507509}
508510
511+ static const int32_t * __get_polyphase_filter (const int32_t * filter , size_t size )
512+ {
513+ #if CONFIG_FAST_GET
514+ return fast_get (filter , size );
515+ #else
516+ return filter ;
517+ #endif
518+ }
519+
520+ #define get_polyphase_filter (f ) __get_polyphase_filter(f, sizeof(f))
521+
522+ static void put_polyphase_filter (const int32_t * filter )
523+ {
524+ #if CONFIG_FAST_GET
525+ fast_put (filter );
526+ #endif
527+ }
528+
529+ void asrc_free_polyphase_filter (struct asrc_farrow * src_obj )
530+ {
531+ if (src_obj && src_obj -> polyphase_filters ) {
532+ put_polyphase_filter (src_obj -> polyphase_filters );
533+ src_obj -> polyphase_filters = NULL ;
534+ }
535+ }
509536
510537/*
511538 * FILTER FUNCTIONS
@@ -533,7 +560,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
533560 /* Reset coefficients for possible exit with error. */
534561 src_obj -> filter_length = 0 ;
535562 src_obj -> num_filters = 0 ;
536- src_obj -> polyphase_filters = NULL ;
563+ asrc_free_polyphase_filter ( src_obj ) ;
537564
538565 if (fs_in == 0 || fs_out == 0 ) {
539566 /* Avoid possible divisions by zero. */
@@ -549,7 +576,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
549576 c_filter_params [CR_48000TO48000 ].filter_length ;
550577 src_obj -> num_filters =
551578 c_filter_params [CR_48000TO48000 ].num_filters ;
552- src_obj -> polyphase_filters = & coeff48000to48000 [ 0 ] ;
579+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to48000 ) ;
553580 } else if (fs_in <= fs_out ) {
554581 /* All upsampling use cases can share the same set of
555582 * filter coefficients.
@@ -558,7 +585,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
558585 c_filter_params [CR_44100TO48000 ].filter_length ;
559586 src_obj -> num_filters =
560587 c_filter_params [CR_44100TO48000 ].num_filters ;
561- src_obj -> polyphase_filters = & coeff44100to48000 [ 0 ] ;
588+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff44100to48000 ) ;
562589 } else if (fs_in == 48000 ) {
563590 switch (fs_out ) {
564591#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_08000 )
@@ -567,7 +594,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
567594 c_filter_params [CR_48000TO08000 ].filter_length ;
568595 src_obj -> num_filters =
569596 c_filter_params [CR_48000TO08000 ].num_filters ;
570- src_obj -> polyphase_filters = & coeff48000to08000 [ 0 ] ;
597+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to08000 ) ;
571598 break ;
572599#endif
573600#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_11025 )
@@ -576,7 +603,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
576603 c_filter_params [CR_48000TO11025 ].filter_length ;
577604 src_obj -> num_filters =
578605 c_filter_params [CR_48000TO11025 ].num_filters ;
579- src_obj -> polyphase_filters = & coeff48000to11025 [ 0 ] ;
606+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to11025 ) ;
580607 break ;
581608#endif
582609#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_12000 )
@@ -585,7 +612,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
585612 c_filter_params [CR_48000TO12000 ].filter_length ;
586613 src_obj -> num_filters =
587614 c_filter_params [CR_48000TO12000 ].num_filters ;
588- src_obj -> polyphase_filters = & coeff48000to12000 [ 0 ] ;
615+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to12000 ) ;
589616 break ;
590617#endif
591618#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_16000 )
@@ -594,7 +621,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
594621 c_filter_params [CR_48000TO16000 ].filter_length ;
595622 src_obj -> num_filters =
596623 c_filter_params [CR_48000TO16000 ].num_filters ;
597- src_obj -> polyphase_filters = & coeff48000to16000 [ 0 ] ;
624+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to16000 ) ;
598625 break ;
599626#endif
600627#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_22050 )
@@ -603,7 +630,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
603630 c_filter_params [CR_48000TO22050 ].filter_length ;
604631 src_obj -> num_filters =
605632 c_filter_params [CR_48000TO22050 ].num_filters ;
606- src_obj -> polyphase_filters = & coeff48000to22050 [ 0 ] ;
633+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to22050 ) ;
607634 break ;
608635#endif
609636#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_24000 )
@@ -612,7 +639,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
612639 c_filter_params [CR_48000TO24000 ].filter_length ;
613640 src_obj -> num_filters =
614641 c_filter_params [CR_48000TO24000 ].num_filters ;
615- src_obj -> polyphase_filters = & coeff48000to24000 [ 0 ] ;
642+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to24000 ) ;
616643 break ;
617644#endif
618645#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_32000 )
@@ -621,7 +648,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
621648 c_filter_params [CR_48000TO32000 ].filter_length ;
622649 src_obj -> num_filters =
623650 c_filter_params [CR_48000TO32000 ].num_filters ;
624- src_obj -> polyphase_filters = & coeff48000to32000 [ 0 ] ;
651+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to32000 ) ;
625652 break ;
626653#endif
627654#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_44100 )
@@ -630,7 +657,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
630657 c_filter_params [CR_48000TO44100 ].filter_length ;
631658 src_obj -> num_filters =
632659 c_filter_params [CR_48000TO44100 ].num_filters ;
633- src_obj -> polyphase_filters = & coeff48000to44100 [ 0 ] ;
660+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff48000to44100 ) ;
634661 break ;
635662#endif
636663 default :
@@ -646,7 +673,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
646673 c_filter_params [CR_24000TO08000 ].filter_length ;
647674 src_obj -> num_filters =
648675 c_filter_params [CR_24000TO08000 ].num_filters ;
649- src_obj -> polyphase_filters = & coeff24000to08000 [ 0 ] ;
676+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff24000to08000 ) ;
650677 break ;
651678#endif
652679#if (CONFIG_ASRC_SUPPORT_CONVERSION_24000_TO_16000 )
@@ -655,7 +682,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev,
655682 c_filter_params [CR_24000TO16000 ].filter_length ;
656683 src_obj -> num_filters =
657684 c_filter_params [CR_24000TO16000 ].num_filters ;
658- src_obj -> polyphase_filters = & coeff24000to16000 [ 0 ] ;
685+ src_obj -> polyphase_filters = get_polyphase_filter ( coeff24000to16000 ) ;
659686 break ;
660687#endif
661688 default :
0 commit comments