From patchwork Mon Sep 6 22:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13696 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 66998BE175 for ; Mon, 6 Sep 2021 22:57:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 280E36917A; Tue, 7 Sep 2021 00:57:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZqFylIcb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E5ADE69168 for ; Tue, 7 Sep 2021 00:57:10 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E3FF993; Tue, 7 Sep 2021 00:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630969030; bh=uk/1IISMeHUL+xlquqyQPEOm8yec0VB/3HEvPxfYe94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqFylIcbzVkCiYQZgDiXfcArn/KfHCOMB9dpmHBEhP/cywo6rDDzPboYcdfYFc8jI Oa1lbrK7bcepZcDRRN3krixYHzZZGY327x4/ygpv5OoTfoWk562WoMefUgynufr1/Z 3PAt3/iS26Ynis2SvgDOBcQmEIj3DqODOPd/mUw0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 7 Sep 2021 01:56:36 +0300 Message-Id: <20210906225636.14683-30-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210906225420.13275-1-laurent.pinchart@ideasonboard.com> References: <20210906225420.13275-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 30/30] v4l2: Sum bytesused for all planes when dequeuing 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The V4L2 compatibility layer supports the single-planar API only, and thuss expose a single V4L2 buffer plane to applications, regardless of the number of planes in the FrameBuffer. For multi-planar frame buffers, the bytesused value isn't correct as it only takes the first plane into account. Fix it by summing the bytesused values for all FrameBuffer planes. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jean-Michel Hautbois --- src/v4l2/v4l2_camera_proxy.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 07d2250bb846..aeffef26c5bf 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -211,7 +212,11 @@ void V4L2CameraProxy::updateBuffers() switch (fmd.status) { case FrameMetadata::FrameSuccess: - buf.bytesused = fmd.planes()[0].bytesused; + buf.bytesused = std::accumulate(fmd.planes().begin(), + fmd.planes().end(), 0, + [](unsigned int total, const auto &plane) { + return total + plane.bytesused; + }); buf.field = V4L2_FIELD_NONE; buf.timestamp.tv_sec = fmd.timestamp / 1000000000; buf.timestamp.tv_usec = fmd.timestamp % 1000000;