summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-05-26 15:16:55 +0200
committerJacopo Mondi <jacopo@jmondi.org>2020-06-08 23:01:55 +0200
commit82d9331efd2b25fc518858499f6d37716feae3b9 (patch)
treeb0a0205cdf499c185b7ebb0eb36b9a69cc635747 /src
parentbde7b98cac25d391cfab2e668c5ada59b0e20224 (diff)
android: camera_device: Translate Android format
Translate the Android format code to the libcamera format code at stream configuration time, using the translation map built at camera device initialization time. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index b4a33509..7a0dc530 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -938,12 +938,26 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
<< ", format: " << utils::hex(stream->format);
}
- /* Hardcode viewfinder role, collecting sizes from the stream config. */
+ /* Only one stream is supported. */
if (stream_list->num_streams != 1) {
LOG(HAL, Error) << "Only one stream supported";
return -EINVAL;
}
+ camera3_stream_t *camera3Stream = stream_list->streams[0];
+
+ /* Translate Android format code to libcamera pixel format. */
+ auto it = formatsMap_.find(camera3Stream->format);
+ if (it == formatsMap_.end()) {
+ LOG(HAL, Error) << "Requested format "
+ << utils::hex(camera3Stream->format)
+ << " not supported";
+ return -EINVAL;
+ }
+ /*
+ * Hardcode viewfinder role, replacing the generated configuration
+ * parameters with the ones requested by the Android framework.
+ */
StreamRoles roles = { StreamRole::Viewfinder };
config_ = camera_->generateConfiguration(roles);
if (!config_ || config_->empty()) {
@@ -951,17 +965,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
return -EINVAL;
}
- /* Only one stream is supported. */
- camera3_stream_t *camera3Stream = stream_list->streams[0];
StreamConfiguration *streamConfiguration = &config_->at(0);
streamConfiguration->size.width = camera3Stream->width;
streamConfiguration->size.height = camera3Stream->height;
-
- /*
- * \todo We'll need to translate from Android defined pixel format codes
- * to the libcamera image format codes. For now, do not change the
- * format returned from Camera::generateConfiguration().
- */
+ streamConfiguration->pixelFormat = it->second;
switch (config_->validate()) {
case CameraConfiguration::Valid: