[Sound-open-firmware] [PATCH] 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 1fde455..b9f2428 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -175,7 +175,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 */ @@ -255,8 +255,8 @@ static void tonegen_set_sweep(struct tone_state *sg, int32_t fc, int32_t ac, */ sg->freq_coef = (fc > 0) ? fc : ONE_Q2_30; /* Set freq mult to 1.0 */ sg->ampl_coef = (ac > 0) ? ac : ONE_Q2_30; /* Set ampl mult to 1.0 */ - sg->tone_length = (l > 0) ? l : INT32_MAXVALUE; /* Count rate 125 us */ - sg->tone_period = (p > 0) ? p : INT32_MAXVALUE; /* Count rate 125 us */ + sg->tone_length = (l > 0) ? l : INT32_MAX; /* Count rate 125 us */ + sg->tone_period = (p > 0) ? p : INT32_MAX; /* Count rate 125 us */ } #endif
@@ -268,7 +268,7 @@ static void tonegen_set_sweep(struct tone_state *sg, int32_t fc, int32_t ac,
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) @@ -298,7 +298,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)); @@ -330,8 +330,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 Wed, 2017-11-01 at 10:40 +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
src/audio/tone.c | 14 +++++++------- src/include/reef/audio/format.h | 27 ++++++++++++--------------- 2 files changed, 19 insertions(+), 22 deletions(-)
Doesn't apply against 1.0-dev. can you redo.
Thanks
Liam
participants (2)
-
Liam Girdwood
-
Ranjani Sridharan