1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (c) 2019 Rockchip Corporation 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Licensed under the Apache License, Version 2.0 (the "License"); 5*4882a593Smuzhiyun * you may not use this file except in compliance with the License. 6*4882a593Smuzhiyun * You may obtain a copy of the License at 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * http://www.apache.org/licenses/LICENSE-2.0 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Unless required by applicable law or agreed to in writing, software 11*4882a593Smuzhiyun * distributed under the License is distributed on an "AS IS" BASIS, 12*4882a593Smuzhiyun * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4882a593Smuzhiyun * See the License for the specific language governing permissions and 14*4882a593Smuzhiyun * limitations under the License. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun */ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun #ifndef _CAM_HW_BASE_H_ 19*4882a593Smuzhiyun #define _CAM_HW_BASE_H_ 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun //#include <map> 22*4882a593Smuzhiyun #include <string> 23*4882a593Smuzhiyun #include "xcam_thread.h" 24*4882a593Smuzhiyun #include "ICamHw.h" 25*4882a593Smuzhiyun #include "v4l2_device.h" 26*4882a593Smuzhiyun #include "fake_v4l2_device.h" 27*4882a593Smuzhiyun #include "poll_thread.h" 28*4882a593Smuzhiyun #ifndef RK_SIMULATOR_HW 29*4882a593Smuzhiyun #include "FlashLight.h" 30*4882a593Smuzhiyun #endif 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #include "rk_aiq.h" 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun using namespace XCam; 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun namespace RkCam { 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun class CamHwBase 39*4882a593Smuzhiyun : public ICamHw 40*4882a593Smuzhiyun , public PollCallback { 41*4882a593Smuzhiyun public: 42*4882a593Smuzhiyun explicit CamHwBase(); 43*4882a593Smuzhiyun virtual ~CamHwBase(); 44*4882a593Smuzhiyun // from ICamHw 45*4882a593Smuzhiyun virtual XCamReturn init(const char* sns_ent_name); 46*4882a593Smuzhiyun virtual XCamReturn deInit(); 47*4882a593Smuzhiyun #ifdef RKAIQ_ENABLE_PARSER_V1 setCalib(const CamCalibDbContext_t * calib)48*4882a593Smuzhiyun virtual void setCalib(const CamCalibDbContext_t* calib) { 49*4882a593Smuzhiyun mCalibDb = calib; 50*4882a593Smuzhiyun } 51*4882a593Smuzhiyun #endif setCalib(const CamCalibDbV2Context_t * calibv2)52*4882a593Smuzhiyun virtual void setCalib(const CamCalibDbV2Context_t* calibv2) { 53*4882a593Smuzhiyun mCalibDbV2 = calibv2; 54*4882a593Smuzhiyun } 55*4882a593Smuzhiyun virtual XCamReturn prepare(uint32_t width, uint32_t height, int mode, int t_dealy, int g_delay); 56*4882a593Smuzhiyun virtual XCamReturn start(); 57*4882a593Smuzhiyun virtual XCamReturn stop(); 58*4882a593Smuzhiyun virtual XCamReturn pause(); 59*4882a593Smuzhiyun virtual XCamReturn resume(); swWorkingModeDyn(int mode)60*4882a593Smuzhiyun virtual XCamReturn swWorkingModeDyn(int mode) { 61*4882a593Smuzhiyun return XCAM_RETURN_NO_ERROR; 62*4882a593Smuzhiyun }; keepHwStAtStop(bool ks)63*4882a593Smuzhiyun virtual void keepHwStAtStop(bool ks) { 64*4882a593Smuzhiyun mKpHwSt = ks; 65*4882a593Smuzhiyun }; 66*4882a593Smuzhiyun virtual XCamReturn getSensorModeData(const char* sns_ent_name, 67*4882a593Smuzhiyun rk_aiq_exposure_sensor_descriptor& sns_des); 68*4882a593Smuzhiyun virtual XCamReturn setHwResListener(HwResListener* resListener); setHdrProcessCount(rk_aiq_luma_params_t luma_params)69*4882a593Smuzhiyun virtual XCamReturn setHdrProcessCount(rk_aiq_luma_params_t luma_params) { 70*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 71*4882a593Smuzhiyun }; applyAnalyzerResult(SmartPtr<SharedItemBase> base,bool sync)72*4882a593Smuzhiyun virtual XCamReturn applyAnalyzerResult(SmartPtr<SharedItemBase> base, bool sync) { 73*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 74*4882a593Smuzhiyun }; applyAnalyzerResult(cam3aResultList & list)75*4882a593Smuzhiyun virtual XCamReturn applyAnalyzerResult(cam3aResultList& list) { 76*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 77*4882a593Smuzhiyun } 78*4882a593Smuzhiyun // from PollCallback 79*4882a593Smuzhiyun virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf, int type); 80*4882a593Smuzhiyun virtual XCamReturn poll_buffer_failed (int64_t timestamp, const char *msg); 81*4882a593Smuzhiyun virtual XCamReturn poll_event_ready (uint32_t sequence, int type); 82*4882a593Smuzhiyun virtual XCamReturn poll_event_failed (int64_t timestamp, const char *msg); 83*4882a593Smuzhiyun virtual XCamReturn poll_buffer_ready (SmartPtr<VideoBuffer> &buf); poll_buffer_ready(SmartPtr<V4l2BufferProxy> & buf,int dev_index)84*4882a593Smuzhiyun virtual XCamReturn poll_buffer_ready (SmartPtr<V4l2BufferProxy> &buf, int dev_index) { return XCAM_RETURN_ERROR_FAILED; }; 85*4882a593Smuzhiyun notify_capture_raw()86*4882a593Smuzhiyun virtual XCamReturn notify_capture_raw() { 87*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 88*4882a593Smuzhiyun } 89*4882a593Smuzhiyun virtual XCamReturn capture_raw_ctl(capture_raw_t type, int count = 0, 90*4882a593Smuzhiyun const char* capture_dir = nullptr, \ 91*4882a593Smuzhiyun char* output_dir = nullptr) { 92*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 93*4882a593Smuzhiyun } enqueueRawBuffer(void * vbuf,bool sync)94*4882a593Smuzhiyun virtual XCamReturn enqueueRawBuffer(void *vbuf, bool sync) { 95*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 96*4882a593Smuzhiyun } enqueueRawFile(const char * path)97*4882a593Smuzhiyun virtual XCamReturn enqueueRawFile(const char *path) { 98*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 99*4882a593Smuzhiyun } registRawdataCb(void (* callback)(void *))100*4882a593Smuzhiyun virtual XCamReturn registRawdataCb(void (*callback)(void *)) { 101*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 102*4882a593Smuzhiyun } rawdataPrepare(rk_aiq_raw_prop_t prop)103*4882a593Smuzhiyun virtual XCamReturn rawdataPrepare(rk_aiq_raw_prop_t prop) { 104*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 105*4882a593Smuzhiyun } setSensorFlip(bool mirror,bool flip,int skip_frm_cnt)106*4882a593Smuzhiyun virtual XCamReturn setSensorFlip(bool mirror, bool flip, int skip_frm_cnt) { 107*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 108*4882a593Smuzhiyun } getSensorFlip(bool & mirror,bool & flip)109*4882a593Smuzhiyun virtual XCamReturn getSensorFlip(bool& mirror, bool& flip) { 110*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 111*4882a593Smuzhiyun } getZoomPosition(int & position)112*4882a593Smuzhiyun virtual XCamReturn getZoomPosition(int& position) { 113*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 114*4882a593Smuzhiyun } setLensVcmCfg(rk_aiq_lens_vcmcfg & lens_cfg)115*4882a593Smuzhiyun virtual XCamReturn setLensVcmCfg(rk_aiq_lens_vcmcfg& lens_cfg) { 116*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 117*4882a593Smuzhiyun } getLensVcmCfg(rk_aiq_lens_vcmcfg & lens_cfg)118*4882a593Smuzhiyun virtual XCamReturn getLensVcmCfg(rk_aiq_lens_vcmcfg& lens_cfg) { 119*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 120*4882a593Smuzhiyun } FocusCorrection()121*4882a593Smuzhiyun virtual XCamReturn FocusCorrection() { 122*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 123*4882a593Smuzhiyun } ZoomCorrection()124*4882a593Smuzhiyun virtual XCamReturn ZoomCorrection() { 125*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 126*4882a593Smuzhiyun } setAngleZ(float angleZ)127*4882a593Smuzhiyun virtual XCamReturn setAngleZ(float angleZ) { 128*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 129*4882a593Smuzhiyun } getShareMemOps(isp_drv_share_mem_ops_t ** mem_ops)130*4882a593Smuzhiyun virtual void getShareMemOps(isp_drv_share_mem_ops_t** mem_ops) {}; getEffectiveIspParams(rkisp_effect_params_v20 & ispParams,uint32_t frame_id)131*4882a593Smuzhiyun virtual XCamReturn getEffectiveIspParams(rkisp_effect_params_v20& ispParams, uint32_t frame_id) { 132*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 133*4882a593Smuzhiyun }; getIspModuleEnState()134*4882a593Smuzhiyun uint64_t getIspModuleEnState() { 135*4882a593Smuzhiyun return true; 136*4882a593Smuzhiyun }; setIspStreamMode(rk_isp_stream_mode_t mode)137*4882a593Smuzhiyun virtual XCamReturn setIspStreamMode(rk_isp_stream_mode_t mode) { 138*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 139*4882a593Smuzhiyun } getIspStreamMode()140*4882a593Smuzhiyun virtual rk_isp_stream_mode_t getIspStreamMode() { 141*4882a593Smuzhiyun return RK_ISP_STREAM_MODE_INVALID; 142*4882a593Smuzhiyun } setCamPhyId(int phyId)143*4882a593Smuzhiyun virtual void setCamPhyId(int phyId) { 144*4882a593Smuzhiyun mCamPhyId = phyId; 145*4882a593Smuzhiyun } getCamPhyId()146*4882a593Smuzhiyun virtual int getCamPhyId() { return mCamPhyId;} setGroupMode(bool bGroup,bool bMain)147*4882a593Smuzhiyun virtual void setGroupMode(bool bGroup, bool bMain) { mIsGroupMode = bGroup; mIsMain = bMain;} setTbInfo(rk_aiq_tb_info_t & info)148*4882a593Smuzhiyun virtual void setTbInfo(rk_aiq_tb_info_t& info) { 149*4882a593Smuzhiyun mTbInfo = info; 150*4882a593Smuzhiyun } setDevBufCnt(const std::map<std::string,int> & dev_buf_cnt_map)151*4882a593Smuzhiyun virtual void setDevBufCnt(const std::map<std::string, int>& dev_buf_cnt_map) { 152*4882a593Smuzhiyun mDevBufCntMap = dev_buf_cnt_map; 153*4882a593Smuzhiyun } reset_hardware()154*4882a593Smuzhiyun virtual XCamReturn reset_hardware() { 155*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 156*4882a593Smuzhiyun }; rawReproc_genIspParams(uint32_t sequence,rk_aiq_frame_info_t * offline_finfo,int mode)157*4882a593Smuzhiyun virtual XCamReturn rawReproc_genIspParams (uint32_t sequence, rk_aiq_frame_info_t *offline_finfo, int mode) { 158*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 159*4882a593Smuzhiyun } rawReProc_prepare(uint32_t sequence,rk_aiq_frame_info_t * offline_finfo)160*4882a593Smuzhiyun virtual XCamReturn rawReProc_prepare (uint32_t sequence, rk_aiq_frame_info_t *offline_finfo) { 161*4882a593Smuzhiyun return XCAM_RETURN_ERROR_FAILED; 162*4882a593Smuzhiyun } setUserSensorFormat(uint16_t width,uint16_t height,uint16_t code)163*4882a593Smuzhiyun virtual void setUserSensorFormat(uint16_t width, uint16_t height, uint16_t code) { } 164*4882a593Smuzhiyun HwResListener* mHwResLintener; 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun protected: 167*4882a593Smuzhiyun SmartPtr<V4l2Device> mIsppFecParamsDev; 168*4882a593Smuzhiyun SmartPtr<V4l2Device> mIspLumaDev; 169*4882a593Smuzhiyun SmartPtr<V4l2Device> mIspStatsDev; 170*4882a593Smuzhiyun SmartPtr<V4l2Device> mIspParamsDev; 171*4882a593Smuzhiyun SmartPtr<V4l2SubDevice> mIspCoreDev; 172*4882a593Smuzhiyun SmartPtr<V4l2SubDevice> mSensorDev; 173*4882a593Smuzhiyun SmartPtr<V4l2SubDevice> mLensDev; 174*4882a593Smuzhiyun SmartPtr<V4l2SubDevice> mIrcutDev; 175*4882a593Smuzhiyun SmartPtr<V4l2Device> mIspSpDev; 176*4882a593Smuzhiyun #ifndef RK_SIMULATOR_HW 177*4882a593Smuzhiyun SmartPtr<FlashLightHw> mFlashLight; 178*4882a593Smuzhiyun SmartPtr<FlashLightHw> mFlashLightIr; 179*4882a593Smuzhiyun #endif 180*4882a593Smuzhiyun int mWorkingMode; 181*4882a593Smuzhiyun const CamCalibDbContext_t* mCalibDb; 182*4882a593Smuzhiyun const CamCalibDbV2Context_t* mCalibDbV2; 183*4882a593Smuzhiyun bool mKpHwSt; 184*4882a593Smuzhiyun int mCamPhyId; 185*4882a593Smuzhiyun bool mIsGroupMode; 186*4882a593Smuzhiyun bool mIsMain; 187*4882a593Smuzhiyun rk_aiq_tb_info_t mTbInfo; 188*4882a593Smuzhiyun std::map<std::string, int> mDevBufCntMap; 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun private: 191*4882a593Smuzhiyun XCAM_DEAD_COPY (CamHwBase); 192*4882a593Smuzhiyun }; 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun } //namespace RkCam 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun #endif 197