summaryrefslogtreecommitdiff
path: root/src/android/camera_device.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-05 13:53:53 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-05 22:22:47 +0200
commitde1b994bbaa4e34dc39c997d99f47026e7cddcfe (patch)
treecd78f465897e1bdab6953293b3cc6479b9ca7aa2 /src/android/camera_device.cpp
parent38f7c2af27aa4357cbeb57d4ab716c82067d5a89 (diff)
android: camera_device: Update gralloc usage flags for streams
When configuring streams, the camera HAL is supposed to update the gralloc usage flags to reflect the operations it will need to do on the stream buffers. Failure to do so leads to incorrect format selection by gralloc for the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format, as gralloc will not take into consideration the need of the camera to access the buffers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/camera_device.cpp')
-rw-r--r--src/android/camera_device.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ae01c362..3ee68370 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1539,6 +1539,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
streamConfig.config.size = size;
streamConfig.config.pixelFormat = format;
streamConfigs.push_back(std::move(streamConfig));
+
+ /* This stream will be produced by hardware. */
+ stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;
}
/* Now handle the MJPEG streams, adding a new stream if required. */
@@ -1548,7 +1551,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
/* Search for a compatible stream in the non-JPEG ones. */
for (size_t i = 0; i < streamConfigs.size(); ++i) {
- const auto &cfg = streamConfigs[i].config;
+ Camera3StreamConfig &streamConfig = streamConfigs[i];
+ const auto &cfg = streamConfig.config;
/*
* \todo The PixelFormat must also be compatible with
@@ -1563,6 +1567,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
type = CameraStream::Type::Mapped;
index = i;
+
+ /*
+ * The source stream will be read by software to
+ * produce the JPEG stream.
+ */
+ camera3_stream_t *stream = streamConfig.streams[0].stream;
+ stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN;
break;
}
@@ -1590,6 +1601,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
index = streamConfigs.size() - 1;
}
+ /* The JPEG stream will be produced by software. */
+ jpegStream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
+
streamConfigs[index].streams.push_back({ jpegStream, type });
}