-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRkAiqManager.h
executable file
·208 lines (184 loc) · 5.74 KB
/
RkAiqManager.h
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
* 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 _RK_AIQ_MANAGER_H_
#define _RK_AIQ_MANAGER_H_
#include "ICamHw.h"
#include "RkAiqCore.h"
#include "RkAiqCoreV21.h"
#include "RkAiqCalibDb.h"
#include "RkLumaCore.h"
#include "rk_aiq.h"
namespace RkCam {
class RkAiqManager;
class RkAiqMngCmdThread
: public Thread {
public:
RkAiqMngCmdThread(RkAiqManager* aiqMng)
: Thread("RkAiqMngCmdThread")
, mAiqMng(aiqMng) {};
~RkAiqMngCmdThread() {};
void triger_stop() {
mAiqCmdQueue.pause_pop ();
};
void triger_start() {
mAiqCmdQueue.resume_pop ();
};
enum MSG_CMD {
MSG_CMD_SW_WORKING_MODE
};
typedef struct message_s {
int cmd;
union {
struct {
rk_aiq_working_mode_t mode;
} sw_wk_mode;
} data;
bool sync;
SmartPtr<Mutex> mutex;
SmartPtr<XCam::Cond> cond;
} msg_t;
bool send_cmd(SmartPtr<msg_t> msg) {
bool ret = true;
if (msg->sync) {
msg->mutex = new Mutex();
msg->cond = new XCam::Cond();
SmartLock lock (*msg->mutex.ptr());
ret = mAiqCmdQueue.push(msg);
msg->cond->wait(*msg->mutex.ptr());
} else {
ret = mAiqCmdQueue.push(msg);
}
return ret;
};
protected:
virtual void stopped () {
mAiqCmdQueue.clear ();
};
virtual bool loop ();
private:
RkAiqManager* mAiqMng;
SafeList<msg_t> mAiqCmdQueue;
};
class RkAiqRstApplyThread
: public Thread {
public:
RkAiqRstApplyThread(RkAiqManager* aiqMng)
: Thread("RkAiqRstApplyThread")
, mAiqMng(aiqMng) {};
~RkAiqRstApplyThread() {};
void triger_stop() {
mAiqRstQueue.pause_pop ();
};
void triger_start() {
mAiqRstQueue.resume_pop ();
};
bool push_results (SmartPtr<RkAiqFullParamsProxy> aiqRst) {
return mAiqRstQueue.push(aiqRst);
};
protected:
virtual void stopped () {
mAiqRstQueue.clear ();
};
virtual bool loop ();
private:
RkAiqManager* mAiqMng;
SafeList<RkAiqFullParamsProxy> mAiqRstQueue;
};
class RkAiqManager
: public IspStatsListener
, public IsppStatsListener
, public IspLumaListener
, public IspEvtsListener
, public RkAiqAnalyzerCb
, public RkLumaAnalyzerCb {
friend RkAiqRstApplyThread;
friend RkAiqMngCmdThread;
public:
explicit RkAiqManager(const char* sns_ent_name,
rk_aiq_error_cb err_cb,
rk_aiq_metas_cb metas_cb);
virtual ~RkAiqManager();
void setCamHw(SmartPtr<ICamHw>& camhw);
void setAnalyzer(SmartPtr<RkAiqCore> analyzer);
void setAiqCalibDb(const CamCalibDbContext_t* calibDb);
void setLumaAnalyzer(SmartPtr<RkLumaCore> analyzer);
XCamReturn init();
XCamReturn prepare(uint32_t width, uint32_t height, rk_aiq_working_mode_t mode);
XCamReturn start();
XCamReturn stop(bool keep_ext_hw_st = false);
XCamReturn deInit();
// from IsppStatsListener
XCamReturn isppStatsCb(SmartPtr<VideoBuffer>& isppStats);
// from IspLumaListener
XCamReturn ispLumaCb(SmartPtr<VideoBuffer>& ispLuma);
// from IspStatsListener
XCamReturn ispStatsCb(SmartPtr<VideoBuffer>& ispStats);
// from IspEvtsListener
XCamReturn ispEvtsCb(ispHwEvt_t* evt);
// from RkAiqAnalyzerCb
void rkAiqCalcDone(SmartPtr<RkAiqFullParamsProxy>& results);
void rkAiqCalcFailed(const char* msg);
// from RkLumaAnalyzerCb
void rkLumaCalcDone(int frame_id, int count);
void rkLumaCalcFailed(const char* msg);
XCamReturn setModuleCtl(rk_aiq_module_id_t mId, bool mod_en);
XCamReturn getModuleCtl(rk_aiq_module_id_t mId, bool& mod_en);
XCamReturn enqueueBuffer(struct rk_aiq_vbuf *vbuf);
XCamReturn offlineRdJobPrepare();
XCamReturn offlineRdJobDone();
XCamReturn setSharpFbcRotation(rk_aiq_rotation_t rot);
XCamReturn setMirrorFlip(bool mirror, bool flip, int skip_frm_cnt);
XCamReturn getMirrorFlip(bool& mirror, bool& flip);
void setDefMirrorFlip();
XCamReturn swWorkingModeDyn_msg(rk_aiq_working_mode_t mode);
void setMulCamConc(bool cc);
protected:
XCamReturn applyAnalyzerResult(SmartPtr<RkAiqFullParamsProxy>& results);
XCamReturn swWorkingModeDyn(rk_aiq_working_mode_t mode);
private:
enum aiq_state_e {
AIQ_STATE_INVALID,
AIQ_STATE_INITED,
AIQ_STATE_PREPARED,
AIQ_STATE_STARTED,
AIQ_STATE_STOPED,
};
XCAM_DEAD_COPY (RkAiqManager);
private:
SmartPtr<ICamHw> mCamHw;
SmartPtr<RkAiqCore> mRkAiqAnalyzer;
SmartPtr<RkAiqRstApplyThread> mAiqRstAppTh;
SmartPtr<RkAiqMngCmdThread> mAiqMngCmdTh;
SmartPtr<RkLumaCore> mRkLumaAnalyzer;
rk_aiq_error_cb mErrCb;
rk_aiq_metas_cb mMetasCb;
const char* mSnsEntName;
const CamCalibDbContext_t* mCalibDb;
rk_aiq_working_mode_t mWorkingMode;
rk_aiq_working_mode_t mOldWkModeForGray;
bool mWkSwitching;
uint32_t mWidth;
uint32_t mHeight;
int _state;
bool mCurMirror;
bool mCurFlip;
SmartPtr<RkAiqCpslParamsProxy> mDleayCpslParams;
int mDelayCpslApplyFrmNum;
int mIspHwVer;
};
}; //namespace RkCam
#endif //_RK_AIQ_MANAGER_H_