From patchwork Fri Jun 30 12:02:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 18770 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 6DBF4C3295 for ; Fri, 30 Jun 2023 12:03:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2495A628C4; Fri, 30 Jun 2023 14:03:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1688126592; bh=rbKBOeF5sQpJW6EhEmh/kYUereAH3ZtKZdLQnrBJgss=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FFpcHXNwKoG+nAVIDEEHu/cqRBqMOTs7b+bTxqKTWQbKyHXjfA6S5k7KQd67149Pz kIejk+yXpUiz1diRw4NJPTYfVBb0+cnOaYevhC1MDaCgb2lPqBU+SRZ4l5+vl+3hxQ H3PjNK7mcQ5t7SnKBiMHQi+iIT/mmbIqx6FQtwavJOkpzESCat36em+YhM5WFkcasE i5SmcvZZQi2IiIFF3LJFG5xJmMG7c+IJwKyQR4CgzevvEoDtviCFzri1QHkW4n+FCJ orhGh2402jm3cbzP/7CqOV8KNOYYL6IN4WlHbfsalGHFHnPVD6dLbJUns/isMEZVUU Zt54asrWUfLuA== 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 B71EF628BD for ; Fri, 30 Jun 2023 14:03:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LrQRmkbm"; dkim-atps=neutral Received: from umang.jainideasonboard.com.praguecc.cz (unknown [193.85.242.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 253429B9; Fri, 30 Jun 2023 14:02:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1688126547; bh=rbKBOeF5sQpJW6EhEmh/kYUereAH3ZtKZdLQnrBJgss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LrQRmkbmicJaF0tFaVwYhPNeMOUnErEig+lIpdYLsgrRAFkuXvX7kTZpEP7CKI+nI 82C7GoY6sM1xuDOrFBj+eXXidnfyS8wLPsuYLnMedL2mHeK+MBSGlt1A40XtxnvbJC v74YOUujuwbXYsNJLAPdYF4u9kLNxHjFGXyViC2k= To: libcamera-devel@lists.libcamera.org Date: Fri, 30 Jun 2023 14:02:59 +0200 Message-Id: <20230630120303.33023-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230630120303.33023-1-umang.jain@ideasonboard.com> References: <20230630120303.33023-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/5] rpi: cam_helper_imx708: Use Span<> to pass PDAF data 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: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Instead of passing raw buffer pointer and length, construct a Span<> and pass it in parsePdafData(). While at it, introduce a constexpr which denotes the scanline of the PDAF data in the embedded data. Use that constexpr to compute the offset of PDAF buffer in the embedded data. Np functional changes intended in this patch. Signed-off-by: Umang Jain --- src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp index 641ba18f..b24ee643 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp @@ -42,6 +42,9 @@ constexpr std::initializer_list registerList = { expHiReg, expLoReg, gainHiReg, gainLoReg, lineLengthHiReg, lineLengthLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; +/* PDAF data is expect to occupy the third scanline of embedded data. */ +constexpr uint32_t pdafLineOffsetImx708 = 2; + class CamHelperImx708 : public CamHelper { public: @@ -75,7 +78,7 @@ private: void populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const override; - static bool parsePdafData(const uint8_t *ptr, size_t len, unsigned bpp, + static bool parsePdafData(libcamera::Span &pdafData, unsigned bpp, PdafRegions &pdaf); bool parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp); @@ -116,17 +119,16 @@ void CamHelperImx708::prepare(libcamera::Span buffer, Metadata &m parseEmbeddedData(buffer, metadata); - /* - * Parse PDAF data, which we expect to occupy the third scanline - * of embedded data. As PDAF is quite sensor-specific, it's parsed here. - */ + /* Parse sensor-specific PDAF data. */ size_t bytesPerLine = (mode_.width * mode_.bitdepth) >> 3; + size_t pdafDataOffset = pdafLineOffsetImx708 * bytesPerLine; - if (buffer.size() > 2 * bytesPerLine) { + if (buffer.size() > pdafDataOffset) { PdafRegions pdaf; - if (parsePdafData(&buffer[2 * bytesPerLine], - buffer.size() - 2 * bytesPerLine, - mode_.bitdepth, pdaf)) + libcamera::Span pdafData{ &buffer[pdafDataOffset], + buffer.size() - pdafDataOffset }; + + if (parsePdafData(pdafData, mode_.bitdepth, pdaf)) metadata.set("pdaf.regions", pdaf); } @@ -241,9 +243,10 @@ void CamHelperImx708::populateMetadata(const MdParser::RegisterMap ®isters, metadata.set("device.status", deviceStatus); } -bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len, - unsigned bpp, PdafRegions &pdaf) +bool CamHelperImx708::parsePdafData(Span &data, unsigned bpp, PdafRegions &pdaf) { + const uint8_t *ptr = data.data(); + unsigned int len = data.size(); size_t step = bpp >> 1; /* bytes per PDAF grid entry */ if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {