From 95d6499ad6b43d95a4ef6aef09b9d6d1671568d6 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 7 Apr 2022 15:27:01 +0200 Subject: [PATCH] pcm_converter: add __sparse_cache annotations PCM converter functions operate on locked and cached buffers, add __sparse_cache annotations to them. Signed-off-by: Guennadi Liakhovetski --- src/audio/pcm_converter/pcm_converter.c | 5 +- .../pcm_converter/pcm_converter_generic.c | 89 ++++++++++--------- src/audio/pcm_converter/pcm_converter_hifi3.c | 49 +++++----- src/include/sof/audio/pcm_converter.h | 4 +- 4 files changed, 75 insertions(+), 72 deletions(-) diff --git a/src/audio/pcm_converter/pcm_converter.c b/src/audio/pcm_converter/pcm_converter.c index 469f69cfa..8e7246b8b 100644 --- a/src/audio/pcm_converter/pcm_converter.c +++ b/src/audio/pcm_converter/pcm_converter.c @@ -10,12 +10,13 @@ * \authors Karol Trzcinski */ +#include #include #include #include -int pcm_convert_as_linear(const struct audio_stream *source, uint32_t ioffset, - struct audio_stream *sink, uint32_t ooffset, +int pcm_convert_as_linear(const struct audio_stream __sparse_cache *source, uint32_t ioffset, + struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples, pcm_converter_lin_func converter) { const int s_size_in = audio_stream_sample_bytes(source); diff --git a/src/audio/pcm_converter/pcm_converter_generic.c b/src/audio/pcm_converter/pcm_converter_generic.c index c6e86c56d..1b9e61eb5 100644 --- a/src/audio/pcm_converter/pcm_converter_generic.c +++ b/src/audio/pcm_converter/pcm_converter_generic.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -30,8 +31,8 @@ #if CONFIG_PCM_CONVERTER_FORMAT_S16LE && CONFIG_PCM_CONVERTER_FORMAT_S24LE -static int pcm_convert_s16_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int16_t *src = source->r_ptr; @@ -59,8 +60,8 @@ static int pcm_convert_s16_to_s24(const struct audio_stream *source, return samples; } -static int pcm_convert_s24_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -92,8 +93,8 @@ static int pcm_convert_s24_to_s16(const struct audio_stream *source, #if CONFIG_PCM_CONVERTER_FORMAT_S16LE && CONFIG_PCM_CONVERTER_FORMAT_S32LE -static int pcm_convert_s16_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int16_t *src = source->r_ptr; @@ -121,8 +122,8 @@ static int pcm_convert_s16_to_s32(const struct audio_stream *source, return samples; } -static int pcm_convert_s32_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -154,8 +155,8 @@ static int pcm_convert_s32_to_s16(const struct audio_stream *source, #if CONFIG_PCM_CONVERTER_FORMAT_S24LE && CONFIG_PCM_CONVERTER_FORMAT_S32LE -static int pcm_convert_s24_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -183,8 +184,8 @@ static int pcm_convert_s24_to_s32(const struct audio_stream *source, return samples; } -static int pcm_convert_s32_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -212,8 +213,8 @@ static int pcm_convert_s32_to_s24(const struct audio_stream *source, return samples; } -static int pcm_convert_s32_to_s24_be(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_s24_be(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -377,16 +378,16 @@ static void pcm_convert_f_to_s16_lin(const void *psrc, void *pdst, dst[i] = sat_int16(_pcm_convert_f_to_i(src[i], 15)); } -static int pcm_convert_s16_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, pcm_convert_s16_to_f_lin); } -static int pcm_convert_f_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -421,16 +422,16 @@ static void pcm_convert_f_to_s24_lin(const void *psrc, void *pdst, dst[i] = sat_int24(_pcm_convert_f_to_i(src[i], 23)); } -static int pcm_convert_s24_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, pcm_convert_s24_to_f_lin); } -static int pcm_convert_f_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -465,16 +466,16 @@ static void pcm_convert_f_to_s32_lin(const void *psrc, void *pdst, dst[i] = _pcm_convert_f_to_i(src[i], 31); } -static int pcm_convert_s32_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, pcm_convert_s32_to_f_lin); } -static int pcm_convert_f_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -527,8 +528,8 @@ const struct pcm_func_map pcm_func_map[] = { const size_t pcm_func_count = ARRAY_SIZE(pcm_func_map); #if CONFIG_PCM_CONVERTER_FORMAT_S16_C16_AND_S16_C32 -static int pcm_convert_s16_c16_to_s16_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_c16_to_s16_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int16_t *src = source->r_ptr; @@ -556,8 +557,8 @@ static int pcm_convert_s16_c16_to_s16_c32(const struct audio_stream *source, return samples; } -static int pcm_convert_s16_c32_to_s16_c16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_c32_to_s16_c16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -586,8 +587,8 @@ static int pcm_convert_s16_c32_to_s16_c16(const struct audio_stream *source, } #endif #if CONFIG_PCM_CONVERTER_FORMAT_S16_C32_AND_S32_C32 -static int pcm_convert_s16_c32_to_s32_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_c32_to_s32_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -615,8 +616,8 @@ static int pcm_convert_s16_c32_to_s32_c32(const struct audio_stream *source, return samples; } -static int pcm_convert_s32_c32_to_s16_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_c32_to_s16_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -645,8 +646,8 @@ static int pcm_convert_s32_c32_to_s16_c32(const struct audio_stream *source, } #endif #if CONFIG_PCM_CONVERTER_FORMAT_S16_C32_AND_S24_C32 -static int pcm_convert_s16_c32_to_s24_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_c32_to_s24_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -674,8 +675,8 @@ static int pcm_convert_s16_c32_to_s24_c32(const struct audio_stream *source, return samples; } -static int pcm_convert_s24_c32_to_s16_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_c32_to_s16_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -705,8 +706,8 @@ static int pcm_convert_s24_c32_to_s16_c32(const struct audio_stream *source, #endif #if CONFIG_PCM_CONVERTER_FORMAT_S24_C24_AND_S24_C32 -static int pcm_convert_s24_c24_to_s24_c32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_c24_to_s24_c32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { uint8_t *src = source->r_ptr; @@ -735,8 +736,8 @@ static int pcm_convert_s24_c24_to_s24_c32(const struct audio_stream *source, return samples; } -static int pcm_convert_s24_c32_to_s24_c24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_c32_to_s24_c24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; @@ -769,8 +770,8 @@ static int pcm_convert_s24_c32_to_s24_c24(const struct audio_stream *source, } /* 2x24bit samples are packed into 3x16bit samples for hda link dma */ -static int pcm_convert_s24_c32_to_s24_c24_link_gtw(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_c32_to_s24_c24_link_gtw(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { int32_t *src = source->r_ptr; diff --git a/src/audio/pcm_converter/pcm_converter_hifi3.c b/src/audio/pcm_converter/pcm_converter_hifi3.c index c4cf3f668..c45e8a2e7 100644 --- a/src/audio/pcm_converter/pcm_converter_hifi3.c +++ b/src/audio/pcm_converter/pcm_converter_hifi3.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -45,8 +46,8 @@ static void pcm_converter_setup_circular(const struct audio_stream *source) * \param[in,out] sink Destination buffer. * \param[in] samples Number of samples to process. */ -static int pcm_convert_s16_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int16 *in = audio_stream_read_frag(source, ioffset, sizeof(int16_t)); @@ -150,8 +151,8 @@ static ae_int32x2 pcm_shift_s24_to_s16(ae_int32x2 sample) * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s24_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int32x2 *in = audio_stream_read_frag(source, ioffset, @@ -262,8 +263,8 @@ static int pcm_convert_s24_to_s16(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s16_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int16 *in = audio_stream_read_frag(source, ioffset, @@ -349,8 +350,8 @@ static int pcm_convert_s16_to_s32(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s32_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int32x2 *in = audio_stream_read_frag(source, ioffset, @@ -457,8 +458,8 @@ static int pcm_convert_s32_to_s16(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s24_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int32x2 *in = audio_stream_read_frag(source, ioffset, @@ -550,8 +551,8 @@ static ae_int32x2 pcm_shift_s32_to_s24(ae_int32x2 sample) * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s32_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { ae_int32x2 *in = audio_stream_read_frag(source, ioffset, @@ -704,8 +705,8 @@ static void pcm_convert_f_to_s16_lin(const void *psrc, void *pdst, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s16_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s16_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -719,8 +720,8 @@ static int pcm_convert_s16_to_f(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_f_to_s16(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s16(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -805,8 +806,8 @@ static void pcm_convert_f_to_s24_lin(const void *psrc, void *pdst, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s24_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s24_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -820,8 +821,8 @@ static int pcm_convert_s24_to_f(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_f_to_s24(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s24(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -902,8 +903,8 @@ static void pcm_convert_f_to_s32_lin(const void *psrc, void *pdst, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_s32_to_f(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_s32_to_f(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, @@ -917,8 +918,8 @@ static int pcm_convert_s32_to_f(const struct audio_stream *source, * \param[in] samples Number of samples to process. * \return error code or number of processed samples. */ -static int pcm_convert_f_to_s32(const struct audio_stream *source, - uint32_t ioffset, struct audio_stream *sink, +static int pcm_convert_f_to_s32(const struct audio_stream __sparse_cache *source, + uint32_t ioffset, struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples) { return pcm_convert_as_linear(source, ioffset, sink, ooffset, samples, diff --git a/src/include/sof/audio/pcm_converter.h b/src/include/sof/audio/pcm_converter.h index 6c3635cf5..706e44574 100644 --- a/src/include/sof/audio/pcm_converter.h +++ b/src/include/sof/audio/pcm_converter.h @@ -167,8 +167,8 @@ pcm_get_conversion_vc_function(enum sof_ipc_frame in_bits, * \param converter core conversion function working on linear memory regions * \return error code or number of processed samples */ -int pcm_convert_as_linear(const struct audio_stream *source, uint32_t ioffset, - struct audio_stream *sink, uint32_t ooffset, +int pcm_convert_as_linear(const struct audio_stream __sparse_cache *source, uint32_t ioffset, + struct audio_stream __sparse_cache *sink, uint32_t ooffset, uint32_t samples, pcm_converter_lin_func converter); #endif /* __SOF_AUDIO_PCM_CONVERTER_H__ */