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>
This commit is contained in:
Niklas Söderlund
2020-03-18 18:02:40 +01:00
parent 4f3096f352
commit 4bc262ecaa
+13 -2
View File
@@ -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();