From patchwork Mon Mar 31 14:43:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23078 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 532B4C3213 for ; Mon, 31 Mar 2025 14:44:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D576868997; Mon, 31 Mar 2025 16:44:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wklTRsNM"; 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 4602468996 for ; Mon, 31 Mar 2025 16:44:10 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:823a:c275:e8b5:b937]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ADE8482A; Mon, 31 Mar 2025 16:42:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743432138; bh=p3VpA4HqZpL55WstkrfogSY/GM1IWuRCUoEtY5V387M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wklTRsNMTZ6liEhfZ88J9v0UvDl76rTjEPfLH0aQPtgxr5jqQjbJtpL7RBB5QqWqG G2SRGTvp/TLkgvAbffUpXZcFat01NrQqrmla4KS1+r3Cxu9bU6ofFixTwB+YeNLUvQ fuJc6o/ciojfGQ55fLjJoAkrV7+1zBjwILF6Bhlc= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 5/9] ipa: rkisp1: params: Check for empty parameters Date: Mon, 31 Mar 2025 16:43:44 +0200 Message-ID: <20250331144352.736700-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250331144352.736700-1-stefan.klug@ideasonboard.com> References: <20250331144352.736700-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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" Add functions to check for empty parameter blocks. Modify the constructor so that a parameter block constructed from an empty span stays empty. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/params.cpp | 3 +++ src/ipa/rkisp1/params.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp index 4c0b051ce65d..b4a889e415fc 100644 --- a/src/ipa/rkisp1/params.cpp +++ b/src/ipa/rkisp1/params.cpp @@ -82,6 +82,9 @@ RkISP1ParamsBlockBase::RkISP1ParamsBlockBase(RkISP1Params *params, BlockType typ const Span &data) : params_(params), type_(type) { + if (data.empty()) + return; + if (params_->format() == V4L2_META_FMT_RK_ISP1_EXT_PARAMS) { header_ = data.subspan(0, sizeof(rkisp1_ext_params_block_header)); data_ = data.subspan(sizeof(rkisp1_ext_params_block_header)); diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h index 40450e34497a..e0aa04ae0f8d 100644 --- a/src/ipa/rkisp1/params.h +++ b/src/ipa/rkisp1/params.h @@ -89,6 +89,9 @@ public: void setEnabled(bool enabled); + bool isValid() const { return !data_.empty(); } + explicit operator bool() const { return !data_.empty(); } + private: LIBCAMERA_DISABLE_COPY(RkISP1ParamsBlockBase) @@ -109,6 +112,16 @@ public: { } + const Type *get() const + { + return reinterpret_cast(data().data()); + } + + Type *get() + { + return reinterpret_cast(data().data()); + } + const Type *operator->() const { return reinterpret_cast(data().data());