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_ABAYERTNRV2_ALGO_INT_H_
21 #define _RK_AIQ_TYPE_ABAYERTNRV2_ALGO_INT_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 "abayertnr2/rk_aiq_types_abayertnr_algo_v2.h"
29 #include "bayertnr_head_v2.h"
30 #include "bayertnr_uapi_head_v2.h"
31 
32 
33 //RKAIQ_BEGIN_DECLARE
34 
35 #define ABAYERTNRV2_DELTA_ISO (10)
36 
37 typedef enum Abayertnr_result_V2_e {
38     ABAYERTNRV2_RET_SUCCESS             = 0,   // this has to be 0, if clauses rely on it
39     ABAYERTNRV2_RET_FAILURE             = 1,   // process failure
40     ABAYERTNRV2_RET_INVALID_PARM        = 2,   // invalid parameter
41     ABAYERTNRV2_RET_WRONG_CONFIG        = 3,   // feature not supported
42     ABAYERTNRV2_RET_BUSY                = 4,   // there's already something going on...
43     ABAYERTNRV2_RET_CANCELED            = 5,   // operation canceled
44     ABAYERTNRV2_RET_OUTOFMEM            = 6,   // out of memory
45     ABAYERTNRV2_RET_OUTOFRANGE          = 7,   // parameter/value out of range
46     ABAYERTNRV2_RET_NULL_POINTER        = 8,   // the/one/all parameter(s) is a(are) NULL pointer(s)
47     ABAYERTNRV2_RET_DIVISION_BY_ZERO    = 9,   // a divisor equals ZERO
48     ABAYERTNRV2_RET_NO_INPUTIMAGE       = 10   // no input image
49 } Abayertnr_result_V2_t;
50 
51 typedef enum Abayertnr_State_V2_e {
52     ABAYERTNRV2_STATE_INVALID           = 0,                   /**< initialization value */
53     ABAYERTNRV2_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
54     ABAYERTNRV2_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
55     ABAYERTNRV2_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
56     ABAYERTNRV2_STATE_LOCKED            = 4,                   /**< instance is locked (for taking snapshots) */
57     ABAYERTNRV2_STATE_MAX                                      /**< max */
58 } Abayertnr_State_V2_t;
59 
60 typedef enum Abayertnr_OPMode_V2_e {
61     ABAYERTNRV2_OP_MODE_INVALID           = 0,                   /**< initialization value */
62     ABAYERTNRV2_OP_MODE_AUTO              = 1,                   /**< instance is created, but not initialized */
63     ABAYERTNRV2_OP_MODE_MANUAL            = 2,                   /**< instance is confiured (ready to start) or stopped */
64     ABAYERTNRV2_OP_MODE_REG_MANUAL        = 3,
65     ABAYERTNRV2_OP_MODE_MAX                                      /**< max */
66 } Abayertnr_OPMode_V2_t;
67 
68 typedef enum Abayertnr_ParamMode_V2_e {
69     ABAYERTNRV2_PARAM_MODE_INVALID           = 0,
70     ABAYERTNRV2_PARAM_MODE_NORMAL          = 1,                   /**< initialization value */
71     ABAYERTNRV2_PARAM_MODE_HDR              = 2,                   /**< instance is created, but not initialized */
72     ABAYERTNRV2_PARAM_MODE_GRAY            = 3,                   /**< instance is confiured (ready to start) or stopped */
73     ABAYERTNRV2_PARAM_MODE_MAX                                      /**< max */
74 } Abayertnr_ParamMode_V2_t;
75 
76 
77 
78 
79 typedef struct RK_Bayertnr_Params_V2_s
80 {
81     int enable;
82 
83     float iso[RK_BAYERNR_V2_MAX_ISO_NUM];
84 
85     //calib
86     int   lumapoint[16];
87     int   sigma[RK_BAYERNR_V2_MAX_ISO_NUM][16];
88     int   lumapoint2[16];
89     int   lo_sigma[RK_BAYERNR_V2_MAX_ISO_NUM][16];
90     int   hi_sigma[RK_BAYERNR_V2_MAX_ISO_NUM][16];
91 
92     //tuning
93     int   thumbds[RK_BAYERNR_V2_MAX_ISO_NUM];
94 
95     int   lo_enable[RK_BAYERNR_V2_MAX_ISO_NUM];
96     int   hi_enable[RK_BAYERNR_V2_MAX_ISO_NUM];
97     int   lo_med_en[RK_BAYERNR_V2_MAX_ISO_NUM];
98     int   lo_gsbay_en[RK_BAYERNR_V2_MAX_ISO_NUM];
99     int   lo_gslum_en[RK_BAYERNR_V2_MAX_ISO_NUM];
100     int   hi_med_en[RK_BAYERNR_V2_MAX_ISO_NUM];
101     int   hi_gslum_en[RK_BAYERNR_V2_MAX_ISO_NUM];
102     int   global_pk_en[RK_BAYERNR_V2_MAX_ISO_NUM];
103     int   global_pksq[RK_BAYERNR_V2_MAX_ISO_NUM];
104 
105     float lo_filter_strength[RK_BAYERNR_V2_MAX_ISO_NUM];
106     float hi_filter_strength[RK_BAYERNR_V2_MAX_ISO_NUM];
107     float soft_threshold_ratio[RK_BAYERNR_V2_MAX_ISO_NUM];
108     float hi_wgt_comp[RK_BAYERNR_V2_MAX_ISO_NUM];
109     float clipwgt[RK_BAYERNR_V2_MAX_ISO_NUM];
110     float hidif_th[RK_BAYERNR_V2_MAX_ISO_NUM];
111 } RK_Bayertnr_Params_V2_t;
112 
113 #if 0
114 typedef struct RK_Bayertnr_Params_V2_Select_s
115 {
116     int enable;
117 
118     //calib
119     int lumapoint[16];
120     int sigma[16];
121     int lumapoint2[16];
122     int lo_sigma[16];
123     int hi_sigma[16];
124 
125     //tuning
126     int thumbds;
127     int lo_enable;
128     int hi_enable;
129     int lo_med_en;
130     int lo_gsbay_en;
131     int lo_gslum_en;
132     int hi_med_en;
133     int hi_gslum_en;
134     int global_pk_en;
135     int global_pksq;
136 
137     float lo_filter_strength;
138     float hi_filter_strength;
139     float soft_threshold_ratio;
140 
141     float clipwgt;
142     float hi_wgt_comp;
143     float hidif_th;
144 } RK_Bayertnr_Params_V2_Select_t;
145 #endif
146 
147 typedef struct Abayertnr_Manual_Attr_V2_s
148 {
149     RK_Bayertnr_Params_V2_Select_t st3DSelect;
150 
151     RK_Bayertnr_Fix_V2_t st3DFix;
152 } Abayertnr_Manual_Attr_V2_t;
153 
154 typedef struct Abayertnr_Auto_Attr_V2_s
155 {
156     //all ISO params and select param
157 
158     RK_Bayertnr_Params_V2_t st3DParams;
159     RK_Bayertnr_Params_V2_Select_t st3DSelect;
160 
161 } Abayertnr_Auto_Attr_V2_t;
162 
163 typedef struct Abayertnr_ProcResult_V2_s {
164 
165     //for sw simultaion
166     //RK_Bayertnr_Params_V2_Select_t st3DSelect;
167 
168     //for hw register
169     RK_Bayertnr_Fix_V2_t* st3DFix;
170 } Abayertnr_ProcResult_V2_t;
171 
172 
173 typedef struct Abayertnr_Config_V2_s {
174     Abayertnr_State_V2_t eState;
175     Abayertnr_OPMode_V2_t eMode;
176 } Abayertnr_Config_V2_t;
177 
178 
179 typedef struct rk_aiq_bayertnr_attrib_v2_s {
180     rk_aiq_uapi_sync_t sync;
181     Abayertnr_OPMode_V2_t eMode;
182     Abayertnr_Auto_Attr_V2_t stAuto;
183     Abayertnr_Manual_Attr_V2_t stManual;
184 } rk_aiq_bayertnr_attrib_v2_t;
185 
186 typedef struct rk_aiq_bayertnr_strength_v2_s {
187     rk_aiq_uapi_sync_t sync;
188     float percent;
189     bool strength_enable;
190 } rk_aiq_bayertnr_strength_v2_t;
191 
192 
193 //RKAIQ_END_DECLARE
194 
195 #endif
196 
197