{"id":13696,"url":"https://patchwork.libcamera.org/api/patches/13696/?format=json","web_url":"https://patchwork.libcamera.org/patch/13696/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210906225636.14683-30-laurent.pinchart@ideasonboard.com>","date":"2021-09-06T22:56:36","name":"[libcamera-devel,v3,30/30] v4l2: Sum bytesused for all planes when dequeuing buffer","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ccbbaf04a36a73e3239d3a6d8ac8b154cd564d93","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13696/mbox/","series":[{"id":2482,"url":"https://patchwork.libcamera.org/api/series/2482/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2482","date":"2021-09-06T22:54:20","name":"libcamera: Handle fallout of FrameBuffer offset support","version":3,"mbox":"https://patchwork.libcamera.org/series/2482/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13696/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13696/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 66998BE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 22:57:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 280E36917A;\n\tTue,  7 Sep 2021 00:57:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E5ADE69168\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 00:57:10 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E3FF993;\n\tTue,  7 Sep 2021 00:57:10 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZqFylIcb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630969030;\n\tbh=uk/1IISMeHUL+xlquqyQPEOm8yec0VB/3HEvPxfYe94=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ZqFylIcbzVkCiYQZgDiXfcArn/KfHCOMB9dpmHBEhP/cywo6rDDzPboYcdfYFc8jI\n\tOa1lbrK7bcepZcDRRN3krixYHzZZGY327x4/ygpv5OoTfoWk562WoMefUgynufr1/Z\n\t3PAt3/iS26Ynis2SvgDOBcQmEIj3DqODOPd/mUw0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 30/30] v4l2: Sum bytesused for all\n\tplanes when dequeuing buffer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The V4L2 compatibility layer supports the single-planar API only, and\nthuss expose a single V4L2 buffer plane to applications, regardless of\nthe number of planes in the FrameBuffer. For multi-planar frame buffers,\nthe bytesused value isn't correct as it only takes the first plane into\naccount. Fix it by summing the bytesused values for all FrameBuffer\nplanes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 07d2250bb846..aeffef26c5bf 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -11,6 +11,7 @@\n #include <array>\n #include <errno.h>\n #include <linux/videodev2.h>\n+#include <numeric>\n #include <set>\n #include <string.h>\n #include <sys/mman.h>\n@@ -211,7 +212,11 @@ void V4L2CameraProxy::updateBuffers()\n \n \t\tswitch (fmd.status) {\n \t\tcase FrameMetadata::FrameSuccess:\n-\t\t\tbuf.bytesused = fmd.planes()[0].bytesused;\n+\t\t\tbuf.bytesused = std::accumulate(fmd.planes().begin(),\n+\t\t\t\t\t\t\tfmd.planes().end(), 0,\n+\t\t\t\t\t\t\t[](unsigned int total, const auto &plane) {\n+\t\t\t\t\t\t\t\treturn total + plane.bytesused;\n+\t\t\t\t\t\t\t});\n \t\t\tbuf.field = V4L2_FIELD_NONE;\n \t\t\tbuf.timestamp.tv_sec = fmd.timestamp / 1000000000;\n \t\t\tbuf.timestamp.tv_usec = fmd.timestamp % 1000000;\n","prefixes":["libcamera-devel","v3","30/30"]}