1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #include "ia_css_types.h"
16 #include "sh_css_defs.h"
17 #ifndef IA_CSS_NO_DEBUG
18 /* FIXME: See BZ 4427 */
19 #include "ia_css_debug.h"
20 #endif
21 #include "sh_css_frac.h"
22 #include "vamem.h"
23 
24 #include "ia_css_gc.host.h"
25 
26 const struct ia_css_gc_config default_gc_config = {
27 	0,
28 	0
29 };
30 
31 const struct ia_css_ce_config default_ce_config = {
32 	0,
33 	255
34 };
35 
36 void
37 ia_css_gc_encode(
38     struct sh_css_isp_gc_params *to,
39     const struct ia_css_gc_config *from,
40     unsigned int size)
41 {
42 	(void)size;
43 	to->gain_k1 =
44 	    uDIGIT_FITTING((int)from->gain_k1, 16,
45 			   IA_CSS_GAMMA_GAIN_K_SHIFT);
46 	to->gain_k2 =
47 	    uDIGIT_FITTING((int)from->gain_k2, 16,
48 			   IA_CSS_GAMMA_GAIN_K_SHIFT);
49 }
50 
51 void
52 ia_css_ce_encode(
53     struct sh_css_isp_ce_params *to,
54     const struct ia_css_ce_config *from,
55     unsigned int size)
56 {
57 	(void)size;
58 	to->uv_level_min = from->uv_level_min;
59 	to->uv_level_max = from->uv_level_max;
60 }
61 
62 void
63 ia_css_gc_vamem_encode(
64     struct sh_css_isp_gc_vamem_params *to,
65     const struct ia_css_gamma_table *from,
66     unsigned int size)
67 {
68 	(void)size;
69 	memcpy(&to->gc,  &from->data, sizeof(to->gc));
70 }
71 
72 #ifndef IA_CSS_NO_DEBUG
73 void
74 ia_css_gc_dump(
75     const struct sh_css_isp_gc_params *gc,
76     unsigned int level)
77 {
78 	if (!gc) return;
79 	ia_css_debug_dtrace(level, "Gamma Correction:\n");
80 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
81 			    "gamma_gain_k1", gc->gain_k1);
82 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
83 			    "gamma_gain_k2", gc->gain_k2);
84 }
85 
86 void
87 ia_css_ce_dump(
88     const struct sh_css_isp_ce_params *ce,
89     unsigned int level)
90 {
91 	ia_css_debug_dtrace(level, "Chroma Enhancement:\n");
92 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
93 			    "ce_uv_level_min", ce->uv_level_min);
94 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
95 			    "ce_uv_level_max", ce->uv_level_max);
96 }
97 
98 void
99 ia_css_gc_debug_dtrace(
100     const struct ia_css_gc_config *config,
101     unsigned int level)
102 {
103 	ia_css_debug_dtrace(level,
104 			    "config.gain_k1=%d, config.gain_k2=%d\n",
105 			    config->gain_k1, config->gain_k2);
106 }
107 
108 void
109 ia_css_ce_debug_dtrace(
110     const struct ia_css_ce_config *config,
111     unsigned int level)
112 {
113 	ia_css_debug_dtrace(level,
114 			    "config.uv_level_min=%d, config.uv_level_max=%d\n",
115 			    config->uv_level_min, config->uv_level_max);
116 }
117 #endif
118