1 /*
2  *rk_aiq_types_alsc_algo_int.h
3  *
4  *  Copyright (c) 2019 Rockchip Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 
20 #ifndef _RK_AIQ_TYPE_ABAYER2DNR_ALGO_INT_V2_H_
21 #define _RK_AIQ_TYPE_ABAYER2DNR_ALGO_INT_V2_H_
22 
23 #include <math.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include "rk_aiq_comm.h"
27 #include "RkAiqCalibDbTypes.h"
28 #include "abayer2dnr2/rk_aiq_types_abayer2dnr_algo_v2.h"
29 #include "bayer2dnr_head_v2.h"
30 #include "bayer2dnr_uapi_head_v2.h"
31 
32 
33 //RKAIQ_BEGIN_DECLARE
34 
35 //#define RK_BAYER2DNR_V2_MAX_ISO_NUM  CALIBDB_MAX_ISO_LEVEL
36 #define ABAYER2DNRV2_DELTA_ISO (10)
37 
38 typedef enum Abayer2dnr_result_V2_e {
39     ABAYER2DNR_RET_SUCCESS             = 0,   // this has to be 0, if clauses rely on it
40     ABAYER2DNR_RET_FAILURE             = 1,   // process failure
41     ABAYER2DNR_RET_INVALID_PARM        = 2,   // invalid parameter
42     ABAYER2DNR_RET_WRONG_CONFIG        = 3,   // feature not supported
43     ABAYER2DNR_RET_BUSY                = 4,   // there's already something going on...
44     ABAYER2DNR_RET_CANCELED            = 5,   // operation canceled
45     ABAYER2DNR_RET_OUTOFMEM            = 6,   // out of memory
46     ABAYER2DNR_RET_OUTOFRANGE          = 7,   // parameter/value out of range
47     ABAYER2DNR_RET_NULL_POINTER        = 8,   // the/one/all parameter(s) is a(are) NULL pointer(s)
48     ABAYER2DNR_RET_DIVISION_BY_ZERO    = 9,   // a divisor equals ZERO
49     ABAYER2DNR_RET_NO_INPUTIMAGE       = 10   // no input image
50 } Abayer2dnr_result_V2_t;
51 
52 typedef enum Abayer2dnr_State_V2_e {
53     ABAYER2DNR_STATE_INVALID           = 0,                   /**< initialization value */
54     ABAYER2DNR_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
55     ABAYER2DNR_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
56     ABAYER2DNR_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
57     ABAYER2DNR_STATE_LOCKED            = 4,                   /**< instance is locked (for taking snapshots) */
58     ABAYER2DNR_STATE_MAX                                      /**< max */
59 } Abayer2dnr_State_V2_t;
60 
61 typedef enum Abayer2dnr_OPMode_V2_e {
62     ABAYER2DNR_OP_MODE_INVALID           = 0,                   /**< initialization value */
63     ABAYER2DNR_OP_MODE_AUTO              = 1,                   /**< instance is created, but not initialized */
64     ABAYER2DNR_OP_MODE_MANUAL            = 2,                   /**< instance is confiured (ready to start) or stopped */
65     ABAYER2DNR_OP_MODE_REG_MANUAL        = 3,                   /**< instance is confiured (ready to start) or stopped */
66     ABAYER2DNR_OP_MODE_MAX                                      /**< max */
67 } Abayer2dnr_OPMode_V2_t;
68 
69 typedef enum Abayer2dnr_ParamMode_V2_e {
70     ABAYER2DNR_PARAM_MODE_INVALID           = 0,
71     ABAYER2DNR_PARAM_MODE_NORMAL          = 1,                   /**< initialization value */
72     ABAYER2DNR_PARAM_MODE_HDR              = 2,                   /**< instance is created, but not initialized */
73     ABAYER2DNR_PARAM_MODE_GRAY            = 3,                   /**< instance is confiured (ready to start) or stopped */
74     ABAYER2DNR_PARAM_MODE_MAX                                      /**< max */
75 } Abayer2dnr_ParamMode_V2_t;
76 
77 
78 
79 
80 #if 0
81 
82 typedef struct RK_Bayer2dnr_Params_V2_s
83 {
84     // bayernr version
85     int enable;
86 
87     bool hdrdgain_ctrl_en;
88 
89     // v2 parse
90     float iso[RK_BAYER2DNR_V2_MAX_ISO_NUM];
91 
92     int   lumapoint[16];
93     int   sigma[RK_BAYER2DNR_V2_MAX_ISO_NUM][16];
94 
95     float filter_strength[RK_BAYER2DNR_V2_MAX_ISO_NUM];
96     float edgesofts[RK_BAYER2DNR_V2_MAX_ISO_NUM];
97     float ratio[RK_BAYER2DNR_V2_MAX_ISO_NUM];
98     float weight[RK_BAYER2DNR_V2_MAX_ISO_NUM];
99     int   gauss_guide[RK_BAYER2DNR_V2_MAX_ISO_NUM];
100 
101     int pix_diff[RK_BAYER2DNR_V2_MAX_ISO_NUM];
102     int diff_thld[RK_BAYER2DNR_V2_MAX_ISO_NUM];
103 
104     float hdr_dgain_scale_s[RK_BAYER2DNR_V2_MAX_ISO_NUM];
105     float hdr_dgain_scale_m[RK_BAYER2DNR_V2_MAX_ISO_NUM];
106 
107 } RK_Bayer2dnr_Params_V2_t;
108 
109 
110 typedef struct RK_Bayer2dnr_Params_V2_Select_s
111 {
112     // v2 version register // edge filter params
113     int enable;
114     bool hdrdgain_ctrl_en;
115 
116     int lumapoint[16];
117     int sigma[16];
118 
119     float filter_strength;
120     float edgesofts;
121     float ratio;
122     float weight;
123     int gauss_guide;
124 
125     int pix_diff;
126     int diff_thld;
127 
128     float hdr_dgain_scale_s;
129     float hdr_dgain_scale_m;
130 
131 
132 } RK_Bayer2dnr_Params_V2_Select_t;
133 #endif
134 
135 typedef struct Abayer2dnr_Manual_Attr_V2_s
136 {
137     RK_Bayer2dnr_Params_V2_Select_t st2DSelect;
138     RK_Bayer2dnr_Fix_V2_t st2Dfix;
139 
140 } Abayer2dnr_Manual_Attr_V2_t;
141 
142 typedef struct Abayer2dnr_Auto_Attr_V2_s
143 {
144     //all ISO params and select param
145 
146     RK_Bayer2dnr_Params_V2_t st2DParams;
147     RK_Bayer2dnr_Params_V2_Select_t st2DSelect;
148 
149 } Abayer2dnr_Auto_Attr_V2_t;
150 
151 typedef struct Abayer2dnr_ProcResult_V2_s {
152 
153     //for sw simultaion
154     //RK_Bayer2dnr_Params_V2_Select_t st2DSelect;
155 
156     //for hw register
157     RK_Bayer2dnr_Fix_V2_t* st2DFix;
158 } Abayer2dnr_ProcResult_V2_t;
159 
160 
161 typedef struct Abayer2dnr_Config_V2_s {
162     Abayer2dnr_State_V2_t eState;
163     Abayer2dnr_OPMode_V2_t eMode;
164 } Abayer2dnr_Config_V2_t;
165 
166 
167 typedef struct rk_aiq_bayer2dnr_attrib_v2_s {
168     rk_aiq_uapi_sync_t sync;
169 
170     Abayer2dnr_OPMode_V2_t eMode;
171     Abayer2dnr_Auto_Attr_V2_t stAuto;
172     Abayer2dnr_Manual_Attr_V2_t stManual;
173 } rk_aiq_bayer2dnr_attrib_v2_t;
174 
175 
176 typedef struct rk_aiq_bayer2dnr_strength_v2_s {
177     rk_aiq_uapi_sync_t sync;
178     float percent;
179     bool strength_enable;
180 } rk_aiq_bayer2dnr_strength_v2_t;
181 
182 
183 
184 //RKAIQ_END_DECLARE
185 
186 #endif
187 
188