[Sound-open-firmware] [PATCH v2] Replace user-defined 32-bit and 16-bit MAX and MIN values
Replace the user-defined MAX and MIN values for 32-bit and 16-bit with standard INTN_MAX/INTN_MIN macro
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- src/audio/tone.c | 14 +++++++------- src/include/reef/audio/format.h | 27 ++++++++++++--------------- 2 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/src/audio/tone.c b/src/audio/tone.c index 3eb08e9..2957270 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -187,7 +187,7 @@ static void tonegen_control(struct tone_state *sg) return;
sg->sample_count = 0; - if (sg->block_count < INT32_MAXVALUE) + if (sg->block_count < INT32_MAX) sg->block_count++;
/* Fadein ramp during tone */ @@ -270,13 +270,13 @@ static void tonegen_set_ampl_mult(struct tone_state *sg, int32_t am) /* Tone length in samples, this is the active length of tone */ static void tonegen_set_length(struct tone_state *sg, uint32_t tl) { - sg->tone_length = (tl > 0) ? tl : INT32_MAXVALUE; /* Count rate 125 us */ + sg->tone_length = (tl > 0) ? tl : INT32_MAX; /* Count rate 125 us */ }
/* Tone period in samples, this is the length including the pause after beep */ static void tonegen_set_period(struct tone_state *sg, uint32_t tp) { - sg->tone_period = (tp > 0) ? tp : INT32_MAXVALUE; /* Count rate 125 us */ + sg->tone_period = (tp > 0) ? tp : INT32_MAX; /* Count rate 125 us */ }
/* Tone ramp parameters: @@ -287,7 +287,7 @@ static void tonegen_set_period(struct tone_state *sg, uint32_t tp)
static inline void tonegen_set_linramp(struct tone_state *sg, int32_t step) { - sg->ramp_step = (step > 0) ? step : INT32_MAXVALUE; + sg->ramp_step = (step > 0) ? step : INT32_MAX; }
static inline int32_t tonegen_get_f(struct tone_state *sg) @@ -317,7 +317,7 @@ static void tonegen_update_f(struct tone_state *sg, int32_t f)
/* Calculate Fs/2, fs is Q32.0, f is Q16.16 */ f_max = Q_SHIFT_LEFT((int64_t) sg->fs, 0, 16 - 1); - f_max = (f_max > INT32_MAXVALUE) ? INT32_MAXVALUE : f_max; + f_max = (f_max > INT32_MAX) ? INT32_MAX : f_max; sg->f = (f > f_max) ? f_max : f; /* Q16 x Q31 -> Q28 */ w_tmp = q_multsr_32x32(sg->f, sg->c, Q_SHIFT_BITS_64(16, 31, 28)); @@ -349,8 +349,8 @@ static void tonegen_reset(struct tone_state *sg) /* Continuous tone */ sg->freq_coef = ONE_Q2_30; /* Set freq multiplier to 1.0 */ sg->ampl_coef = ONE_Q2_30; /* Set ampl multiplier to 1.0 */ - sg->tone_length = INT32_MAXVALUE; - sg->tone_period = INT32_MAXVALUE; + sg->tone_length = INT32_MAX; + sg->tone_period = INT32_MAX; sg->ramp_step = ONE_Q1_31; /* Set lin ramp modification to max */ }
diff --git a/src/include/reef/audio/format.h b/src/include/reef/audio/format.h index b9263f1..8964f33 100644 --- a/src/include/reef/audio/format.h +++ b/src/include/reef/audio/format.h @@ -33,13 +33,10 @@ #ifndef AUDIO_FORMAT_H #define AUDIO_FORMAT_H
-/* Maximum and minimum values for integer types */ -#define INT16_MAXVALUE 32767 -#define INT16_MINVALUE -32768 +/* Maximum and minimum values for 24 bit */ #define INT24_MAXVALUE 8388607 #define INT24_MINVALUE -8388608 -#define INT32_MAXVALUE 2147483647 -#define INT32_MINVALUE -2147483648 +
/* Collection of common fractional numbers */ #define ONE_Q2_30 1073741824 /* Q2.30 1.0 */ @@ -91,8 +88,8 @@ #define Q_MULTSR_32X32(px, py, qx, qy, qp) (((px) * (py) >> (((qx)+(qy)-(qp)-1) +1) >> 1))
/* Saturation */ -#define SATP_INT32(x) (((x) > INT32_MAXVALUE) ? INT32_MAXVALUE : (x)) -#define SATM_INT32(x) (((x) < INT32_MINVALUE) ? INT32_MINVALUE : (x)) +#define SATP_INT32(x) (((x) > INT32_MAX) ? INT32_MAX : (x)) +#define SATM_INT32(x) (((x) < INT32_MIN) ? INT32_MIN : (x))
static inline int64_t q_mults_32x32(int32_t x, int32_t y, const int shift_bits) { @@ -120,10 +117,10 @@ static inline int32_t sat_int32(int64_t x) { #if 1 /* TODO: Is this faster */ - if (x > INT32_MAXVALUE) - return INT32_MAXVALUE; - else if (x < INT32_MINVALUE) - return INT32_MINVALUE; + if (x > INT32_MAX) + return INT32_MAX; + else if (x < INT32_MIN) + return INT32_MIN; else return (int32_t)x; #else @@ -147,10 +144,10 @@ static inline int32_t sat_int24(int32_t x)
static inline int16_t sat_int16(int32_t x) { - if (x > INT16_MAXVALUE) - return INT16_MAXVALUE; - else if (x < INT16_MINVALUE) - return INT16_MINVALUE; + if (x > INT16_MAX) + return INT16_MAX; + else if (x < INT16_MIN) + return INT16_MIN; else return (int16_t)x; }
On Fri, 2017-11-03 at 13:26 +0000, Ranjani Sridharan wrote:
Replace the user-defined MAX and MIN values for 32-bit and 16-bit with standard INTN_MAX/INTN_MIN macro
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com
Applied.
Thanks
Liam
participants (2)
-
Liam Girdwood
-
Ranjani Sridharan