cameraserver: Reduced Quad Bayer support.
Allow devices which don't have the ULTRA_HIGH_RESOLUTION_SENSOR
capability to get the same framework behaviour as devices which:
1) SENSOR_PIXEL_MODE is advertised in ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS
2) The following keys are present in CameraCharacteristics for basic functionality
a) ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION
b) ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION
c) ANDROID_SCALER_AVAILABLE_STALL_DURATIONS_MAXIMUM_RESOLUTION
d) ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
e) ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
f) ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION
Bug: 261232769
Test: Manual
Change-Id: Ib2261a63b9d1cf7d960ab158fa66dc65160c3344
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
index f786b79..48b27be 100644
--- a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
+++ b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
@@ -196,6 +196,8 @@
if (bestWidth == -1) {
// Return false if no configurations for this format were listed
+ ALOGE("%s: No configurations for format %d width %d, height %d, maxResolution ? %s",
+ __FUNCTION__, format, width, height, maxResolution ? "true" : "false");
return false;
}
@@ -937,7 +939,7 @@
const std::unordered_set<int32_t> &sensorPixelModesUsedSet =
convertToSet(sensorPixelModesUsed);
- if (!isUltraHighResolutionSensor(staticInfo)) {
+ if (!supportsUltraHighResolutionCapture(staticInfo)) {
if (sensorPixelModesUsedSet.find(ANDROID_SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION) !=
sensorPixelModesUsedSet.end()) {
// invalid value for non ultra high res sensors
@@ -961,12 +963,14 @@
// Case 1: The client has not changed the sensor mode defaults. In this case, we check if the
// size + format of the OutputConfiguration is found exclusively in 1.
// If yes, add that sensorPixelMode to overriddenSensorPixelModes.
- // If no, add 'DEFAULT' to sensorPixelMode. This maintains backwards
- // compatibility.
+ // If no, add 'DEFAULT' and MAXIMUM_RESOLUTION to overriddenSensorPixelModes.
+ // This maintains backwards compatibility and also tells the framework the stream
+ // might be used in either sensor pixel mode.
if (sensorPixelModesUsedSet.size() == 0) {
- // Ambiguous case, default to only 'DEFAULT' mode.
+ // Ambiguous case, override to include both cases.
if (isInDefaultStreamConfigurationMap && isInMaximumResolutionStreamConfigurationMap) {
overriddenSensorPixelModesUsed->insert(ANDROID_SENSOR_PIXEL_MODE_DEFAULT);
+ overriddenSensorPixelModesUsed->insert(ANDROID_SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION);
return OK;
}
// We don't allow flexible consumer for max resolution mode.
diff --git a/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.cpp b/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.cpp
index 28a22e1..7d344f8 100644
--- a/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.cpp
+++ b/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.cpp
@@ -73,7 +73,62 @@
return -1;
}
-bool isUltraHighResolutionSensor(const CameraMetadata &deviceInfo) {
+static bool isKeyPresentWithCount(const CameraMetadata &deviceInfo, uint32_t tag, uint32_t count) {
+ auto countFound = deviceInfo.find(tag).count;
+ return (countFound != 0) && (countFound % count == 0);
+}
+
+static bool supportsKeysForBasicUltraHighResolutionCapture(const CameraMetadata &deviceInfo) {
+ // Check whether the following conditions are satisfied for reduced ultra high
+ // resolution support :
+ // 1) SENSOR_PIXEL_MODE is advertised in ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS
+ // 2) The following keys are present in CameraCharacteristics for basic functionality
+ // a) ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION
+ // b) ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION
+ // c) ANDROID_SCALER_AVAILABLE_STALL_DURATIONS_MAXIMUM_RESOLUTION
+ // d) ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ // e) ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ // f) ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ camera_metadata_ro_entry_t entryChar;
+ entryChar = deviceInfo.find(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS);
+ bool supportsSensorPixelMode = false;
+ for (size_t i = 0; i < entryChar.count; i++) {
+ int32_t key = entryChar.data.i32[i];
+ if (key == ANDROID_SENSOR_PIXEL_MODE) {
+ supportsSensorPixelMode = true;
+ break;
+ }
+ }
+ if (!supportsSensorPixelMode) {
+ return false;
+ }
+
+ // Basic sensor array size information tags are present
+ if (!isKeyPresentWithCount(deviceInfo, ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION,
+ /*count*/2) ||
+ !isKeyPresentWithCount(deviceInfo,
+ ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION,
+ /*count*/4) ||
+ !isKeyPresentWithCount(deviceInfo,
+ ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION, /*count*/4) ||
+ !isKeyPresentWithCount(deviceInfo, ANDROID_SENSOR_INFO_BINNING_FACTOR, /*count*/2)) {
+ return false;
+ }
+
+ // Basic stream configuration tags are present
+ if (!isKeyPresentWithCount(deviceInfo,
+ ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION, /*count*/4) ||
+ !isKeyPresentWithCount(deviceInfo,
+ ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION, /*count*/4) ||
+ !isKeyPresentWithCount(deviceInfo,
+ ANDROID_SCALER_AVAILABLE_STALL_DURATIONS_MAXIMUM_RESOLUTION, /*count*/ 4)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool supportsUltraHighResolutionCapture(const CameraMetadata &deviceInfo) {
camera_metadata_ro_entry_t entryCap;
entryCap = deviceInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
// Go through the capabilities and check if it has
@@ -84,7 +139,10 @@
return true;
}
}
- return false;
+
+ // If not, then check that the keys which guarantee basic supports for
+ // ultra high resolution capture are supported.
+ return supportsKeysForBasicUltraHighResolutionCapture(deviceInfo);
}
bool getArrayWidthAndHeight(const CameraMetadata *deviceInfo,
diff --git a/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.h b/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.h
index 45b1e91..dac1824 100644
--- a/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.h
+++ b/services/camera/libcameraservice/utils/SessionConfigurationUtilsHost.h
@@ -22,7 +22,7 @@
namespace camera3 {
namespace SessionConfigurationUtils {
-bool isUltraHighResolutionSensor(const CameraMetadata &deviceInfo);
+bool supportsUltraHighResolutionCapture(const CameraMetadata &deviceInfo);
int32_t getAppropriateModeTag(int32_t defaultTag, bool maxResolution = false);
@@ -33,4 +33,4 @@
} // camera3
} // android
-#endif
\ No newline at end of file
+#endif