From patchwork Thu Aug 26 11:25:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13508 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 87683C3245 for ; Thu, 26 Aug 2021 11:26:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31D3B688A6; Thu, 26 Aug 2021 13:26:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="cgnYyoLO"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 256A868921 for ; Thu, 26 Aug 2021 13:26:04 +0200 (CEST) Received: by mail-pf1-x430.google.com with SMTP id e16so2065587pfc.6 for ; Thu, 26 Aug 2021 04:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sdvZj+O5ZkY80gq4NQVCkYqBtQlsOOMwEm2QRiBE960=; b=cgnYyoLObtc085VnCPEwb+lmNyUJnzIkEUMWmhJ2YO84fxbVuFWU72vOoqMZ2/hpXl AMOVHrlzxpo3ne3PmSkVH4mtuE49ljA6Aj5J0iKr7qrY7vrVQh5D2PIYH4RNfIsjME0B 3+VZJEmnSS0/K+Dt2y0ruQAcBt9DqL5vW9dZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sdvZj+O5ZkY80gq4NQVCkYqBtQlsOOMwEm2QRiBE960=; b=o+91DBFfk9QQ6Os/yybUxM8qU54sKJ4SxQBvGqjeVCHwGpLjgyBtXasBvYzdNXduDu sF8qowVFGnazzjRbHnhleA6SRUOcpnYyhCCPCKRgsDZi9Ecr/XEmhA7C9wzbiOBpR7+v JPGH7gTzpt57kfvQKhjNBrK7O4xdayjWVfFwQ4SVZhHHrdBcs4xBLgFxhbTTgltmEgZx IKxBAFmpHLCeVhuTotOQBkYqzf+L0EsoKxOYVrnc7WIXrRX9Fda3ejIDdrK2q2dVXiHJ k4G2CziHx0hXn9GH9wwiiSsuIADN4R4vhFpd8uMF8y2sD0+3lIpgEBSErDw8hWge0SpV FCLQ== X-Gm-Message-State: AOAM531okg3nT9qLmSseJ6jp/CpkVPJKM8JzPuVPf+IgTtqQhc+MoUpC CyNGprmOuqfH130NdGeqDSPtAkelToLwXw== X-Google-Smtp-Source: ABdhPJxU9steJFMtAaJUKs0h0THz0NMBkm0+TgtqRfyhNc3+yRFsrd0CA9xxt/o6XWpcpEb+mFOCpg== X-Received: by 2002:a63:d250:: with SMTP id t16mr2975281pgi.95.1629977162480; Thu, 26 Aug 2021 04:26:02 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a5bc:b3dd:7208:bec1]) by smtp.gmail.com with ESMTPSA id s29sm3472057pgl.38.2021.08.26.04.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 04:26:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 26 Aug 2021 20:25:39 +0900 Message-Id: <20210826112539.170694-10-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog In-Reply-To: <20210826112539.170694-1-hiroh@chromium.org> References: <20210826112539.170694-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 9/9] libcamera: framebuffer: Add assertion to detect offset is unfilled 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 offset variable is introduced to FrameBuffer::Plane. In order to detect that the plane is used while the offset is not set, this adds the assertion to FrameBuffer::planes(). It should be removed in the future. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- include/libcamera/framebuffer.h | 13 +++++++++++-- src/libcamera/framebuffer.cpp | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 5de3c744..d5aeff00 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -7,6 +7,8 @@ #ifndef __LIBCAMERA_FRAMEBUFFER_H__ #define __LIBCAMERA_FRAMEBUFFER_H__ +#include +#include #include #include @@ -41,14 +43,21 @@ class FrameBuffer final : public Extensible public: struct Plane { + static constexpr unsigned int kInvalidOffset = std::numeric_limits::max(); FileDescriptor fd; - unsigned int offset; + unsigned int offset = kInvalidOffset; unsigned int length; }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - const std::vector &planes() const { return planes_; } + const std::vector &planes() const + { + /* \todo Remove the assertions after sufficient testing */ + for (const auto &plane : planes_) + assert(plane.offset != Plane::kInvalidOffset); + return planes_; + } Request *request() const; const FrameMetadata &metadata() const { return metadata_; } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index bf7a52ad..c99f5b15 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -170,6 +170,11 @@ FrameBuffer::Private::Private() * multiple dmabufs, based on the camera requirements. */ +/** + * \var FrameBuffer::Plane::kInvalidOffset + * \brief Invalid offset value, to identify uninitialized planes + */ + /** * \var FrameBuffer::Plane::fd * \brief The dmabuf file descriptor