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 "ia_css_debug.h"
10 #include "sh_css_frac.h"
11
12 #include "ia_css_bnr.host.h"
13
14 void
ia_css_bnr_encode(struct sh_css_isp_bnr_params * to,const struct ia_css_nr_config * from,unsigned int size)15 ia_css_bnr_encode(
16 struct sh_css_isp_bnr_params *to,
17 const struct ia_css_nr_config *from,
18 unsigned int size)
19 {
20 (void)size;
21 /* BNR (Bayer Noise Reduction) */
22 to->threshold_low =
23 uDIGIT_FITTING(from->direction, 16, SH_CSS_BAYER_BITS);
24 to->threshold_width_log2 = uFRACTION_BITS_FITTING(8);
25 to->threshold_width =
26 1 << to->threshold_width_log2;
27 to->gain_all =
28 uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
29 to->gain_dir =
30 uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
31 to->clip = uDIGIT_FITTING(16384U, 16, SH_CSS_BAYER_BITS);
32 }
33
34 void
ia_css_bnr_dump(const struct sh_css_isp_bnr_params * bnr,unsigned int level)35 ia_css_bnr_dump(
36 const struct sh_css_isp_bnr_params *bnr,
37 unsigned int level)
38 {
39 if (!bnr)
40 return;
41 ia_css_debug_dtrace(level, "Bayer Noise Reduction:\n");
42 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
43 "bnr_gain_all", bnr->gain_all);
44 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
45 "bnr_gain_dir", bnr->gain_dir);
46 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
47 "bnr_threshold_low",
48 bnr->threshold_low);
49 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
50 "bnr_threshold_width_log2",
51 bnr->threshold_width_log2);
52 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
53 "bnr_threshold_width",
54 bnr->threshold_width);
55 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
56 "bnr_clip", bnr->clip);
57 }
58