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 #ifndef IA_CSS_NO_DEBUG
10 /* FIXME: See BZ 4427 */
11 #include "ia_css_debug.h"
12 #endif
13 #include "sh_css_frac.h"
14 #include "vamem.h"
15 
16 #include "ia_css_gc.host.h"
17 
18 const struct ia_css_gc_config default_gc_config = {
19 	0,
20 	0
21 };
22 
23 const struct ia_css_ce_config default_ce_config = {
24 	0,
25 	255
26 };
27 
28 void
ia_css_gc_encode(struct sh_css_isp_gc_params * to,const struct ia_css_gc_config * from,unsigned int size)29 ia_css_gc_encode(
30     struct sh_css_isp_gc_params *to,
31     const struct ia_css_gc_config *from,
32     unsigned int size)
33 {
34 	(void)size;
35 	to->gain_k1 =
36 	    uDIGIT_FITTING((int)from->gain_k1, 16,
37 			   IA_CSS_GAMMA_GAIN_K_SHIFT);
38 	to->gain_k2 =
39 	    uDIGIT_FITTING((int)from->gain_k2, 16,
40 			   IA_CSS_GAMMA_GAIN_K_SHIFT);
41 }
42 
43 void
ia_css_ce_encode(struct sh_css_isp_ce_params * to,const struct ia_css_ce_config * from,unsigned int size)44 ia_css_ce_encode(
45     struct sh_css_isp_ce_params *to,
46     const struct ia_css_ce_config *from,
47     unsigned int size)
48 {
49 	(void)size;
50 	to->uv_level_min = from->uv_level_min;
51 	to->uv_level_max = from->uv_level_max;
52 }
53 
54 void
ia_css_gc_vamem_encode(struct sh_css_isp_gc_vamem_params * to,const struct ia_css_gamma_table * from,unsigned int size)55 ia_css_gc_vamem_encode(
56     struct sh_css_isp_gc_vamem_params *to,
57     const struct ia_css_gamma_table *from,
58     unsigned int size)
59 {
60 	(void)size;
61 	memcpy(&to->gc,  &from->data, sizeof(to->gc));
62 }
63 
64 #ifndef IA_CSS_NO_DEBUG
65 void
ia_css_gc_dump(const struct sh_css_isp_gc_params * gc,unsigned int level)66 ia_css_gc_dump(
67     const struct sh_css_isp_gc_params *gc,
68     unsigned int level)
69 {
70 	if (!gc) return;
71 	ia_css_debug_dtrace(level, "Gamma Correction:\n");
72 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
73 			    "gamma_gain_k1", gc->gain_k1);
74 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
75 			    "gamma_gain_k2", gc->gain_k2);
76 }
77 
78 void
ia_css_ce_dump(const struct sh_css_isp_ce_params * ce,unsigned int level)79 ia_css_ce_dump(
80     const struct sh_css_isp_ce_params *ce,
81     unsigned int level)
82 {
83 	ia_css_debug_dtrace(level, "Chroma Enhancement:\n");
84 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
85 			    "ce_uv_level_min", ce->uv_level_min);
86 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
87 			    "ce_uv_level_max", ce->uv_level_max);
88 }
89 
90 void
ia_css_gc_debug_dtrace(const struct ia_css_gc_config * config,unsigned int level)91 ia_css_gc_debug_dtrace(
92     const struct ia_css_gc_config *config,
93     unsigned int level)
94 {
95 	ia_css_debug_dtrace(level,
96 			    "config.gain_k1=%d, config.gain_k2=%d\n",
97 			    config->gain_k1, config->gain_k2);
98 }
99 
100 void
ia_css_ce_debug_dtrace(const struct ia_css_ce_config * config,unsigned int level)101 ia_css_ce_debug_dtrace(
102     const struct ia_css_ce_config *config,
103     unsigned int level)
104 {
105 	ia_css_debug_dtrace(level,
106 			    "config.uv_level_min=%d, config.uv_level_max=%d\n",
107 			    config->uv_level_min, config->uv_level_max);
108 }
109 #endif
110