1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include "ia_css_types.h"
17#include "ia_css_frame.h"
18#include "sh_css_defs.h"
19#include "ia_css_debug.h"
20#include "sh_css_frac.h"
21#include "assert_support.h"
22#define IA_CSS_INCLUDE_CONFIGURATIONS
23#include "ia_css_isp_configs.h"
24#include "isp.h"
25
26#include "ia_css_tnr.host.h"
27const struct ia_css_tnr_config default_tnr_config = {
28 32768,
29 32,
30 32,
31};
32
33void
34ia_css_tnr_encode(
35 struct sh_css_isp_tnr_params *to,
36 const struct ia_css_tnr_config *from,
37 unsigned int size)
38{
39 (void)size;
40 to->coef =
41 uDIGIT_FITTING(from->gain, 16, SH_CSS_TNR_COEF_SHIFT);
42 to->threshold_Y =
43 uDIGIT_FITTING(from->threshold_y, 16, SH_CSS_ISP_YUV_BITS);
44 to->threshold_C =
45 uDIGIT_FITTING(from->threshold_uv, 16, SH_CSS_ISP_YUV_BITS);
46}
47
48void
49ia_css_tnr_dump(
50 const struct sh_css_isp_tnr_params *tnr,
51 unsigned int level)
52{
53 if (!tnr) return;
54 ia_css_debug_dtrace(level, "Temporal Noise Reduction:\n");
55 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
56 "tnr_coef", tnr->coef);
57 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
58 "tnr_threshold_Y", tnr->threshold_Y);
59 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
60 "tnr_threshold_C", tnr->threshold_C);
61}
62
63void
64ia_css_tnr_debug_dtrace(
65 const struct ia_css_tnr_config *config,
66 unsigned int level)
67{
68 ia_css_debug_dtrace(level,
69 "config.gain=%d, config.threshold_y=%d, config.threshold_uv=%d\n",
70 config->gain,
71 config->threshold_y, config->threshold_uv);
72}
73
74void
75ia_css_tnr_config(
76 struct sh_css_isp_tnr_isp_config *to,
77 const struct ia_css_tnr_configuration *from,
78 unsigned int size)
79{
80 unsigned int elems_a = ISP_VEC_NELEMS;
81 unsigned int i;
82
83 (void)size;
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;
87 for (i = 0; i < NUM_TNR_FRAMES; i++) {
88 to->tnr_frame_addr[i] = from->tnr_frames[i]->data +
89 from->tnr_frames[i]->planes.yuyv.offset;
90 }
91
92
93 assert(elems_a % to->port_b.elems == 0);
94}
95
96void
97ia_css_tnr_configure(
98 const struct ia_css_binary *binary,
99 const struct ia_css_frame * const *frames)
100{
101 struct ia_css_tnr_configuration config;
102 unsigned int i;
103
104 for (i = 0; i < NUM_TNR_FRAMES; i++)
105 config.tnr_frames[i] = frames[i];
106
107 ia_css_configure_tnr(binary, &config);
108}
109
110void
111ia_css_init_tnr_state(
112 struct sh_css_isp_tnr_dmem_state *state,
113 size_t size)
114{
115 (void)size;
116
117 assert(NUM_TNR_FRAMES >= 2);
118 assert(sizeof(*state) == size);
119 state->tnr_in_buf_idx = 0;
120 state->tnr_out_buf_idx = 1;
121}
122