1 /*
2 * rk_aiq_types_adebayer_algo_prvt.h
3 
4 * for rockchip v2.0.0
5 *
6 *  Copyright (c) 2019 Rockchip Corporation
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21 /* for rockchip v2.0.0*/
22 
23 #ifndef __RKAIQ_TYPES_ADEBAYER_ALGO_PRVT_H__
24 #define __RKAIQ_TYPES_ADEBAYER_ALGO_PRVT_H__
25 
26 /**
27  * @file rk_aiq_types_adebayer_algo_prvt.h
28  *
29  * @brief
30  *
31  *****************************************************************************/
32 /**
33  * @page module_name_page Module Name
34  * Describe here what this module does.
35  *
36  * For a detailed list of functions and implementation detail refer to:
37  * - @ref module_name
38  *
39  * @defgroup ADEBAYER Auto debayer
40  * @{
41  *
42  */
43 #include <atomic>
44 #include "rk_aiq_types_adebayer_algo_int.h"
45 #include "RkAiqCalibDbTypes.h"
46 #include "RkAiqCalibDbTypesV2.h"
47 #include "RkAiqCalibDbV2Helper.h"
48 #include "xcam_log.h"
49 
50 #define INTERP_DEBAYER_V2(x0, x1, ratio)    ((ratio) * ((x1) - (x0)) + x0)
51 #define LOG2(x)                             (log((double)x) / log((double)2))
52 
53 #define RK_DEBAYER_ISO_STEP_MAX 13
54 
55 
56 typedef enum AdebayerState_e {
57     ADEBAYER_STATE_INVALID           = 0,
58     ADEBAYER_STATE_INITIALIZED       = 1,
59     ADEBAYER_STATE_STOPPED           = 2,
60     ADEBAYER_STATE_RUNNING           = 3,
61     ADEBAYER_STATE_LOCKED            = 4,
62     ADEBAYER_STATE_MAX
63 } AdebayerState_t;
64 
65 typedef struct AdebayerFullParam_s {
66     unsigned char enable;
67     int iso[9];
68     signed char filter1[5];
69     signed char filter2[5];
70     unsigned char gain_offset;
71     unsigned char sharp_strength[9];
72     unsigned char offset;
73     unsigned short hf_offset[9];
74     unsigned char clip_en;
75     unsigned char filter_g_en;
76     unsigned char filter_c_en;
77     unsigned char thed0;
78     unsigned char thed1;
79     unsigned char dist_scale;
80     unsigned char cnr_strength;
81     unsigned char shift_num;
82 } AdebayerFullParam_t;
83 
84 typedef struct AdebayerContext_s {
85     std::atomic<bool> is_reconfig; //used for api
86     AdebayerState_t state;
87     rk_aiq_debayer_op_mode_t mode;
88 
89 
90 #if RKAIQ_HAVE_DEBAYER_V1
91     AdebayerHwConfigV1_t config; //result params
92     AdebayerFullParam_t full_param; //json params
93     AdebayerSeletedParamV1_t manualAttrib;
94 #endif
95 
96 #if RKAIQ_HAVE_DEBAYER_V2
97     AdebayerHwConfigV2_t config; //result params
98     CalibDbV2_Debayer_Tuning_t full_param_v2; //json params
99     AdebayerSeletedParamV2_t   select_param_v2;//actually use params
100 #endif
101 
102 #if RKAIQ_HAVE_DEBAYER_V2_LITE
103     AdebayerHwConfigV2_t config; //result params
104     CalibDbV2_Debayer_Tuning_Lite_t full_param_v2_lite; //json params
105     AdebayerSeletedParamV2Lite_t   select_param_v2_lite;//actually use params
106 #endif
107 
108     int iso;
109 } AdebayerContext_t;
110 
111 typedef struct _RkAiqAlgoContext {
112     AdebayerContext_t adebayerCtx;
113 } RkAiqAlgoContext;
114 
115 #endif//__RKAIQ_TYPES_ADEBAYER_ALGO_PRVT_H__
116