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 "ia_css_frame.h"
17 #include "sh_css_defs.h"
18 #include "ia_css_debug.h"
19 #include "sh_css_frac.h"
20 #include "assert_support.h"
21 #define IA_CSS_INCLUDE_CONFIGURATIONS
22 #include "ia_css_isp_configs.h"
25 #include "ia_css_tnr.host.h"
26 const struct ia_css_tnr_config default_tnr_config = {
34 struct sh_css_isp_tnr_params *to,
35 const struct ia_css_tnr_config *from,
40 uDIGIT_FITTING(from->gain, 16, SH_CSS_TNR_COEF_SHIFT);
42 uDIGIT_FITTING(from->threshold_y, 16, SH_CSS_ISP_YUV_BITS);
44 uDIGIT_FITTING(from->threshold_uv, 16, SH_CSS_ISP_YUV_BITS);
49 const struct sh_css_isp_tnr_params *tnr,
53 ia_css_debug_dtrace(level, "Temporal Noise Reduction:\n");
54 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
55 "tnr_coef", tnr->coef);
56 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
57 "tnr_threshold_Y", tnr->threshold_Y);
58 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
59 "tnr_threshold_C", tnr->threshold_C);
63 ia_css_tnr_debug_dtrace(
64 const struct ia_css_tnr_config *config,
67 ia_css_debug_dtrace(level,
69 "config.threshold_y=%d, config.threshold_uv=%d\n",
71 config->threshold_y, config->threshold_uv);
76 struct sh_css_isp_tnr_isp_config *to,
77 const struct ia_css_tnr_configuration *from,
80 unsigned elems_a = ISP_VEC_NELEMS;
84 ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info);
85 to->width_a_over_b = elems_a / to->port_b.elems;
86 to->frame_height = from->tnr_frames[0]->info.res.height;
88 for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++) {
90 for (i = 0; i < NUM_TNR_FRAMES; i++) {
92 to->tnr_frame_addr[i] = from->tnr_frames[i]->data + from->tnr_frames[i]->planes.yuyv.offset;
95 /* Assume divisiblity here, may need to generalize to fixed point. */
96 assert (elems_a % to->port_b.elems == 0);
100 ia_css_tnr_configure(
101 const struct ia_css_binary *binary,
102 const struct ia_css_frame **frames)
104 struct ia_css_tnr_configuration config;
108 for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++)
110 for (i = 0; i < NUM_TNR_FRAMES; i++)
112 config.tnr_frames[i] = frames[i];
114 ia_css_configure_tnr(binary, &config);
118 ia_css_init_tnr_state(
119 struct sh_css_isp_tnr_dmem_state *state,
125 assert(NUM_VIDEO_TNR_FRAMES >= 2);
127 assert(sizeof(*state) == size);
128 state->tnr_in_buf_idx = 0;
129 state->tnr_out_buf_idx = 1;