xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/hwi/isp20/Isp20_module_dbg.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (c) 2019 Rockchip Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include "Isp20_module_dbg.h"
19 #include "base/xcam_log.h"
20 #include "rk_isp20_hw.h"
21 
22 #ifdef RUNTIME_MODULE_DEBUG
23 /* bit 36 */
24 #define ALL_ISP_MODULES    RK_ISP2X_MAX_ID
25 /* bit 41 */
26 #define ALL_ISPP_MODULES   RK_ISP2X_PP_MAX_ID
27 /* bit 42 */
28 #define SENSOR_EXPOSURE_ID (ALL_ISPP_MODULES + 1)
29 /* bit 43 */
30 #define ONLY_INIT_PARAMS   (SENSOR_EXPOSURE_ID + 1)
31 
32 static const char* rkaiq_runtime_dbg_en = "rkaiq_runtime_dbg_en";
33 static const char* force_disable_modules_en = "force_disable_modules_en";
34 static const char* force_disable_modules_cfg_update = "force_disable_modules_cfg_update";
35 static const char* force_bypass_modules_params = "force_bypass_modules_params";
36 static const char* disable_algo_user_api_mask = "disable_algo_user_api_mask";
37 static unsigned long long g_disable_modules_en = 0x0;
38 static unsigned long long g_disable_modules_cfg_update = 0x0;
39 static unsigned long long g_bypass_module_params = 0;
40 
41 /* disable specific isp modules ennable or cfg_update */
42 unsigned long long g_disable_isp_modules_en = 0x0;
43 unsigned long long g_disable_isp_modules_cfg_update = 0x0;
44 /* disable specific ispp modules ennable or cfg_update */
45 int g_disable_ispp_modules_en = 0x0;
46 int g_disable_ispp_modules_cfg_update = 0x0;
47 /* not apply exposure params, including the first params */
48 int g_bypass_exp_params = 0;
49 /* not apply isp params, including the first params */
50 int g_bypass_isp_params = 0;
51 /* not apply ispp params, including the first params */
52 int g_bypass_ispp_params = 0;
53 /* just apply the init params, and bypass the latter params */
54 int g_apply_init_params_only = 0;
55 /* mask bit refer to RkAiqAlgoType_t in rk_aiq_algo_des.h */
56 uint64_t g_disable_algo_user_api_mask = 0x0ULL;
57 
get_rkaiq_runtime_dbg()58 int get_rkaiq_runtime_dbg()
59 {
60     unsigned long long rkaiq_runtime_dbg_en_tmp = 0x0;
61 
62     xcam_get_enviroment_value(rkaiq_runtime_dbg_en, &rkaiq_runtime_dbg_en_tmp);
63 
64     return (int)rkaiq_runtime_dbg_en_tmp;
65 }
66 
get_dbg_force_disable_mods_env()67 void get_dbg_force_disable_mods_env()
68 {
69     unsigned long long tmp = 0;
70     xcam_get_enviroment_value(disable_algo_user_api_mask, &tmp);
71     g_disable_algo_user_api_mask = (int)tmp;
72 
73     xcam_get_enviroment_value(force_bypass_modules_params, &g_bypass_module_params);
74 
75     if (g_bypass_module_params & (1ULL << SENSOR_EXPOSURE_ID))
76         g_bypass_exp_params = 1;
77     else
78         g_bypass_exp_params = 0;
79 
80     if (g_bypass_module_params & (1ULL << ALL_ISP_MODULES))
81         g_bypass_isp_params = 1;
82     else
83         g_bypass_isp_params = 0;
84 
85     if (g_bypass_module_params & (1ULL << ALL_ISPP_MODULES))
86         g_bypass_ispp_params = 1;
87     else
88         g_bypass_ispp_params = 0;
89     LOGI("ALL_ISP_MODULES %d, ALL_ISPP_MODULES %d,ONLY_INIT_PARAMS %d",
90          ALL_ISP_MODULES, ALL_ISPP_MODULES, ONLY_INIT_PARAMS);
91     LOGI("g_bypass_module_params 0x%llx", g_bypass_module_params);
92     if (g_bypass_module_params & (1ULL << ONLY_INIT_PARAMS))
93         g_apply_init_params_only = 1;
94     else
95         g_apply_init_params_only = 0;
96 
97     xcam_get_enviroment_value(force_disable_modules_en, &g_disable_modules_en);
98 
99     if (g_disable_modules_en & (1ULL << ALL_ISP_MODULES)) {
100         for (int i = 0; i < ALL_ISP_MODULES; i++)
101             g_disable_isp_modules_en |= 1ULL << i;
102     } else {
103         for (int i = 0; i < ALL_ISP_MODULES; i++) {
104             if (g_disable_modules_en & (1ULL << i))
105                 g_disable_isp_modules_en |= 1ULL << i;
106             else
107                 g_disable_isp_modules_en &= ~(1ULL << i);
108         }
109     }
110 
111     if (g_disable_modules_en & (1ULL << ALL_ISPP_MODULES)) {
112         for (int i = 0; i < ALL_ISPP_MODULES - ALL_ISP_MODULES; i++)
113             g_disable_ispp_modules_en |= 1ULL << i;
114 
115     } else {
116         for (int i = 0; i < ALL_ISPP_MODULES - ALL_ISP_MODULES; i++) {
117             if (g_disable_modules_en & (1ULL << (ALL_ISP_MODULES + 1 + i)))
118                 g_disable_ispp_modules_en |= 1ULL << i;
119             else
120                 g_disable_ispp_modules_en &= ~(1ULL << i);
121         }
122     }
123 
124     xcam_get_enviroment_value(force_disable_modules_cfg_update, &g_disable_modules_cfg_update);
125 
126     if (g_disable_modules_cfg_update & (1ULL << ALL_ISP_MODULES)) {
127         for (int i = 0; i < ALL_ISP_MODULES; i++)
128             g_disable_isp_modules_cfg_update |= 1ULL << i;
129     } else {
130         for (int i = 0; i < ALL_ISP_MODULES; i++) {
131             if (g_disable_modules_cfg_update & (1ULL << i))
132                 g_disable_isp_modules_cfg_update |= 1ULL << i;
133             else
134                 g_disable_isp_modules_cfg_update &= ~(1ULL << i);
135         }
136     }
137 
138     if (g_disable_modules_cfg_update & (1ULL << ALL_ISPP_MODULES)) {
139         for (int i = 0; i < ALL_ISPP_MODULES - ALL_ISP_MODULES; i++)
140             g_disable_ispp_modules_cfg_update |= 1 << i;
141 
142     } else {
143         for (int i = 0; i < ALL_ISPP_MODULES - ALL_ISP_MODULES; i++) {
144             if (g_disable_modules_cfg_update & (1ULL << (ALL_ISP_MODULES + 1 + i)))
145                 g_disable_ispp_modules_cfg_update |= 1 << i;
146             else
147                 g_disable_ispp_modules_cfg_update &= ~(1 << i);
148         }
149     }
150 
151     LOGI("isp(en:0x%llx, cfg_up:0x%llx, bypass:%d),\n"
152          "ispp(en:0x%x, cfg_up:0x%x, bypass:%d),\n"
153          "exp_byapss:%d, init_params_only:%d",
154          g_disable_isp_modules_en, g_disable_isp_modules_cfg_update, g_bypass_isp_params,
155          g_disable_ispp_modules_en, g_disable_ispp_modules_cfg_update, g_bypass_ispp_params,
156          g_bypass_exp_params, g_apply_init_params_only);
157 }
158 
159 #endif
160