OSDN Git Service

media: atomisp: simplify math_support.h
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sun, 19 Apr 2020 17:12:04 +0000 (19:12 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 20 May 2020 10:32:15 +0000 (12:32 +0200)
There are some uneeded defines there. Simplify it, and make
it independent of defines.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c

index fc32c89..bc61ffe 100644 (file)
 
 #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_EVEN(a)           (!IS_ODD(a))
 
 /* 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 */
index 886abff..e6c4e0f 100644 (file)
@@ -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