Message ID | 20200318033200.3042855-6-niklas.soderlund@ragnatech.se |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Niklas, Thank you for the patch. On Wed, Mar 18, 2020 at 04:31:57AM +0100, Niklas Söderlund wrote: > When generating a camera configuration pixel formats directly from the > video device are used that contains V4L2 pixel formats. Translate the > pixel formats to DRM before using them in the camera configuration. I find the first sentence a bit hard to read. How about the following ? 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> > --- > 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 320da2685795c041..1de091e0c0e57f7c 100644 > --- a/src/libcamera/pipeline/uvcvideo.cpp > +++ b/src/libcamera/pipeline/uvcvideo.cpp > @@ -153,8 +153,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();
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 320da2685795c041..1de091e0c0e57f7c 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -153,8 +153,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();