From patchwork Fri Oct 18 15:42:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2197 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 460CD600EB for ; Fri, 18 Oct 2019 17:42:06 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BCD6D3FDC; Fri, 18 Oct 2019 17:42:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571413325; bh=2pjPnWZo4ouaEFErbLhOVYg5wbz9U5Kpqk4b/TBxLes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVYYb0SD6ZtnKYGssGFFlvyor6SNEaOhvtrd01tnsCKYoHfc4qKVm3F1Kl6suhpGC SgfTQ6o4oYRbDPBk7ZA2eygXNFXfTqCwWIf7cxRXKzSR31YjolaRxnRNI1Awp9r8Dd yn2PEKOgx50SWRv41RjmXtyB7NyYSuXq+VmyLY+k= From: Kieran Bingham To: LibCamera Devel Date: Fri, 18 Oct 2019 16:42:00 +0100 Message-Id: <20191018154201.13540-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> References: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: v4l2_videodevice: Normalise multiPlanar configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Oct 2019 15:42:07 -0000 The use of either single planar or multi planar API is constant throughout the usage of a device, based upon the buffer type of the stream, and once determined it does not change. Rather than interrogate the bufferType_ each time, set a device flag at open() time as to whether we are using planar or multi-planar buffer APIs. Signed-off-by: Kieran Bingham --- src/libcamera/include/v4l2_videodevice.h | 1 + src/libcamera/v4l2_videodevice.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 4b8cf9394eb9..60fca01670c6 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -182,6 +182,7 @@ private: enum v4l2_buf_type bufferType_; enum v4l2_memory memoryType_; + bool multiPlanar_; BufferPool *bufferPool_; std::map queuedBuffers_; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 208ab54199b1..37f61b90ac46 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -350,6 +350,8 @@ int V4L2VideoDevice::open() return -EINVAL; } + multiPlanar_ = V4L2_TYPE_IS_MULTIPLANAR(bufferType_); + fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable); fdEvent_->setEnabled(false); @@ -436,6 +438,8 @@ int V4L2VideoDevice::open(int handle, enum v4l2_buf_type type) return -EINVAL; } + multiPlanar_ = V4L2_TYPE_IS_MULTIPLANAR(bufferType_); + fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable); fdEvent_->setEnabled(false); @@ -870,7 +874,7 @@ int V4L2VideoDevice::exportBuffers(BufferPool *pool) break; } - if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) { + if (multiPlanar_) { for (unsigned int p = 0; p < buf.length; ++p) { ret = createPlane(&buffer, i, p, buf.m.planes[p].length); @@ -993,12 +997,11 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer) buf.memory = memoryType_; buf.field = V4L2_FIELD_NONE; - bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); BufferMemory *mem = &bufferPool_->buffers()[buf.index]; const std::vector &planes = mem->planes(); if (buf.memory == V4L2_MEMORY_DMABUF) { - if (multiPlanar) { + if (multiPlanar_) { for (unsigned int p = 0; p < planes.size(); ++p) v4l2Planes[p].m.fd = planes[p].dmabuf(); } else { @@ -1006,7 +1009,7 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer) } } - if (multiPlanar) { + if (multiPlanar_) { buf.length = planes.size(); buf.m.planes = v4l2Planes; } @@ -1099,7 +1102,7 @@ Buffer *V4L2VideoDevice::dequeueBuffer() buf.type = bufferType_; buf.memory = memoryType_; - if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) { + if (multiPlanar_) { buf.length = VIDEO_MAX_PLANES; buf.m.planes = planes; } From patchwork Fri Oct 18 15:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2198 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6EFB1600FD for ; Fri, 18 Oct 2019 17:42:06 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0DA1C3FDE; Fri, 18 Oct 2019 17:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571413326; bh=AjBOhWlDStrE0wqKfG6W7nlfHCpb9Dbaq081Y+pDRGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGK9sUfkwQGheu6IoScT+da78bGvORYRZhG5paXFzcpse5nW7nsJef8igdsNQI68z 9PcC3eaQm9ZkUwM656IIxrXEG0ObNcFDSTzn0Zjv7JTSCiaJe8UVAiDdmNWMhHgKYO PkttDSOTUSD8C7Ie2ctbouYRROPJ9Of/efmBJcb0= From: Kieran Bingham To: LibCamera Devel Date: Fri, 18 Oct 2019 16:42:01 +0100 Message-Id: <20191018154201.13540-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> References: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: v4l2_videodevice: Update bytesused when dq'ing MPLANE buffers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Oct 2019 15:42:07 -0000 When we dequeue a buffer using the MPLANE API, we currently set our buffer->bytesused field to zero due to the zero entry in the V4L2 buffer bytesused field. The bytesused field is only really tracked for debug purposes currently, so store the total bytese used from each plane in our local statistics to identify actual data flow. Signed-off-by: Kieran Bingham --- This patch comes with a pinch of salt, we could also add a bytesused field to the Plane class and intead update all the debug prints to report the bytesused on a per-plane basis. --- src/libcamera/v4l2_videodevice.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 37f61b90ac46..71f141e7b511 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1124,13 +1124,20 @@ Buffer *V4L2VideoDevice::dequeueBuffer() fdEvent_->setEnabled(false); buffer->index_ = buf.index; - buffer->bytesused_ = buf.bytesused; buffer->timestamp_ = buf.timestamp.tv_sec * 1000000000ULL + buf.timestamp.tv_usec * 1000ULL; buffer->sequence_ = buf.sequence; buffer->status_ = buf.flags & V4L2_BUF_FLAG_ERROR ? Buffer::BufferError : Buffer::BufferSuccess; + if (multiPlanar_) { + buffer->bytesused_ = 0; + for (unsigned int p = 0; p < buf.length; ++p) + buffer->bytesused_ += planes[p].bytesused; + } else { + buffer->bytesused_ = buf.bytesused; + } + return buffer; }