1 /* 2 * Copyright (c) 2019-2022 Rockchip Eletronics Co., Ltd. 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 #ifndef _RK_AIQ_AF_HANDLE_INT_H_ 17 #define _RK_AIQ_AF_HANDLE_INT_H_ 18 19 #include <atomic> 20 21 #include "RkAiqHandle.h" 22 #include "af/rk_aiq_uapi_af_int.h" 23 #include "rk_aiq_api_private.h" 24 #include "rk_aiq_pool.h" 25 #include "xcam_mutex.h" 26 27 namespace RkCam { 28 29 class RkAiqAfHandleInt : virtual public RkAiqHandle { 30 public: RkAiqAfHandleInt(RkAiqAlgoDesComm * des,RkAiqCore * aiqCore)31 explicit RkAiqAfHandleInt(RkAiqAlgoDesComm* des, RkAiqCore* aiqCore) 32 : RkAiqHandle(des, aiqCore) { 33 #ifndef DISABLE_HANDLE_ATTRIB 34 memset(&mCurAtt, 0, sizeof(rk_aiq_af_attrib_t)); 35 memset(&mNewAtt, 0, sizeof(rk_aiq_af_attrib_t)); 36 isUpdateAttDone = false; 37 #endif 38 isUpdateZoomPosDone = false; 39 }; ~RkAiqAfHandleInt()40 virtual ~RkAiqAfHandleInt() { RkAiqHandle::deInit(); }; 41 virtual XCamReturn updateConfig(bool needSync); 42 virtual XCamReturn prepare(); 43 virtual XCamReturn preProcess(); 44 virtual XCamReturn processing(); 45 virtual XCamReturn postProcess(); 46 virtual XCamReturn genIspResult(RkAiqFullParams* params, RkAiqFullParams* cur_params); 47 // TODO add algo specific methords, this is a sample 48 XCamReturn setAttrib(rk_aiq_af_attrib_t* att); 49 XCamReturn getAttrib(rk_aiq_af_attrib_t* att); 50 XCamReturn lock(); 51 XCamReturn unlock(); 52 XCamReturn Oneshot(); 53 XCamReturn ManualTriger(); 54 XCamReturn Tracking(); 55 XCamReturn setZoomIndex(int index); 56 XCamReturn getZoomIndex(int* index); 57 XCamReturn endZoomChg(); 58 XCamReturn startZoomCalib(); 59 XCamReturn resetZoom(); 60 XCamReturn GetSearchPath(rk_aiq_af_sec_path_t* path); 61 XCamReturn GetSearchResult(rk_aiq_af_result_t* result); 62 XCamReturn GetFocusRange(rk_aiq_af_focusrange* range); 63 XCamReturn setAeStable(bool ae_stable); 64 65 protected: 66 virtual void init(); deInit()67 virtual void deInit() { RkAiqHandle::deInit(); }; 68 69 private: 70 bool getValueFromFile(const char* path, int* pos); 71 72 #ifndef DISABLE_HANDLE_ATTRIB 73 // TODO 74 rk_aiq_af_attrib_t mCurAtt; 75 rk_aiq_af_attrib_t mNewAtt; 76 mutable std::atomic<bool> isUpdateAttDone; 77 #endif 78 mutable std::atomic<bool> isUpdateZoomPosDone; 79 int mLastZoomIndex; 80 81 RkAiqAlgoProcResAf mLastAfResult; 82 83 XCam::Mutex mAeStableMutex; 84 bool mAeStable = false; 85 uint32_t mAfMeasResSyncFalg{(uint32_t)(-1)}; 86 uint32_t mAfFocusResSyncFalg{(uint32_t)(-1)}; 87 private: 88 DECLARE_HANDLE_REGISTER_TYPE(RkAiqAfHandleInt); 89 }; 90 91 } // namespace RkCam 92 93 #endif 94