[libcamera-devel,v2,11/27] libcamera: v4l2_videodevice: Document plane handling in createBuffer()
diff mbox series

Message ID 20210906020100.14430-12-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: Handle fallout of FrameBuffer offset support
Related show

Commit Message

Laurent Pinchart Sept. 6, 2021, 2 a.m. UTC
The V4L2VideoDevice::createBuffer() calculates offsets manually when
using a multi-planar pixel format and a single-planar V4L2 format. The
process isn't trivial, document it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/v4l2_videodevice.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jean-Michel Hautbois Sept. 6, 2021, 7:11 a.m. UTC | #1
Hi Laurent,

On 06/09/2021 04:00, Laurent Pinchart wrote:
> The V4L2VideoDevice::createBuffer() calculates offsets manually when
> using a multi-planar pixel format and a single-planar V4L2 format. The
> process isn't trivial, document it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> ---
>  src/libcamera/v4l2_videodevice.cpp | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 1483181a0856..88535f5a07c7 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1334,10 +1334,19 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
>  	}
>  
>  	/*
> +	 * If we have a multi-planar format with a V4L2 single-planar buffer,
> +	 * split the single V4L2 plane into multiple FrameBuffer planes by
> +	 * computing the offsets manually.
> +	 *
>  	 * The format info is not guaranteed to be valid, as there are no
>  	 * PixelFormatInfo for metadata formats, so check it first.
>  	 */
>  	if (formatInfo_->isValid() && formatInfo_->numPlanes() != numPlanes) {
> +		/*
> +		 * There's no valid situation where the number of colour planes
> +		 * differs from the number of V4L2 planes and the V4L2 buffer
> +		 * has more than one plane.
> +		 */
>  		ASSERT(numPlanes == 1u);
>  
>  		planes.resize(formatInfo_->numPlanes());
>
Hirokazu Honda Sept. 6, 2021, 12:53 p.m. UTC | #2
Hi Laurent,

On Mon, Sep 6, 2021 at 4:11 PM Jean-Michel Hautbois
<jeanmichel.hautbois@ideasonboard.com> wrote:
>
> Hi Laurent,
>
> On 06/09/2021 04:00, Laurent Pinchart wrote:
> > The V4L2VideoDevice::createBuffer() calculates offsets manually when
> > using a multi-planar pixel format and a single-planar V4L2 format. The
> > process isn't trivial, document it.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> > ---
> >  src/libcamera/v4l2_videodevice.cpp | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> > index 1483181a0856..88535f5a07c7 100644
> > --- a/src/libcamera/v4l2_videodevice.cpp
> > +++ b/src/libcamera/v4l2_videodevice.cpp
> > @@ -1334,10 +1334,19 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
> >       }
> >
> >       /*
> > +      * If we have a multi-planar format with a V4L2 single-planar buffer,
> > +      * split the single V4L2 plane into multiple FrameBuffer planes by
> > +      * computing the offsets manually.
> > +      *
> >        * The format info is not guaranteed to be valid, as there are no
> >        * PixelFormatInfo for metadata formats, so check it first.
> >        */
> >       if (formatInfo_->isValid() && formatInfo_->numPlanes() != numPlanes) {
> > +             /*
> > +              * There's no valid situation where the number of colour planes
> > +              * differs from the number of V4L2 planes and the V4L2 buffer
> > +              * has more than one plane.
> > +              */
> >               ASSERT(numPlanes == 1u);
> >
> >               planes.resize(formatInfo_->numPlanes());
> >

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 1483181a0856..88535f5a07c7 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1334,10 +1334,19 @@  std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
 	}
 
 	/*
+	 * If we have a multi-planar format with a V4L2 single-planar buffer,
+	 * split the single V4L2 plane into multiple FrameBuffer planes by
+	 * computing the offsets manually.
+	 *
 	 * The format info is not guaranteed to be valid, as there are no
 	 * PixelFormatInfo for metadata formats, so check it first.
 	 */
 	if (formatInfo_->isValid() && formatInfo_->numPlanes() != numPlanes) {
+		/*
+		 * There's no valid situation where the number of colour planes
+		 * differs from the number of V4L2 planes and the V4L2 buffer
+		 * has more than one plane.
+		 */
 		ASSERT(numPlanes == 1u);
 
 		planes.resize(formatInfo_->numPlanes());