From patchwork Fri Jul 9 09:56:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12875 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 ECCB2BD794 for ; Fri, 9 Jul 2021 09:56:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA96868523; Fri, 9 Jul 2021 11:56:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="aO5KNYtR"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A84A868523 for ; Fri, 9 Jul 2021 11:56:51 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id i8so11321677wrp.12 for ; Fri, 09 Jul 2021 02:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SL2VE/oHSC2fXzf+qdGiYlkTgGyRfJpTg5+hSXVd9yw=; b=aO5KNYtRkrd0bUXwOAq/hAmwv4dUYGSglb6cWhyQdsyF+D3YymdAPr4L8AXV2XsGZn WlwcMCXA7ouGt7NuBsLyTHag+JHMATiH+j09Mu4zUMoxIQLcO+KoD4vNf/uuaWrgmtaZ RZj59YEk6HuXpafYNTH6TN6qwVF7dnnEXtAShningpNSSBJIi6Q+rrJ5Z5pNvvEIkjj4 aX4R/V1xSTJjmqH1j2SIRskwbFd8IlsVuaKJM82tXFkQxAk6r6vD/MwTi16zDtC2foUZ 5oFKq4eqNr5IcLgripLT/dpJ264O6arLZBJa8oQM8OZC++ofsLWddadR4cXMhDlqDB0i hV6g== 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=SL2VE/oHSC2fXzf+qdGiYlkTgGyRfJpTg5+hSXVd9yw=; b=hlE3Ilc/k2/jJlxNaMovI2EJRIGLoAsEdjlU8GNHf1gGN9BFdCRuvITXr6+kzoTWEi T4ueYd7JV1fHs/yAYr0M30gdOvevHfJvNOrtB7IoveL+/dvWCzyM84CP8GZtQnreg2YD au03ydUmxWzErDk6sgxiubHshESu+B/Qd1AhTmh/EYJ22RzJPzroHipsbCQJuZyUGkr5 icG21mCutO9Btx7T5WXjIEfOEcs22ItvSMac6Vv7RgYUHDSZBLeJckLKgMNNqrPTqT6X XIEv+UR5rc+l8wWJ1PwjLHdcxtdXhdCJHoTghDZO1YQunCrXWgi4Hq/XWeAk7ut3kCbp e+3A== X-Gm-Message-State: AOAM530WFDNcEvNqQZc7Nf36U+iwlqr4ZfbphM+k+RXMg8t8hNiLPWMf oUTTooIS7JrDukeLdKOoh7IV0zUcJRxlPg== X-Google-Smtp-Source: ABdhPJzC+JZlWseELQNbe+RE0UYNqTkSVpVvMxrURV7cRl1ZKU3FsDQntdPNFB2gB4DlXl324cadHA== X-Received: by 2002:adf:c448:: with SMTP id a8mr20181620wrg.103.1625824610994; Fri, 09 Jul 2021 02:56:50 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:34 +0100 Message-Id: <20210709095638.2801713-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/8] ipa: raspberrypi: Add frame_length to DeviceStatus 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" Update the IPA to fill frame length into the DeviceStatus struct from the VBLANK Control value passed from DelayedControls. Update imx477 and imx219 CamHelper classes to extract the frame length from the embedded data buffer. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham when it's --- src/ipa/raspberrypi/cam_helper.cpp | 1 + src/ipa/raspberrypi/cam_helper_imx219.cpp | 6 +++++- src/ipa/raspberrypi/cam_helper_imx477.cpp | 6 +++++- src/ipa/raspberrypi/controller/device_status.h | 5 ++++- src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 1ec3f03e1aa3..3c6afce7572b 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -187,6 +187,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; + deviceStatus.frame_length = parsedDeviceStatus.frame_length; LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 4d68e01fce71..a3caab714602 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -30,7 +30,10 @@ using namespace RPiController; constexpr uint32_t gainReg = 0x157; constexpr uint32_t expHiReg = 0x15a; constexpr uint32_t expLoReg = 0x15b; -constexpr std::initializer_list registerList [[maybe_unused]] = { expHiReg, expLoReg, gainReg }; +constexpr uint32_t frameLengthHiReg = 0x160; +constexpr uint32_t frameLengthLoReg = 0x161; +constexpr std::initializer_list registerList [[maybe_unused]] + = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg }; class CamHelperImx219 : public CamHelper { @@ -93,6 +96,7 @@ void CamHelperImx219::PopulateMetadata(const MdParser::RegisterMap ®isters, deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); deviceStatus.analogue_gain = Gain(registers.at(gainReg)); + deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index efd1a5893db8..91d05d9226ff 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -23,7 +23,10 @@ constexpr uint32_t expHiReg = 0x0202; constexpr uint32_t expLoReg = 0x0203; constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; -constexpr std::initializer_list registerList = { expHiReg, expLoReg, gainHiReg, gainLoReg }; +constexpr uint32_t frameLengthHiReg = 0x0340; +constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr std::initializer_list registerList = + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; class CamHelperImx477 : public CamHelper { @@ -81,6 +84,7 @@ void CamHelperImx477::PopulateMetadata(const MdParser::RegisterMap ®isters, deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); + deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index e2511d19b96d..916471ab258b 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -17,7 +17,7 @@ struct DeviceStatus { DeviceStatus() - : shutter_speed(std::chrono::seconds(0)), analogue_gain(0.0), + : shutter_speed(std::chrono::seconds(0)), frame_length(0), analogue_gain(0.0), lens_position(0.0), aperture(0.0), flash_intensity(0.0) { } @@ -28,6 +28,7 @@ struct DeviceStatus { out << "Exposure: " << d.shutter_speed << " Gain: " << d.analogue_gain + << " Frame Length: " << d.frame_length << " Aperture: " << d.aperture << " Lens: " << d.lens_position << " Flash: " << d.flash_intensity; @@ -37,6 +38,8 @@ struct DeviceStatus { /* time shutter is open */ libcamera::utils::Duration shutter_speed; + // frame length given in number of lines + uint32_t frame_length; double analogue_gain; /* 1.0/distance-in-metres, or 0 if unknown */ double lens_position; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index f51c970befb5..db103a885b7a 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1015,9 +1015,11 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t exposureLines = sensorControls.get(V4L2_CID_EXPOSURE).get(); int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); + int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); deviceStatus.shutter_speed = helper_->Exposure(exposureLines); deviceStatus.analogue_gain = helper_->Gain(gainCode); + deviceStatus.frame_length = mode_.height + vblank; LOG(IPARPI, Debug) << "Metadata - " << deviceStatus;