[libcamera-devel,RFC,v1,12/12] libcamera: v4l2_videodevice: Use utils::enumerate()
diff mbox series

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

Commit Message

Laurent Pinchart Sept. 2, 2021, 4:23 a.m. UTC
Replace a manual counter with the utils::enumerate() utility function.

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

Comments

Kieran Bingham Sept. 2, 2021, 10:42 a.m. UTC | #1
On 02/09/2021 05:23, Laurent Pinchart wrote:
> Replace a manual counter with the utils::enumerate() utility function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/v4l2_videodevice.cpp | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index b80b9038a914..8a7d847c060e 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1338,13 +1338,12 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
>  		planes.resize(formatInfo_->numPlanes());
>  		const FileDescriptor &fd = planes[0].fd;
>  		size_t offset = 0;
> -		for (size_t i = 0; i < planes.size(); ++i) {
> -			planes[i].fd = fd;
> -			planes[i].offset = offset;
> -
> +		for (auto [i, plane] : utils::enumerate(planes)) {
> +			plane.fd = fd;
> +			plane.offset = offset;
>  			/* \todo Take the V4L2 stride into account */

Is this todo still valid ?

I don't think it's affected by this patch anyway though so:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> -			planes[i].length = formatInfo_->planeSize(format_.size, i);
> -			offset += planes[i].length;
> +			plane.length = formatInfo_->planeSize(format_.size, i);
> +			offset += plane.length;
>  		}
>  	}
>  
>
Laurent Pinchart Sept. 2, 2021, 6:32 p.m. UTC | #2
Hi Kieran,

On Thu, Sep 02, 2021 at 11:42:24AM +0100, Kieran Bingham wrote:
> On 02/09/2021 05:23, Laurent Pinchart wrote:
> > Replace a manual counter with the utils::enumerate() utility function.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/libcamera/v4l2_videodevice.cpp | 11 +++++------
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> > 
> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> > index b80b9038a914..8a7d847c060e 100644
> > --- a/src/libcamera/v4l2_videodevice.cpp
> > +++ b/src/libcamera/v4l2_videodevice.cpp
> > @@ -1338,13 +1338,12 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
> >  		planes.resize(formatInfo_->numPlanes());
> >  		const FileDescriptor &fd = planes[0].fd;
> >  		size_t offset = 0;
> > -		for (size_t i = 0; i < planes.size(); ++i) {
> > -			planes[i].fd = fd;
> > -			planes[i].offset = offset;
> > -
> > +		for (auto [i, plane] : utils::enumerate(planes)) {
> > +			plane.fd = fd;
> > +			plane.offset = offset;
> >  			/* \todo Take the V4L2 stride into account */
> 
> Is this todo still valid ?

Yes it is, we don't support programming a non-default stride yet.

> I don't think it's affected by this patch anyway though so:
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > -			planes[i].length = formatInfo_->planeSize(format_.size, i);
> > -			offset += planes[i].length;
> > +			plane.length = formatInfo_->planeSize(format_.size, i);
> > +			offset += plane.length;
> >  		}
> >  	}
> >
Hirokazu Honda Sept. 3, 2021, 12:37 p.m. UTC | #3
Hi Laurent,

On Fri, Sep 3, 2021 at 3:32 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Kieran,
>
> On Thu, Sep 02, 2021 at 11:42:24AM +0100, Kieran Bingham wrote:
> > On 02/09/2021 05:23, Laurent Pinchart wrote:
> > > Replace a manual counter with the utils::enumerate() utility function.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

Thanks,
-Hiro
> > > ---
> > >  src/libcamera/v4l2_videodevice.cpp | 11 +++++------
> > >  1 file changed, 5 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> > > index b80b9038a914..8a7d847c060e 100644
> > > --- a/src/libcamera/v4l2_videodevice.cpp
> > > +++ b/src/libcamera/v4l2_videodevice.cpp
> > > @@ -1338,13 +1338,12 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
> > >             planes.resize(formatInfo_->numPlanes());
> > >             const FileDescriptor &fd = planes[0].fd;
> > >             size_t offset = 0;
> > > -           for (size_t i = 0; i < planes.size(); ++i) {
> > > -                   planes[i].fd = fd;
> > > -                   planes[i].offset = offset;
> > > -
> > > +           for (auto [i, plane] : utils::enumerate(planes)) {
> > > +                   plane.fd = fd;
> > > +                   plane.offset = offset;
> > >                     /* \todo Take the V4L2 stride into account */
> >
> > Is this todo still valid ?
>
> Yes it is, we don't support programming a non-default stride yet.
>
> > I don't think it's affected by this patch anyway though so:
> >
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >
> > > -                   planes[i].length = formatInfo_->planeSize(format_.size, i);
> > > -                   offset += planes[i].length;
> > > +                   plane.length = formatInfo_->planeSize(format_.size, i);
> > > +                   offset += plane.length;
> > >             }
> > >     }
> > >
>
> --
> Regards,
>
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index b80b9038a914..8a7d847c060e 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1338,13 +1338,12 @@  std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
 		planes.resize(formatInfo_->numPlanes());
 		const FileDescriptor &fd = planes[0].fd;
 		size_t offset = 0;
-		for (size_t i = 0; i < planes.size(); ++i) {
-			planes[i].fd = fd;
-			planes[i].offset = offset;
-
+		for (auto [i, plane] : utils::enumerate(planes)) {
+			plane.fd = fd;
+			plane.offset = offset;
 			/* \todo Take the V4L2 stride into account */
-			planes[i].length = formatInfo_->planeSize(format_.size, i);
-			offset += planes[i].length;
+			plane.length = formatInfo_->planeSize(format_.size, i);
+			offset += plane.length;
 		}
 	}