[libcamera-devel,11/30] libcamera: v4l2_videodevice: Align which type variable is used in queueBuffer()

Message ID 20191126233620.1695316-12-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: Rework buffer API
Related show

Commit Message

Niklas Söderlund Nov. 26, 2019, 11:36 p.m. UTC
Reading V4L2VideoDevice::queueBuffer() is confusing since buf.type is
first set to bufferType_ but then both variables are used in V4L2 macros
to operate based on which type of buffer is being processed. Aligen on
only using buf.type since it have the most existing users.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/v4l2_videodevice.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi Nov. 27, 2019, 2:48 p.m. UTC | #1
Hi Niklas,

On Wed, Nov 27, 2019 at 12:36:01AM +0100, Niklas Söderlund wrote:
> Reading V4L2VideoDevice::queueBuffer() is confusing since buf.type is
> first set to bufferType_ but then both variables are used in V4L2 macros
> to operate based on which type of buffer is being processed. Aligen on
> only using buf.type since it have the most existing users.

I'm not sure which one of the two is mostly used to be honest.

This change won't hurt though if you want it in.
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/v4l2_videodevice.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 166b0abc1b101f88..7b6fa5347ef320f8 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1000,7 +1000,7 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)
>  		buf.m.planes = v4l2Planes;
>  	}
>
> -	if (V4L2_TYPE_IS_OUTPUT(bufferType_)) {
> +	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
>  		buf.bytesused = buffer->bytesused_;
>  		buf.sequence = buffer->sequence_;
>  		buf.timestamp.tv_sec = buffer->timestamp_ / 1000000000;
> --
> 2.24.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi Dec. 2, 2019, 9:58 a.m. UTC | #2
Hi Niklas,
   sorry for the double comment

On Wed, Nov 27, 2019 at 03:48:33PM +0100, Jacopo Mondi wrote:
> Hi Niklas,
>
> On Wed, Nov 27, 2019 at 12:36:01AM +0100, Niklas Söderlund wrote:
> > Reading V4L2VideoDevice::queueBuffer() is confusing since buf.type is
> > first set to bufferType_ but then both variables are used in V4L2 macros
> > to operate based on which type of buffer is being processed. Aligen on

s/Aligen/Align

Thanks
   j

> > only using buf.type since it have the most existing users.
>
> I'm not sure which one of the two is mostly used to be honest.
>
> This change won't hurt though if you want it in.
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
>
> Thanks
>   j
>
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/libcamera/v4l2_videodevice.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> > index 166b0abc1b101f88..7b6fa5347ef320f8 100644
> > --- a/src/libcamera/v4l2_videodevice.cpp
> > +++ b/src/libcamera/v4l2_videodevice.cpp
> > @@ -1000,7 +1000,7 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)
> >  		buf.m.planes = v4l2Planes;
> >  	}
> >
> > -	if (V4L2_TYPE_IS_OUTPUT(bufferType_)) {
> > +	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
> >  		buf.bytesused = buffer->bytesused_;
> >  		buf.sequence = buffer->sequence_;
> >  		buf.timestamp.tv_sec = buffer->timestamp_ / 1000000000;
> > --
> > 2.24.0
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel



> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Dec. 9, 2019, 6:24 p.m. UTC | #3
Hi Niklas,

Thank you for the patch.

On Wed, Nov 27, 2019 at 12:36:01AM +0100, Niklas Söderlund wrote:
> Reading V4L2VideoDevice::queueBuffer() is confusing since buf.type is
> first set to bufferType_ but then both variables are used in V4L2 macros
> to operate based on which type of buffer is being processed. Aligen on

s/Aligen/Align/

> only using buf.type since it have the most existing users.

s/have/has/

> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/v4l2_videodevice.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 166b0abc1b101f88..7b6fa5347ef320f8 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1000,7 +1000,7 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)
>  		buf.m.planes = v4l2Planes;
>  	}
>  
> -	if (V4L2_TYPE_IS_OUTPUT(bufferType_)) {
> +	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
>  		buf.bytesused = buffer->bytesused_;
>  		buf.sequence = buffer->sequence_;
>  		buf.timestamp.tv_sec = buffer->timestamp_ / 1000000000;

Patch

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 166b0abc1b101f88..7b6fa5347ef320f8 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1000,7 +1000,7 @@  int V4L2VideoDevice::queueBuffer(Buffer *buffer)
 		buf.m.planes = v4l2Planes;
 	}
 
-	if (V4L2_TYPE_IS_OUTPUT(bufferType_)) {
+	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
 		buf.bytesused = buffer->bytesused_;
 		buf.sequence = buffer->sequence_;
 		buf.timestamp.tv_sec = buffer->timestamp_ / 1000000000;