xref: /linux/drivers/staging/media/atomisp/pci/hive_isp_css_include/math_support.h (revision 42b16d3ac371a2fac9b6f08fd75f23f34ba3955a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __MATH_SUPPORT_H
17 #define __MATH_SUPPORT_H
18 
19 /* Override the definition of max/min from Linux kernel */
20 #include <linux/minmax.h>
21 
22 /* force a value to a lower even value */
23 #define EVEN_FLOOR(x)        ((x) & ~1)
24 
25 #define CEIL_DIV(a, b)       (((b) != 0) ? ((a) + (b) - 1) / (b) : 0)
26 #define CEIL_MUL(a, b)       (CEIL_DIV(a, b) * (b))
27 #define CEIL_MUL2(a, b)      (((a) + (b) - 1) & ~((b) - 1))
28 #define CEIL_SHIFT(a, b)     (((a) + (1 << (b)) - 1) >> (b))
29 #define CEIL_SHIFT_MUL(a, b) (CEIL_SHIFT(a, b) << (b))
30 
31 /*
32  * For SP and ISP, SDK provides the definition of OP_std_modadd.
33  * We need it only for host
34  */
35 #define OP_std_modadd(base, offset, size) ((base + offset) % (size))
36 
37 #endif /* __MATH_SUPPORT_H */
38