From patchwork Sun Feb 3 11:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 498 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 48A5D60DBF for ; Sun, 3 Feb 2019 12:01:09 +0100 (CET) Received: from localhost.localdomain (218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E777A5AA; Sun, 3 Feb 2019 12:01:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549191669; bh=xd95viNIHdkTi2L4JZPRetCmmmWxPGMMERwPWaUI7gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BeN9QsPUInoU6CeR4Jj1ILeCMSN2EUFwuDsJzwNEXvEO2WFWnCZfvL53+LkBEiAD5 JsPaVgyvQybD6IZGZCHd7a8cZjo0K7143+I7VN85tUASER3hOgg0ONP1YsAGoMlEIU K7dPf+Kd2Ws5gbh+5h1VZ7IvdgBv5n0PeuOzHhQE= From: Kieran Bingham To: LibCamera Devel Date: Sun, 3 Feb 2019 12:01:02 +0100 Message-Id: <20190203110102.5663-12-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190203110102.5663-1-kieran.bingham@ideasonboard.com> References: <20190203110102.5663-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/11] libcamera: v4l2device: update Buffer with information from v4l2_buffer when dequeueing X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2019 11:01:10 -0000 From: Niklas Söderlund Copy the information from the struct v4l2_buffer when dequeueing the buffer as applications need this information to make sens of the captured data. Signed-off-by: Niklas Söderlund [Kieran: Re-adapt to use the V4L2Buffer class casting] --- include/libcamera/buffer.h | 12 ++++++++++++ src/libcamera/include/v4l2_device.h | 2 ++ src/libcamera/v4l2_device.cpp | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 97fab5c65cce..b4dd0851bc7f 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_BUFFER_H__ #define __LIBCAMERA_BUFFER_H__ +#include #include namespace libcamera { @@ -46,8 +47,19 @@ public: unsigned int index() const { return index_; }; const std::vector &planes() { return planes_; }; + unsigned int bytesused() const { return bytesused_; }; + unsigned int flags() const { return flags_; }; + unsigned int field() const { return field_; }; + struct timeval timestamp() const { return timestamp_; }; + unsigned int sequence() const { return sequence_; }; + protected: unsigned int index_; + unsigned int bytesused_; + unsigned int flags_; + unsigned int field_; + struct timeval timestamp_; + unsigned int sequence_; unsigned int format_; unsigned int width_; diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index fbbddad68082..641362ff594c 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -61,6 +61,8 @@ class V4L2Buffer : public Buffer { public: V4L2Buffer(struct v4l2_buffer &vb); + + void update(struct v4l2_buffer &vb); }; class V4L2DeviceFormat diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 630b43532c3e..7fafe2af393d 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -111,6 +112,16 @@ V4L2Buffer::V4L2Buffer(struct v4l2_buffer &vb) } } +void V4L2Buffer::update(struct v4l2_buffer &vb) +{ + /* Update buffer information */ + bytesused_ = vb.bytesused; + flags_ = vb.flags; + field_ = vb.field; + timestamp_ = vb.timestamp; + sequence_ = vb.sequence; +} + /** * \class V4L2DeviceFormat * \brief The V4L2 device image format and sizes @@ -673,7 +684,11 @@ Buffer *V4L2Device::dequeueBuffer() return nullptr; } - return bufferPool_->buffers()[buf.index]; + V4L2Buffer *b; + b = reinterpret_cast(bufferPool_->buffers()[buf.index]); + b->update(buf); + + return b; } /**