summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-17 03:19:05 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-18 18:02:40 +0100
commit4bc262ecaa736b956cf8878d8f3459c9caf7c37e (patch)
tree51570a888a3bf88a68a51c508aaffc5f9b827d25
parent4f3096f352edc2803b14c97c0fe04903528eae42 (diff)
libcamera: pipeline: uvcvideo: Translate from V4L2 to DRM pixel formats
When generating a camera configuration, pixel formats from the video device are used directly. They however contain V4L2 pixel format FourCCs, not DRM pixel format FourCCs. Translate the pixel formats to DRM before using them in the camera configuration. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index cf419e8b..5ff29240 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -155,8 +155,19 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera,
if (roles.empty())
return config;
- ImageFormats v4l2formats = data->video_->formats();
- StreamFormats formats(v4l2formats.data());
+ std::map<unsigned int, std::vector<SizeRange>> v4l2Formats =
+ data->video_->formats().data();
+ std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
+ std::transform(v4l2Formats.begin(), v4l2Formats.end(),
+ std::inserter(deviceFormats, deviceFormats.begin()),
+ [&](const decltype(v4l2Formats)::value_type &format) {
+ return decltype(deviceFormats)::value_type{
+ data->video_->toPixelFormat(format.first),
+ format.second
+ };
+ });
+
+ StreamFormats formats(deviceFormats);
StreamConfiguration cfg(formats);
cfg.pixelFormat = formats.pixelformats().front();