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_AGAIN_ALGO_INT_V2_H_
21 #define _RK_AIQ_TYPE_AGAIN_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 "again2/rk_aiq_types_again_algo_v2.h"
29 #include "gain_head_v2.h"
30 #include "gain_uapi_head_v2.h"
31 
32 //RKAIQ_BEGIN_DECLARE
33 #define RK_GAIN_V2_MAX_ISO_NUM  CALIBDB_MAX_ISO_LEVEL
34 
35 
36 #define AGAINV2_RECALCULATE_DELTA_ISO       (10)
37 
38 #define     GAIN_BAYERTNR_IN_BITS_INTE          0
39 
40 
41 #define     GAIN_HDR_MERGE_IN_FIX_BITS_DECI             6
42 #define     GAIN_HDR_MERGE_IN0_FIX_BITS_INTE            8
43 #define     GAIN_HDR_MERGE_IN1_FIX_BITS_INTE            8
44 #define     GAIN_HDR_MERGE_IN2_FIX_BITS_INTE            12
45 
46 
47 typedef enum Again_result_V2_e {
48     AGAINV2_RET_SUCCESS             = 0,   // this has to be 0, if clauses rely on it
49     AGAINV2_RET_FAILURE             = 1,   // process failure
50     AGAINV2_RET_INVALID_PARM        = 2,   // invalid parameter
51     AGAINV2_RET_WRONG_CONFIG        = 3,   // feature not supported
52     AGAINV2_RET_BUSY                = 4,   // there's already something going on...
53     AGAINV2_RET_CANCELED            = 5,   // operation canceled
54     AGAINV2_RET_OUTOFMEM            = 6,   // out of memory
55     AGAINV2_RET_OUTOFRANGE          = 7,   // parameter/value out of range
56     AGAINV2_RET_NULL_POINTER        = 8,   // the/one/all parameter(s) is a(are) NULL pointer(s)
57     AGAINV2_RET_DIVISION_BY_ZERO    = 9,   // a divisor equals ZERO
58     AGAINV2_RET_NO_INPUTIMAGE       = 10   // no input image
59 } Again_result_V2_t;
60 
61 typedef enum Again_State_V2_e {
62     AGAINV2_STATE_INVALID           = 0,                   /**< initialization value */
63     AGAINV2_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
64     AGAINV2_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
65     AGAINV2_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
66     AGAINV2_STATE_LOCKED            = 4,                   /**< instance is locked (for taking snapshots) */
67     AGAINV2_STATE_MAX                                      /**< max */
68 } Again_State_V2_t;
69 
70 typedef enum Again_OPMode_V2_e {
71     AGAINV2_OP_MODE_INVALID           = 0,                   /**< initialization value */
72     AGAINV2_OP_MODE_AUTO              = 1,                   /**< instance is created, but not initialized */
73     AGAINV2_OP_MODE_MANUAL            = 2,                   /**< instance is confiured (ready to start) or stopped */
74     AGAINV2_OP_MODE_MAX                                      /**< max */
75 } Again_OPMode_V2_t;
76 
77 typedef enum Again_ParamMode_V2_e {
78     AGAINV2_PARAM_MODE_INVALID           = 0,
79     AGAINV2_PARAM_MODE_NORMAL          = 1,                   /**< initialization value */
80     AGAINV2_PARAM_MODE_HDR              = 2,                   /**< instance is created, but not initialized */
81     AGAINV2_PARAM_MODE_GRAY            = 3,                   /**< instance is confiured (ready to start) or stopped */
82     AGAINV2_PARAM_MODE_MAX                                      /**< max */
83 } Again_ParamMode_V2_t;
84 
85 
86 
87 #if 0
88 typedef struct RK_GAIN_Select_V2_s
89 {
90     bool hdrgain_ctrl_enable;
91     float hdr_gain_scale_s;
92     float hdr_gain_scale_m;
93 
94 } RK_GAIN_Select_V2_t;
95 #endif
96 
97 typedef struct RK_GAIN_Params_V2_s
98 {   bool hdrgain_ctrl_enable;
99     int iso[RK_GAIN_V2_MAX_ISO_NUM];
100     RK_GAIN_Select_V2_t iso_params[RK_GAIN_V2_MAX_ISO_NUM];
101 } RK_GAIN_Params_V2_t;
102 
103 
104 typedef struct Again_Manual_Attr_V2_s
105 {
106     RK_GAIN_Select_V2_t stSelect;
107     RK_GAIN_Fix_V2_t stFix;
108 } Again_Manual_Attr_V2_t;
109 
110 typedef struct AgainV2_Auto_Attr_V2_s
111 {
112     //all ISO params and select param
113 
114     RK_GAIN_Params_V2_t stParams;
115     RK_GAIN_Select_V2_t stSelect;
116 
117 } Again_Auto_Attr_V2_t;
118 
119 typedef struct AgainV2_ProcResult_V2_s {
120     //for sw simultaion
121     //RK_GAIN_Select_V2_t stSelect;
122 
123     //for hw register
124     RK_GAIN_Fix_V2_t* stFix;
125 
126 } Again_ProcResult_V2_t;
127 
128 
129 typedef struct Again_Config_V2_s {
130     Again_State_V2_t eState;
131     Again_OPMode_V2_t eMode;
132 } Again_Config_V2_t;
133 
134 
135 typedef struct rk_aiq_gain_attrib_v2_s {
136     rk_aiq_uapi_sync_t sync;
137     Again_OPMode_V2_t eMode;
138     Again_Auto_Attr_V2_t stAuto;
139     Again_Manual_Attr_V2_t stManual;
140 } rk_aiq_gain_attrib_v2_t;
141 
142 
143 //RKAIQ_END_DECLARE
144 
145 #endif
146 
147