From patchwork Fri Oct 22 10:00:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 14251 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 19B64BF415 for ; Fri, 22 Oct 2021 10:00:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B46AB68F59; Fri, 22 Oct 2021 12:00:47 +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="usNk7lnU"; dkim-atps=neutral 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 95B4D6012A for ; Fri, 22 Oct 2021 12:00:46 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2312151D; Fri, 22 Oct 2021 12:00:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634896846; bh=GT8Ow8uX5CdCgghgqzSKmR+t8bR+dN+bg8hXROaco78=; h=From:To:Cc:Subject:Date:From; b=usNk7lnU7Di9wjA5grKXKDcr3vlSiNBtqSgQGM4CeMbjZyArpP0zLyeiVwpBg7/dS 2zYj9VrDd2LqyeeGIe+Zn2C7YSw154ajn/OnO/PnChUjRGSy2D0G1zrtZ25ZRyIeVL nyMTtsRs6WIxpUWwqVrYE9t4c2XKcsKyuNsWoYuo= From: Kieran Bingham To: libcamera devel Date: Fri, 22 Oct 2021 11:00:42 +0100 Message-Id: <20211022100042.4187349-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Explain multiplanar bytesused reasoning 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 ternary operation used to get the total bytesused of a V4L2 single planar format which is stored in a multiplanar buffer can easily be mis-read to think it's a bug, and appears to be reading the value of the first of N planes as the total. Directly explain the reasoning for why it looks like the condition is inverted, as it is correct that the total bytes used is stored in only the first plane of the multiplanar buffer. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Paul Elder --- v2: - Update with more descriptive text from Laurent src/libcamera/v4l2_videodevice.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 2745e5798419..0cc622f91f2d 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1711,6 +1711,13 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() return buffer; } + /* + * With a V4L2 single-planar format, all the data is stored in + * a single memory plane. The number of bytes used is conveyed + * through that plane when using the V4L2 multi-planar API, or + * set directly in the buffer when using the V4L2 single-planar + * API. + */ unsigned int bytesused = multiPlanar ? planes[0].bytesused : buf.bytesused; unsigned int remaining = bytesused;