From patchwork Thu Oct 6 13:17:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17551 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 AF71BC3287 for ; Thu, 6 Oct 2022 13:18:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3BED962D18; Thu, 6 Oct 2022 15:18:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665062285; bh=hV19k6+5ZyQUG7rvYzMq3gDrTHgp05W10hHjsFaKaPk=; 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=PceIWNvQp01vKF51ufM+9x9KncaYm6a6GdW2iYFZeKuPOrpEHWYlxqEH50ynCMmnr /bdSJU6+99LgKWYnd/zkDWxdJjeE4NC4uYuDQb4UjHl17dje74GxZL3rM5A3DzRkrz 0F/am0rv9OR/w/bIKnS5mY/EM9Jx2yQ8UnjrfevTPdg/ul703RI3eYfpKapVb/3mGw StrqfDNC10H3Y1uHjQONcIk/nRtqjNIFK6+qfN01Kzdt7Qqiavza2n601UUa141AU0 PDiJYJm2VihvU1bk0U+Vv3zezCcvHdk87wFxAl1wmYvc4jARj0SaF4F9it4wuLUSnO XrJxv/lKRJmZw== Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 60C3962D0B for ; Thu, 6 Oct 2022 15:18:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Az05FNQw"; dkim-atps=neutral Received: by mail-wr1-x42b.google.com with SMTP id b4so2706728wrs.1 for ; Thu, 06 Oct 2022 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/spMsGEdXBbA5Mp/XA3rOFmIjFUaZnuuSdKv/kJBWeQ=; b=Az05FNQwwnuD9doSxwBNp3eREGiHlkHLohaeLzt+5J3joWv+CKomaYSDM86BP5HRYx A7PlDGCgv6rUjqrmnl6gK+e4C27mfnKzzEbMd9SV/DZBDxwhqF1nIdNjQnKmuSz9tCVt U15wbogC9Sbse86lXaA3cxybv/OfAwXtXAkdXJo8/l4SP3U2NiZ5SPtcb9vlF0Ky0kCz 076OGSe6cacbG82kYnOxhnj5rYskk4KAGO50ts9BHXLGzSx5tVkFHwlvP60qKL1EObRd DaS6d8ywv7/+uvPGFy/EsKmJsOFYGrduMu/J+V3NafMKPf956qV6zvs1yxZX7zuLx5Fb I/kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/spMsGEdXBbA5Mp/XA3rOFmIjFUaZnuuSdKv/kJBWeQ=; b=dkPkPaLSkpVKf3kCL9GuPAv0yGPXq9O9PqYz2YxFHH57TZp5jichhPkGzGdXresW6H 9nXIdUc+EsSNiGQ9J+1hmwVqwP0ZYGrl1ynHrY/19pOFRTqYP1oJdfgtOMkPn+2qG0gS +lWYtEy7XsFKAl0EnqoLv7F61L3g55JTryXG3H9qATrRhKM+T521yK88Zqr6/2ueofOs rP1JoTGkmWNEAenGJK+S/hAal1cfvFlL2IeYax7tFdWPOqIyKTFWUx5YVKeKJBGyGKdV w2V3ortB9btZi+8HnjzkEoW/o9LPYwDAVcnINvKJJl5WYC0inoMkrtw3f2X7XnYwHLIa A7WQ== X-Gm-Message-State: ACrzQf1g2NgzpUmH6gZKggoC/hxjyCvvvJ9igtfjltiNCvSrkfuG3cmQ s2vMeDvI1OZCpSWDPT0pkvatpYgmf28BLg== X-Google-Smtp-Source: AMsMyM5BbKtFj+3FVEyJAkL5BdIq6SMt3UWWOaf7iHg2yi0kSbhhFSfADdLNndaSnO4aiXei2T59UA== X-Received: by 2002:a5d:6c6b:0:b0:225:dde:ab40 with SMTP id r11-20020a5d6c6b000000b002250ddeab40mr3230686wrz.690.1665062281943; Thu, 06 Oct 2022 06:18:01 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 06:18:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Oct 2022 14:17:44 +0100 Message-Id: <20221006131744.5179-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221006131744.5179-1-naush@raspberrypi.com> References: <20221006131744.5179-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/10] ipa: raspberrypi: Extract line length from the embedded data parser 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update the imx219, imx477 and imx519 parsers to extract the line length values from the embedded data stream and use these values in the deviceStatus metadata, replacing the DelayedControls provided values. Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 3 ++- src/ipa/raspberrypi/cam_helper_imx219.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx477.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx519.cpp | 9 +++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index afbc03d36b02..d90ac1deda47 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -222,7 +222,7 @@ void CamHelper::parseEmbeddedData(Span buffer, metadata.merge(parsedMetadata); /* - * Overwrite the exposure/gain, frame length and sensor temperature values + * Overwrite the exposure/gain, line/frame length and sensor temperature values * in the existing DeviceStatus with values from the parsed embedded buffer. * Fetch it first in case any other fields were set meaningfully. */ @@ -236,6 +236,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutterSpeed = parsedDeviceStatus.shutterSpeed; deviceStatus.analogueGain = parsedDeviceStatus.analogueGain; deviceStatus.frameLength = parsedDeviceStatus.frameLength; + deviceStatus.lineLength = parsedDeviceStatus.lineLength; if (parsedDeviceStatus.sensorTemperature) deviceStatus.sensorTemperature = parsedDeviceStatus.sensorTemperature; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 98a3b31956ec..c3337ed08466 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -32,8 +32,11 @@ constexpr uint32_t expHiReg = 0x15a; constexpr uint32_t expLoReg = 0x15b; constexpr uint32_t frameLengthHiReg = 0x160; constexpr uint32_t frameLengthLoReg = 0x161; +constexpr uint32_t lineLengthHiReg = 0x162; +constexpr uint32_t lineLengthLoReg = 0x163; constexpr std::initializer_list registerList [[maybe_unused]] - = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg }; + = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx219 : public CamHelper { @@ -94,8 +97,10 @@ void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 19a5e471c27e..bc769ca75baa 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -35,9 +35,12 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr uint32_t temperatureReg = 0x013a; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg, temperatureReg }; class CamHelperImx477 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index d2eb171912da..c7262aa0b6e6 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -36,8 +36,11 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx519 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);