libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()
The V4L2VideoDevice::toV4L2PixelFormat() function is incorrectly implemented, as it will pick a multi-planar format if the device supports the multi-planar API, even if only single-planar formats are supported. This currently works because the implementation calls V4L2PixelFormat::fromPixelFormat(), which ignores the multiplanar argument and always returns a single-planar format. Fixing this isn't trivial. As we don't need to support multi-planar V4L2 formats at this point, drop the function instead of pretending everything is fine, and call V4L2PixelFormat::fromPixelFormat() directly from pipeline handlers. As the single-planar case is the most common, set the multiplanar argument to false by default to avoid long lines. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
parent
8e18f8d45f
commit
395d43d6d7
12 changed files with 26 additions and 47 deletions
|
@ -970,8 +970,7 @@ with the fourcc and size attributes to apply directly to the capture device
|
|||
node. The fourcc attribute is a `V4L2PixelFormat`_ and differs from the
|
||||
``libcamera::PixelFormat``. Converting the format requires knowledge of the
|
||||
plane configuration for multiplanar formats, so you must explicitly convert it
|
||||
using the helper ``V4L2VideoDevice::toV4L2PixelFormat()`` provided by the
|
||||
V4L2VideoDevice instance of which the format will be applied on.
|
||||
using the helper ``V4L2PixelFormat::fromPixelFormat()``.
|
||||
|
||||
.. _V4L2DeviceFormat: http://libcamera.org/api-html/classlibcamera_1_1V4L2DeviceFormat.html
|
||||
.. _V4L2PixelFormat: http://libcamera.org/api-html/classlibcamera_1_1V4L2PixelFormat.html
|
||||
|
@ -981,7 +980,7 @@ Add the following code beneath the code from above:
|
|||
.. code-block:: cpp
|
||||
|
||||
V4L2DeviceFormat format = {};
|
||||
format.fourcc = data->video_->toV4L2PixelFormat(cfg.pixelFormat);
|
||||
format.fourcc = V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat);
|
||||
format.size = cfg.size;
|
||||
|
||||
Set the video device format defined above using the
|
||||
|
@ -1001,7 +1000,7 @@ Continue the implementation with the following code:
|
|||
return ret;
|
||||
|
||||
if (format.size != cfg.size ||
|
||||
format.fourcc != data->video_->toV4L2PixelFormat(cfg.pixelFormat))
|
||||
format.fourcc != V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat))
|
||||
return -EINVAL;
|
||||
|
||||
Finally, store and set stream-specific data reflecting the state of the stream.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue