1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Medifield PNW Camera Imaging ISP subsystem.
4  *
5  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6  *
7  * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version
11  * 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  *
19  */
20 
21 #ifndef	__HMM_BO_COMMON_H__
22 #define	__HMM_BO_COMMON_H__
23 
24 #define	HMM_BO_NAME	"HMM"
25 
26 /*
27  * some common use micros
28  */
29 #define	var_equal_return(var1, var2, exp, fmt, arg ...)	\
30 	do { \
31 		if ((var1) == (var2)) { \
32 			dev_err(atomisp_dev, \
33 			fmt, ## arg); \
34 			return exp;\
35 		} \
36 	} while (0)
37 
38 #define	var_equal_return_void(var1, var2, fmt, arg ...)	\
39 	do { \
40 		if ((var1) == (var2)) { \
41 			dev_err(atomisp_dev, \
42 			fmt, ## arg); \
43 			return;\
44 		} \
45 	} while (0)
46 
47 #define	var_equal_goto(var1, var2, label, fmt, arg ...)	\
48 	do { \
49 		if ((var1) == (var2)) { \
50 			dev_err(atomisp_dev, \
51 			fmt, ## arg); \
52 			goto label;\
53 		} \
54 	} while (0)
55 
56 #define	var_not_equal_goto(var1, var2, label, fmt, arg ...)	\
57 	do { \
58 		if ((var1) != (var2)) { \
59 			dev_err(atomisp_dev, \
60 			fmt, ## arg); \
61 			goto label;\
62 		} \
63 	} while (0)
64 
65 #define	check_null_return(ptr, exp, fmt, arg ...)	\
66 		var_equal_return(ptr, NULL, exp, fmt, ## arg)
67 
68 #define	check_null_return_void(ptr, fmt, arg ...)	\
69 		var_equal_return_void(ptr, NULL, fmt, ## arg)
70 
71 /* hmm_mem_stat is used to trace the hmm mem used by ISP pipe. The unit is page
72  * number.
73  *
74  * res_size:  reserved mem pool size, being allocated from system at system boot time.
75  *		res_size >= res_cnt.
76  * sys_size:  system mem pool size, being allocated from system at camera running time.
77  *		dyc_size:  dynamic mem pool size.
78  *		dyc_thr:   dynamic mem pool high watermark.
79  *		dyc_size <= dyc_thr.
80  * usr_size:  user ptr mem size.
81  *
82  * res_cnt:   track the mem allocated from reserved pool at camera running time.
83  * tol_cnt:   track the total mem used by ISP pipe at camera running time.
84  */
85 struct _hmm_mem_stat {
86 	int res_size;
87 	int sys_size;
88 	int dyc_size;
89 	int dyc_thr;
90 	int usr_size;
91 	int res_cnt;
92 	int tol_cnt;
93 };
94 
95 extern struct _hmm_mem_stat hmm_mem_stat;
96 
97 #endif
98