From 4bc262ecaa736b956cf8878d8f3459c9caf7c37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Tue, 17 Mar 2020 03:19:05 +0100 Subject: libcamera: pipeline: uvcvideo: Translate from V4L2 to DRM pixel formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 15 +++++++++++++-- 1 file 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> v4l2Formats = + data->video_->formats().data(); + std::map> 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(); -- cgit v1.2.1