From patchwork Sun Oct 2 00:36:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17483 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 10F24BD16B for ; Sun, 2 Oct 2022 00:36:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B835262CB6; Sun, 2 Oct 2022 02:36:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664670977; bh=tmA9ctq5gKfYG/CrI3y/pJiY2IWhhB6FwdgTYHBRWrQ=; 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=xmPelMLP28j0W3hb7zaNnpWVkIH70NIxGWwiv06rjtE+5t664dn5BZT4ZIVhbW3Ge Mb39nir/X2rbitB/sPrTm9CDkhGcPaT41PJZ7nLiDx9xHikNrXAhTiXeEVFwqk2n+2 n4sNJk3tqmzGYHuAh+jbpqfL4tbI7yRGiRbDR4fDVT3S1enkbtHoS55KkLOLKNS7fr PI0/34CC2efK1rDiqoyCg9mldIZx9unh0Lxx4bta/JWqZ+KdfWYLOiVokXVu2ET6rr ppWUtLabh0FdtnzH4G4FKLxS80Nzq/G2BXXwQcXhaDGtK/aFxB5xKjfK+ENpjFaaGF k8h6K4P+ImAgQ== 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 9657362CB6 for ; Sun, 2 Oct 2022 02:36:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HkztxGVf"; 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 0779D2D8 for ; Sun, 2 Oct 2022 02:36:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664670975; bh=tmA9ctq5gKfYG/CrI3y/pJiY2IWhhB6FwdgTYHBRWrQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HkztxGVfb1vdTQ3/uGmyPS/sDc8bCnC1mFQoeU/4lyBB8YVswAfVtXL0gAd9X46cK 1+yydk3OAJkG+fxjwCsD9feVk4/xaG8sQaIx9oCmy22YpUqAb2oL23eNr1y5Xavkd4 lU+H9jdZJARdm+NodH1HzmaU7x2C9/tRUXwbqZEQ= To: libcamera-devel@lists.libcamera.org Date: Sun, 2 Oct 2022 03:36:09 +0300 Message-Id: <20221002003612.13603-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> References: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] libcamera: v4l2_videodevice: Ensure non-zero bytesused for output 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-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 V4L2 API specification indicates that, for an output video device, the driver will interpret a zero bytesused value as the buffer length (for v4l2_buffer) or the plane length (for v4l2_plane). The videobuf2 framework implements this behaviour, but also considers this case 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. Avoid the warning by setting bytesused to the buffer or plane length before queuing a buffer to an output video device. Signed-off-by: Laurent Pinchart --- src/libcamera/v4l2_videodevice.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 955e150867ef..1dbb839ed456 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1645,10 +1645,10 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) } if (multiPlanar) { - v4l2Planes[0].bytesused = bytesused; + v4l2Planes[0].bytesused = bytesused ? : length; v4l2Planes[0].length = length; } else { - buf.bytesused = bytesused; + buf.bytesused = bytesused ? : length; buf.length = length; } } else if (multiPlanar) { @@ -1658,7 +1658,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) * V4L2 buffer is guaranteed to be equal at this point. */ for (auto [i, plane] : utils::enumerate(planes)) { - v4l2Planes[i].bytesused = metadata.planes()[i].bytesused; + v4l2Planes[i].bytesused = metadata.planes()[i].bytesused + ? : plane.length; v4l2Planes[i].length = plane.length; } } else { @@ -1666,7 +1667,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) * Single-planar API with a single plane in the buffer * is trivial to handle. */ - buf.bytesused = metadata.planes()[0].bytesused; + buf.bytesused = metadata.planes()[0].bytesused + ? : planes[0].length; buf.length = planes[0].length; } From patchwork Sun Oct 2 00:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17484 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 58A2BC327E for ; Sun, 2 Oct 2022 00:36:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D2EE62CBC; Sun, 2 Oct 2022 02:36:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664670978; bh=E0CoYczNWdeQXZYuKIEpVnhLw2lVORRzsFwE0+UCYpo=; 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=CgNs9Au+N45LyVaTqkWwMWVXDgrUbm4ZG9mOxkog3ShidpwabtmFjwJuAAEWTr8HA gQmU6EypUWoHXubRxUGAVNrJb9P7CwY1kIhCAbVxksxRUQhc8hEBtMkF+A3ysF0wLZ bF+W1rxtsWqsxzpShhJnCrMGi4C9eXYIMxWIwuwNopW9eENw8c4LcdHkgRsn9Vw1kZ 8fJpNngqGpip6K2P3g3rGa69QnVyKuROEweL/r2KA7SYEHCRmLYovd/EWV9dD7Ded9 2tkPpHmACzFDxSNX1mBzBOFY0ByxfZKYRiypfjcNX0EW0r4lU8vw+TttnjA0dGfxBw EWxDJyapJ17TA== 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 C2F9161FB1 for ; Sun, 2 Oct 2022 02:36:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AwxkWSBH"; 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 48E10517 for ; Sun, 2 Oct 2022 02:36:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664670976; bh=E0CoYczNWdeQXZYuKIEpVnhLw2lVORRzsFwE0+UCYpo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AwxkWSBHokWZ/tnIH8rosmc/BPbTYQauB+FNHJ8BRB5GUfD9aUOS+hnS1ZQkKniSU 3MtTCwgtkLwLNeafYcb5bqbuc/ZLEbMeSOW9BgRjhQ+A2899cVViWJD/Rgrp9GiCFI m1i77A9v7zMbCbsjo4LagjNgBnuot3xilS76T/cs= To: libcamera-devel@lists.libcamera.org Date: Sun, 2 Oct 2022 03:36:10 +0300 Message-Id: <20221002003612.13603-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> References: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/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" Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- 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..8ff4241f1506 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 1dbb839ed456..d25a785adeea 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1793,12 +1793,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; @@ -1814,10 +1816,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()) { /* @@ -1943,9 +1944,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 Sun Oct 2 00:36:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17485 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 5A208BD16B for ; Sun, 2 Oct 2022 00:36:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0838562CC0; Sun, 2 Oct 2022 02:36:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664670981; bh=lNmBj/hq6wT2f5i5/WjoHWz3vFp6YEGUENmrDVivnRQ=; 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=pMHMbqHsj5kzoGG1OUImruHlsk0rfkROKyuwwDHLyjeYxvx1mL2Ey60nAy6RkvjlA 7cxceiKMohKCUv277pfxIPt4W114dz4kx573kmQanZE/CFNYkmSJ1jGQE1VIo99CXk Rq/Au7aAwSF4WO0AMk5+cq2P8Lse8KMmUWNkNKL1xHZ+dNIDLhek/k4AwoDB3f2OAu 8//YMm3Q2D7oKl93KeN6x+dGyjceTFkKxf2Ru52LaLu9QKK2mjeOO9dkLaGw4Dz2ad aM0zqWHH5kEJrj0n3XHerLxFvrmABYvFJ0mpVNcSfS/A+2x7mu3nH6WKLMv7aw12Fw QFtLJsVoGbL1A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27B8B62CB2 for ; Sun, 2 Oct 2022 02:36:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SNMTBD5j"; 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 9E4C2517 for ; Sun, 2 Oct 2022 02:36:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664670977; bh=lNmBj/hq6wT2f5i5/WjoHWz3vFp6YEGUENmrDVivnRQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SNMTBD5jdTvXrDNcUtS9ljCyeZIOmGhS0P2QdiZDP1XK+jTr8YWuGm2Uof8MI44J5 /LYRt2dzXNvj8g8dV+WDEk0hzRK8bIsQWK0RwUD7IM1sc/VF0rBz5121M0ZW8t4aMl r8v0l95awpYkICv5G+qc8800273OW6JwXT3DBLuA= To: libcamera-devel@lists.libcamera.org Date: Sun, 2 Oct 2022 03:36:11 +0300 Message-Id: <20221002003612.13603-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> References: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/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 --- 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 Sun Oct 2 00:36:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17486 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 0922AC327E for ; Sun, 2 Oct 2022 00:36:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 97AC662CBF; Sun, 2 Oct 2022 02:36:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664670981; bh=wuvYJnxWqiRujtRNfHqpvwzxadfbuedvqw+B/SOF460=; 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=j7vmuYGHFHBg0MdvxLE4EieYhSYzpNBK32IyvA+x3zzbDPjNo97fFf3k4z2+zICeG DaOhS7ZVH5eDI1BnPMVE+CczEY9NdjX0tABr+6u9Z9HGDJDi3si1ql4eUfti/6SszC Xe2M46sINVaoHlQ7aT/xW7hYhCwW2dIuoPrkoRdDwQg97TgRzXCd5ztgB1apPe7lOB grlV05o9K8rEIzY/qgnhEASIyE8ldB32S04dQGWaAewEenZ3ze4enU7Vy598NYjDYR ztoHh6FPPOngOG3wUF6Qg00Ng4O+9W0AgiPc4GSX0P+NbAPwaGsN7MqFJsMZ4t2NMx xIiGE/ZayWhVw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 596A062CB7 for ; Sun, 2 Oct 2022 02:36:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SZmFRFKy"; 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 DB2E8517 for ; Sun, 2 Oct 2022 02:36:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664670979; bh=wuvYJnxWqiRujtRNfHqpvwzxadfbuedvqw+B/SOF460=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SZmFRFKyKz74I9D6oWVcIMCdWvaA4WiTLB8sj8/BosHe+s7zFHa39gU3v4Se9KsyX s+90HSlI4Z1f6iP+nJx2VyTBpNPgJEjPsKkEAD/9RsUmAV+FWh6/lz+MtA15adOhf3 2XumSvtLVUP/oM3oORA6JbA5ZKnzeLFpv32FljeU= To: libcamera-devel@lists.libcamera.org Date: Sun, 2 Oct 2022 03:36:12 +0300 Message-Id: <20221002003612.13603-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> References: <20221002003612.13603-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/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 --- 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);