media: atomisp: simplify math_support.h

There are some uneeded defines there. Simplify it, and make
it independent of defines.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2020-04-19 19:12:04 +02:00
Родитель 02330fb010
Коммит 9a0d7fb5ec
2 изменённых файлов: 2 добавлений и 58 удалений

Просмотреть файл

@ -17,24 +17,6 @@
#include <linux/kernel.h> /* Override the definition of max/min from linux kernel*/ #include <linux/kernel.h> /* Override the definition of max/min from linux kernel*/
/* in case we have min/max/MIN/MAX macro's undefine them */
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef MIN /* also defined in include/hrt/numeric.h from SDK */
#undef MIN
#endif
#ifdef MAX
#undef MAX
#endif
#ifdef ABS
#undef ABS
#endif
#define IS_ODD(a) ((a) & 0x1) #define IS_ODD(a) ((a) & 0x1)
#define IS_EVEN(a) (!IS_ODD(a)) #define IS_EVEN(a) (!IS_ODD(a))
@ -49,24 +31,19 @@
/* A => B */ /* A => B */
#define IMPLIES(a, b) (!(a) || (b)) #define IMPLIES(a, b) (!(a) || (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
/* for preprocessor and array sizing use MIN and MAX /* for preprocessor and array sizing use MIN and MAX
otherwise use min and max */ otherwise use min and max */
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b))
#ifdef ISP2401
#define ROUND_DIV(a, b) (((b) != 0) ? ((a) + ((b) >> 1)) / (b) : 0) #define ROUND_DIV(a, b) (((b) != 0) ? ((a) + ((b) >> 1)) / (b) : 0)
#endif
#define CEIL_DIV(a, b) (((b) != 0) ? ((a) + (b) - 1) / (b) : 0) #define CEIL_DIV(a, b) (((b) != 0) ? ((a) + (b) - 1) / (b) : 0)
#define CEIL_MUL(a, b) (CEIL_DIV(a, b) * (b)) #define CEIL_MUL(a, b) (CEIL_DIV(a, b) * (b))
#define CEIL_MUL2(a, b) (((a) + (b) - 1) & ~((b) - 1)) #define CEIL_MUL2(a, b) (((a) + (b) - 1) & ~((b) - 1))
#define CEIL_SHIFT(a, b) (((a) + (1 << (b)) - 1) >> (b)) #define CEIL_SHIFT(a, b) (((a) + (1 << (b)) - 1) >> (b))
#define CEIL_SHIFT_MUL(a, b) (CEIL_SHIFT(a, b) << (b)) #define CEIL_SHIFT_MUL(a, b) (CEIL_SHIFT(a, b) << (b))
#ifdef ISP2401
#define ROUND_HALF_DOWN_DIV(a, b) (((b) != 0) ? ((a) + (b / 2) - 1) / (b) : 0) #define ROUND_HALF_DOWN_DIV(a, b) (((b) != 0) ? ((a) + (b / 2) - 1) / (b) : 0)
#define ROUND_HALF_DOWN_MUL(a, b) (ROUND_HALF_DOWN_DIV(a, b) * (b)) #define ROUND_HALF_DOWN_MUL(a, b) (ROUND_HALF_DOWN_DIV(a, b) * (b))
#endif
/*To Find next power of 2 number from x */ /*To Find next power of 2 number from x */
#define bit2(x) ((x) | ((x) >> 1)) #define bit2(x) ((x) | ((x) >> 1))
@ -84,7 +61,6 @@
#if !defined(PIPE_GENERATION) #if !defined(PIPE_GENERATION)
#ifndef INLINE_MATH_SUPPORT_UTILS
/* /*
This macro versions are added back as we are mixing types in usage of inline. This macro versions are added back as we are mixing types in usage of inline.
This causes corner cases of calculations to be incorrect due to conversions This causes corner cases of calculations to be incorrect due to conversions
@ -95,38 +71,8 @@ and therefore adding them back.
Leaving out the other math utility functions as they are newly added Leaving out the other math utility functions as they are newly added
*/ */
#define max(a, b) (MAX(a, b))
#define min(a, b) (MIN(a, b))
#define ceil_div(a, b) (CEIL_DIV(a, b)) #define ceil_div(a, b) (CEIL_DIV(a, b))
#else /* !defined(INLINE_MATH_SUPPORT_UTILS) */
static inline int max(int a, int b)
{
return MAX(a, b);
}
static inline int min(int a, int b)
{
return MIN(a, b);
}
static inline unsigned int ceil_div(unsigned int a, unsigned int b)
{
return CEIL_DIV(a, b);
}
#endif /* !defined(INLINE_MATH_SUPPORT_UTILS) */
static inline unsigned int umax(unsigned int a, unsigned int b)
{
return MAX(a, b);
}
static inline unsigned int umin(unsigned int a, unsigned int b)
{
return MIN(a, b);
}
static inline unsigned int ceil_mul(unsigned int a, unsigned int b) static inline unsigned int ceil_mul(unsigned int a, unsigned int b)
{ {
return CEIL_MUL(a, b); return CEIL_MUL(a, b);
@ -199,12 +145,10 @@ static inline unsigned int ceil_pow2(unsigned int a)
#endif /* !defined(PIPE_GENERATION) */ #endif /* !defined(PIPE_GENERATION) */
#if !defined(__ISP)
/* /*
* For SP and ISP, SDK provides the definition of OP_std_modadd. * For SP and ISP, SDK provides the definition of OP_std_modadd.
* We need it only for host * We need it only for host
*/ */
#define OP_std_modadd(base, offset, size) ((base + offset) % (size)) #define OP_std_modadd(base, offset, size) ((base + offset) % (size))
#endif /* !defined(__ISP) */
#endif /* __MATH_SUPPORT_H */ #endif /* __MATH_SUPPORT_H */

Просмотреть файл

@ -145,7 +145,7 @@ compute_blending(int strength)
* exactly as s0.11 fixed point, but -1.0 can. * exactly as s0.11 fixed point, but -1.0 can.
*/ */
isp_strength = -(((strength * isp_scale) + offset) / host_scale); isp_strength = -(((strength * isp_scale) + offset) / host_scale);
return max(min(isp_strength, 0), -XNR_BLENDING_SCALE_FACTOR); return MAX(MIN(isp_strength, 0), -XNR_BLENDING_SCALE_FACTOR);
} }
void void