GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / bnr / bnr_1.0 / ia_css_bnr.host.c
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 #include "ia_css_debug.h"
18 #include "sh_css_frac.h"
19
20 #include "ia_css_bnr.host.h"
21
22 void
23 ia_css_bnr_encode(
24         struct sh_css_isp_bnr_params *to,
25         const struct ia_css_nr_config *from,
26         unsigned size)
27 {
28         (void)size;
29         /* BNR (Bayer Noise Reduction) */
30         to->threshold_low =
31             uDIGIT_FITTING(from->direction, 16, SH_CSS_BAYER_BITS);
32         to->threshold_width_log2 = uFRACTION_BITS_FITTING(8);
33         to->threshold_width =
34             1 << to->threshold_width_log2;
35         to->gain_all =
36             uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
37         to->gain_dir =
38             uDIGIT_FITTING(from->bnr_gain, 16, SH_CSS_BNR_GAIN_SHIFT);
39         to->clip = uDIGIT_FITTING((unsigned)16384, 16, SH_CSS_BAYER_BITS);
40 }
41
42 void
43 ia_css_bnr_dump(
44         const struct sh_css_isp_bnr_params *bnr,
45         unsigned level)
46 {
47         if (!bnr) return;
48         ia_css_debug_dtrace(level, "Bayer Noise Reduction:\n");
49         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
50                         "bnr_gain_all", bnr->gain_all);
51         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
52                         "bnr_gain_dir", bnr->gain_dir);
53         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
54                         "bnr_threshold_low",
55                         bnr->threshold_low);
56         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
57                         "bnr_threshold_width_log2",
58                         bnr->threshold_width_log2);
59         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
60                         "bnr_threshold_width",
61                         bnr->threshold_width);
62         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
63                         "bnr_clip", bnr->clip);
64 }