QCamera2/HAL3: Increase inflight request count for 60FPS encode
With 16.67 ms time per frame expected, the current in-flight request count
is insufficient. Increase it to 6 to avoid the frame drops.
Ack-by: Ashvin Deodhar
BUG=28313712
CRs-Fixed: 1020354
Change-Id: I6d9fe11402e53eb3b11be42a30a86f76a9c4e0ff
diff --git a/QCamera2/HAL3/QCamera3HWI.cpp b/QCamera2/HAL3/QCamera3HWI.cpp
index 0b60483..f308005 100644
--- a/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/QCamera2/HAL3/QCamera3HWI.cpp
@@ -371,6 +371,8 @@
mOpMode(CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE),
mFirstFrameNumberInBatch(0),
mNeedSensorRestart(false),
+ mMinInFlightRequests(MIN_INFLIGHT_REQUESTS),
+ mMaxInFlightRequests(MAX_INFLIGHT_REQUESTS),
mLdafCalibExist(false),
mPowerHintEnabled(false),
mLastCustIntentFrmNum(-1),
@@ -3404,8 +3406,6 @@
int rc = NO_ERROR;
int32_t request_id;
CameraMetadata meta;
- uint32_t minInFlightRequests = MIN_INFLIGHT_REQUESTS;
- uint32_t maxInFlightRequests = MAX_INFLIGHT_REQUESTS;
bool isVidBufRequested = false;
camera3_stream_buffer_t *pInputBuffer = NULL;
@@ -3523,9 +3523,23 @@
/* Set fps and hfr mode while sending meta stream info so that sensor
* can configure appropriate streaming mode */
mHFRVideoFps = DEFAULT_VIDEO_FPS;
+ mMinInFlightRequests = MIN_INFLIGHT_REQUESTS;
+ mMaxInFlightRequests = MAX_INFLIGHT_REQUESTS;
if (meta.exists(ANDROID_CONTROL_AE_TARGET_FPS_RANGE)) {
rc = setHalFpsRange(meta, mParameters);
- if (rc != NO_ERROR) {
+ if (rc == NO_ERROR) {
+ int32_t max_fps =
+ (int32_t) meta.find(ANDROID_CONTROL_AE_TARGET_FPS_RANGE).data.i32[1];
+ if (max_fps == 60) {
+ mMinInFlightRequests = MIN_INFLIGHT_60FPS_REQUESTS;
+ }
+ /* For HFR, more buffers are dequeued upfront to improve the performance */
+ if (mBatchSize) {
+ mMinInFlightRequests = MIN_INFLIGHT_HFR_REQUESTS;
+ mMaxInFlightRequests = MAX_INFLIGHT_HFR_REQUESTS;
+ }
+ }
+ else {
LOGE("setHalFpsRange failed");
}
}
@@ -4188,16 +4202,12 @@
// Make timeout as 5 sec for request to be honored
ts.tv_sec += 5;
}
- //Block on conditional variable
- if (mBatchSize) {
- /* For HFR, more buffers are dequeued upfront to improve the performance */
- minInFlightRequests = MIN_INFLIGHT_HFR_REQUESTS;
- maxInFlightRequests = MAX_INFLIGHT_HFR_REQUESTS;
- }
+
if (m_perfLock.isPerfLockTimedAcquired() && m_perfLock.isTimerReset())
m_perfLock.lock_rel_timed();
- while ((mPendingLiveRequest >= minInFlightRequests) && !pInputBuffer &&
+ //Block on conditional variable
+ while ((mPendingLiveRequest >= mMinInFlightRequests) && !pInputBuffer &&
(mState != ERROR) && (mState != DEINIT)) {
if (!isValidTimeout) {
LOGD("Blocking on conditional wait");
@@ -4215,7 +4225,7 @@
LOGD("Unblocked");
if (mWokenUpByDaemon) {
mWokenUpByDaemon = false;
- if (mPendingLiveRequest < maxInFlightRequests)
+ if (mPendingLiveRequest < mMaxInFlightRequests)
break;
}
}
diff --git a/QCamera2/HAL3/QCamera3HWI.h b/QCamera2/HAL3/QCamera3HWI.h
index cbd36e9..3948040 100644
--- a/QCamera2/HAL3/QCamera3HWI.h
+++ b/QCamera2/HAL3/QCamera3HWI.h
@@ -478,6 +478,8 @@
uint32_t mFirstFrameNumberInBatch;
camera3_stream_t mDummyBatchStream;
bool mNeedSensorRestart;
+ uint32_t mMinInFlightRequests;
+ uint32_t mMaxInFlightRequests;
/* sensor output size with current stream configuration */
QCamera3CropRegionMapper mCropRegionMapper;
diff --git a/QCamera2/stack/common/cam_types.h b/QCamera2/stack/common/cam_types.h
index 1f3fa1d..8e9ac5c 100644
--- a/QCamera2/stack/common/cam_types.h
+++ b/QCamera2/stack/common/cam_types.h
@@ -109,6 +109,7 @@
#define MAX_INFLIGHT_REQUESTS 6
#define MAX_INFLIGHT_BLOB 3
#define MIN_INFLIGHT_REQUESTS 3
+#define MIN_INFLIGHT_60FPS_REQUESTS (6)
#define MAX_INFLIGHT_REPROCESS_REQUESTS 1
#define MAX_INFLIGHT_HFR_REQUESTS (48)
#define MIN_INFLIGHT_HFR_REQUESTS (40)