Camera: Map between bufferqueue gralloc0 usage, and HIDL gralloc1 usages
Otherwise some bits aren't where they're supposed to be.
Also stop using HW_CAMERA_ZSL; we need to only set HW_CAMERA_READ, and it's
confusing to set a producer flag on the consumer usage side.
Test: Camera CTS passes
Bug: 35215313
Change-Id: I23e6e60bf875fe9d8f2d7a1f805d2ef854c16b97
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 1de2edc..e7b0c6b 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -44,6 +44,8 @@
#include <utils/Timers.h>
#include <cutils/properties.h>
+#include <grallocusage/GrallocUsageConversion.h>
+
#include <android/hardware/camera2/ICameraDeviceUser.h>
#include "utils/CameraTraces.h"
@@ -495,11 +497,6 @@
return dataSpace;
}
-ConsumerUsageFlags Camera3Device::mapToConsumerUsage(
- uint32_t usage) {
- return usage;
-}
-
StreamRotation Camera3Device::mapToStreamRotation(camera3_stream_rotation_t rotation) {
switch (rotation) {
case CAMERA3_STREAM_ROTATION_0:
@@ -549,16 +546,6 @@
return static_cast<uint32_t>(pixelFormat);
}
-uint32_t Camera3Device::mapConsumerToFrameworkUsage(
- ConsumerUsageFlags usage) {
- return usage;
-}
-
-uint32_t Camera3Device::mapProducerToFrameworkUsage(
- ProducerUsageFlags usage) {
- return usage;
-}
-
ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const {
// Get max jpeg size (area-wise).
Size maxJpegResolution = getMaxJpegResolution();
@@ -3173,7 +3160,9 @@
dst.width = src->width;
dst.height = src->height;
dst.format = mapToPixelFormat(src->format);
- dst.usage = mapToConsumerUsage(src->usage);
+ uint64_t consumerUsage, producerUsage;
+ ::android_convertGralloc0To1Usage(src->usage, &producerUsage, &consumerUsage);
+ dst.usage = consumerUsage;
dst.dataSpace = mapToHidlDataspace(src->data_space);
dst.rotation = mapToStreamRotation((camera3_stream_rotation_t) src->rotation);
@@ -3255,7 +3244,6 @@
__FUNCTION__, streamId);
return INVALID_OPERATION;
}
- dst->usage = mapConsumerToFrameworkUsage(src.consumerUsage);
} else {
// OUTPUT
if (src.consumerUsage != 0) {
@@ -3263,8 +3251,8 @@
__FUNCTION__, streamId);
return INVALID_OPERATION;
}
- dst->usage = mapProducerToFrameworkUsage(src.producerUsage);
}
+ dst->usage = ::android_convertGralloc1To0Usage(src.producerUsage, src.consumerUsage);
dst->max_buffers = src.maxBuffers;
}
}
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index d873b27..70dd302 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -598,7 +598,6 @@
static hardware::graphics::common::V1_0::PixelFormat mapToPixelFormat(int frameworkFormat);
static hardware::camera::device::V3_2::DataspaceFlags mapToHidlDataspace(
android_dataspace dataSpace);
- static hardware::camera::device::V3_2::ConsumerUsageFlags mapToConsumerUsage(uint32_t usage);
static hardware::camera::device::V3_2::StreamRotation mapToStreamRotation(
camera3_stream_rotation_t rotation);
// Returns a negative error code if the passed-in operation mode is not valid.
@@ -606,10 +605,6 @@
/*out*/ hardware::camera::device::V3_2::StreamConfigurationMode *mode);
static camera3_buffer_status_t mapHidlBufferStatus(hardware::camera::device::V3_2::BufferStatus status);
static int mapToFrameworkFormat(hardware::graphics::common::V1_0::PixelFormat pixelFormat);
- static uint32_t mapConsumerToFrameworkUsage(
- hardware::camera::device::V3_2::ConsumerUsageFlags usage);
- static uint32_t mapProducerToFrameworkUsage(
- hardware::camera::device::V3_2::ProducerUsageFlags usage);
struct RequestTrigger {
// Metadata tag number, e.g. android.control.aePrecaptureTrigger
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
index 51dc20a..b4c8eb7 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
@@ -624,7 +624,7 @@
NATIVE_WINDOW_CONSUMER_USAGE_BITS, &u);
// If an opaque output stream's endpoint is ImageReader, add
- // GRALLOC_USAGE_HW_CAMERA_ZSL to the usage so HAL knows it will be used
+ // GRALLOC_USAGE_HW_CAMERA_READ to the usage so HAL knows it will be used
// for the ZSL use case.
// Assume it's for ImageReader if the consumer usage doesn't have any of these bits set:
// 1. GRALLOC_USAGE_HW_TEXTURE
@@ -634,7 +634,7 @@
if (camera3_stream::format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
(u & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER |
GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_VIDEO_ENCODER)) == 0) {
- u |= GRALLOC_USAGE_HW_CAMERA_ZSL;
+ u |= GRALLOC_USAGE_HW_CAMERA_READ;
}
*usage = u;