xref: /linux/drivers/staging/media/atomisp/pci/hive_isp_css_include/math_support.h (revision 3fd6c59042dbba50391e30862beac979491145fe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #ifndef __MATH_SUPPORT_H
8 #define __MATH_SUPPORT_H
9 
10 /* Override the definition of max/min from Linux kernel */
11 #include <linux/minmax.h>
12 
13 /* force a value to a lower even value */
14 #define EVEN_FLOOR(x)        ((x) & ~1)
15 
16 #define CEIL_DIV(a, b)       (((b) != 0) ? ((a) + (b) - 1) / (b) : 0)
17 #define CEIL_MUL(a, b)       (CEIL_DIV(a, b) * (b))
18 #define CEIL_MUL2(a, b)      (((a) + (b) - 1) & ~((b) - 1))
19 #define CEIL_SHIFT(a, b)     (((a) + (1 << (b)) - 1) >> (b))
20 #define CEIL_SHIFT_MUL(a, b) (CEIL_SHIFT(a, b) << (b))
21 
22 /*
23  * For SP and ISP, SDK provides the definition of OP_std_modadd.
24  * We need it only for host
25  */
26 #define OP_std_modadd(base, offset, size) ((base + offset) % (size))
27 
28 #endif /* __MATH_SUPPORT_H */
29