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 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 44 ia_css_bnr_dump( 45 const struct sh_css_isp_bnr_params *bnr, 46 unsigned int level) 47 { 48 if (!bnr) return; 49 ia_css_debug_dtrace(level, "Bayer Noise Reduction:\n"); 50 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 51 "bnr_gain_all", bnr->gain_all); 52 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 53 "bnr_gain_dir", bnr->gain_dir); 54 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 55 "bnr_threshold_low", 56 bnr->threshold_low); 57 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 58 "bnr_threshold_width_log2", 59 bnr->threshold_width_log2); 60 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 61 "bnr_threshold_width", 62 bnr->threshold_width); 63 ia_css_debug_dtrace(level, "\t%-32s = %d\n", 64 "bnr_clip", bnr->clip); 65 } 66