1 /* 2 * x3a_isp_config.h - 3A ISP config 3 * 4 * Copyright (c) 2014-2015 Intel 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 * Author: Wind Yuan <feng.yuan (at) intel.com> 19 */ 20 21 #include "x3a_isp_config.h" 22 #include "isp_config_translator.h" 23 24 namespace XCam { 25 26 void AtomIspConfigContent::clear () 27 { 28 memset (this, 0, sizeof (AtomIspConfigContent)); 29 } 30 31 void 32 AtomIspConfigContent::copy (const struct atomisp_parameters &config) 33 { 34 xcam_mem_clear (isp_config); 35 if (config.wb_config) { 36 wb = *config.wb_config; 37 isp_config.wb_config = &wb; 38 } 39 if (config.cc_config) { 40 cc = *config.cc_config; 41 isp_config.cc_config = &cc; 42 } 43 if (config.tnr_config) { 44 tnr = *config.tnr_config; 45 isp_config.tnr_config = &tnr; 46 } 47 if (config.ecd_config) { 48 ecd_config = *config.ecd_config; 49 isp_config.ecd_config = &ecd_config; 50 } 51 if (config.ynr_config) { 52 ynr = *config.ynr_config; 53 isp_config.ynr_config = &ynr; 54 } 55 if (config.fc_config) { 56 fc_config = *config.fc_config; 57 isp_config.fc_config = &fc_config; 58 } 59 if (config.cnr_config) { 60 cnr = *config.cnr_config; 61 isp_config.cnr_config = &cnr; 62 } 63 if (config.macc_config) { 64 macc_config = *config.macc_config; 65 isp_config.macc_config = &macc_config; 66 } 67 if (config.ctc_config) { 68 ctc_config = *config.ctc_config; 69 isp_config.ctc_config = &ctc_config; 70 } 71 if (config.formats_config) { 72 formats = *config.formats_config; 73 isp_config.formats_config = &formats; 74 } 75 if (config.aa_config) { 76 aa = *config.aa_config; 77 isp_config.aa_config = &aa; 78 } 79 if (config.baa_config) { 80 baa = *config.baa_config; 81 isp_config.baa_config = &baa; 82 } 83 if (config.ce_config) { 84 ce = *config.ce_config; 85 isp_config.ce_config = &ce; 86 } 87 if (config.dvs_6axis_config) { 88 dvs_6axis = *config.dvs_6axis_config; 89 isp_config.dvs_6axis_config = &dvs_6axis; 90 } 91 if (config.ob_config) { 92 ob = *config.ob_config; 93 isp_config.ob_config = &ob; 94 } 95 if (config.nr_config) { 96 nr = *config.nr_config; 97 isp_config.nr_config = &nr; 98 } 99 if (config.dp_config) { 100 dp = *config.dp_config; 101 isp_config.dp_config = &dp; 102 } 103 if (config.ee_config) { 104 ee = *config.ee_config; 105 isp_config.ee_config = ⅇ 106 } 107 if (config.de_config) { 108 de = *config.de_config; 109 isp_config.de_config = &de; 110 } 111 if (config.ctc_table) { 112 ctc_table = *config.ctc_table; 113 isp_config.ctc_table = &ctc_table; 114 } 115 if (config.gc_config) { 116 gc_config = *config.gc_config; 117 isp_config.gc_config = &gc_config; 118 } 119 if (config.anr_config) { 120 anr = *config.anr_config; 121 isp_config.anr_config = &anr; 122 } 123 if (config.a3a_config) { 124 a3a = *config.a3a_config; 125 isp_config.a3a_config = &a3a; 126 } 127 if (config.xnr_config) { 128 xnr = *config.xnr_config; 129 isp_config.xnr_config = &xnr; 130 } 131 if (config.dz_config) { 132 dz_config = *config.dz_config; 133 isp_config.dz_config = &dz_config; 134 } 135 if (config.yuv2rgb_cc_config) { 136 yuv2rgb_cc = *config.yuv2rgb_cc_config; 137 isp_config.yuv2rgb_cc_config = &yuv2rgb_cc; 138 } 139 if (config.rgb2yuv_cc_config) { 140 rgb2yuv_cc = *config.rgb2yuv_cc_config; 141 isp_config.rgb2yuv_cc_config = &rgb2yuv_cc; 142 } 143 if (config.macc_table) { 144 macc_table = *config.macc_table; 145 isp_config.macc_table = &macc_table; 146 } 147 if (config.gamma_table) { 148 gamma_table = *config.gamma_table; 149 isp_config.gamma_table = &gamma_table; 150 } 151 if (config.r_gamma_table) { 152 r_gamma_table = *config.r_gamma_table; 153 isp_config.r_gamma_table = &r_gamma_table; 154 } 155 if (config.g_gamma_table) { 156 g_gamma_table = *config.g_gamma_table; 157 isp_config.g_gamma_table = &g_gamma_table; 158 } 159 if (config.b_gamma_table) { 160 b_gamma_table = *config.b_gamma_table; 161 isp_config.b_gamma_table = &b_gamma_table; 162 } 163 if (config.shading_table) { 164 shading_table = *config.shading_table; 165 isp_config.shading_table = &shading_table; 166 } 167 if (config.morph_table) { 168 morph_table = *config.morph_table; 169 isp_config.morph_table = &morph_table; 170 } 171 if (config.xnr_table) { 172 xnr_table = *config.xnr_table; 173 isp_config.xnr_table = &xnr_table; 174 } 175 if (config.anr_thres) { 176 anr_thres = *config.anr_thres; 177 isp_config.anr_thres = &anr_thres; 178 } 179 if (config.motion_vector) { 180 motion_vector = *config.motion_vector; 181 isp_config.motion_vector = &motion_vector; 182 } 183 } 184 185 X3aIspConfig::X3aIspConfig () 186 { 187 } 188 189 X3aIspConfig::~X3aIspConfig() 190 { 191 clear (); 192 } 193 194 195 bool X3aIspConfig::clear() 196 { 197 _isp_content.clear (); 198 _3a_results.clear (); 199 return true; 200 } 201 202 bool 203 X3aIspConfig::attach (SmartPtr<X3aResult> &result, IspConfigTranslator *translator) 204 { 205 if (result.ptr() == NULL) 206 return false; 207 208 uint32_t type = result->get_type (); 209 210 XCAM_ASSERT (translator); 211 212 if (!result.ptr() || !result->get_ptr ()) { 213 XCAM_LOG_ERROR ("3A result empty"); 214 return false; 215 } 216 switch (type) { 217 case X3aIspConfig::IspAllParameters: { 218 SmartPtr<X3aAtomIspParametersResult> isp_3a = 219 result.dynamic_cast_ptr<X3aAtomIspParametersResult> (); 220 XCAM_ASSERT (isp_3a.ptr ()); 221 _isp_content.copy (isp_3a->get_isp_config()); 222 } 223 break; 224 225 case XCAM_3A_RESULT_WHITE_BALANCE: { 226 struct atomisp_wb_config wb; 227 SmartPtr<X3aWhiteBalanceResult> wb_res = 228 result.dynamic_cast_ptr<X3aWhiteBalanceResult> (); 229 XCAM_ASSERT (wb_res.ptr ()); 230 xcam_mem_clear (wb); 231 if (translator->translate_white_balance (wb_res->get_standard_result(), wb) 232 != XCAM_RETURN_NO_ERROR) { 233 XCAM_LOG_WARNING ("translate white balance failed"); 234 return false; 235 } 236 _isp_content.wb = wb; 237 _isp_content.isp_config.wb_config = &_isp_content.wb; 238 } 239 break; 240 case XCAM_3A_RESULT_BLACK_LEVEL: { 241 struct atomisp_ob_config ob; 242 SmartPtr<X3aBlackLevelResult> bl_res = 243 result.dynamic_cast_ptr<X3aBlackLevelResult> (); 244 XCAM_ASSERT (bl_res.ptr ()); 245 xcam_mem_clear (ob); 246 if (translator->translate_black_level (bl_res->get_standard_result(), ob) 247 != XCAM_RETURN_NO_ERROR) { 248 XCAM_LOG_WARNING ("translate black level failed"); 249 return false; 250 } 251 _isp_content.ob = ob; 252 _isp_content.isp_config.ob_config = &_isp_content.ob; 253 } 254 break; 255 case XCAM_3A_RESULT_YUV2RGB_MATRIX: 256 case XCAM_3A_RESULT_RGB2YUV_MATRIX: 257 { 258 struct atomisp_cc_config cc; 259 SmartPtr<X3aColorMatrixResult> cc_res = 260 result.dynamic_cast_ptr<X3aColorMatrixResult> (); 261 XCAM_ASSERT (cc_res.ptr ()); 262 xcam_mem_clear (cc); 263 if (translator->translate_color_matrix (cc_res->get_standard_result(), cc) 264 != XCAM_RETURN_NO_ERROR) { 265 XCAM_LOG_WARNING ("translate color matrix failed"); 266 return false; 267 } 268 if (type == XCAM_3A_RESULT_YUV2RGB_MATRIX) { 269 _isp_content.yuv2rgb_cc = cc; 270 _isp_content.isp_config.yuv2rgb_cc_config = &_isp_content.yuv2rgb_cc; 271 } else { 272 _isp_content.rgb2yuv_cc = cc; 273 _isp_content.isp_config.rgb2yuv_cc_config = &_isp_content.rgb2yuv_cc; 274 } 275 } 276 break; 277 default: 278 return false; 279 } 280 281 _3a_results.push_back (result); 282 return true; 283 } 284 285 }; 286 287