diff --git a/config/linux/ipu6ep/libcamhal_profile.xml b/config/linux/ipu6ep/libcamhal_profile.xml
index 7a1f87ed..64be41d1 100644
--- a/config/linux/ipu6ep/libcamhal_profile.xml
+++ b/config/linux/ipu6ep/libcamhal_profile.xml
@@ -1,5 +1,5 @@
-
+ isx031,imx390,ar0234-1-1,ar0234-2-2,external_source,ar0234_usb,
+ lt6911uxc-1-1,lt6911uxc-2-2,lt6911uxc-pdata1-1,lt6911uxc-pdata2-2,lt6911uxe-1-1,lt6911uxe-2-2"/>
diff --git a/config/linux/ipu6ep/sensors/ar0234-1.xml b/config/linux/ipu6ep/sensors/ar0234-1.xml
new file mode 100644
index 00000000..3db0a20a
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/ar0234-1.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/linux/ipu6ep/sensors/ar0234-2.xml b/config/linux/ipu6ep/sensors/ar0234-2.xml
new file mode 100644
index 00000000..9e897641
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/ar0234-2.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxc-1.xml b/config/linux/ipu6ep/sensors/lt6911uxc-1.xml
index b6ee2a3b..bca847d3 100644
--- a/config/linux/ipu6ep/sensors/lt6911uxc-1.xml
+++ b/config/linux/ipu6ep/sensors/lt6911uxc-1.xml
@@ -40,18 +40,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -63,7 +51,7 @@
-
+
@@ -75,7 +63,7 @@
-
+
@@ -107,17 +95,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
@@ -127,7 +105,7 @@
-
+
@@ -137,7 +115,7 @@
-
+
@@ -152,13 +130,12 @@
+ V4L2_PIX_FMT_UYVY,2560x1440,0,2,
+ V4L2_PIX_FMT_UYVY,1920x2160,0,3,
+ V4L2_PIX_FMT_UYVY,3840x2160,0,4"/>
-
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxc-2.xml b/config/linux/ipu6ep/sensors/lt6911uxc-2.xml
index 29ffcac5..cfb24160 100644
--- a/config/linux/ipu6ep/sensors/lt6911uxc-2.xml
+++ b/config/linux/ipu6ep/sensors/lt6911uxc-2.xml
@@ -41,9 +41,9 @@
-
-
-
+
+
+
@@ -53,9 +53,9 @@
-
-
-
+
+
+
@@ -95,17 +95,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
@@ -115,7 +105,7 @@
-
+
@@ -125,7 +115,7 @@
-
+
@@ -135,16 +125,17 @@
+
-
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxc-pdata1-1.xml b/config/linux/ipu6ep/sensors/lt6911uxc-pdata1-1.xml
new file mode 100644
index 00000000..9f01388d
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/lt6911uxc-pdata1-1.xml
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxc-pdata2-2.xml b/config/linux/ipu6ep/sensors/lt6911uxc-pdata2-2.xml
new file mode 100644
index 00000000..c5857470
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/lt6911uxc-pdata2-2.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxe-1.xml b/config/linux/ipu6ep/sensors/lt6911uxe-1.xml
new file mode 100644
index 00000000..72f92806
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/lt6911uxe-1.xml
@@ -0,0 +1,166 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/linux/ipu6ep/sensors/lt6911uxe-2.xml b/config/linux/ipu6ep/sensors/lt6911uxe-2.xml
new file mode 100644
index 00000000..1711d407
--- /dev/null
+++ b/config/linux/ipu6ep/sensors/lt6911uxe-2.xml
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/algowrapper/IntelTNR7US.cpp b/modules/algowrapper/IntelTNR7US.cpp
index 66404596..2f5e8f36 100644
--- a/modules/algowrapper/IntelTNR7US.cpp
+++ b/modules/algowrapper/IntelTNR7US.cpp
@@ -18,9 +18,6 @@
#include "modules/algowrapper/IntelTNR7US.h"
-#include
-#include
-
#include
#include "iutils/CameraLog.h"
@@ -34,6 +31,8 @@ namespace icamera {
IntelTNR7US* IntelTNR7US::createIntelTNR(int cameraId) {
#ifdef TNR7_CM
return new IntelC4mTNR(cameraId);
+#else
+ return nullptr;
#endif
}
@@ -45,6 +44,15 @@ Tnr7Param* IntelTNR7US::allocTnr7ParamBuf() {
#ifdef TNR7_CM
IntelC4mTNR::~IntelC4mTNR() {
+ icamera::Thread::requestExit();
+ {
+ std::lock_guard l(mLock);
+ mThreadRunning = false;
+ mRequestCondition.notify_one();
+ }
+
+ icamera::Thread::requestExitAndWait();
+
for (auto surface : mCMSurfaceMap) {
destroyCMSurface(surface.second);
}
@@ -58,8 +66,9 @@ int IntelC4mTNR::init(int width, int height, TnrType type) {
mTnrType = type;
std::string threadName = "IntelC4mTNR" + std::to_string(type + (mCameraId << 1));
- mThread = std::unique_ptr(new base::Thread(threadName));
- mThread->Start();
+ run(threadName);
+ mThreadRunning = true;
+
return OK;
}
@@ -116,10 +125,7 @@ int IntelC4mTNR::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t i
}
CheckAndLogError(outSurface == nullptr, UNKNOWN_ERROR,
"Failed to get CMSurface for output buffer");
- struct timespec beginTime = {};
- if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
- clock_gettime(CLOCK_MONOTONIC, &beginTime);
- }
+
/* call Tnr api to run tnr for the inSurface and store the result in outSurface */
int ret =
run_tnr7us_frame(mWidth, mHeight, mWidth, inSurface, outSurface, &tnrParam->scale,
@@ -127,23 +133,43 @@ int IntelC4mTNR::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t i
if (fd >= 0) {
destroyCMSurface(outSurface);
}
- CheckAndLogError(ret != OK, UNKNOWN_ERROR, "tnr7us process failed");
- if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
- struct timespec endTime = {};
- clock_gettime(CLOCK_MONOTONIC, &endTime);
- uint64_t timeUsedUs = (endTime.tv_sec - beginTime.tv_sec) * 1000000 +
- (endTime.tv_nsec - beginTime.tv_nsec) / 1000;
- LOG2(ST_GPU_TNR, "%s time:%lu us", __func__, timeUsedUs);
+
+ return ret;
+}
+bool IntelC4mTNR::threadLoop() {
+ {
+ std::unique_lock lock(mLock);
+ if (!mThreadRunning) return false;
+ if (mParamGainRequest.empty()) {
+ std::cv_status ret = mRequestCondition.wait_for(
+ lock, std::chrono::nanoseconds(kMaxDuration * SLOWLY_MULTIPLIER));
+
+ // Already stopped
+ if (!mThreadRunning) return false;
+
+ if (ret == std::cv_status::timeout) {
+ return true;
+ }
+ }
}
- return OK;
+
+ ParamGain param;
+ {
+ std::lock_guard l(mLock);
+ param = mParamGainRequest.front();
+ mParamGainRequest.pop();
+ }
+
+ tnr7usParamUpdate(param.gain, param.forceUpdate, mTnrType);
+
+ return true;
}
int IntelC4mTNR::asyncParamUpdate(int gain, bool forceUpdate) {
- if (mThread->task_runner()) {
- mThread->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&IntelC4mTNR::handleParamUpdate, base::Unretained(this), gain,
- forceUpdate));
- }
+ std::lock_guard l(mLock);
+ mParamGainRequest.push({gain, forceUpdate});
+ mRequestCondition.notify_one();
+
return OK;
}
@@ -158,24 +184,6 @@ int32_t IntelC4mTNR::getTnrBufferSize(int width, int height, uint32_t* size) {
return OK;
}
-void IntelC4mTNR::handleParamUpdate(int gain, bool forceUpdate) {
- LOG2("@%s gain: %d", __func__, gain);
- // gain value is from AE expore analog_gain * digital_gain
- struct timespec beginTime = {};
- if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
- clock_gettime(CLOCK_MONOTONIC, &beginTime);
- }
-
- tnr7usParamUpdate(gain, forceUpdate, mTnrType);
- if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
- struct timespec endTime = {};
- clock_gettime(CLOCK_MONOTONIC, &endTime);
- uint64_t timeUsedUs = (endTime.tv_sec - beginTime.tv_sec) * 1000000 +
- (endTime.tv_nsec - beginTime.tv_nsec) / 1000;
- LOG2(ST_GPU_TNR, "%s time:%lu us", __func__, timeUsedUs);
- }
-}
-
CmSurface2DUP* IntelC4mTNR::getBufferCMSurface(void* bufAddr) {
if (mCMSurfaceMap.find(bufAddr) != mCMSurfaceMap.end()) {
return mCMSurfaceMap[bufAddr];
diff --git a/modules/algowrapper/IntelTNR7US.h b/modules/algowrapper/IntelTNR7US.h
index 2db4d59b..dcb59895 100644
--- a/modules/algowrapper/IntelTNR7US.h
+++ b/modules/algowrapper/IntelTNR7US.h
@@ -16,7 +16,6 @@
#pragma once
-#include
#include
#include
@@ -28,8 +27,11 @@ extern "C" {
#include "CameraBuffer.h"
#include "PlatformData.h"
#include "TNRCommon.h"
+#include "iutils/Thread.h"
#ifdef TNR7_CM
+#define HANDLE cancel_fw_pre_define
+#ifndef HAVE_ANDROID_OS
/* the cm_rt.h has some build error with current clang build flags
* use the ignored setting to ignore these errors, and use
* push/pop to make the ignore only take effect on this file */
@@ -37,9 +39,11 @@ extern "C" {
#pragma clang diagnostic ignored "-Wbitfield-constant-conversion"
#pragma clang diagnostic ignored "-Wunused-private-field"
// HANDLE is redefined in cm_rt.h, avoid the redefinition build error
-#define HANDLE cancel_fw_pre_define
#include "cm_rt.h"
#pragma clang diagnostic pop
+#else
+#include "cm_rt.h"
+#endif
extern int run_tnr7us_frame(int width, int height, int stride, CmSurface2DUP*& inputSurface,
CmSurface2DUP*& outputSurface, tnr_scale_1_0_t* dsPtr,
@@ -99,11 +103,11 @@ class IntelTNR7US {
};
#ifdef TNR7_CM
-class IntelC4mTNR : public IntelTNR7US {
+class IntelC4mTNR : public IntelTNR7US, public icamera::Thread {
public:
explicit IntelC4mTNR(int cameraId) : IntelTNR7US(cameraId) {}
virtual ~IntelC4mTNR();
- virtual int init(int width, int height, TnrType type = TNR_INSTANCE0);
+ virtual int init(int width, int height, TnrType type = TNR_INSTANCE0) override;
/**
* call tnr api to calc tnr result
*
@@ -113,12 +117,13 @@ class IntelC4mTNR : public IntelTNR7US {
* \param fd: user output buffer file handle
*/
virtual int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd = -1);
- virtual void* allocCamBuf(uint32_t bufSize, int id);
- virtual void freeAllBufs();
- virtual int prepareSurface(void* bufAddr, int size);
- virtual int asyncParamUpdate(int gain, bool forceUpdate);
- virtual int getTnrBufferSize(int width, int height, uint32_t* size);
+ uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate,
+ int fd = -1) override;
+ virtual void* allocCamBuf(uint32_t bufSize, int id) override;
+ virtual void freeAllBufs() override;
+ virtual int prepareSurface(void* bufAddr, int size) override;
+ virtual int asyncParamUpdate(int gain, bool forceUpdate) override;
+ virtual int getTnrBufferSize(int width, int height, uint32_t* size) override;
private:
/* tnr api use CmSurface2DUP object as data buffer, call this api to create
@@ -127,14 +132,21 @@ class IntelC4mTNR : public IntelTNR7US {
int32_t destroyCMSurface(CmSurface2DUP* surface);
// get the CmSurface object of the bufAddr in mCMSurfaceMap
CmSurface2DUP* getBufferCMSurface(void* bufAddr);
- /* call tnr7us API to update params */
- void handleParamUpdate(int gain, bool forceUpdate);
DISALLOW_COPY_AND_ASSIGN(IntelC4mTNR);
private:
// Tnr will create CMSurface for input buffers and cache them in the map
std::unordered_map mCMSurfaceMap;
- std::unique_ptr mThread;
+ virtual bool threadLoop() override;
+ std::mutex mLock;
+ std::condition_variable mRequestCondition;
+ const uint64_t kMaxDuration = 5000000000; // 5s
+ typedef struct {
+ int gain;
+ bool forceUpdate;
+ } ParamGain;
+ std::queue mParamGainRequest;
+ bool mThreadRunning;
};
#endif
} // namespace icamera
diff --git a/src/3a/AiqUnit.cpp b/src/3a/AiqUnit.cpp
index c5306073..a1f8da66 100644
--- a/src/3a/AiqUnit.cpp
+++ b/src/3a/AiqUnit.cpp
@@ -241,14 +241,15 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
// Initialize cca_cpf data
ia_binary_data cpfData;
- cca::cca_init_params params = {};
+ std::unique_ptr params =
+ std::unique_ptr(new cca::cca_init_params());
ret = PlatformData::getCpf(mCameraId, tuningMode, &cpfData);
if (ret == OK && cpfData.data) {
CheckAndLogError(cpfData.size > cca::MAX_CPF_LEN, UNKNOWN_ERROR,
"%s, AIQB buffer is too small cpfData:%d > MAX_CPF_LEN:%d", __func__,
cpfData.size, cca::MAX_CPF_LEN);
- MEMCPY_S(params.aiq_cpf.buf, cca::MAX_CPF_LEN, cpfData.data, cpfData.size);
- params.aiq_cpf.size = cpfData.size;
+ MEMCPY_S(params->aiq_cpf.buf, cca::MAX_CPF_LEN, cpfData.data, cpfData.size);
+ params->aiq_cpf.size = cpfData.size;
}
// Initialize cca_nvm data
@@ -257,8 +258,8 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
CheckAndLogError(nvmData->size > cca::MAX_NVM_LEN, UNKNOWN_ERROR,
"%s, NVM buffer is too small: nvmData:%d MAX_NVM_LEN:%d", __func__,
nvmData->size, cca::MAX_NVM_LEN);
- MEMCPY_S(params.aiq_nvm.buf, cca::MAX_NVM_LEN, nvmData->data, nvmData->size);
- params.aiq_nvm.size = nvmData->size;
+ MEMCPY_S(params->aiq_nvm.buf, cca::MAX_NVM_LEN, nvmData->data, nvmData->size);
+ params->aiq_nvm.size = nvmData->size;
}
// Initialize cca_aiqd data
@@ -267,25 +268,25 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
CheckAndLogError(aiqdData->size > cca::MAX_AIQD_LEN, UNKNOWN_ERROR,
"%s, AIQD buffer is too small aiqdData:%d > MAX_AIQD_LEN:%d", __func__,
aiqdData->size, cca::MAX_AIQD_LEN);
- MEMCPY_S(params.aiq_aiqd.buf, cca::MAX_AIQD_LEN, aiqdData->data, aiqdData->size);
- params.aiq_aiqd.size = aiqdData->size;
+ MEMCPY_S(params->aiq_aiqd.buf, cca::MAX_AIQD_LEN, aiqdData->data, aiqdData->size);
+ params->aiq_aiqd.size = aiqdData->size;
}
SensorFrameParams sensorParam = {};
ret = PlatformData::calculateFrameParams(mCameraId, sensorParam);
CheckAndLogError(ret != OK, ret, "%s: Failed to calculate frame params", __func__);
- AiqUtils::convertToAiqFrameParam(sensorParam, params.frameParams);
+ AiqUtils::convertToAiqFrameParam(sensorParam, params->frameParams);
- params.frameUse = ia_aiq_frame_use_video;
- params.aiqStorageLen = MAX_SETTING_COUNT;
+ params->frameUse = ia_aiq_frame_use_video;
+ params->aiqStorageLen = MAX_SETTING_COUNT;
// handle AE delay in AiqEngine
- params.aecFrameDelay = 0;
+ params->aecFrameDelay = 0;
// Initialize functions which need to be started
- params.bitmap = cca::CCA_MODULE_AE | cca::CCA_MODULE_AWB | cca::CCA_MODULE_PA |
- cca::CCA_MODULE_SA | cca::CCA_MODULE_GBCE | cca::CCA_MODULE_LARD;
+ params->bitmap = cca::CCA_MODULE_AE | cca::CCA_MODULE_AWB | cca::CCA_MODULE_PA |
+ cca::CCA_MODULE_SA | cca::CCA_MODULE_GBCE | cca::CCA_MODULE_LARD;
if (PlatformData::getLensHwType(mCameraId) == LENS_VCM_HW) {
- params.bitmap |= cca::CCA_MODULE_AF;
+ params->bitmap |= cca::CCA_MODULE_AF;
}
std::shared_ptr graphConfig =
@@ -305,7 +306,7 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
PlatformData::isDolMediumEnabled(mCameraId));
// DOL_FEATURE_E
if (hasLtm && mLtm) {
- params.bitmap |= cca::CCA_MODULE_LTM;
+ params->bitmap |= cca::CCA_MODULE_LTM;
ret = mLtm->configure(configModes, graphConfig, VIDEO_STREAM_ID);
CheckAndLogError(ret != OK, ret, "configure LTM engine error: %d", ret);
}
@@ -324,11 +325,11 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
}
ret = mDvs->configure(cfg, &dvsConfig);
CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, configure DVS error", __func__);
- params.bitmap |= cca::CCA_MODULE_DVS;
- params.dvsOutputType = dvsConfig.outputType;
- params.dvsZoomRatio = dvsConfig.zoomRatio;
- params.enableVideoStablization = dvsConfig.enableDvs;
- params.gdcConfigs = dvsConfig.gdcConfigs;
+ params->bitmap |= cca::CCA_MODULE_DVS;
+ params->dvsOutputType = dvsConfig.outputType;
+ params->dvsZoomRatio = dvsConfig.zoomRatio;
+ params->enableVideoStablization = dvsConfig.enableDvs;
+ params->gdcConfigs = dvsConfig.gdcConfigs;
}
// INTEL_DVS_E
@@ -339,25 +340,25 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
// Parse the DOL mode and CG ratio from sensor mode config
if (graphConfig != nullptr) {
std::string dol_mode_name;
- graphConfig->getDolInfo(params.conversionGainRatio, dol_mode_name);
+ graphConfig->getDolInfo(params->conversionGainRatio, dol_mode_name);
std::map dolModeNameMap;
dolModeNameMap["DOL_MODE_2_3_FRAME"] = ia_bcomp_dol_two_or_three_frame;
dolModeNameMap["DOL_MODE_DCG"] = ia_bcomp_dol_dcg;
dolModeNameMap["DOL_MODE_COMBINED_VERY_SHORT"] = ia_bcomp_dol_combined_very_short;
dolModeNameMap["DOL_MODE_DCG_VERY_SHORT"] = ia_bcomp_dol_dcg_very_short;
if (dolModeNameMap.count(dol_mode_name)) {
- params.dolMode = dolModeNameMap[dol_mode_name];
+ params->dolMode = dolModeNameMap[dol_mode_name];
}
}
- LOG2("conversionGainRatio: %f, dolMode: %d", params.conversionGainRatio,
- params.dolMode);
- params.bitmap = params.bitmap | cca::CCA_MODULE_BCOM;
+ LOG2("conversionGainRatio: %f, dolMode: %d", params->conversionGainRatio,
+ params->dolMode);
+ params->bitmap = params->bitmap | cca::CCA_MODULE_BCOM;
} else if (PlatformData::getSensorAeEnable(mCameraId)) {
- params.conversionGainRatio = 1;
- params.dolMode = ia_bcomp_linear_hdr_mode;
- LOG2("WA: conversionGainRatio: %f, dolMode: %d", params.conversionGainRatio,
- params.dolMode);
- params.bitmap = params.bitmap | cca::CCA_MODULE_BCOM;
+ params->conversionGainRatio = 1;
+ params->dolMode = ia_bcomp_linear_hdr_mode;
+ LOG2("WA: conversionGainRatio: %f, dolMode: %d", params->conversionGainRatio,
+ params->dolMode);
+ params->bitmap = params->bitmap | cca::CCA_MODULE_BCOM;
}
// DOL_FEATURE_E
@@ -365,18 +366,18 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) {
if (graphConfig != nullptr) {
std::vector streamIds;
graphConfig->graphGetStreamIds(streamIds);
- params.aic_stream_ids.count = streamIds.size();
+ params->aic_stream_ids.count = streamIds.size();
CheckAndLogError(streamIds.size() > cca::MAX_STREAM_NUM, UNKNOWN_ERROR,
"%s, Too many streams: %zu in graph", __func__, streamIds.size());
for (size_t i = 0; i < streamIds.size(); ++i) {
- params.aic_stream_ids.ids[i] = streamIds[i];
+ params->aic_stream_ids.ids[i] = streamIds[i];
}
}
}
IntelCca* intelCca = IntelCca::getInstance(mCameraId, tuningMode);
CheckAndLogError(!intelCca, UNKNOWN_ERROR, "Failed to get cca. mode:%d cameraId:%d",
tuningMode, mCameraId);
- ia_err iaErr = intelCca->init(params);
+ ia_err iaErr = intelCca->init(*params);
if (iaErr == ia_err_none) {
mTuningModes.push_back(tuningMode);
} else {
@@ -404,10 +405,11 @@ void AiqUnit::deinitIntelCcaHandle() {
__func__, mode, mCameraId);
if (PlatformData::isAiqdEnabled(mCameraId)) {
- cca::cca_aiqd aiqd = {};
- ia_err iaErr = intelCca->getAiqd(&aiqd);
+ std::unique_ptr aiqd =
+ std::unique_ptr(new cca::cca_aiqd());
+ ia_err iaErr = intelCca->getAiqd(aiqd.get());
if (AiqUtils::convertError(iaErr) == OK) {
- ia_binary_data data = {aiqd.buf, static_cast(aiqd.size)};
+ ia_binary_data data = {aiqd->buf, static_cast(aiqd->size)};
PlatformData::saveAiqd(mCameraId, mode, data);
} else {
LOGW("@%s, failed to get aiqd data, iaErr %d", __func__, iaErr);
diff --git a/src/core/CameraBuffer.cpp b/src/core/CameraBuffer.cpp
index ef446628..76531e2c 100644
--- a/src/core/CameraBuffer.cpp
+++ b/src/core/CameraBuffer.cpp
@@ -43,8 +43,6 @@ CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, i
mU(nullptr),
mBufferUsage(usage),
mSettingSequence(-1) {
- int num_plane = 1;
-
LOG2("%s: construct buffer with usage:%d, memory:%d, size:%d, format:%d, index:%d",
cameraId, __func__, usage, memory, size, format, index);
@@ -57,13 +55,7 @@ CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, i
CLEAR(mMmapAddrs);
CLEAR(mDmaFd);
- if ((usage == BUFFER_USAGE_PSYS_INPUT || usage == BUFFER_USAGE_PSYS_INTERNAL ||
- usage == BUFFER_USAGE_GENERAL) &&
- (PlatformData::isIsysEnabled(cameraId) && PlatformData::isCSIFrontEndCapture(cameraId))) {
- num_plane = CameraUtils::getNumOfPlanes(format);
- } else if (usage == BUFFER_USAGE_MIPI_CAPTURE || usage == BUFFER_USAGE_METADATA) {
- num_plane = CameraUtils::getNumOfPlanes(format);
- }
+ int num_plane = CameraUtils::getNumOfPlanes(format);
initBuffer(memory, v4l2BufType, size, index, num_plane);
}
diff --git a/src/core/RequestThread.cpp b/src/core/RequestThread.cpp
index 0719195d..2de5834c 100644
--- a/src/core/RequestThread.cpp
+++ b/src/core/RequestThread.cpp
@@ -165,7 +165,13 @@ int RequestThread::processRequest(int bufferNum, camera_buffer_t** ubuffer,
}
}
- if (mFirstRequest && !hasVideoBuffer) {
+ if (!mActive) {
+ request.mIsFirstRequest = true;
+ mActive = true;
+ LOG2("%s: process first request.", mCameraId, __func__);
+ }
+
+ if (request.mIsFirstRequest && !hasVideoBuffer) {
LOG2("there is no video buffer in first request, so don't block request processing.");
mBlockRequest = false;
}
@@ -173,10 +179,6 @@ int RequestThread::processRequest(int bufferNum, camera_buffer_t** ubuffer,
request.mRequestParam = copyRequestParams(params);
mPendingRequests.push_back(request);
- if (!mActive) {
- mActive = true;
- }
-
if (mRequestsInProcessing == 0 || !mPerframeControlSupport) {
mRequestTriggerEvent |= NEW_REQUEST;
mRequestSignal.signal();
@@ -374,7 +376,7 @@ bool RequestThread::threadLoop() {
}
if (!mActive) {
- return false;
+ return true;
}
CameraRequest request;
@@ -448,7 +450,7 @@ void RequestThread::handleRequest(CameraRequest& request, int64_t applyingSeq) {
{
AutoMutex l(mFirstRequestLock);
- if (mFirstRequest) {
+ if (request.mIsFirstRequest) {
LOG1("%s: first request done", __func__);
mFirstRequest = false;
mFirstRequestSignal.signal();
diff --git a/src/core/RequestThread.h b/src/core/RequestThread.h
index 466415a4..6f2dd004 100644
--- a/src/core/RequestThread.h
+++ b/src/core/RequestThread.h
@@ -77,9 +77,12 @@ class RequestThread : public Thread, public EventSource, public EventListener {
std::shared_ptr mFakeBuffer;
struct CameraRequest {
- CameraRequest() : mBufferNum(0), mRequestParam(nullptr) { CLEAR(mBuffer); }
+ CameraRequest() : mBufferNum(0), mIsFirstRequest(false), mRequestParam(nullptr) {
+ CLEAR(mBuffer);
+ }
int mBufferNum;
+ bool mIsFirstRequest;
camera_buffer_t* mBuffer[MAX_STREAM_NUMBER];
std::shared_ptr mRequestParam;
};
diff --git a/src/core/SofSource.cpp b/src/core/SofSource.cpp
index bd2b68f2..83d358a2 100644
--- a/src/core/SofSource.cpp
+++ b/src/core/SofSource.cpp
@@ -17,6 +17,7 @@
#include "SofSource.h"
+#include
#include
#include
@@ -41,6 +42,21 @@ SofSource::SofSource(int cameraId)
mExitPending(false) {
LOG1("%s: SofSource is constructed", __func__);
+ mFlushFd[0] = -1;
+ mFlushFd[1] = -1;
+
+ int ret = pipe(mFlushFd);
+ if (ret >= 0) {
+ ret = fcntl(mFlushFd[0], F_SETFL, O_NONBLOCK);
+ if (ret < 0) {
+ LOG1("failed to set flush pipe flag: %s", strerror(errno));
+ close(mFlushFd[0]);
+ close(mFlushFd[1]);
+ mFlushFd[0] = -1;
+ mFlushFd[1] = -1;
+ }
+ LOG1("%s, mFlushFd [%d-%d]", __func__, mFlushFd[0], mFlushFd[1]);
+ }
mSofDisabled = !PlatformData::isIsysEnabled(cameraId);
// FILE_SOURCE_S
mSofDisabled = mSofDisabled || PlatformData::isFileSourceEnabled();
@@ -49,6 +65,8 @@ SofSource::SofSource(int cameraId)
SofSource::~SofSource() {
LOG1("%s: SofSource is distructed.", __func__);
+ if (mFlushFd[0] != -1) close(mFlushFd[0]);
+ if (mFlushFd[1] != -1) close(mFlushFd[1]);
}
int SofSource::init() {
@@ -155,6 +173,12 @@ int SofSource::start() {
return OK;
}
+ if (mFlushFd[0] != -1) {
+ // read pipe just in case there is data in pipe.
+ char readBuf;
+ int readSize = read(mFlushFd[0], reinterpret_cast(&readBuf), sizeof(char));
+ LOG1("%s, readSize %d", __func__, readSize);
+ }
int status = mPollThread->run("SofSource", PRIORITY_URGENT_AUDIO);
mExitPending = false;
return status;
@@ -167,40 +191,45 @@ int SofSource::stop() {
}
mExitPending = true;
+ if (mFlushFd[1] != -1) {
+ char buf = 0xf; // random value to write to flush fd.
+ int size = write(mFlushFd[1], &buf, sizeof(char));
+ LOG1("%s, write size %d", __func__, size);
+ }
+
int status = mPollThread->requestExitAndWait();
return status;
}
int SofSource::poll() {
int ret = 0;
- const int pollTimeoutCount = 100;
- const int pollTimeout = 100;
+ const int pollTimeoutCount = 10;
+ const int pollTimeout = 1000;
std::vector pollDevs;
pollDevs.push_back(mIsysReceiverSubDev);
- V4L2DevicePoller poller{pollDevs, -1};
+ V4L2DevicePoller poller{pollDevs, mFlushFd[0]};
std::vector readyDevices;
int timeOutCount = pollTimeoutCount;
while (timeOutCount-- && ret == 0) {
+ if (mExitPending) {
+ LOG2("%s: mExitPending is true, exit", __func__);
+ return -1;
+ }
+
ret = poller.Poll(pollTimeout, POLLPRI | POLLIN | POLLOUT | POLLERR, &readyDevices);
+ }
- if (ret == 0 && mExitPending) {
- // timed out
- LOGI("Time out or thread is not running, ret = %d", ret);
- return BAD_VALUE;
- }
+ if (mExitPending) {
+ LOG2("%s: mExitPending is true, exit", __func__);
+ return -1;
}
// handle the poll error
if (ret < 0) {
- if (mExitPending) {
- // Exiting, no error
- return 0;
- }
-
LOGE("Poll error");
return ret;
} else if (ret == 0) {
diff --git a/src/core/SofSource.h b/src/core/SofSource.h
index 737b2905..d67e3675 100644
--- a/src/core/SofSource.h
+++ b/src/core/SofSource.h
@@ -67,6 +67,7 @@ class SofSource : public EventSource {
bool mSofDisabled;
int poll();
+ int mFlushFd[2]; // Flush file descriptor
};
} // namespace icamera
diff --git a/src/platformdata/CameraParser.cpp b/src/platformdata/CameraParser.cpp
index ef41f752..639fbb9a 100644
--- a/src/platformdata/CameraParser.cpp
+++ b/src/platformdata/CameraParser.cpp
@@ -1406,7 +1406,6 @@ void CameraParser::parseLinkElement(CameraParser* profiles, const char* name, co
void CameraParser::parseRouteElement(CameraParser* profiles, const char* name, const char** atts) {
McRoute route;
- MediaCtlConf& mc = profiles->pCurrentCam->mMediaCtlConfs.back();
route.flag = MEDIA_LNK_FL_ENABLED;
int idx = 0;
@@ -1432,6 +1431,8 @@ void CameraParser::parseRouteElement(CameraParser* profiles, const char* name, c
}
idx += 2;
}
+ // VIRTUAL_CHANNEL_S
+ MediaCtlConf& mc = profiles->pCurrentCam->mMediaCtlConfs.back();
auto it = mc.routings.find(route.entityName);
if (it != mc.routings.end()) {
@@ -1441,6 +1442,7 @@ void CameraParser::parseRouteElement(CameraParser* profiles, const char* name, c
routes.push_back(route);
mc.routings.insert(std::pair>(route.entityName, routes));
}
+ // VIRTUAL_CHANNEL_E
}
void CameraParser::parseVideoElement(CameraParser* profiles, const char* name,