camera: intel: ipu6: Add API to run TNR in sync mode
Add api to run tnr in sync mode
BUG=b:149068439, b:149068672
TEST=Full tested pass for camera functions.
Change-Id: I9a81dee475d80d974df0f8d4bbc2759916c04a4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2594542
Tested-by: Zong Li <zong.li@intel.com>
Reviewed-by: Ren-Pei Zeng <kamesan@chromium.org>
Commit-Queue: Ren-Pei Zeng <kamesan@chromium.org>
diff --git a/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.cpp b/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.cpp
index 44e4345..060c405 100644
--- a/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.cpp
+++ b/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.cpp
@@ -101,7 +101,7 @@
}
int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, Tnr7Param* tnrParam, int fd) {
+ uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd) {
PERF_CAMERA_ATRACE();
TRACE_LOG_PROCESS("IntelTNR7US", "runTnrFrame");
LOG1("%s mCameraId %d, type %d", __func__, mCameraId, mTnrType);
@@ -119,9 +119,10 @@
}
CheckError(outSurface == nullptr, UNKNOWN_ERROR, "Failed to get CMSurface for output buffer");
- /* call Tnr api to run tnr for the inSurface and store the result in refOutSurface */
- int ret = run_tnr7us_frame(mWidth, mHeight, mWidth, inSurface, outSurface, &tnrParam->scale,
- &tnrParam->ims, &tnrParam->bc, &tnrParam->blend, false, mTnrType);
+ /* 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,
+ &tnrParam->ims, &tnrParam->bc, &tnrParam->blend, syncUpdate, mTnrType);
if (fd >= 0) {
destroyCMSurface(outSurface);
}
diff --git a/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.h b/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.h
index 45b49b3..2242b7b 100644
--- a/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.h
+++ b/camera/hal/intel/ipu6/modules/algowrapper/IntelTNR7US.h
@@ -68,7 +68,7 @@
* \param fd: user output buffer file handle
*/
int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, Tnr7Param* tnrParam, int fd = -1);
+ uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd = -1);
Tnr7Param* allocTnr7ParamBuf();
void* allocCamBuf(uint32_t bufSize, int id);
void freeAllBufs();
diff --git a/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.cpp b/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.cpp
index b63fe00..2de3c5a 100644
--- a/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.cpp
+++ b/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.cpp
@@ -84,7 +84,7 @@
}
int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, Tnr7Param* tnrParam, int fd) {
+ uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd) {
LOG1("%s type:%d", __func__, mTnrType);
CheckError(!inBufAddr || !outBufAddr || !tnrParam, UNKNOWN_ERROR,
"@%s, invalid data buffer or parameter buffer", __func__);
@@ -107,6 +107,7 @@
mTnrRequestInfo->type = mTnrType;
mTnrRequestInfo->cameraId = mCameraId;
mTnrRequestInfo->outBufFd = fd;
+ mTnrRequestInfo->isForceUpdate = syncUpdate;
int32_t requestHandle =
mCommon.getShmMemHandle(static_cast<void*>(mTnrRequestInfo), GPU_ALGO_SHM);
diff --git a/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.h b/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.h
index 477a83d..5c706ea 100644
--- a/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.h
+++ b/camera/hal/intel/ipu6/modules/sandboxing/client/IntelTNR7US.h
@@ -32,7 +32,7 @@
~IntelTNR7US();
int init(int width, int height, TnrType type);
int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, Tnr7Param* tnrParam, int fd = -1);
+ uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd = -1);
Tnr7Param* allocTnr7ParamBuf();
void* allocCamBuf(uint32_t bufSize, int id);
void freeAllBufs();
diff --git a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelGPUAlgoServer.cpp b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelGPUAlgoServer.cpp
index 40a9baf..08e9d6c 100644
--- a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelGPUAlgoServer.cpp
+++ b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelGPUAlgoServer.cpp
@@ -66,8 +66,7 @@
break;
}
}
- status = mTNR.prepareSurface(surfaceBuffer.addr, surfaceBuffer.size,
- requestInfo->cameraId, requestInfo->type);
+ status = mTNR.prepareSurface(surfaceBuffer.addr, surfaceBuffer.size, requestInfo);
break;
}
case IPC_GPU_TNR_RUN_FRAME: {
@@ -98,19 +97,17 @@
}
status = mTNR.runTnrFrame(inBuffer.addr, outBuffer.addr, inBuffer.size, outBuffer.size,
- paramBuffer.addr, requestInfo->cameraId, requestInfo->type,
- requestInfo->outBufFd);
+ paramBuffer.addr, requestInfo);
break;
}
case IPC_GPU_TNR_PARAM_UPDATE: {
TnrRequestInfo* requestInfo = static_cast<TnrRequestInfo*>(addr);
- status = mTNR.asyncParamUpdate(requestInfo->cameraId, requestInfo->gain,
- requestInfo->type, requestInfo->isForceUpdate);
+ status = mTNR.asyncParamUpdate(requestInfo);
break;
}
case IPC_GPU_TNR_DEINIT: {
TnrRequestInfo* requestInfo = static_cast<TnrRequestInfo*>(addr);
- status = mTNR.deInit(requestInfo->cameraId, requestInfo->type);
+ status = mTNR.deInit(requestInfo);
break;
}
#endif
diff --git a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.cpp b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.cpp
index 5332169..529b686 100644
--- a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.cpp
+++ b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.cpp
@@ -70,39 +70,42 @@
static_cast<TnrType>(tnrInstance));
}
-int IntelTNRServer::deInit(int cameraId, TnrType type) {
- LOG1("@%s", __func__);
- int key = getIndex(cameraId, type);
+int IntelTNRServer::deInit(TnrRequestInfo* requestInfo) {
+ CheckError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", __func__);
+ int key = getIndex(requestInfo->cameraId, requestInfo->type);
CheckError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR,
- "%s, IntelTNR type:%d is nullptr", __func__, type);
+ "%s, IntelTNR type:%d is nullptr", __func__, requestInfo->type);
mIntelTNRMap.erase(key);
mTnrSlotMap.erase(key);
return OK;
}
-int IntelTNRServer::prepareSurface(void* pData, int dataSize, int cameraId, TnrType type) {
- CheckError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__);
- int key = getIndex(cameraId, type);
+int IntelTNRServer::prepareSurface(void* pData, int dataSize, TnrRequestInfo* requestInfo) {
+ CheckError(pData == nullptr || requestInfo == nullptr, UNKNOWN_ERROR, "@%s, param is nullptr",
+ __func__);
+ int key = getIndex(requestInfo->cameraId, requestInfo->type);
CheckError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR,
- "%s, IntelTNR type:%d is nullptr", __func__, type);
+ "%s, IntelTNR type:%d is nullptr", __func__, requestInfo->type);
return mIntelTNRMap[key]->prepareSurface(pData, dataSize);
}
int IntelTNRServer::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, void* tnrParam, int cameraId, TnrType type,
- int outBufFd) {
- int key = getIndex(cameraId, type);
+ uint32_t outBufSize, void* tnrParam, TnrRequestInfo* requestInfo) {
+ CheckError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, param is nullptr", __func__);
+ int key = getIndex(requestInfo->cameraId, requestInfo->type);
CheckError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR,
- "%s, IntelTNR type:%d is nullptr", __func__, type);
+ "%s, IntelTNR type:%d is nullptr", __func__, requestInfo->type);
return mIntelTNRMap[key]->runTnrFrame(inBufAddr, outBufAddr, inBufSize, outBufSize,
- static_cast<Tnr7Param*>(tnrParam), outBufFd);
+ static_cast<Tnr7Param*>(tnrParam),
+ requestInfo->isForceUpdate, requestInfo->outBufFd);
}
-int IntelTNRServer::asyncParamUpdate(int cameraId, int gain, TnrType type, bool forceUpdate) {
- int key = getIndex(cameraId, type);
+int IntelTNRServer::asyncParamUpdate(TnrRequestInfo* requestInfo) {
+ CheckError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", __func__);
+ int key = getIndex(requestInfo->cameraId, requestInfo->type);
CheckError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR,
- "%s, IntelTNR type:%d is nullptr", __func__, type);
- return mIntelTNRMap[key]->asyncParamUpdate(gain, forceUpdate);
+ "%s, IntelTNR type:%d is nullptr", __func__, requestInfo->type);
+ return mIntelTNRMap[key]->asyncParamUpdate(requestInfo->gain, requestInfo->isForceUpdate);
}
} // namespace icamera
diff --git a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.h b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.h
index 0d2c820..d4e2194 100644
--- a/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.h
+++ b/camera/hal/intel/ipu6/modules/sandboxing/server/IntelTNRServer.h
@@ -30,11 +30,11 @@
virtual ~IntelTNRServer();
int init(void* pData, int dataSize);
- int deInit(int cameraId, TnrType type);
- int prepareSurface(void* pData, int dataSize, int cameraId, TnrType type);
+ int deInit(TnrRequestInfo* requestInfo);
+ int prepareSurface(void* pData, int dataSize, TnrRequestInfo* requestInfo);
int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
- uint32_t outBufSize, void* tnrParam, int cameraId, TnrType type, int outBufFd);
- int asyncParamUpdate(int cameraId, int gain, TnrType type, bool forceUpdate);
+ uint32_t outBufSize, void* tnrParam, TnrRequestInfo* requestInfo);
+ int asyncParamUpdate(TnrRequestInfo* requestInfo);
private:
// the tnr instance of the id
diff --git a/camera/hal/intel/ipu6/src/core/psysprocessor/GPUExecutor.cpp b/camera/hal/intel/ipu6/src/core/psysprocessor/GPUExecutor.cpp
index c027a71..ce5a461 100644
--- a/camera/hal/intel/ipu6/src/core/psysprocessor/GPUExecutor.cpp
+++ b/camera/hal/intel/ipu6/src/core/psysprocessor/GPUExecutor.cpp
@@ -560,8 +560,9 @@
// when use internal tnr buffer, we don't need to use fd map buffer
dstFd = -1;
}
+ bool isTnrParamSyncUpdate = mStreamId == STILL_STREAM_ID ? true : false;
ret = mIntelTNR->runTnrFrame(inBuf->getBufferAddr(), dstBuf, inBuf->getBufferSize(), dstSize,
- mTnr7usParam, dstFd);
+ mTnr7usParam, isTnrParamSyncUpdate, dstFd);
if (ret == OK) {
if (useInternalBuffer) {
@@ -589,7 +590,7 @@
CheckError(ret != OK, UNKNOWN_ERROR, " %s tnr7us run frame failed", __func__);
mLastSequence = sequence;
- if (mStreamId != STILL_STREAM_ID) {
+ if (!isTnrParamSyncUpdate) {
// still stream will update params in tnr7us, skip async update
float totalGain = 0.0f;
ret = getTotalGain(sequence, &totalGain);