summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-04-03 22:10:13 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-04 04:02:16 +0300
commit4ae2a75200e0062ecade3634c43d5d6266fc179f (patch)
tree4053029c2b71716c8ec8b80d4ebff6b271d7f7f6 /src/android
parent185574b741f0eca6c6225f4dec6be847aa73738f (diff)
android: CameraDevice: Validate crop_rotate_scale_degrees in configuration
libcamera doesn't handle |crop_rotate_scale_degrees| in camera3_stream at all. This adds the validation of the requested |crop_rotate_scale_degrees| in configuration, but still not handle the specified values. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 6bee49a5..249fd8cc 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -298,6 +298,44 @@ bool isValidRequest(camera3_capture_request_t *camera3Request)
return true;
}
+#if defined(OS_CHROMEOS)
+/*
+ * Check whether the crop_rotate_scale_degrees values for all streams in
+ * the list are valid according to the Chrome OS camera HAL API.
+ */
+bool validateCropRotate(const camera3_stream_configuration_t &streamList)
+{
+ ASSERT(streamList.num_streams > 0);
+ const int cropRotateScaleDegrees =
+ streamList.streams[0]->crop_rotate_scale_degrees;
+ for (unsigned int i = 0; i < streamList.num_streams; ++i) {
+ const camera3_stream_t &stream = *streamList.streams[i];
+
+ switch (stream.crop_rotate_scale_degrees) {
+ case CAMERA3_STREAM_ROTATION_0:
+ case CAMERA3_STREAM_ROTATION_90:
+ case CAMERA3_STREAM_ROTATION_270:
+ break;
+
+ /* 180° rotation is specified by Chrome OS as invalid. */
+ case CAMERA3_STREAM_ROTATION_180:
+ default:
+ LOG(HAL, Error) << "Invalid crop_rotate_scale_degrees: "
+ << stream.crop_rotate_scale_degrees;
+ return false;
+ }
+
+ if (cropRotateScaleDegrees != stream.crop_rotate_scale_degrees) {
+ LOG(HAL, Error) << "crop_rotate_scale_degrees in all "
+ << "streams are not identical";
+ return false;
+ }
+ }
+
+ return true;
+}
+#endif
+
} /* namespace */
/*
@@ -1601,6 +1639,11 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
return -EINVAL;
}
+#if defined(OS_CHROMEOS)
+ if (!validateCropRotate(*stream_list))
+ return -EINVAL;
+#endif
+
/*
* Generate an empty configuration, and construct a StreamConfiguration
* for each camera3_stream to add to it.