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