[libcamera-devel] [PATCH 12/15] v4l2: v4l2_camera_proxy: Add sequence number
Paul Elder
paul.elder at ideasonboard.com
Thu Jun 18 11:12:40 CEST 2020
On Wed, Jun 17, 2020 at 05:36:37PM +0200, Jacopo Mondi wrote:
> Hi Paul,
>
> On Tue, Jun 16, 2020 at 10:12:41PM +0900, Paul Elder wrote:
> > Populate the sequence number field in the V4L2 buffers. Reset upon
> > streamon.
> >
> > Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> > ---
> > src/v4l2/v4l2_camera_proxy.cpp | 4 +++-
> > src/v4l2/v4l2_camera_proxy.h | 2 ++
> > 2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> > index 079961a..81f9282 100644
> > --- a/src/v4l2/v4l2_camera_proxy.cpp
> > +++ b/src/v4l2/v4l2_camera_proxy.cpp
> > @@ -33,7 +33,7 @@ LOG_DECLARE_CATEGORY(V4L2Compat);
> > V4L2CameraProxy::V4L2CameraProxy(unsigned int index,
> > std::shared_ptr<Camera> camera)
> > : refcount_(0), index_(index), bufferCount_(0), currentBuf_(0),
> > - vcam_(std::make_unique<V4L2Camera>(camera)), efd_(-1),
> > + sequence_(0), vcam_(std::make_unique<V4L2Camera>(camera)), efd_(-1),
>
> Why not use the sequence number reported by the video device and
> available in the frame metadata ?
Huh, apparently I already was. I don't know why v4l2-compliance
complained.
Paul
> > v4l2RecordPriorityFd_(-1), acquiredFd_(-1), initialized_(false),
> > streaming_(false)
> > {
> > @@ -665,6 +665,7 @@ int V4L2CameraProxy::vidioc_dqbuf(int fd, struct v4l2_buffer *arg)
> >
> > buf.flags &= ~V4L2_BUF_FLAG_QUEUED;
> > buf.length = sizeimage_;
> > + buf.sequence = sequence_++;
> > *arg = buf;
> >
> > currentBuf_ = (currentBuf_ + 1) % bufferCount_;
> > @@ -696,6 +697,7 @@ int V4L2CameraProxy::vidioc_streamon(int fd, int *arg)
> >
> > currentBuf_ = 0;
> > streaming_ = true;
> > + sequence_ = 0;
> >
> > return vcam_->streamOn();
> > }
> > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
> > index 28b2fa0..1d8e9a6 100644
> > --- a/src/v4l2/v4l2_camera_proxy.h
> > +++ b/src/v4l2/v4l2_camera_proxy.h
> > @@ -82,6 +82,8 @@ private:
> > unsigned int currentBuf_;
> > unsigned int sizeimage_;
> >
> > + uint32_t sequence_;
> > +
> > std::vector<struct v4l2_buffer> buffers_;
> > std::map<void *, unsigned int> mmaps_;
> >
> > --
> > 2.27.0
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel at lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
More information about the libcamera-devel
mailing list