Show a patch.

GET /api/1.1/patches/18854/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18854,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18854/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18854/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230718144301.3612-3-david.plowman@raspberrypi.com>",
    "date": "2023-07-18T14:43:01",
    "name": "[libcamera-devel,v5,2/2] ipa: rpi: common: Handle AEC/AGC flicker controls",
    "commit_ref": "a2eadc40a78f73410d2dcf76a24313a83a1c51c8",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ac4c36817c0f491caa07ba1313b0322a7b93a7d8",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18854/mbox/",
    "series": [
        {
            "id": 3977,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3977/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3977",
            "date": "2023-07-18T14:42:59",
            "name": "Add flicker avoidance controls",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/3977/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18854/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18854/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 D4F6AC32AA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Jul 2023 14:43:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1251628C8;\n\tTue, 18 Jul 2023 16:43:08 +0200 (CEST)",
            "from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04AB9628C2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jul 2023 16:43:06 +0200 (CEST)",
            "by mail-wm1-x331.google.com with SMTP id\n\t5b1f17b1804b1-3fbf7fbe722so60072215e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jul 2023 07:43:06 -0700 (PDT)",
            "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:2bce:64d6:1a5c:49a2])\n\tby smtp.gmail.com with ESMTPSA id\n\t12-20020a05600c230c00b003f90b9b2c31sm10469686wmo.28.2023.07.18.07.43.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 18 Jul 2023 07:43:05 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689691388;\n\tbh=KbG1U3RdatzlRHTz88vkr9smMIdXLOH3J7WBupWg8FA=;\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=TlhYjVne1QJqzx+9/nb3g/4s39XRqrAMlPUS1ZL+rOc/wbjp+AiEO7oO3rRiGNuad\n\twCqapVs9csD4JsD9PVTBtMgzpjqS4ygXdZcw1ZDx3BDf301Ie1LtmXc1Rz4yG/Cphk\n\tM67O8UWZSVy6tDcKW/rk1mvFZhf1NwzzpeymMwfWgcQZMgVZ0cVvZ+85yvCull7QNl\n\t4uIaOuO2lUgtRVSATt/pmHV826PxnAFjDd0t9CfKUqEp59sHb8DvRrzeZ2jNJkKFeU\n\tCbiyu60vfgkbKDO2mPuyasKEEy2sCLYaRrtXGFzYmvZ+YYklBFb2GHFJJVP+6QtgA2\n\tf+Jd4h1ob7tfA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689691386; x=1692283386;\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\t:message-id:reply-to;\n\tbh=AZEm6gA229Srb7s98kzWNEYtc3dFuABlq3BByQqRhLs=;\n\tb=hxnvc8vkwnpuLqDOkx5XjMAV8IZGXdx2g0QC2iw7xCEEaYqprrqddauN0sjTqq8wfF\n\tihleFuMt55oLCpSzW7UT14gxEYkv5jrCZOfFtwtKWhNolQGXV2P2piGI0KwAEwCwFdzi\n\t9y2khfBkVHydX21wjkeTPl67rh3Z7vZcfHpjgckJBKVdnmLFIH/AYkUPIvStuXpXTf1Q\n\trf4awhTvwOuQoHx0aYQn828pQq3theipaeVY1aHJOMmbsSYnUIcSp9ZrRKrJNmIAgVB+\n\tbyQFNhtQShwT+hQTCJIKcKvG7jKsZ93XHo0FBZBFoa0P52kUa4VnKWxdA/8CAROmnjCJ\n\tivoQ=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"hxnvc8vk\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689691386; x=1692283386;\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:message-id:reply-to;\n\tbh=AZEm6gA229Srb7s98kzWNEYtc3dFuABlq3BByQqRhLs=;\n\tb=VM49quz7wf9NGTv8jDlrNxewaQPxgl98r8BBv3zJDlYD1paHa8Pt6t+lcAvwpy7k9B\n\tWhZ6fwgTBj4g19LbMLE6CnTFBgfmdpDdHfMKYfCSbBHMPsVBFDnaTt23Jjwq8RnzM/CA\n\t1XgZ2jaqDwUdck0QYUoS8NjmBla8IprNzbgHChv0/kR/IE1Qr3VFzsPZ/C3VNXg9GoX8\n\tEYzdwLmBcHDe8iw4eXb7I5qc5JbKpwHoDhkjhfWOv59KtgxsMnkQ5VyqctbxNv/NYbAM\n\txbnhPYNCKULlNkp7jWy97NjueHAeYVOxJZa7yPFdjT6ctKmLRLHyiRxeO0WCgtgtuGta\n\tkqrw==",
        "X-Gm-Message-State": "ABy/qLYn0jmAKk8BWuOLfryTiDslLmcIYPujLFjsN3vRt5lOaf+GMrA4\n\t2BeRVyS5+mvEh9kmDDU7SRbXFkRkeKj64hz94ZU=",
        "X-Google-Smtp-Source": "APBJJlFbDvIxRhZzCHGxJ+z3mh9q7Z81KPGiiVF/FdtdCaHvmPHltoI4MP8j5Pk59126WIFIdILnKQ==",
        "X-Received": "by 2002:a05:600c:ac9:b0:3fb:4053:a9d5 with SMTP id\n\tc9-20020a05600c0ac900b003fb4053a9d5mr2298320wmr.25.1689691386166; \n\tTue, 18 Jul 2023 07:43:06 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 18 Jul 2023 15:43:01 +0100",
        "Message-Id": "<20230718144301.3612-3-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20230718144301.3612-1-david.plowman@raspberrypi.com>",
        "References": "<20230718144301.3612-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 2/2] ipa: rpi: common: Handle AEC/AGC\n\tflicker controls",
        "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": "David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "David Plowman <david.plowman@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "We handle the flicker modes by passing the correct period to the\nAEC/AGC algorithm which already contains the necessary code.\n\nThe \"Auto\" mode, as well as reporting the detected flicker period via\nthe \"AeFlickerDetected\" metadata, are unsupported for now.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/common/ipa_base.cpp | 64 ++++++++++++++++++++++++++++++++-\n src/ipa/rpi/common/ipa_base.h   |  6 ++++\n 2 files changed, 69 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\nindex f40f2e71..4438ecd9 100644\n--- a/src/ipa/rpi/common/ipa_base.cpp\n+++ b/src/ipa/rpi/common/ipa_base.cpp\n@@ -61,6 +61,10 @@ const ControlInfoMap::Map ipaControls{\n \t{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },\n \t{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },\n \t{ &controls::ExposureValue, ControlInfo(-8.0f, 8.0f, 0.0f) },\n+\t{ &controls::AeFlickerMode, ControlInfo(static_cast<int>(controls::FlickerOff),\n+\t\t\t\t\t\tstatic_cast<int>(controls::FlickerManual),\n+\t\t\t\t\t\tstatic_cast<int>(controls::FlickerOff)) },\n+\t{ &controls::AeFlickerPeriod, ControlInfo(100, 1000000) },\n \t{ &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) },\n \t{ &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) },\n \t{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },\n@@ -97,7 +101,7 @@ namespace ipa::RPi {\n \n IpaBase::IpaBase()\n \t: controller_(), frameCount_(0), mistrustCount_(0), lastRunTimestamp_(0),\n-\t  firstStart_(true)\n+\t  firstStart_(true), flickerState_({ 0, 0s })\n {\n }\n \n@@ -812,6 +816,64 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::AE_FLICKER_MODE: {\n+\t\t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n+\t\t\t\tcontroller_.getAlgorithm(\"agc\"));\n+\t\t\tif (!agc) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AeFlickerMode - no AGC algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tint32_t mode = ctrl.second.get<int32_t>();\n+\t\t\tbool modeValid = true;\n+\n+\t\t\tswitch (mode) {\n+\t\t\tcase controls::FlickerOff:\n+\t\t\t\tagc->setFlickerPeriod(0us);\n+\n+\t\t\t\tbreak;\n+\n+\t\t\tcase controls::FlickerManual:\n+\t\t\t\tagc->setFlickerPeriod(flickerState_.manualPeriod);\n+\n+\t\t\t\tbreak;\n+\n+\t\t\tdefault:\n+\t\t\t\tLOG(IPARPI, Error) << \"Flicker mode \" << mode << \" is not supported\";\n+\t\t\t\tmodeValid = false;\n+\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tif (modeValid)\n+\t\t\t\tflickerState_.mode = mode;\n+\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AE_FLICKER_PERIOD: {\n+\t\t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n+\t\t\t\tcontroller_.getAlgorithm(\"agc\"));\n+\t\t\tif (!agc) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AeFlickerPeriod - no AGC algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tuint32_t manualPeriod = ctrl.second.get<int32_t>();\n+\t\t\tflickerState_.manualPeriod = manualPeriod * 1.0us;\n+\n+\t\t\t/*\n+\t\t\t * We note that it makes no difference if the mode gets set to \"manual\"\n+\t\t\t * first, and the period updated after, or vice versa.\n+\t\t\t */\n+\t\t\tif (flickerState_.mode == controls::FlickerManual)\n+\t\t\t\tagc->setFlickerPeriod(flickerState_.manualPeriod);\n+\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tcase controls::AWB_ENABLE: {\n \t\t\t/* Silently ignore this control for a mono sensor. */\n \t\t\tif (monoSensor_)\ndiff --git a/src/ipa/rpi/common/ipa_base.h b/src/ipa/rpi/common/ipa_base.h\nindex 39d00760..097f436a 100644\n--- a/src/ipa/rpi/common/ipa_base.h\n+++ b/src/ipa/rpi/common/ipa_base.h\n@@ -116,6 +116,12 @@ private:\n \t/* Frame duration (1/fps) limits. */\n \tutils::Duration minFrameDuration_;\n \tutils::Duration maxFrameDuration_;\n+\n+\t/* The current state of flicker avoidance. */\n+\tstruct FlickerState {\n+\t\tint32_t mode;\n+\t\tutils::Duration manualPeriod;\n+\t} flickerState_;\n };\n \n } /* namespace ipa::RPi */\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "2/2"
    ]
}