diff --git a/src/audio/dcblock/Kconfig b/src/audio/dcblock/Kconfig index 7a4113153b51..1b38cdf7ff54 100644 --- a/src/audio/dcblock/Kconfig +++ b/src/audio/dcblock/Kconfig @@ -6,3 +6,22 @@ config COMP_DCBLOCK help Select for DC Blocking Filter component. This component filters out the DC offset which often originates from a microphone's output. + +choice + prompt "DC Blocking Filter HIFI level" + depends on COMP_DCBLOCK + default DCBLOCK_HIFI_MAX + +config DCBLOCK_HIFI_MAX + bool "Max level available in the toolchain" + +config DCBLOCK_HIFI_4 + bool "HIFI4 DCBLOCK" + +config DCBLOCK_HIFI_3 + bool "HIFI3 DCBLOCK" + +config DCBLOCK_HIFI_NONE + bool "Generic DCBLOCK, no HIFI" + +endchoice diff --git a/src/audio/dcblock/dcblock.h b/src/audio/dcblock/dcblock.h index bc2bec3f339a..eaf09da22bf2 100644 --- a/src/audio/dcblock/dcblock.h +++ b/src/audio/dcblock/dcblock.h @@ -15,20 +15,6 @@ #include #include -/* __XCC__ is both for xt_xcc and xt_clang */ -#if defined(__XCC__) -# include -# if XCHAL_HAVE_HIFI4 -# define DCBLOCK_HIFI4 -# elif XCHAL_HAVE_HIFI3 -# define DCBLOCK_HIFI3 -# else -# define DCBLOCK_GENERIC -# endif -#else -# define DCBLOCK_GENERIC -#endif - struct audio_stream; struct comp_dev; diff --git a/src/audio/dcblock/dcblock_generic.c b/src/audio/dcblock/dcblock_generic.c index 2ca1d0a70f10..4ff5fa11315b 100644 --- a/src/audio/dcblock/dcblock_generic.c +++ b/src/audio/dcblock/dcblock_generic.c @@ -10,7 +10,7 @@ #include "dcblock.h" -#ifdef DCBLOCK_GENERIC +#if SOF_USE_HIFI(NONE, DCBLOCK) LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL); diff --git a/src/audio/dcblock/dcblock_hifi3.c b/src/audio/dcblock/dcblock_hifi3.c index f731bdbdbb18..d49a1ccca986 100644 --- a/src/audio/dcblock/dcblock_hifi3.c +++ b/src/audio/dcblock/dcblock_hifi3.c @@ -10,7 +10,7 @@ #include "dcblock.h" -#ifdef DCBLOCK_HIFI3 +#if SOF_USE_HIFI(3, DCBLOCK) #include LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL); diff --git a/src/audio/dcblock/dcblock_hifi4.c b/src/audio/dcblock/dcblock_hifi4.c index dc8090efa7b8..44afa6834c91 100644 --- a/src/audio/dcblock/dcblock_hifi4.c +++ b/src/audio/dcblock/dcblock_hifi4.c @@ -10,7 +10,7 @@ #include "dcblock.h" -#ifdef DCBLOCK_HIFI4 +#if SOF_USE_HIFI(4, DCBLOCK) #include LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL); diff --git a/src/include/sof/common.h b/src/include/sof/common.h index a2ccf29a49f4..349b806e08a8 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -177,6 +177,33 @@ #define IS_ENABLED_STEP_3(ignore, value, ...) (!!(value)) #endif +#define SOF_CONFIG_HIFI(level, component) (CONFIG_ ## component ## _HIFI_ ## level) + +/* True if: + * (1) EITHER this particular level was manually forced in Kconfig, + * (2) OR: - this component defaulted to "MAX" + * - AND this level is the max available in the XC HAL. + */ +#define SOF_USE_HIFI(level, component) (SOF_CONFIG_HIFI(level, component) || \ + (SOF_CONFIG_HIFI(MAX, component) && level == SOF_MAX_XCHAL_HIFI)) + +#ifndef __XCC__ // Cadence toolchains: either xt-xcc or xt-clang. +# define SOF_MAX_XCHAL_HIFI NONE +#else +# include +// Maybe we could make this fully generic (and less readable!) using +// IS_ENABLED() above. +# if XCHAL_HAVE_HIFI5 +# define SOF_MAX_XCHAL_HIFI 5 +# elif XCHAL_HAVE_HIFI4 +# define SOF_MAX_XCHAL_HIFI 4 +# elif XCHAL_HAVE_HIFI3 +# define SOF_MAX_XCHAL_HIFI 3 +# else +# define SOF_MAX_XCHAL_HIFI NONE +# endif +#endif + #ifndef __GLIBC_USE #define __GLIBC_USE(x) 0 #endif