1 /* 2 * hybrid_analyzer_loader.cpp - hybrid analyzer loader 3 * 4 * Copyright (c) 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 * Zong Wei <wei.zong (at) intel.com> 20 */ 21 22 #include "hybrid_analyzer_loader.h" 23 #include "handler_interface.h" 24 #include "hybrid_analyzer.h" 25 #include <dlfcn.h> 26 27 namespace XCam { 28 29 HybridAnalyzerLoader::HybridAnalyzerLoader (const char *lib_path, const char *symbol) 30 : AnalyzerLoader (lib_path, symbol) 31 , _cpf_path (NULL) 32 { 33 } 34 35 HybridAnalyzerLoader::~HybridAnalyzerLoader () 36 { 37 _isp.release (); 38 } 39 40 bool 41 HybridAnalyzerLoader::set_cpf_path (const char *cpf_path) 42 { 43 XCAM_ASSERT (cpf_path && !_cpf_path); 44 _cpf_path = cpf_path; 45 return true; 46 } 47 48 bool 49 HybridAnalyzerLoader::set_isp_controller (SmartPtr<IspController> &isp) 50 { 51 XCAM_ASSERT (isp.ptr() && !_isp.ptr()); 52 _isp = isp; 53 return true; 54 } 55 56 SmartPtr<X3aAnalyzer> 57 HybridAnalyzerLoader::load_analyzer (SmartPtr<AnalyzerLoader> &self) 58 { 59 XCAM_ASSERT (self.ptr () == this); 60 61 SmartPtr<X3aAnalyzer> analyzer; 62 63 #if HAVE_IA_AIQ 64 XCam3ADescription *desc = (XCam3ADescription*)load_library (get_lib_path ()); 65 analyzer = new HybridAnalyzer (desc, self, _isp, _cpf_path); 66 #endif 67 68 if (!analyzer.ptr ()) { 69 XCAM_LOG_WARNING ("create HybridAnalyzer from lib failed"); 70 close_handle (); 71 return NULL; 72 } 73 74 XCAM_LOG_INFO ("analyzer(%s) created from 3a lib", XCAM_STR (analyzer->get_name())); 75 return analyzer; 76 } 77 78 void * 79 HybridAnalyzerLoader::load_symbol (void* handle) 80 { 81 XCam3ADescription *desc = NULL; 82 83 desc = (XCam3ADescription *)AnalyzerLoader::get_symbol (handle); 84 if (!desc) { 85 XCAM_LOG_DEBUG ("get symbol failed from lib"); 86 return NULL; 87 } 88 if (desc->version < xcam_version ()) { 89 XCAM_LOG_DEBUG ("get symbolfailed. version is:0x%04x, but expect:0x%04x", 90 desc->version, xcam_version ()); 91 return NULL; 92 } 93 if (desc->size < sizeof (XCam3ADescription)) { 94 XCAM_LOG_DEBUG ("get symbol failed, XCam3ADescription size is:%" PRIu32 ", but expect:%" PRIuS, 95 desc->size, sizeof (XCam3ADescription)); 96 return NULL; 97 } 98 99 if (!desc->create_context || !desc->destroy_context || 100 !desc->configure_3a || !desc->set_3a_stats || 101 !desc->analyze_awb || !desc->analyze_ae || 102 !desc->analyze_af || !desc->combine_analyze_results || 103 !desc->free_results) { 104 XCAM_LOG_DEBUG ("some functions in symbol not set from lib"); 105 return NULL; 106 } 107 return (void*)desc; 108 } 109 110 }; 111