1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16 #include "ia_css_types.h"
17 #include "sh_css_defs.h"
18 #include "ia_css_debug.h"
19 #include "sh_css_frac.h"
20
21 #include "ia_css_bnr.host.h"
22
23 void
ia_css_bnr_encode(struct sh_css_isp_bnr_params * to,const struct ia_css_nr_config * from,unsigned int size)24 ia_css_bnr_encode(
25 struct sh_css_isp_bnr_params *to,
26 const struct ia_css_nr_config *from,
27 unsigned int size)
28 {
29 (void)size;
30 /* BNR (Bayer Noise Reduction) */
31 to->threshold_low =
32 uDIGIT_FITTING(from->direction, 16, SH_CSS_BAYER_BITS);
33 to->threshold_width_log2 = uFRACTION_BITS_FITTING(8);
34 to->threshold_width =
35 1 << to->threshold_width_log2;
36 to->gain_all =
37 uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
38 to->gain_dir =
39 uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
40 to->clip = uDIGIT_FITTING(16384U, 16, SH_CSS_BAYER_BITS);
41 }
42
43 void
ia_css_bnr_dump(const struct sh_css_isp_bnr_params * bnr,unsigned int level)44 ia_css_bnr_dump(
45 const struct sh_css_isp_bnr_params *bnr,
46 unsigned int level)
47 {
48 if (!bnr)
49 return;
50 ia_css_debug_dtrace(level, "Bayer Noise Reduction:\n");
51 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
52 "bnr_gain_all", bnr->gain_all);
53 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
54 "bnr_gain_dir", bnr->gain_dir);
55 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
56 "bnr_threshold_low",
57 bnr->threshold_low);
58 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
59 "bnr_threshold_width_log2",
60 bnr->threshold_width_log2);
61 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
62 "bnr_threshold_width",
63 bnr->threshold_width);
64 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
65 "bnr_clip", bnr->clip);
66 }
67