Patch Detail
Show a patch.
GET /api/patches/17544/?format=api
{ "id": 17544, "url": "https://patchwork.libcamera.org/api/patches/17544/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17544/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20221006131744.5179-4-naush@raspberrypi.com>", "date": "2022-10-06T13:17:37", "name": "[libcamera-devel,v2,03/10] ipa: raspberrypi: Pass lineLength into the CamHelper API", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "cddd0a00106d4a40c275d30533e5ef4c61bbf4c8", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17544/mbox/", "series": [ { "id": 3537, "url": "https://patchwork.libcamera.org/api/series/3537/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3537", "date": "2022-10-06T13:17:34", "name": "Raspberry Pi: Horizontal blanking control", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3537/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17544/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17544/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 63F64C327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 6 Oct 2022 13:17:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1297C62CFD;\n\tThu, 6 Oct 2022 15:17:59 +0200 (CEST)", "from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 655C062CFC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 6 Oct 2022 15:17:56 +0200 (CEST)", "by mail-wr1-x42b.google.com with SMTP id b4so2706252wrs.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 06 Oct 2022 06:17:56 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tq18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 06 Oct 2022 06:17:54 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665062279;\n\tbh=J8lJ6PGCLvUfkjHvaRUY8NgDNAIkJP7WBkY+MQMcq8I=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Jv+sKHNCnl/+nx+fuPdfxPLkye5KB8MK4wcNS8FLDrPAq/fSrtE/wrcXXLxUuZnho\n\tRYMsqqPjCe/BcBM+0WsYJ3ZurXYAdr2ce7GxtMRluwsejFHe4P1oITs1y34vvIcMDB\n\tFbe9fEet3Kh9SqC4yDYVwkqBCIx+UK92Jxva+L+8lr117xkp56GYC3W5Wpp8H7EVlA\n\t1YyiAYFT8FdG3TwxkmtqgepSf1/lNpGg3V/MQIe21pZ/JVjOUp8mKLuZeJSqvF7yqA\n\tYss5kMymwwx0ANzGz7o7G5l25RlC+RLC+JNIGe/rr9Krozr1q2SzYu4ICNU++WO0Sl\n\tEZATOedYdNZpg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date;\n\tbh=PPWqyUmpb6N+I4R6BCY7bFIr1oMEW/5912qbXTEqvGA=;\n\tb=IoBqAW78xokAioPc5hwwNIlFvNHhBidEGUcahce9LWhZPeFyrHp+f2idyxjARGjqqy\n\tCKGTWohS+0Qr07oCM5e34TUc8HZeBKn/25UJNnGkj1A4uc+eGUqeqETDljCbbjRlD5B2\n\tYE0jXxwkJ58Fa1b9hG69jdugXAfzW7pYxk+QbCKz50BLecOp7+q8s80R9LOpz0jgfA7Q\n\tUrHZhQuqwyXmlFvwR47JlAFa1Mp5Mf7yRzwukraUU+bZ/3PVLna6JYFDWmQFrYF7oGIC\n\tfC1F8SvikrjlRsV7xLqDkpQch1hrWfwvKdQhqPqhY+FMLonm8l3q7MezD3Zl/6cv1x4a\n\tfOJA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"IoBqAW78\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date;\n\tbh=PPWqyUmpb6N+I4R6BCY7bFIr1oMEW/5912qbXTEqvGA=;\n\tb=VL7QKSHhHcn2PhFSTposLOK7lQYAFdF6A6h/+LH36JtuG0dlot83c3go/oEQNjcvOU\n\ttRDa/fGhTyiNkigI4wq2GQRCKwzXa+vbRDslBimmL57wRUxkMZAuFRsSxoN8/SO2s9dp\n\tbi7oayV9B8gtdToW+XTyO2jpW8W78e5EqwjXc0GGV35EVRg1fDxR0fOLfIyOzwD1yTrO\n\t5bGEDiLOBVtw2wAyP2v0FrSMS0o6WzmAuyMWyShEuqAjU008vXDb+VY1ddVjy/tH/ltR\n\t3SzmUCWdryVylKyh9kk0aAVZl2xJeEOCwaEP2CwMj9BxJA0gPg2QSysErB86G/N5NP7Q\n\tPBSQ==", "X-Gm-Message-State": "ACrzQf3pEeEW5PNz1uXxVIe/FxkCxG2J8/VN8dows75CHw1u9Ztn58V6\n\teJXZ//EmlJNwglFBD7yTiW+kxI+954WEFw==", "X-Google-Smtp-Source": "AMsMyM7sNUP2xsCd793PCCqrBYv2qOz2w95uLca9Ulf/o5qtWStsbcNt7KQSFokolkpaykR0usVWAw==", "X-Received": "by 2002:a5d:4a01:0:b0:21d:8ce1:8b6d with SMTP id\n\tm1-20020a5d4a01000000b0021d8ce18b6dmr3180226wrq.718.1665062275548; \n\tThu, 06 Oct 2022 06:17:55 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 6 Oct 2022 14:17:37 +0100", "Message-Id": "<20221006131744.5179-4-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", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 03/10] ipa: raspberrypi: Pass\n\tlineLength into the CamHelper API", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Update CamHelper::exposureLines() and CamHelper::exposure() to take a\nline length duration parameter for use in the exposure calculations.\n\nFor now, only use the minimum line length for all the calculations to match\nthe existing IPA behavior.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>\n---\n src/ipa/raspberrypi/cam_helper.cpp | 12 ++++++------\n src/ipa/raspberrypi/cam_helper.h | 6 ++++--\n src/ipa/raspberrypi/cam_helper_imx219.cpp | 3 ++-\n src/ipa/raspberrypi/cam_helper_imx296.cpp | 10 ++++++----\n src/ipa/raspberrypi/cam_helper_imx477.cpp | 7 ++++---\n src/ipa/raspberrypi/cam_helper_imx519.cpp | 7 ++++---\n src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++----\n 7 files changed, 30 insertions(+), 23 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\nindex 42251ba29682..fd3527b94501 100644\n--- a/src/ipa/raspberrypi/cam_helper.cpp\n+++ b/src/ipa/raspberrypi/cam_helper.cpp\n@@ -61,16 +61,16 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats,\n {\n }\n \n-uint32_t CamHelper::exposureLines(const Duration exposure) const\n+uint32_t CamHelper::exposureLines(const Duration exposure, const Duration lineLength) const\n {\n \tassert(initialized_);\n-\treturn exposure / mode_.minLineLength;\n+\treturn exposure / lineLength;\n }\n \n-Duration CamHelper::exposure(uint32_t exposureLines) const\n+Duration CamHelper::exposure(uint32_t exposureLines, const Duration lineLength) const\n {\n \tassert(initialized_);\n-\treturn exposureLines * mode_.minLineLength;\n+\treturn exposureLines * lineLength;\n }\n \n uint32_t CamHelper::getVBlanking(Duration &exposure,\n@@ -78,7 +78,7 @@ uint32_t CamHelper::getVBlanking(Duration &exposure,\n \t\t\t\t Duration maxFrameDuration) const\n {\n \tuint32_t frameLengthMin, frameLengthMax, vblank;\n-\tuint32_t exposureLines = CamHelper::exposureLines(exposure);\n+\tuint32_t exposureLines = CamHelper::exposureLines(exposure, mode_.minLineLength);\n \n \tassert(initialized_);\n \n@@ -94,7 +94,7 @@ uint32_t CamHelper::getVBlanking(Duration &exposure,\n \t * re-calculate if it has been clipped.\n \t */\n \texposureLines = std::min(frameLengthMax - frameIntegrationDiff_, exposureLines);\n-\texposure = CamHelper::exposure(exposureLines);\n+\texposure = CamHelper::exposure(exposureLines, mode_.minLineLength);\n \n \t/* Limit the vblank to the range allowed by the frame length limits. */\n \tvblank = std::clamp(exposureLines + frameIntegrationDiff_,\ndiff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h\nindex 70d62719da86..9b5e602689f3 100644\n--- a/src/ipa/raspberrypi/cam_helper.h\n+++ b/src/ipa/raspberrypi/cam_helper.h\n@@ -78,8 +78,10 @@ public:\n \tvirtual void prepare(libcamera::Span<const uint8_t> buffer,\n \t\t\t Metadata &metadata);\n \tvirtual void process(StatisticsPtr &stats, Metadata &metadata);\n-\tvirtual uint32_t exposureLines(libcamera::utils::Duration exposure) const;\n-\tvirtual libcamera::utils::Duration exposure(uint32_t exposureLines) const;\n+\tvirtual uint32_t exposureLines(const libcamera::utils::Duration exposure,\n+\t\t\t\t const libcamera::utils::Duration lineLength) const;\n+\tvirtual libcamera::utils::Duration exposure(uint32_t exposureLines,\n+\t\t\t\t\t\t const libcamera::utils::Duration lineLength) const;\n \tvirtual uint32_t getVBlanking(libcamera::utils::Duration &exposure,\n \t\t\t\t libcamera::utils::Duration minFrameDuration,\n \t\t\t\t libcamera::utils::Duration maxFrameDuration) const;\ndiff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp\nindex 7ded07a213cd..98a3b31956ec 100644\n--- a/src/ipa/raspberrypi/cam_helper_imx219.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n@@ -94,7 +94,8 @@ void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters,\n {\n \tDeviceStatus deviceStatus;\n \n-\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n+\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg),\n+\t\t\t\t\t mode_.minLineLength);\n \tdeviceStatus.analogueGain = gain(registers.at(gainReg));\n \tdeviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n \ndiff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp\nindex 66d21e36ecd0..d86ff3878983 100644\n--- a/src/ipa/raspberrypi/cam_helper_imx296.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp\n@@ -21,8 +21,8 @@ public:\n \tCamHelperImx296();\n \tuint32_t gainCode(double gain) const override;\n \tdouble gain(uint32_t gainCode) const override;\n-\tuint32_t exposureLines(Duration exposure) const override;\n-\tDuration exposure(uint32_t exposureLines) const override;\n+\tuint32_t exposureLines(const Duration exposure, const Duration lineLength) const override;\n+\tDuration exposure(uint32_t exposureLines, const Duration lineLength) const override;\n \tvoid getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay) const override;\n \n private:\n@@ -53,12 +53,14 @@ double CamHelperImx296::gain(uint32_t gainCode) const\n \treturn std::pow(10.0, gainCode / 200.0);\n }\n \n-uint32_t CamHelperImx296::exposureLines(Duration exposure) const\n+uint32_t CamHelperImx296::exposureLines(const Duration exposure,\n+\t\t\t\t\t[[maybe_unused]] const Duration lineLength) const\n {\n \treturn std::max<uint32_t>(minExposureLines, (exposure - 14.26us) / timePerLine);\n }\n \n-Duration CamHelperImx296::exposure(uint32_t exposureLines) const\n+Duration CamHelperImx296::exposure(uint32_t exposureLines,\n+\t\t\t\t [[maybe_unused]] const Duration lineLength) const\n {\n \treturn std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us;\n }\ndiff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp\nindex aa306d6661c6..71529bdd3034 100644\n--- a/src/ipa/raspberrypi/cam_helper_imx477.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n@@ -144,9 +144,9 @@ uint32_t CamHelperImx477::getVBlanking(Duration &exposure,\n \tif (shift) {\n \t\t/* Account for any rounding in the scaled frame length value. */\n \t\tframeLength <<= shift;\n-\t\texposureLines = CamHelperImx477::exposureLines(exposure);\n+\t\texposureLines = CamHelperImx477::exposureLines(exposure, mode_.minLineLength);\n \t\texposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n-\t\texposure = CamHelperImx477::exposure(exposureLines);\n+\t\texposure = CamHelperImx477::exposure(exposureLines, mode_.minLineLength);\n \t}\n \n \treturn frameLength - mode_.height;\n@@ -170,7 +170,8 @@ void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters,\n {\n \tDeviceStatus deviceStatus;\n \n-\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n+\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg),\n+\t\t\t\t\t mode_.minLineLength);\n \tdeviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n \tdeviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n \tdeviceStatus.sensorTemperature = std::clamp<int8_t>(registers.at(temperatureReg), -20, 80);\ndiff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp\nindex 54e104e7659a..2c120dad1680 100644\n--- a/src/ipa/raspberrypi/cam_helper_imx519.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n@@ -144,9 +144,9 @@ uint32_t CamHelperImx519::getVBlanking(Duration &exposure,\n \tif (shift) {\n \t\t/* Account for any rounding in the scaled frame length value. */\n \t\tframeLength <<= shift;\n-\t\texposureLines = CamHelperImx519::exposureLines(exposure);\n+\t\texposureLines = CamHelperImx519::exposureLines(exposure, mode_.minLineLength);\n \t\texposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n-\t\texposure = CamHelperImx519::exposure(exposureLines);\n+\t\texposure = CamHelperImx519::exposure(exposureLines, mode_.minLineLength);\n \t}\n \n \treturn frameLength - mode_.height;\n@@ -170,7 +170,8 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters,\n {\n \tDeviceStatus deviceStatus;\n \n-\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n+\tdeviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg),\n+\t\t\t\t\t mode_.minLineLength);\n \tdeviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n \tdeviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n \ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 67326bcf4a14..13807f4d47f7 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -477,7 +477,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n \tconst uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get<int32_t>();\n \n \tctrlMap[&controls::ExposureTime] =\n-\t\tControlInfo(static_cast<int32_t>(helper_->exposure(exposureMin).get<std::micro>()),\n+\t\tControlInfo(static_cast<int32_t>(helper_->exposure(exposureMin, mode_.minLineLength).get<std::micro>()),\n \t\t\t static_cast<int32_t>(maxShutter.get<std::micro>()));\n \n \tresult->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls);\n@@ -550,7 +550,7 @@ void IPARPi::reportMetadata()\n \t\t\t\t deviceStatus->shutterSpeed.get<std::micro>());\n \t\tlibcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain);\n \t\tlibcameraMetadata_.set(controls::FrameDuration,\n-\t\t\t\t helper_->exposure(deviceStatus->frameLength).get<std::micro>());\n+\t\t\t\t helper_->exposure(deviceStatus->frameLength, mode_.minLineLength).get<std::micro>());\n \t\tif (deviceStatus->sensorTemperature)\n \t\t\tlibcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature);\n \t}\n@@ -1106,7 +1106,7 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls)\n \tint32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();\n \tint32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get<int32_t>();\n \n-\tdeviceStatus.shutterSpeed = helper_->exposure(exposureLines);\n+\tdeviceStatus.shutterSpeed = helper_->exposure(exposureLines, mode_.minLineLength);\n \tdeviceStatus.analogueGain = helper_->gain(gainCode);\n \tdeviceStatus.frameLength = mode_.height + vblank;\n \n@@ -1198,7 +1198,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n \t/* getVBlanking might clip exposure time to the fps limits. */\n \tDuration exposure = agcStatus->shutterTime;\n \tint32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_);\n-\tint32_t exposureLines = helper_->exposureLines(exposure);\n+\tint32_t exposureLines = helper_->exposureLines(exposure, mode_.minLineLength);\n \n \tLOG(IPARPI, Debug) << \"Applying AGC Exposure: \" << exposure\n \t\t\t << \" (Shutter lines: \" << exposureLines << \", AGC requested \"\n", "prefixes": [ "libcamera-devel", "v2", "03/10" ] }