[libcamera-devel,v2,4/4] libcamera: v4l2_videodevice: Warn if bytesused == 0 when queuing output buffer
diff mbox series

Message ID 20221004222903.6393-5-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Fix kernel deprecation warning with output buffers
Related show

Commit Message

Laurent Pinchart Oct. 4, 2022, 10:29 p.m. UTC
V4L2 has deprecated queuing output buffers with bytesused set to 0. Warn
if the caller attempts to do so.

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

Comments

Umang Jain Oct. 5, 2022, 6:48 a.m. UTC | #1
Hi Laurent,

On 10/5/22 3:59 AM, Laurent Pinchart via libcamera-devel wrote:
> V4L2 has deprecated queuing output buffers with bytesused set to 0. Warn
> if the caller attempts to do so.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>   src/libcamera/v4l2_videodevice.cpp | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 4d846f6be7fa..e30858c9fa02 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1623,6 +1623,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
>   	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
>   		const FrameMetadata &metadata = buffer->metadata();
>   
> +		for (const auto &plane : metadata.planes()) {
> +			if (!plane.bytesused)
> +				LOG(V4L2, Warning) << "byteused == 0 is deprecated";
> +		}
> +

Should the warning be printed depending on the kernel's version?

As far as code is concerned,, it looks good to me.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>


>   		if (numV4l2Planes != planes.size()) {
>   			/*
>   			 * If we have a multi-planar buffer with a V4L2
Laurent Pinchart Oct. 5, 2022, 8:09 a.m. UTC | #2
Hi Umang,

On Wed, Oct 05, 2022 at 12:18:58PM +0530, Umang Jain wrote:
> On 10/5/22 3:59 AM, Laurent Pinchart via libcamera-devel wrote:
> > V4L2 has deprecated queuing output buffers with bytesused set to 0. Warn
> > if the caller attempts to do so.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >   src/libcamera/v4l2_videodevice.cpp | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> > index 4d846f6be7fa..e30858c9fa02 100644
> > --- a/src/libcamera/v4l2_videodevice.cpp
> > +++ b/src/libcamera/v4l2_videodevice.cpp
> > @@ -1623,6 +1623,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
> >   	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
> >   		const FrameMetadata &metadata = buffer->metadata();
> >   
> > +		for (const auto &plane : metadata.planes()) {
> > +			if (!plane.bytesused)
> > +				LOG(V4L2, Warning) << "byteused == 0 is deprecated";
> > +		}
> > +
> 
> Should the warning be printed depending on the kernel's version?

I don't think so. This behaviour has been deprecated in V4L2 for years,
and it will keep working for quite some time still. The goal of this
patch is to catch offenders in libcamera, to make sure pipeline handler
do the right thing going forward.

> As far as code is concerned,, it looks good to me.
> 
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> 
> >   		if (numV4l2Planes != planes.size()) {
> >   			/*
> >   			 * If we have a multi-planar buffer with a V4L2

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 4d846f6be7fa..e30858c9fa02 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1623,6 +1623,11 @@  int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
 	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
 		const FrameMetadata &metadata = buffer->metadata();
 
+		for (const auto &plane : metadata.planes()) {
+			if (!plane.bytesused)
+				LOG(V4L2, Warning) << "byteused == 0 is deprecated";
+		}
+
 		if (numV4l2Planes != planes.size()) {
 			/*
 			 * If we have a multi-planar buffer with a V4L2