From patchwork Tue Oct 4 22:29:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17524 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BE008C327C for ; Tue, 4 Oct 2022 22:29:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78FA660ACB; Wed, 5 Oct 2022 00:29:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664922550; bh=8e63qUQWXCtxp8pTQYx+QAgcCAOXD4p/LIiz/Ofkt9g=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=m3ouXR/h8baHIIenGeWPdfo/HuUi6zj9sogIK12AoeoqL1MU/Cf1hqwvbjEFywl/D fP5b1y+QCivfY813XwPfZ+9aGX7n6tRHoji4K7GbXq6V6U1/AFq6g8yZ5ssnLDzz4S as1c8vgh7FFjvZeXarHvi1YtE8vKYYfZ6HBmnLvKzunAhLxlTfgafAt17L8s0cLld4 V9ZbDF31irQqsrg8KLeAUFQWZUNUhVDYlXId1GRYwI07lbAbUiMqAxiBmiNrDQAibo I1QLv2sAREdB4ewVGW+AOEvIuX5cNrVmnP73t2/kT67YGWl7N/n+N7Hgy/uH5hN+QN RzyJ1Xph9Tu6A== 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 9F93360AA5 for ; Wed, 5 Oct 2022 00:29:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="s70CWPKY"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A399997; Wed, 5 Oct 2022 00:29:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664922548; bh=8e63qUQWXCtxp8pTQYx+QAgcCAOXD4p/LIiz/Ofkt9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s70CWPKY/w/fBw+NH7M8On//X8QlXdI1OEmdUK/XFzjzHx2cmB6FG6tziL5ZJjvu7 QKRLREdPyTjdIzxNwFq7OIIE0q0eb0/RF7N9gxfTYFD3foX52aIetjkFawUhuXgiJ5 Rq08cORqB7FU9vNyt+QkvFCqyX8UIvCNv09T/RR4= To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Oct 2022 01:29:00 +0300 Message-Id: <20221004222903.6393-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> References: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] libcamera: framebuffer: Move remaining private data to Private class 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Private members of the FrameBuffer class are split between FrameBuffer and FrameBuffer::Private. There was no real justification for this split, and keeping some members private in the FrameBuffer class causes multiple issues: - Future modifications of the FrameBuffer class without breaking the ABI may be more difficult. - Mutable access to members that should not be modified by applications require a friend statement, or going through the Private class. Move all remaining private members to the Private class to address the first issue, and add a Private::metadata() function to address the second problem. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- Changes since v1: - Add commit message - Fix compilation issue --- include/libcamera/framebuffer.h | 19 ++---- include/libcamera/internal/framebuffer.h | 10 +++- .../mm/cros_frame_buffer_allocator.cpp | 8 +-- .../mm/generic_frame_buffer_allocator.cpp | 9 +-- src/libcamera/framebuffer.cpp | 58 ++++++++++++------- src/libcamera/v4l2_videodevice.cpp | 20 ++++--- 6 files changed, 71 insertions(+), 53 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 36b91d11ed79..695539993f96 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -59,28 +59,19 @@ public: }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - FrameBuffer(std::unique_ptr d, - const std::vector &planes, unsigned int cookie = 0); + FrameBuffer(std::unique_ptr d); - const std::vector &planes() const { return planes_; } + const std::vector &planes() const; Request *request() const; - const FrameMetadata &metadata() const { return metadata_; } + const FrameMetadata &metadata() const; - uint64_t cookie() const { return cookie_; } - void setCookie(uint64_t cookie) { cookie_ = cookie; } + uint64_t cookie() const; + void setCookie(uint64_t cookie); std::unique_ptr releaseFence(); private: LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer) - - friend class V4L2VideoDevice; /* Needed to update metadata_. */ - - std::vector planes_; - - FrameMetadata metadata_; - - uint64_t cookie_; }; } /* namespace libcamera */ diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index 8a9cc98e22e3..1f42a4fcc865 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -22,7 +22,7 @@ class FrameBuffer::Private : public Extensible::Private LIBCAMERA_DECLARE_PUBLIC(FrameBuffer) public: - Private(); + Private(const std::vector &planes, uint64_t cookie = 0); virtual ~Private(); void setRequest(Request *request) { request_ = request; } @@ -31,9 +31,15 @@ public: Fence *fence() const { return fence_.get(); } void setFence(std::unique_ptr fence) { fence_ = std::move(fence); } - void cancel() { LIBCAMERA_O_PTR()->metadata_.status = FrameMetadata::FrameCancelled; } + void cancel() { metadata_.status = FrameMetadata::FrameCancelled; } + + FrameMetadata &metadata() { return metadata_; } private: + std::vector planes_; + FrameMetadata metadata_; + uint64_t cookie_; + std::unique_ptr fence_; Request *request_; bool isContiguous_; diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp index 52e8c180e3db..1e6f1ef55434 100644 --- a/src/android/mm/cros_frame_buffer_allocator.cpp +++ b/src/android/mm/cros_frame_buffer_allocator.cpp @@ -28,8 +28,9 @@ class CrosFrameBufferData : public FrameBuffer::Private LIBCAMERA_DECLARE_PUBLIC(FrameBuffer) public: - CrosFrameBufferData(cros::ScopedBufferHandle scopedHandle) - : FrameBuffer::Private(), scopedHandle_(std::move(scopedHandle)) + CrosFrameBufferData(cros::ScopedBufferHandle scopedHandle, + const std::vector &planes) + : FrameBuffer::Private(planes), scopedHandle_(std::move(scopedHandle)) { } @@ -81,8 +82,7 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, } return std::make_unique( - std::make_unique(std::move(scopedHandle)), - planes); + std::make_unique(std::move(scopedHandle), planes)); } PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index acb2fa2b699d..956623df1f80 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -32,8 +32,10 @@ class GenericFrameBufferData : public FrameBuffer::Private public: GenericFrameBufferData(struct alloc_device_t *allocDevice, - buffer_handle_t handle) - : allocDevice_(allocDevice), handle_(handle) + buffer_handle_t handle, + const std::vector &planes) + : FrameBuffer::Private(planes), allocDevice_(allocDevice), + handle_(handle) { ASSERT(allocDevice_); ASSERT(handle_); @@ -136,8 +138,7 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, } return std::make_unique( - std::make_unique(allocDevice_, handle), - planes); + std::make_unique(allocDevice_, handle, planes)); } PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 7be18560417c..5a7f3c0b5f9a 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -114,9 +114,16 @@ LOG_DEFINE_CATEGORY(Buffer) * pipeline handlers. */ -FrameBuffer::Private::Private() - : request_(nullptr), isContiguous_(true) +/** + * \brief Construct a FrameBuffer::Private instance + * \param[in] planes The frame memory planes + * \param[in] cookie Cookie + */ +FrameBuffer::Private::Private(const std::vector &planes, uint64_t cookie) + : planes_(planes), cookie_(cookie), request_(nullptr), + isContiguous_(true) { + metadata_.planes_.resize(planes_.size()); } /** @@ -194,6 +201,12 @@ FrameBuffer::Private::~Private() * indicate that the metadata is invalid. */ +/** + * \fn FrameBuffer::Private::metadata() + * \brief Retrieve the dynamic metadata + * \return Dynamic metadata for the frame contained in the buffer + */ + /** * \class FrameBuffer * \brief Frame buffer data and its associated dynamic metadata @@ -291,29 +304,22 @@ ino_t fileDescriptorInode(const SharedFD &fd) * \param[in] cookie Cookie */ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) - : FrameBuffer(std::make_unique(), planes, cookie) + : FrameBuffer(std::make_unique(planes, cookie)) { } /** - * \brief Construct a FrameBuffer with an extensible private class and an array - * of planes + * \brief Construct a FrameBuffer with an extensible private class * \param[in] d The extensible private class - * \param[in] planes The frame memory planes - * \param[in] cookie Cookie */ -FrameBuffer::FrameBuffer(std::unique_ptr d, - const std::vector &planes, - unsigned int cookie) - : Extensible(std::move(d)), planes_(planes), cookie_(cookie) +FrameBuffer::FrameBuffer(std::unique_ptr d) + : Extensible(std::move(d)) { - metadata_.planes_.resize(planes_.size()); - unsigned int offset = 0; bool isContiguous = true; ino_t inode = 0; - for (const auto &plane : planes_) { + for (const auto &plane : _d()->planes_) { ASSERT(plane.offset != Plane::kInvalidOffset); if (plane.offset != offset) { @@ -325,9 +331,9 @@ FrameBuffer::FrameBuffer(std::unique_ptr d, * Two different dmabuf file descriptors may still refer to the * same dmabuf instance. Check this using inodes. */ - if (plane.fd != planes_[0].fd) { + if (plane.fd != _d()->planes_[0].fd) { if (!inode) - inode = fileDescriptorInode(planes_[0].fd); + inode = fileDescriptorInode(_d()->planes_[0].fd); if (fileDescriptorInode(plane.fd) != inode) { isContiguous = false; break; @@ -344,10 +350,13 @@ FrameBuffer::FrameBuffer(std::unique_ptr d, } /** - * \fn FrameBuffer::planes() * \brief Retrieve the static plane descriptors * \return Array of plane descriptors */ +const std::vector &FrameBuffer::planes() const +{ + return _d()->planes_; +} /** * \brief Retrieve the request this buffer belongs to @@ -368,13 +377,15 @@ Request *FrameBuffer::request() const } /** - * \fn FrameBuffer::metadata() * \brief Retrieve the dynamic metadata * \return Dynamic metadata for the frame contained in the buffer */ +const FrameMetadata &FrameBuffer::metadata() const +{ + return _d()->metadata_; +} /** - * \fn FrameBuffer::cookie() * \brief Retrieve the cookie * * The cookie belongs to the creator of the FrameBuffer, which controls its @@ -384,9 +395,12 @@ Request *FrameBuffer::request() const * * \return The cookie */ +uint64_t FrameBuffer::cookie() const +{ + return _d()->cookie_; +} /** - * \fn FrameBuffer::setCookie() * \brief Set the cookie * \param[in] cookie Cookie to set * @@ -395,6 +409,10 @@ Request *FrameBuffer::request() const * modify the cookie value of buffers they haven't created themselves. The * libcamera core never modifies the buffer cookie. */ +void FrameBuffer::setCookie(uint64_t cookie) +{ + _d()->cookie_ = cookie; +} /** * \brief Extract the Fence associated with this Framebuffer diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 955e150867ef..4d846f6be7fa 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1791,12 +1791,14 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); } - buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR - ? FrameMetadata::FrameError - : FrameMetadata::FrameSuccess; - buffer->metadata_.sequence = buf.sequence; - buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL - + buf.timestamp.tv_usec * 1000ULL; + FrameMetadata &metadata = buffer->_d()->metadata(); + + metadata.status = buf.flags & V4L2_BUF_FLAG_ERROR + ? FrameMetadata::FrameError + : FrameMetadata::FrameSuccess; + metadata.sequence = buf.sequence; + metadata.timestamp = buf.timestamp.tv_sec * 1000000000ULL + + buf.timestamp.tv_usec * 1000ULL; if (V4L2_TYPE_IS_OUTPUT(buf.type)) return buffer; @@ -1812,10 +1814,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() << buf.sequence << ")"; firstFrame_ = buf.sequence; } - buffer->metadata_.sequence -= firstFrame_.value(); + metadata.sequence -= firstFrame_.value(); unsigned int numV4l2Planes = multiPlanar ? buf.length : 1; - FrameMetadata &metadata = buffer->metadata_; if (numV4l2Planes != buffer->planes().size()) { /* @@ -1941,9 +1942,10 @@ int V4L2VideoDevice::streamOff() /* Send back all queued buffers. */ for (auto it : queuedBuffers_) { FrameBuffer *buffer = it.second; + FrameMetadata &metadata = buffer->_d()->metadata(); cache_->put(it.first); - buffer->metadata_.status = FrameMetadata::FrameCancelled; + metadata.status = FrameMetadata::FrameCancelled; bufferReady.emit(buffer); } From patchwork Tue Oct 4 22:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17525 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3BB5EBD16B for ; Tue, 4 Oct 2022 22:29:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E67F160ACA; Wed, 5 Oct 2022 00:29:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664922551; bh=l48UoKpgn2xtn7SvJNa0pHvCj4usc5TCidd2hWVXZ8k=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QUmUw5nzscAq6ajnbov2NBj7UPL5U4oPaZbx1LG9MFwQHao+1SKFhI8WVe762ASyt l/FSZWsedv3Pk8h0FysYfRHdSlGsB1xSrRZz9A7FwF45zqOgoSaWZFJ56IxnJN/MI/ fOYgczGDbU5GU7BLmEmVSKHVARqPQNzseDF0nMYVOTm29SAYe88HAQfnQrfrpRiVp8 pQxlVWreTVhwqxt1nsBN9PfLxuGinmOKajZH5ecPbw9tpCPyMwWo5ezaVom39XMvyi z9rNFiQTwXuVnoGCL/JzkK7LLml+YaMpm7l3BbDcGOwZmXYrOg0iUe5EMdHvme3W+5 rAJeQ6ZoGPkNQ== 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 2A8A760AC9 for ; Wed, 5 Oct 2022 00:29:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D/XEdoVr"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A8B11997; Wed, 5 Oct 2022 00:29:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664922549; bh=l48UoKpgn2xtn7SvJNa0pHvCj4usc5TCidd2hWVXZ8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/XEdoVrjit3y4JsMyYMw1qOCu5GrLmH+bXmOdxfSQ2ngMUN/K6D76uztMxeKUKRd GJBCqN+3iqS3vz6f2invnVYWsN3OPNwRxeJWDEhdCJks7kwP9+4ou5ZmNEZzZ/DVSX nTbUXcKEn5gYX5N95Uky61jKJ8mbZ/y3QhxzFD+4= To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Oct 2022 01:29:01 +0300 Message-Id: <20221004222903.6393-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> References: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] pipeline: ipu3: Set bytesused before queuing parameters buffer 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The bytesused value for the parameters buffer is initialized to 0 and never set. The V4L2 API specification indicates that, for an output video device, the driver will set the bytesused value to the size of the plane in that case. The videobuf2 framework does so, but considers this as deprecated and prints a warning: [ 54.375534] use of bytesused == 0 is deprecated and will be removed in the future, [ 54.388026] use the actual size instead. Fix it by setting bytesused to the correct value before queuing the parameters buffer. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 93219a6c1134..3b892d9671c5 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include @@ -1298,6 +1300,8 @@ void IPU3CameraData::paramsBufferReady(unsigned int id) imgu_->viewfinder_->queueBuffer(outbuffer); } + info->paramBuffer->_d()->metadata().planes()[0].bytesused = + sizeof(struct ipu3_uapi_params); imgu_->param_->queueBuffer(info->paramBuffer); imgu_->stat_->queueBuffer(info->statBuffer); imgu_->input_->queueBuffer(info->rawBuffer); From patchwork Tue Oct 4 22:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17526 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AC923C327C for ; Tue, 4 Oct 2022 22:29:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D2CD60AD1; Wed, 5 Oct 2022 00:29:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664922553; bh=wnq0fDCsKrF3lIbogEVCUb6rc83T/y14IHAljEfb7IY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rOvEPtm/nBiPmT/UfbbxOOY8vyiViFUFjyYU5DSJsC74GScveauwKWzgfE3H3eG9E pjrqxyQWBOJoZbb+lX0kCwkJrUPTiEY2USoRyIDlrX8pnV8qFZrh7ueuOYHTRVYZJv x0pFWHdfdqQg5DdZ9JDpUMET9vhvv3vK/EWXkVflvokTJI2ODRH0Ja2v9FbTqjZMgh roJRYheOOCYIsUSUc8RcWCFEhAb70My6qmNbpYYXKBchhUfJVVemDs/LMw7hAuvc+L eBbZuYSfcBIvcphFEhXo3IHucXsLRz5YKm0R7r3R4D/3aDgQq2ryNrYZNetbfbkVKU J0a3tYkJX5fAQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C40660AC6 for ; Wed, 5 Oct 2022 00:29:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="h4Fw5GDN"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1622BFA0; Wed, 5 Oct 2022 00:29:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664922551; bh=wnq0fDCsKrF3lIbogEVCUb6rc83T/y14IHAljEfb7IY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4Fw5GDNIg5dvEMa7LT3LHlvtaQ3iC2wGJ0IMMpxq3KHwBYOgc+2rLVvkTUrs4bir KB4ZdfSp7gX28S5Igf3KMkS5d1yms70ikcqUj0E+1PTa+FniVTSn3remgrIvD1XlC/ vkNH3FectvAi+2VsnPv1GX+f6bTktcZ9EAkdBaC4= To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Oct 2022 01:29:02 +0300 Message-Id: <20221004222903.6393-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> References: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] pipeline: rkisp1: Set bytesused before queuing parameters buffer 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The bytesused value for the parameters buffer is initialized to 0 and never set. The V4L2 API specification indicates that, for an output video device, the driver will set the bytesused value to the size of the plane in that case. The videobuf2 framework does so, but considers this as deprecated and prints a warning: [ 54.375534] use of bytesused == 0 is deprecated and will be removed in the future, [ 54.388026] use the actual size instead. Fix it by setting bytesused to the correct value before queuing the parameters buffer. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 25fbf9f1a0a9..455ee2a0a711 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -32,6 +33,7 @@ #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" @@ -362,6 +364,8 @@ void RkISP1CameraData::paramFilled(unsigned int frame) if (!info) return; + info->paramBuffer->_d()->metadata().planes()[0].bytesused = + sizeof(struct rkisp1_params_cfg); pipe->param_->queueBuffer(info->paramBuffer); pipe->stat_->queueBuffer(info->statBuffer); From patchwork Tue Oct 4 22:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17527 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4B1B7BD16B for ; Tue, 4 Oct 2022 22:29:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E77D460AD5; Wed, 5 Oct 2022 00:29:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664922555; bh=vWH2LUYILonTvkpw4vveH6IDgHoiXjjT/zYq6vV3Q94=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Vw0wIvkZg6svyzRFz5VrV8Ves0MTxy4aa9D4a+A/Y0GvVTM4tYiG3iA2XbXGh4A26 N9/fj5p7HsQW9AfVKg/v39FQy7xknuENRR99IxnXKhd6DUTKIdBCSGa5SLhyxDaT+8 H3/pNFoBDAJnwDuWS64S8lqrNMwGHuFEMasXRoRSSgK/e68fx0n7l2J1Ijw7uMYIBb Vwl9AhLtRN95xURzUUWXWy+UQVdcuPCx1nAJTP+KPJ2GkxbQd7BXxCVCM+ZqfBUGCK SlX+0/7W+Pp/FuePUH/Co97mNcRfSlRcOlaRpVD45bjZmOZjmj77P6LKyLinQBBl6m mvUnaT4ZoQ3lg== 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 AC5B960AC6 for ; Wed, 5 Oct 2022 00:29:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kBFiX4V7"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2755AFA0; Wed, 5 Oct 2022 00:29:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664922553; bh=vWH2LUYILonTvkpw4vveH6IDgHoiXjjT/zYq6vV3Q94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kBFiX4V71tk4LyFntzrK9fdPHbTx4lNHQ5ZaG++rnQzIpgKxKCROPM802BsgnQjhv WpSoPjZxoVihnymmx4KmBtSKfN+qmI7v4tw7JNeoDPDwHgoJ1qrbYzD0uTmXZIx3jU fcyQnI7wyHRysnOLMz3Wzsxw1FbVLZyboTmCvpZk= To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Oct 2022 01:29:03 +0300 Message-Id: <20221004222903.6393-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> References: <20221004222903.6393-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] libcamera: v4l2_videodevice: Warn if bytesused == 0 when queuing output buffer 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" V4L2 has deprecated queuing output buffers with bytesused set to 0. Warn if the caller attempts to do so. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/libcamera/v4l2_videodevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 4d846f6be7fa..e30858c9fa02 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1623,6 +1623,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) if (V4L2_TYPE_IS_OUTPUT(buf.type)) { const FrameMetadata &metadata = buffer->metadata(); + for (const auto &plane : metadata.planes()) { + if (!plane.bytesused) + LOG(V4L2, Warning) << "byteused == 0 is deprecated"; + } + if (numV4l2Planes != planes.size()) { /* * If we have a multi-planar buffer with a V4L2