manta: libcamera2: drain requests on empty request queue
Bug: 18118823
Bug: 17771002
Bug: 17660746
Bug: 13921808
Bug: 13358648
Bug: 13299991
Change-Id: Ib81b7d8b76470eebcd434a20b46d6235f5381f8b
diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp
index 8fce907..cab01b4 100644
--- a/libcamera2/ExynosCameraHWInterface2.cpp
+++ b/libcamera2/ExynosCameraHWInterface2.cpp
@@ -615,10 +615,15 @@
ALOGV("DEBUG(%s): frameCnt(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount);
for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) {
- if((entries[i].internal_shot.shot.ctl.request.frameCount == shot_ext->shot.ctl.request.frameCount)
- && (entries[i].status == CAPTURED)){
- entries[i].status = METADONE;
- break;
+ if (entries[i].internal_shot.shot.ctl.request.frameCount
+ == shot_ext->shot.ctl.request.frameCount) {
+ if (entries[i].status == CAPTURED) {
+ entries[i].status = METADONE;
+ break;
+ }
+ if (entries[i].status == METADONE) {
+ return;
+ }
}
}
@@ -861,9 +866,10 @@
return ¤tEntry->internal_shot;
}
-int RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext)
+int RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain)
{
Mutex::Autolock lock(m_requestMutex);
+ Mutex::Autolock lock2(m_numOfEntriesLock);
int i;
if (m_numOfEntries == 0) {
@@ -879,6 +885,9 @@
entries[i].status = CAPTURED;
return entries[i].internal_shot.shot.ctl.request.frameCount;
}
+ if (drain && (entries[i].status >= CAPTURED)) {
+ return entries[i].internal_shot.shot.ctl.request.frameCount;
+ }
CAM_LOGE("ERR(%s): frameCount(%d), index(%d), status(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount, i, entries[i].status);
}
@@ -3154,7 +3163,7 @@
matchedFrameCnt = m_ctlInfo.flash.m_flashFrameCount;
ALOGV("Skip frame, request is fixed at %d", matchedFrameCnt);
} else {
- matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext);
+ matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext, m_isRequestQueueNull);
}
if (matchedFrameCnt == -1 && m_vdisBubbleCnt > 0) {
diff --git a/libcamera2/ExynosCameraHWInterface2.h b/libcamera2/ExynosCameraHWInterface2.h
index a8e3348..927eace 100644
--- a/libcamera2/ExynosCameraHWInterface2.h
+++ b/libcamera2/ExynosCameraHWInterface2.h
@@ -283,7 +283,7 @@
uint8_t GetOutputStream(int index);
camera2_shot_ext * GetInternalShotExtByFrameCnt(int frameCnt);
camera2_shot_ext * GetInternalShotExt(int index);
- int FindFrameCnt(struct camera2_shot_ext * shot_ext);
+ int FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain);
bool IsVdisEnable(void);
int FindEntryIndexByFrameCnt(int frameCnt);
void Dump(void);