From 256548ad43588b3595c64cb7552e5fa838c1b8f5 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Tue, 29 Sep 2026 20:24:31 +0200 Subject: [PATCH] audio: volume: use unsigned int for channel count and iterators Convert the local channel-count variables and the loops iterating over channels to unsigned int to match channels type in vol_data structure. Signed-off-by: Adrian Warecki --- src/audio/volume/volume_generic.c | 21 +++-- .../volume/volume_generic_with_peakvol.c | 30 ++++--- src/audio/volume/volume_hifi3.c | 16 ++-- src/audio/volume/volume_hifi3_with_peakvol.c | 30 ++++--- src/audio/volume/volume_hifi4.c | 14 ++-- src/audio/volume/volume_hifi4_with_peakvol.c | 66 ++++++++------- src/audio/volume/volume_hifi5.c | 14 ++-- src/audio/volume/volume_hifi5_with_peakvol.c | 82 ++++++++++--------- 8 files changed, 150 insertions(+), 123 deletions(-) diff --git a/src/audio/volume/volume_generic.c b/src/audio/volume/volume_generic.c index 4851409f019f..38379700adb9 100644 --- a/src/audio/volume/volume_generic.c +++ b/src/audio/volume/volume_generic.c @@ -63,8 +63,9 @@ static void vol_s24_to_s24(struct processing_module *mod, struct cir_buf_source const int32_t *x, *x0; int32_t *y, *y0; int32_t vol; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -108,7 +109,7 @@ static void vol_passthrough_s24_to_s24(struct processing_module *mod, const int32_t *x; int32_t *y; int nmax, n; - const int nch = cd->channels; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -145,8 +146,9 @@ static void vol_s32_to_s32(struct processing_module *mod, struct cir_buf_source const int32_t *x, *x0; int32_t *y, *y0; int32_t vol; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -194,7 +196,7 @@ static void vol_passthrough_s32_to_s32(struct processing_module *mod, const int32_t *x; int32_t *y; int nmax, n; - const int nch = cd->channels; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -231,8 +233,9 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source const int16_t *x, *x0; int16_t *y, *y0; int32_t vol; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -277,7 +280,7 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, const int16_t *x; int16_t *y; int nmax, n; - const int nch = cd->channels; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; diff --git a/src/audio/volume/volume_generic_with_peakvol.c b/src/audio/volume/volume_generic_with_peakvol.c index 4db4b53e9071..f162d4f48e7a 100644 --- a/src/audio/volume/volume_generic_with_peakvol.c +++ b/src/audio/volume/volume_generic_with_peakvol.c @@ -60,8 +60,9 @@ static void vol_s24_to_s24(struct processing_module *mod, struct cir_buf_source int32_t *y, *y0; int32_t vol; int32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -109,8 +110,9 @@ static void vol_passthrough_s24_to_s24(struct processing_module *mod, const int32_t *x, *x0; int32_t *y, *y0; int32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -158,8 +160,9 @@ static void vol_s32_to_s32(struct processing_module *mod, struct cir_buf_source int32_t *y, *y0; int32_t vol; int32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -211,8 +214,9 @@ static void vol_passthrough_s32_to_s32(struct processing_module *mod, const int32_t *x, *x0; int32_t *y, *y0; int32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -263,8 +267,9 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source int16_t *y, *y0; int32_t vol; uint32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; @@ -313,8 +318,9 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, const int16_t *x, *x0; int16_t *y, *y0; uint32_t tmp; - int nmax, n, i, j; - const int nch = cd->channels; + int nmax, n, i; + unsigned int j; + const unsigned int nch = cd->channels; int remaining_samples = frames * nch; x = source->ptr; diff --git a/src/audio/volume/volume_hifi3.c b/src/audio/volume/volume_hifi3.c index 52de382ea671..c3cfca5773bb 100644 --- a/src/audio/volume/volume_hifi3.c +++ b/src/audio/volume/volume_hifi3.c @@ -33,9 +33,9 @@ LOG_MODULE_DECLARE(volume_hifi3, CONFIG_SOF_LOG_LEVEL); * \param[in,out] cd Volume component private data. * \param[in] channels_count Number of channels to process. */ -static void vol_store_gain(struct vol_data *cd, const int channels_count) +static void vol_store_gain(struct vol_data *cd, const unsigned int channels_count) { - int32_t i; + unsigned int i; /* using for loop instead of memcpy_s(), because for loop costs less cycles */ for (i = 0; i < channels_count; i++) { @@ -72,7 +72,7 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_valign outu = AE_ZALIGN64(); const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; @@ -148,7 +148,7 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, ae_valign outu = AE_ZALIGN64(); const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; while (samples) { @@ -195,7 +195,7 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 *vol; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; @@ -269,7 +269,7 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, int i, n, m; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; @@ -322,7 +322,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; @@ -409,7 +409,7 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; while (samples) { diff --git a/src/audio/volume/volume_hifi3_with_peakvol.c b/src/audio/volume/volume_hifi3_with_peakvol.c index bb38fc9bf7ef..5aec1108bb62 100644 --- a/src/audio/volume/volume_hifi3_with_peakvol.c +++ b/src/audio/volume/volume_hifi3_with_peakvol.c @@ -44,11 +44,12 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 in_sample; ae_f32x2 out_sample; ae_f32x2 volume; - int channel, n, i, m; + unsigned int channel; + int n, i, m; ae_f32 *in0 = (void *)source->ptr; ae_f32 *out0 = sink->ptr; ae_f32 *in, *out; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32) * channels_count; int samples = channels_count * frames; ae_f32x2 peak_vol; @@ -114,11 +115,12 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, { struct vol_data *cd = module_get_private_data(mod); ae_f32x2 in_sample; - int channel, n, i, m; + unsigned int channel; + int n, i, m; ae_f32 *in0 = (void *)source->ptr; ae_f32 *out0 = sink->ptr; ae_f32 *in, *out; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32) * channels_count; int samples = channels_count * frames; ae_f32x2 peak_vol; @@ -170,8 +172,9 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 in_sample; ae_f32x2 out_sample; ae_f32x2 volume; - int i, n, channel, m; - const int channels_count = cd->channels; + int i, n, m; + unsigned int channel; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32) * channels_count; int samples = channels_count * frames; ae_f32 *in0 = (void *)source->ptr; @@ -238,8 +241,9 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, { struct vol_data *cd = module_get_private_data(mod); ae_f32x2 in_sample; - int i, n, channel, m; - const int channels_count = cd->channels; + int i, n, m; + unsigned int channel; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32) * channels_count; int samples = channels_count * frames; ae_f32 *in0 = (void *)source->ptr; @@ -295,12 +299,13 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_f32x2 out_sample0; ae_f16x4 in_sample; ae_f16x4 out_sample; - int i, n, channel, m; + int i, n, m; + unsigned int channel; ae_f16 *in; ae_f16 *out; ae_f16 *in0 = (void *)source->ptr; ae_f16 *out0 = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f16) * channels_count; int samples = channels_count * frames; ae_f32x2 peak_vol; @@ -370,12 +375,13 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, { struct vol_data *cd = module_get_private_data(mod); ae_f16x4 in_sample; - int i, n, channel, m; + int i, n, m; + unsigned int channel; ae_f16 *in; ae_f16 *out; ae_f16 *in0 = (void *)source->ptr; ae_f16 *out0 = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f16) * channels_count; int samples = channels_count * frames; ae_f32x2 peak_vol; diff --git a/src/audio/volume/volume_hifi4.c b/src/audio/volume/volume_hifi4.c index 0b6fbeff8af2..d6959d224dd3 100644 --- a/src/audio/volume/volume_hifi4.c +++ b/src/audio/volume/volume_hifi4.c @@ -33,9 +33,9 @@ LOG_MODULE_DECLARE(volume_hifi4, CONFIG_SOF_LOG_LEVEL); * \param[in,out] cd Volume component private data. * \param[in] channels_count Number of channels to process. */ -static void vol_store_gain(struct vol_data *cd, const int channels_count) +static void vol_store_gain(struct vol_data *cd, const unsigned int channels_count) { - int32_t i; + unsigned int i; /* using for loop instead of memcpy_s(), because for loop costs less cycles */ for (i = 0; i < channels_count; i++) { @@ -72,7 +72,7 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_valign outu = AE_ZALIGN64(); const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; @@ -195,7 +195,7 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 *vol; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; @@ -271,7 +271,7 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, int i, n, m; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; @@ -324,7 +324,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; @@ -438,7 +438,7 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; while (samples) { diff --git a/src/audio/volume/volume_hifi4_with_peakvol.c b/src/audio/volume/volume_hifi4_with_peakvol.c index ece81edb83cf..9fa61ba8d40b 100644 --- a/src/audio/volume/volume_hifi4_with_peakvol.c +++ b/src/audio/volume/volume_hifi4_with_peakvol.c @@ -26,9 +26,9 @@ LOG_MODULE_DECLARE(volume_hifi4, CONFIG_SOF_LOG_LEVEL); #if CONFIG_COMP_PEAK_VOL #include -static inline void vol_store_gain(struct vol_data *cd, const int channels_count) +static inline void vol_store_gain(struct vol_data *cd, const unsigned int channels_count) { - int32_t i; + unsigned int i; /* using for loop instead of memcpy_s(), because for loop costs less cycles */ for (i = 0; i < channels_count; i++) { @@ -58,12 +58,13 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 out_sample; ae_f32x2 volume; int i, n, m; + unsigned int j; ae_f32x2 *vol; ae_valign inu; ae_valign outu = AE_ZALIGN64(); const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; ae_f32x2 temp; @@ -124,9 +125,9 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) - cd->peak_regs.peak_meter[i] = MAX(cd->peak_vol[i], - cd->peak_vol[i + channels_count]) + for (j = 0; j < channels_count; j++) + cd->peak_regs.peak_meter[j] = MAX(cd->peak_vol[j], + cd->peak_vol[j + channels_count]) << (attenuation + PEAK_24S_32C_ADJUST); } @@ -147,11 +148,12 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, ae_f32x2 in_sample; int i, n, m; + unsigned int j; ae_valign inu; ae_valign outu = AE_ZALIGN64(); const ae_f32x2 *in = source->ptr; ae_f32x2 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; ae_f32x2 temp; @@ -183,9 +185,9 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) - cd->peak_regs.peak_meter[i] = MAX(cd->peak_vol[i], - cd->peak_vol[i + channels_count]) + for (j = 0; j < channels_count; j++) + cd->peak_regs.peak_meter[j] = MAX(cd->peak_vol[j], + cd->peak_vol[j + channels_count]) << (attenuation + PEAK_24S_32C_ADJUST); } #endif /* CONFIG_FORMAT_S24LE */ @@ -208,12 +210,13 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_f32x2 out_sample; ae_f32x2 volume; int i, n, m; + unsigned int j; ae_f32x2 *buf; ae_f32x2 *buf_end; ae_f32x2 *vol; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; @@ -279,9 +282,9 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) - cd->peak_regs.peak_meter[i] = MAX(cd->peak_vol[i], - cd->peak_vol[i + channels_count]) << attenuation; + for (j = 0; j < channels_count; j++) + cd->peak_regs.peak_meter[j] = MAX(cd->peak_vol[j], + cd->peak_vol[j + channels_count]) << attenuation; } /** @@ -300,9 +303,10 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, struct vol_data *cd = module_get_private_data(mod); ae_f32x2 in_sample; int i, n, m; + unsigned int j; ae_valign inu; ae_valign outu = AE_ZALIGN64(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; const ae_f32x2 *in = source->ptr; @@ -335,9 +339,9 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) - cd->peak_regs.peak_meter[i] = MAX(cd->peak_vol[i], - cd->peak_vol[i + channels_count]) << attenuation; + for (j = 0; j < channels_count; j++) + cd->peak_regs.peak_meter[j] = MAX(cd->peak_vol[j], + cd->peak_vol[j + channels_count]) << attenuation; } #endif /* CONFIG_FORMAT_S32LE */ @@ -362,6 +366,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_f16x4 in_sample; ae_f16x4 out_sample; int i, n, m, left; + unsigned int j; ae_f32x2 *buf; ae_f32x2 *buf_end; ae_f32x2 *vol; @@ -369,7 +374,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; ae_f32x2 temp; @@ -480,11 +485,11 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << PEAK_16S_32C_ADJUST; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << PEAK_16S_32C_ADJUST; } } @@ -504,11 +509,12 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, struct vol_data *cd = module_get_private_data(mod); ae_f16x4 in_sample; int i, n, m, left; + unsigned int j; ae_valign inu; ae_valign outu = AE_ZALIGN64(); const ae_f16x4 *in = source->ptr; ae_f16x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_f32x2); int samples = channels_count * frames; ae_f32x2 temp; @@ -560,11 +566,11 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << PEAK_16S_32C_ADJUST; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << PEAK_16S_32C_ADJUST; } } #endif /* CONFIG_FORMAT_S16LE */ diff --git a/src/audio/volume/volume_hifi5.c b/src/audio/volume/volume_hifi5.c index eaa1cdcc5abc..a3a4b0fe06c6 100644 --- a/src/audio/volume/volume_hifi5.c +++ b/src/audio/volume/volume_hifi5.c @@ -33,9 +33,9 @@ LOG_MODULE_DECLARE(volume, CONFIG_SOF_LOG_LEVEL); * \param[in,out] cd Volume component private data. * \param[in] channels_count Number of channels to process. */ -static void vol_store_gain(struct vol_data *cd, const int channels_count) +static void vol_store_gain(struct vol_data *cd, const unsigned int channels_count) { - int32_t i; + unsigned int i; for (i = 0; i < channels_count; i++) { cd->vol[i] = cd->volume[i]; @@ -71,7 +71,7 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_valignx2 outu = AE_ZALIGN128(); const ae_int32x4 *in = source->ptr; ae_int32x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; @@ -201,7 +201,7 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_int32x4 *vol; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; const ae_int32x4 *in = source->ptr; @@ -282,7 +282,7 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, int i, n, m; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; const ae_int32x4 *in = source->ptr; ae_int32x4 *out = sink->ptr; @@ -333,7 +333,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_valignx2 outu = AE_ZALIGN128(); const ae_int16x8 *in = source->ptr; ae_int16x8 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; @@ -426,7 +426,7 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, ae_valignx2 outu = AE_ZALIGN128(); const ae_int16x8 *in = source->ptr; ae_int16x8 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; int samples = channels_count * frames; while (samples) { diff --git a/src/audio/volume/volume_hifi5_with_peakvol.c b/src/audio/volume/volume_hifi5_with_peakvol.c index d2315a928be9..c11c04a39705 100644 --- a/src/audio/volume/volume_hifi5_with_peakvol.c +++ b/src/audio/volume/volume_hifi5_with_peakvol.c @@ -33,9 +33,9 @@ LOG_MODULE_DECLARE(volume, CONFIG_SOF_LOG_LEVEL); #if CONFIG_COMP_PEAK_VOL #include -static inline void vol_store_gain(struct vol_data *cd, const int channels_count) +static inline void vol_store_gain(struct vol_data *cd, const unsigned int channels_count) { - int32_t i; + unsigned int i; for (i = 0; i < channels_count; i++) { cd->vol[i] = cd->volume[i]; @@ -63,12 +63,13 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_int32x2 out_sample, out_sample1; ae_int32x2 volume, volume1; int i, n, m; + unsigned int j; ae_int32x4 *vol; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); const ae_int32x4 *in = source->ptr; ae_int32x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; ae_int32x2 temp, temp1; @@ -139,11 +140,11 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct cir_buf_sou out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << (attenuation + PEAK_24S_32C_ADJUST); + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << (attenuation + PEAK_24S_32C_ADJUST); } } @@ -163,11 +164,12 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, struct vol_data *cd = module_get_private_data(mod); ae_int32x2 in_sample, in_sample1; int i, n, m; + unsigned int j; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); const ae_int32x4 *in = source->ptr; ae_int32x4 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; ae_int32x2 temp, temp1; @@ -200,11 +202,11 @@ static void vol_passthrough_s24_to_s24_s32(struct processing_module *mod, in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << (attenuation + PEAK_24S_32C_ADJUST); + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << (attenuation + PEAK_24S_32C_ADJUST); } } #endif /* CONFIG_FORMAT_S24LE */ @@ -226,12 +228,13 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou ae_int32x2 out_sample, out_sample1; ae_int32x2 volume, volume1; int i, n, m; + unsigned int j; ae_int32x4 *buf; ae_int32x4 *buf_end; ae_int32x4 *vol; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; const ae_int32x4 *in = source->ptr; @@ -303,11 +306,11 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct cir_buf_sou in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << attenuation; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << attenuation; } } @@ -327,9 +330,10 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, struct vol_data *cd = module_get_private_data(mod); ae_int32x2 in_sample, in_sample1; int i, n, m; + unsigned int j; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; const ae_int32x4 *in = source->ptr; @@ -364,11 +368,11 @@ static void vol_passthrough_s32_to_s24_s32(struct processing_module *mod, in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << attenuation; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << attenuation; } } #endif /* CONFIG_FORMAT_S32LE */ @@ -391,6 +395,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_int16x4 in_sample, in_sample1; ae_int16x4 out_sample, out_sample1; int i, n, m; + unsigned int j; ae_int32x4 *buf; ae_int32x4 *buf_end; ae_int32x4 *vol; @@ -398,7 +403,7 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source ae_valignx2 outu = AE_ZALIGN128(); const ae_int16x8 *in = source->ptr; ae_int16x8 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; ae_int32x2 temp, temp1; @@ -483,11 +488,11 @@ static void vol_s16_to_s16(struct processing_module *mod, struct cir_buf_source in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << PEAK_16S_32C_ADJUST; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << PEAK_16S_32C_ADJUST; } } @@ -507,11 +512,12 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, struct vol_data *cd = module_get_private_data(mod); ae_int16x4 in_sample, in_sample1; int i, n, m; + unsigned int j; ae_valignx2 inu; ae_valignx2 outu = AE_ZALIGN128(); const ae_int16x8 *in = source->ptr; ae_int16x8 *out = sink->ptr; - const int channels_count = cd->channels; + const unsigned int channels_count = cd->channels; const int inc = sizeof(ae_int32x4); int samples = channels_count * frames; ae_int32x2 temp, temp1; @@ -549,11 +555,11 @@ static void vol_passthrough_s16_to_s16(struct processing_module *mod, in = source_cir_buf_wrap(in, source->buf_start, source->buf_end); out = cir_buf_wrap(out, sink->buf_start, sink->buf_end); } - for (i = 0; i < channels_count; i++) { - m = MAX(cd->peak_vol[i], cd->peak_vol[i + channels_count]); - m = MAX(m, cd->peak_vol[i + channels_count * 2]); - m = MAX(m, cd->peak_vol[i + channels_count * 3]); - cd->peak_regs.peak_meter[i] = m << PEAK_16S_32C_ADJUST; + for (j = 0; j < channels_count; j++) { + m = MAX(cd->peak_vol[j], cd->peak_vol[j + channels_count]); + m = MAX(m, cd->peak_vol[j + channels_count * 2]); + m = MAX(m, cd->peak_vol[j + channels_count * 3]); + cd->peak_regs.peak_meter[j] = m << PEAK_16S_32C_ADJUST; } } #endif /* CONFIG_FORMAT_S16LE */