Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: atomisp: Clean up unused macros from math_support.h

Clean up unused macros from math_support.h and replace rarely
used by generic ones from Linux kernel headers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240424184421.1737776-2-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Andy Shevchenko and committed by
Hans Verkuil
143fd8fe e323de47

+20 -139
-11
drivers/staging/media/atomisp/pci/camera/util/interface/ia_css_util.h
··· 100 100 bool ia_css_util_resolution_is_zero( 101 101 const struct ia_css_resolution resolution); 102 102 103 - /* ISP2401 */ 104 - /** 105 - * @brief Check if resolution is even 106 - * 107 - * @param[in] resolution The resolution to check 108 - * 109 - * @returns true if resolution is even 110 - */ 111 - bool ia_css_util_resolution_is_even( 112 - const struct ia_css_resolution resolution); 113 - 114 103 /* @brief check width and height 115 104 * 116 105 * @param[in] stream_format
+11 -14
drivers/staging/media/atomisp/pci/camera/util/src/util.c
··· 119 119 return 0; 120 120 } 121 121 122 - int ia_css_util_check_res(unsigned int width, unsigned int height) 123 - { 124 - /* height can be odd number for jpeg/embedded data from ISYS2401 */ 125 - if (((width == 0) || 126 - (height == 0) || 127 - IS_ODD(width))) { 128 - return -EINVAL; 129 - } 130 - return 0; 131 - } 132 - 133 122 /* ISP2401 */ 134 123 bool ia_css_util_res_leq(struct ia_css_resolution a, struct ia_css_resolution b) 135 124 { ··· 131 142 return (resolution.width == 0) || (resolution.height == 0); 132 143 } 133 144 134 - /* ISP2401 */ 135 - bool ia_css_util_resolution_is_even(const struct ia_css_resolution resolution) 145 + int ia_css_util_check_res(unsigned int width, unsigned int height) 136 146 { 137 - return IS_EVEN(resolution.height) && IS_EVEN(resolution.width); 147 + const struct ia_css_resolution resolution = { .width = width, .height = height }; 148 + 149 + if (ia_css_util_resolution_is_zero(resolution)) 150 + return -EINVAL; 151 + 152 + /* height can be odd number for jpeg/embedded data from ISYS2401 */ 153 + if (width & 1) 154 + return -EINVAL; 155 + 156 + return 0; 138 157 } 139 158 140 159 bool ia_css_util_is_input_format_raw(enum atomisp_input_format format)
+2 -108
drivers/staging/media/atomisp/pci/hive_isp_css_include/math_support.h
··· 16 16 #ifndef __MATH_SUPPORT_H 17 17 #define __MATH_SUPPORT_H 18 18 19 - #include <linux/kernel.h> /* Override the definition of max/min from linux kernel*/ 20 - 21 - #define IS_ODD(a) ((a) & 0x1) 22 - #define IS_EVEN(a) (!IS_ODD(a)) 19 + /* Override the definition of max/min from Linux kernel */ 20 + #include <linux/minmax.h> 23 21 24 22 /* force a value to a lower even value */ 25 23 #define EVEN_FLOOR(x) ((x) & ~1) 26 - 27 - /* ISP2401 */ 28 - /* If the number is odd, find the next even number */ 29 - #define EVEN_CEIL(x) ((IS_ODD(x)) ? ((x) + 1) : (x)) 30 - 31 - /* A => B */ 32 - #define IMPLIES(a, b) (!(a) || (b)) 33 24 34 25 /* for preprocessor and array sizing use MIN and MAX 35 26 otherwise use min and max */ 36 27 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 37 28 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 38 29 39 - #define ROUND_DIV(a, b) (((b) != 0) ? ((a) + ((b) >> 1)) / (b) : 0) 40 30 #define CEIL_DIV(a, b) (((b) != 0) ? ((a) + (b) - 1) / (b) : 0) 41 31 #define CEIL_MUL(a, b) (CEIL_DIV(a, b) * (b)) 42 32 #define CEIL_MUL2(a, b) (((a) + (b) - 1) & ~((b) - 1)) 43 33 #define CEIL_SHIFT(a, b) (((a) + (1 << (b)) - 1) >> (b)) 44 34 #define CEIL_SHIFT_MUL(a, b) (CEIL_SHIFT(a, b) << (b)) 45 - #define ROUND_HALF_DOWN_DIV(a, b) (((b) != 0) ? ((a) + (b / 2) - 1) / (b) : 0) 46 - #define ROUND_HALF_DOWN_MUL(a, b) (ROUND_HALF_DOWN_DIV(a, b) * (b)) 47 - 48 - /*To Find next power of 2 number from x */ 49 - #define bit2(x) ((x) | ((x) >> 1)) 50 - #define bit4(x) (bit2(x) | (bit2(x) >> 2)) 51 - #define bit8(x) (bit4(x) | (bit4(x) >> 4)) 52 - #define bit16(x) (bit8(x) | (bit8(x) >> 8)) 53 - #define bit32(x) (bit16(x) | (bit16(x) >> 16)) 54 - #define NEXT_POWER_OF_2(x) (bit32(x - 1) + 1) 55 - 56 - /* min and max should not be macros as they will evaluate their arguments twice. 57 - if you really need a macro (e.g. for CPP or for initializing an array) 58 - use MIN() and MAX(), otherwise use min() and max(). 59 - 60 - */ 61 35 62 36 #if !defined(PIPE_GENERATION) 63 37 64 - /* 65 - This macro versions are added back as we are mixing types in usage of inline. 66 - This causes corner cases of calculations to be incorrect due to conversions 67 - between signed and unsigned variables or overflows. 68 - Before the addition of the inline functions, max, min and ceil_div were macros 69 - and therefore adding them back. 70 - 71 - Leaving out the other math utility functions as they are newly added 72 - */ 73 - 74 38 #define ceil_div(a, b) (CEIL_DIV(a, b)) 75 - 76 - static inline unsigned int ceil_mul(unsigned int a, unsigned int b) 77 - { 78 - return CEIL_MUL(a, b); 79 - } 80 - 81 - static inline unsigned int ceil_mul2(unsigned int a, unsigned int b) 82 - { 83 - return CEIL_MUL2(a, b); 84 - } 85 - 86 - static inline unsigned int ceil_shift(unsigned int a, unsigned int b) 87 - { 88 - return CEIL_SHIFT(a, b); 89 - } 90 - 91 - static inline unsigned int ceil_shift_mul(unsigned int a, unsigned int b) 92 - { 93 - return CEIL_SHIFT_MUL(a, b); 94 - } 95 - 96 - /* ISP2401 */ 97 - static inline unsigned int round_half_down_div(unsigned int a, unsigned int b) 98 - { 99 - return ROUND_HALF_DOWN_DIV(a, b); 100 - } 101 - 102 - /* ISP2401 */ 103 - static inline unsigned int round_half_down_mul(unsigned int a, unsigned int b) 104 - { 105 - return ROUND_HALF_DOWN_MUL(a, b); 106 - } 107 - 108 - /* @brief Next Power of Two 109 - * 110 - * @param[in] unsigned number 111 - * 112 - * @return next power of two 113 - * 114 - * This function rounds input to the nearest power of 2 (2^x) 115 - * towards infinity 116 - * 117 - * Input Range: 0 .. 2^(8*sizeof(int)-1) 118 - * 119 - * IF input is a power of 2 120 - * out = in 121 - * OTHERWISE 122 - * out = 2^(ceil(log2(in)) 123 - * 124 - */ 125 - 126 - static inline unsigned int ceil_pow2(unsigned int a) 127 - { 128 - if (a == 0) { 129 - return 1; 130 - } 131 - /* IF input is already a power of two*/ 132 - else if ((!((a) & ((a) - 1)))) { 133 - return a; 134 - } else { 135 - unsigned int v = a; 136 - 137 - v |= v >> 1; 138 - v |= v >> 2; 139 - v |= v >> 4; 140 - v |= v >> 8; 141 - v |= v >> 16; 142 - return (v + 1); 143 - } 144 - } 145 39 146 40 #endif /* !defined(PIPE_GENERATION) */ 147 41
+1
drivers/staging/media/atomisp/pci/ia_css_3a.h
··· 20 20 * This file contains types used for 3A statistics 21 21 */ 22 22 23 + #include <math_support.h> 23 24 #include <type_support.h> 24 25 #include "ia_css_types.h" 25 26 #include "ia_css_err.h"
+3 -3
drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c
··· 13 13 * more details. 14 14 */ 15 15 16 + #include <linux/log2.h> 17 + 16 18 #include "type_support.h" 17 19 #include "math_support.h" 18 20 #include "sh_css_defs.h" ··· 139 137 unsigned int size) 140 138 { 141 139 int kernel_size = XNR_FILTER_SIZE; 142 - /* The adjust factor is the next power of 2 143 - w.r.t. the kernel size*/ 144 - int adjust_factor = ceil_pow2(kernel_size); 140 + int adjust_factor = roundup_pow_of_two(kernel_size); 145 141 s32 max_diff = (1 << (ISP_VEC_ELEMBITS - 1)) - 1; 146 142 s32 min_diff = -(1 << (ISP_VEC_ELEMBITS - 1)); 147 143
-2
drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
··· 43 43 44 44 #include "assert_support.h" 45 45 46 - #define IMPLIES(a, b) (!(a) || (b)) /* A => B */ 47 - 48 46 static struct ia_css_binary_xinfo *all_binaries; /* ISP binaries only (no SP) */ 49 47 static struct ia_css_binary_xinfo 50 48 *binary_infos[IA_CSS_BINARY_NUM_MODES] = { NULL, };
+3 -1
drivers/staging/media/atomisp/pci/sh_css_frac.h
··· 16 16 #ifndef __SH_CSS_FRAC_H 17 17 #define __SH_CSS_FRAC_H 18 18 19 - #include <math_support.h> 19 + #include <linux/minmax.h> 20 + 21 + #include "mamoiada_params.h" 20 22 21 23 #define sISP_REG_BIT ISP_VEC_ELEMBITS 22 24 #define uISP_REG_BIT ((unsigned int)(sISP_REG_BIT - 1))