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; }