2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
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.
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
15 #include "ia_css_types.h"
16 #include "sh_css_defs.h"
17 #include "ia_css_debug.h"
18 #include "sh_css_frac.h"
20 #include "bnr/bnr_1.0/ia_css_bnr.host.h"
21 #include "ia_css_ynr.host.h"
23 const struct ia_css_nr_config default_nr_config = {
31 const struct ia_css_ee_config default_ee_config = {
39 struct sh_css_isp_ynr_params *to,
40 const struct ia_css_nr_config *from,
44 /* YNR (Y Noise Reduction) */
46 uDIGIT_FITTING((unsigned)8192, 16, SH_CSS_BAYER_BITS);
48 uDIGIT_FITTING(from->ynr_gain, 16, SH_CSS_YNR_GAIN_SHIFT);
50 uDIGIT_FITTING(from->ynr_gain, 16, SH_CSS_YNR_GAIN_SHIFT);
52 uDIGIT_FITTING(from->threshold_cb, 16, SH_CSS_BAYER_BITS);
54 uDIGIT_FITTING(from->threshold_cr, 16, SH_CSS_BAYER_BITS);
59 struct sh_css_isp_yee_params *to,
60 const struct ia_css_yee_config *from,
63 int asiWk1 = (int) from->ee.gain;
64 int asiWk2 = asiWk1 / 8;
65 int asiWk3 = asiWk1 / 4;
68 /* YEE (Y Edge Enhancement) */
70 min((uDIGIT_FITTING(from->nr.direction, 16, SH_CSS_BAYER_BITS)
74 min((uDIGIT_FITTING(from->nr.direction, 16, SH_CSS_BAYER_BITS)
77 to->dirthreshold_width_log2 =
78 uFRACTION_BITS_FITTING(8);
79 to->dirthreshold_width =
80 1 << to->dirthreshold_width_log2;
82 uDIGIT_FITTING(from->ee.detail_gain, 11,
83 SH_CSS_YEE_DETAIL_GAIN_SHIFT);
85 (uDIGIT_FITTING((unsigned)56, 16, SH_CSS_BAYER_BITS) *
86 from->ee.threshold) >> 8;
88 (uDIGIT_FITTING((unsigned)224, 16, SH_CSS_BAYER_BITS) *
89 from->ee.threshold) >> 8;
90 /* 8; // *1.125 ->[s4.8] */
92 (asiWk1 + asiWk2) >> (11 - SH_CSS_YEE_SCALE_SHIFT);
93 /* 8; // ( * -.25)->[s4.8] */
95 (0 - asiWk3) >> (11 - SH_CSS_YEE_SCALE_SHIFT);
96 /* 8; // *0.875 ->[s4.8] */
98 (asiWk1 - asiWk2) >> (11 - SH_CSS_YEE_SCALE_SHIFT);
99 /* 8; // ( *.25 ) ->[s4.8] */
101 (asiWk3) >> (11 - SH_CSS_YEE_SCALE_SHIFT);
103 uDIGIT_FITTING((unsigned)32760, 16, SH_CSS_BAYER_BITS);
106 uDIGIT_FITTING((unsigned)504, 16, SH_CSS_BAYER_BITS);
108 uDIGIT_FITTING((unsigned)32256, 16, SH_CSS_BAYER_BITS);
109 to->Yclip = SH_CSS_BAYER_MAXVAL;
114 const struct sh_css_isp_ynr_params *ynr,
118 ia_css_debug_dtrace(level,
119 "Y Noise Reduction:\n");
120 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
121 "ynr_threshold", ynr->threshold);
122 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
123 "ynr_gain_all", ynr->gain_all);
124 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
125 "ynr_gain_dir", ynr->gain_dir);
126 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
127 "ynr_threshold_cb", ynr->threshold_cb);
128 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
129 "ynr_threshold_cr", ynr->threshold_cr);
134 const struct sh_css_isp_yee_params *yee,
137 ia_css_debug_dtrace(level,
138 "Y Edge Enhancement:\n");
139 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
140 "ynryee_dirthreshold_s",
141 yee->dirthreshold_s);
142 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
143 "ynryee_dirthreshold_g",
144 yee->dirthreshold_g);
145 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
146 "ynryee_dirthreshold_width_log2",
147 yee->dirthreshold_width_log2);
148 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
149 "ynryee_dirthreshold_width",
150 yee->dirthreshold_width);
151 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
154 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
157 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
160 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
163 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
166 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
169 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
172 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
175 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
178 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
181 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
184 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
190 ia_css_nr_debug_dtrace(
191 const struct ia_css_nr_config *config,
194 ia_css_debug_dtrace(level,
195 "config.direction=%d, "
196 "config.bnr_gain=%d, config.ynr_gain=%d, "
197 "config.threshold_cb=%d, config.threshold_cr=%d\n",
199 config->bnr_gain, config->ynr_gain,
200 config->threshold_cb, config->threshold_cr);
204 ia_css_ee_debug_dtrace(
205 const struct ia_css_ee_config *config,
208 ia_css_debug_dtrace(level,
209 "config.threshold=%d, config.gain=%d, config.detail_gain=%d\n",
210 config->threshold, config->gain, config->detail_gain);
214 ia_css_init_ynr_state(
215 void/*struct sh_css_isp_ynr_vmem_state*/ *state,
218 memset(state, 0, size);