From patchwork Mon Sep 6 22:56:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13677 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 17FACBE175 for ; Mon, 6 Sep 2021 22:57:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 87AEB69171; Tue, 7 Sep 2021 00:57:16 +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="FDFPJ/vN"; 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 7C3CB6916D for ; Tue, 7 Sep 2021 00:57:03 +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 116FE993; Tue, 7 Sep 2021 00:57:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630969023; bh=XJQIoEiIryeoez7TWTX9unKSFLX6i1uryjTsFB9b6io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDFPJ/vN8mQymv75ukj0Vf4OvJLoT6jfyjDGqVZ0BbjbvVBH1ydT0LI1cwEHfgoae X49A+BNlsX89YXZHDLWKgOhtj1lVVNlJH/OPjB6RIF7Ejr0WqqgGNeqDLidN3b9naY 3oHKsVcVBW2B8cX75mzZm8t6WqQVa9wuC5UyoJDo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 7 Sep 2021 01:56:17 +0300 Message-Id: <20210906225636.14683-11-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 11/30] libcamera: v4l2_videodevice: Document plane handling in createBuffer() 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 V4L2VideoDevice::createBuffer() calculates offsets manually when using a multi-planar pixel format and a single-planar V4L2 format. The process isn't trivial, document it. Signed-off-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Reviewed-by: Hirokazu Honda Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_videodevice.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 1483181a0856..88535f5a07c7 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1334,10 +1334,19 @@ std::unique_ptr V4L2VideoDevice::createBuffer(unsigned int index) } /* + * If we have a multi-planar format with a V4L2 single-planar buffer, + * split the single V4L2 plane into multiple FrameBuffer planes by + * computing the offsets manually. + * * The format info is not guaranteed to be valid, as there are no * PixelFormatInfo for metadata formats, so check it first. */ if (formatInfo_->isValid() && formatInfo_->numPlanes() != numPlanes) { + /* + * There's no valid situation where the number of colour planes + * differs from the number of V4L2 planes and the V4L2 buffer + * has more than one plane. + */ ASSERT(numPlanes == 1u); planes.resize(formatInfo_->numPlanes());