Camera: Limit framerate re-configurations during HFR
Per API specification the maximum framerate range is the only
value that needs to be considered during constrained camera
sessions. If target fps is part of the session parameters, then
we should only monitor for modifications in the upper range.
Bug: 78494729
Test: Camera CTS
Change-Id: Ic7de406820347f8e58bf3d4fee7750f694372604
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 6b958a8..9acbf0a 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -4045,6 +4045,7 @@
mRepeatingLastFrameNumber(
hardware::camera2::ICameraDeviceUser::NO_IN_FLIGHT_REPEATING_FRAMES),
mPrepareVideoStream(false),
+ mConstrainedMode(false),
mRequestLatency(kRequestLatencyBinSize),
mSessionParamKeys(sessionParamKeys),
mLatestSessionParams(sessionParamKeys.size()) {
@@ -4068,6 +4069,7 @@
mLatestSessionParams = sessionParams;
// Prepare video stream for high speed recording.
mPrepareVideoStream = isConstrainedHighSpeed;
+ mConstrainedMode = isConstrainedHighSpeed;
}
status_t Camera3Device::RequestThread::queueRequestList(
@@ -4482,6 +4484,17 @@
return maxExpectedDuration;
}
+bool Camera3Device::RequestThread::skipHFRTargetFPSUpdate(int32_t tag,
+ const camera_metadata_ro_entry_t& newEntry, const camera_metadata_entry_t& currentEntry) {
+ if (mConstrainedMode && (ANDROID_CONTROL_AE_TARGET_FPS_RANGE == tag) &&
+ (newEntry.count == currentEntry.count) && (currentEntry.count == 2) &&
+ (currentEntry.data.i32[1] == newEntry.data.i32[1])) {
+ return true;
+ }
+
+ return false;
+}
+
bool Camera3Device::RequestThread::updateSessionParameters(const CameraMetadata& settings) {
ATRACE_CALL();
bool updatesDetected = false;
@@ -4514,8 +4527,10 @@
if (isDifferent) {
ALOGV("%s: Session parameter tag id %d changed", __FUNCTION__, tag);
+ if (!skipHFRTargetFPSUpdate(tag, entry, lastEntry)) {
+ updatesDetected = true;
+ }
mLatestSessionParams.update(entry);
- updatesDetected = true;
}
} else if (lastEntry.count > 0) {
// Value has been removed
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index 13b83ba..5372407 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -861,6 +861,11 @@
// Check and update latest session parameters based on the current request settings.
bool updateSessionParameters(const CameraMetadata& settings);
+ // Check whether FPS range session parameter re-configuration is needed in constrained
+ // high speed recording camera sessions.
+ bool skipHFRTargetFPSUpdate(int32_t tag, const camera_metadata_ro_entry_t& newEntry,
+ const camera_metadata_entry_t& currentEntry);
+
// Re-configure camera using the latest session parameters.
bool reconfigureCamera();
@@ -919,6 +924,8 @@
// Flag indicating if we should prepare video stream for video requests.
bool mPrepareVideoStream;
+ bool mConstrainedMode;
+
static const int32_t kRequestLatencyBinSize = 40; // in ms
CameraLatencyHistogram mRequestLatency;