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 #include "ia_css_types.h"
8 #include "sh_css_defs.h"
9 #include "sh_css_frac.h"
10 #ifndef IA_CSS_NO_DEBUG
11 #include "ia_css_debug.h"
12 #endif
13 #include "isp.h"
14 #include "ia_css_ob2.host.h"
15 
16 const struct ia_css_ob2_config default_ob2_config = {
17 	0,
18 	0,
19 	0,
20 	0
21 };
22 
23 void
ia_css_ob2_encode(struct sh_css_isp_ob2_params * to,const struct ia_css_ob2_config * from,unsigned int size)24 ia_css_ob2_encode(
25     struct sh_css_isp_ob2_params *to,
26     const struct ia_css_ob2_config *from,
27     unsigned int size)
28 {
29 	(void)size;
30 
31 	/* Blacklevels types are u0_16 */
32 	to->blacklevel_gr = uDIGIT_FITTING(from->level_gr, 16, SH_CSS_BAYER_BITS);
33 	to->blacklevel_r  = uDIGIT_FITTING(from->level_r,  16, SH_CSS_BAYER_BITS);
34 	to->blacklevel_b  = uDIGIT_FITTING(from->level_b,  16, SH_CSS_BAYER_BITS);
35 	to->blacklevel_gb = uDIGIT_FITTING(from->level_gb, 16, SH_CSS_BAYER_BITS);
36 }
37 
38 #ifndef IA_CSS_NO_DEBUG
39 void
ia_css_ob2_dump(const struct sh_css_isp_ob2_params * ob2,unsigned int level)40 ia_css_ob2_dump(
41     const struct sh_css_isp_ob2_params *ob2,
42     unsigned int level)
43 {
44 	if (!ob2)
45 		return;
46 
47 	ia_css_debug_dtrace(level, "Optical Black 2:\n");
48 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
49 			    "ob2_blacklevel_gr", ob2->blacklevel_gr);
50 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
51 			    "ob2_blacklevel_r", ob2->blacklevel_r);
52 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
53 			    "ob2_blacklevel_b", ob2->blacklevel_b);
54 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
55 			    "ob2_blacklevel_gb", ob2->blacklevel_gb);
56 }
57 
58 void
ia_css_ob2_debug_dtrace(const struct ia_css_ob2_config * config,unsigned int level)59 ia_css_ob2_debug_dtrace(
60     const struct ia_css_ob2_config *config,
61     unsigned int level)
62 {
63 	ia_css_debug_dtrace(level,
64 			    "config.level_gr=%d, config.level_r=%d, config.level_b=%d,  config.level_gb=%d, ",
65 			    config->level_gr, config->level_r,
66 			    config->level_b, config->level_gb);
67 }
68 #endif
69