From 9a0d7fb5ece6d61b4b943db3216a3ecbb31f0917 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 19 Apr 2020 19:12:04 +0200 Subject: [PATCH] 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 --- .../css2400/hive_isp_css_include/math_support.h | 58 +--------------------- .../isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c | 2 +- 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h index fc32c89eba14..bc61ffebf1b7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h @@ -17,24 +17,6 @@ #include /* 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_EVEN(a) (!IS_ODD(a)) @@ -49,24 +31,19 @@ /* A => B */ #define IMPLIES(a, b) (!(a) || (b)) -#define ABS(a) ((a) >= 0 ? (a) : -(a)) - /* for preprocessor and array sizing use MIN and MAX otherwise use min and max */ #define MAX(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) -#endif #define CEIL_DIV(a, b) (((b) != 0) ? ((a) + (b) - 1) / (b) : 0) #define CEIL_MUL(a, b) (CEIL_DIV(a, b) * (b)) #define CEIL_MUL2(a, b) (((a) + (b) - 1) & ~((b) - 1)) #define CEIL_SHIFT(a, b) (((a) + (1 << (b)) - 1) >> (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_MUL(a, b) (ROUND_HALF_DOWN_DIV(a, b) * (b)) -#endif /*To Find next power of 2 number from x */ #define bit2(x) ((x) | ((x) >> 1)) @@ -84,7 +61,6 @@ #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 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 */ -#define max(a, b) (MAX(a, b)) -#define min(a, b) (MIN(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) { return CEIL_MUL(a, b); @@ -199,12 +145,10 @@ static inline unsigned int ceil_pow2(unsigned int a) #endif /* !defined(PIPE_GENERATION) */ -#if !defined(__ISP) /* * For SP and ISP, SDK provides the definition of OP_std_modadd. * We need it only for host */ #define OP_std_modadd(base, offset, size) ((base + offset) % (size)) -#endif /* !defined(__ISP) */ #endif /* __MATH_SUPPORT_H */ diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c index 886abff24a21..e6c4e0fe34f0 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c @@ -145,7 +145,7 @@ compute_blending(int strength) * exactly as s0.11 fixed point, but -1.0 can. */ 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 -- 2.11.0