Show a patch.

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

{
    "id": 21768,
    "url": "https://patchwork.libcamera.org/api/patches/21768/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21768/",
    "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": "<20241029112501.140252-1-stanislaw.gruszka@linux.intel.com>",
    "date": "2024-10-29T11:25:00",
    "name": "[1/2] libcamera: software_isp: Initialize exposure+gain before agc calculations",
    "commit_ref": "bb1aa92eb9ee7e713d997d5786129e88219e166a",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "832be0e766bbbc2b6a815e67770ac93a8a51fe4c",
    "submitter": {
        "id": 211,
        "url": "https://patchwork.libcamera.org/api/people/211/?format=api",
        "name": "Stanislaw Gruszka",
        "email": "stanislaw.gruszka@linux.intel.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21768/mbox/",
    "series": [
        {
            "id": 4752,
            "url": "https://patchwork.libcamera.org/api/series/4752/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4752",
            "date": "2024-10-29T11:25:00",
            "name": "[1/2] libcamera: software_isp: Initialize exposure+gain before agc calculations",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4752/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21768/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21768/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 25949C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Oct 2024 11:25:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F18C6539F;\n\tTue, 29 Oct 2024 12:25:09 +0100 (CET)",
            "from mgamail.intel.com (mgamail.intel.com [192.198.163.19])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36BC860366\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Oct 2024 12:25:06 +0100 (CET)",
            "from fmviesa003.fm.intel.com ([10.60.135.143])\n\tby fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t29 Oct 2024 04:25:04 -0700",
            "from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.246.8.237]) by fmviesa003-auth.fm.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 04:25:03 -0700"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"i2ZQKUQw\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1730201107; x=1761737107;\n\th=from:to:cc:subject:date:message-id:mime-version:\n\tcontent-transfer-encoding;\n\tbh=FXiuxxqi1c+vuMUxhBh7Jto5dgBhQcwTBrgQIeWoF5A=;\n\tb=i2ZQKUQwlT75vbxJbPd+bM48OA766irwR5XJqM+12KrSIoPf+U/tk3sz\n\tnc3OO04TbuU/QNnyVt6DUe8oq/RoqMMeSxMzNMEuckF2A2P8yBysJZgWs\n\tJ8uw6g8fr3Meq/70pWx0EawMORIUr7ug7UCaF0xIOTwUvRCnjqpMH9nO6\n\tuCSxokQj+rpJricG7S8pTxeLYAQ4amTyy02+AVB314ANQJYwHFycNhgAF\n\t+KwNUEXsVF+cFZ6zZF045Bi9yGBsuNCXye/SBnj/efiUIigvtKj/IkqNq\n\tFQOZPNd+jXNZQY2onmZrcFy/CZiBPcJxW7xX6nxqhe3ZrFK7BGc42drY4 g==;",
        "X-CSE-ConnectionGUID": [
            "DpPnmRC2SK2AwHW+yLzzWA==",
            "Skz/2GX+Sc2x8nPyDCrhDA=="
        ],
        "X-CSE-MsgGUID": [
            "9iaC6KpFR9O8wtoofeC2+w==",
            "6ZXixHotS2iFsysoDXWr9g=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6700,10204,11239\"; a=\"29289311\"",
            "E=Sophos;i=\"6.11,241,1725346800\"; d=\"scan'208\";a=\"29289311\"",
            "E=Sophos;i=\"6.11,241,1725346800\"; d=\"scan'208\";a=\"85890418\""
        ],
        "X-ExtLoop1": "1",
        "From": "Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Milan Zamazal <mzamazal@redhat.com>",
        "Subject": "[PATCH 1/2] libcamera: software_isp: Initialize exposure+gain before\n\tagc calculations",
        "Date": "Tue, 29 Oct 2024 12:25:00 +0100",
        "Message-Id": "<20241029112501.140252-1-stanislaw.gruszka@linux.intel.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "On my setup, since commit fb8ad13d (\"libcamera: software_isp: Move exposure+gain\nto an algorithm module\"), at start camera output stays very dark for dozen\nof seconds, and then later slowly gets to normal. This is because existing\nsensor exposure+gain settings are not used at start. We save initial\nvalues in frameContext but in the agc algorithm we use IPA context.\n\nFix the problem by using in frameContext sensor values, since we already\nuse those in blc algorithm and change exposure type to int32_t to\nunnecessary castings.\n\nSigned-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n---\n src/ipa/simple/algorithms/agc.cpp | 8 ++++----\n src/ipa/simple/algorithms/agc.h   | 2 +-\n src/ipa/simple/algorithms/blc.h   | 2 +-\n src/ipa/simple/ipa_context.h      | 2 +-\n src/ipa/simple/soft_simple.cpp    | 4 ++--\n 5 files changed, 9 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\nindex df92edd7..72aade14 100644\n--- a/src/ipa/simple/algorithms/agc.cpp\n+++ b/src/ipa/simple/algorithms/agc.cpp\n@@ -39,7 +39,7 @@ Agc::Agc()\n {\n }\n \n-void Agc::updateExposure(IPAContext &context, double exposureMSV)\n+void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)\n {\n \t/*\n \t * kExpDenominator of 10 gives ~10% increment/decrement;\n@@ -50,8 +50,8 @@ void Agc::updateExposure(IPAContext &context, double exposureMSV)\n \tstatic constexpr uint8_t kExpNumeratorDown = kExpDenominator - 1;\n \n \tdouble next;\n-\tint32_t &exposure = context.activeState.agc.exposure;\n-\tdouble &again = context.activeState.agc.again;\n+\tint32_t &exposure = frameContext.sensor.exposure;\n+\tdouble &again = frameContext.sensor.gain;\n \n \tif (exposureMSV < kExposureOptimal - kExposureSatisfactory) {\n \t\tnext = exposure * kExpNumeratorUp / kExpDenominator;\n@@ -129,7 +129,7 @@ void Agc::process(IPAContext &context,\n \t}\n \n \tfloat exposureMSV = (denom == 0 ? 0 : static_cast<float>(num) / denom);\n-\tupdateExposure(context, exposureMSV);\n+\tupdateExposure(context, frameContext, exposureMSV);\n }\n \n REGISTER_IPA_ALGORITHM(Agc, \"Agc\")\ndiff --git a/src/ipa/simple/algorithms/agc.h b/src/ipa/simple/algorithms/agc.h\nindex ad5fca9f..112d9f5a 100644\n--- a/src/ipa/simple/algorithms/agc.h\n+++ b/src/ipa/simple/algorithms/agc.h\n@@ -25,7 +25,7 @@ public:\n \t\t     ControlList &metadata) override;\n \n private:\n-\tvoid updateExposure(IPAContext &context, double exposureMSV);\n+\tvoid updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV);\n };\n \n } /* namespace ipa::soft::algorithms */\ndiff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h\nindex 2cf2a877..67c688ae 100644\n--- a/src/ipa/simple/algorithms/blc.h\n+++ b/src/ipa/simple/algorithms/blc.h\n@@ -27,7 +27,7 @@ public:\n \t\t     ControlList &metadata) override;\n \n private:\n-\tuint32_t exposure_;\n+\tint32_t exposure_;\n \tdouble gain_;\n };\n \ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex fd121eeb..c510c436 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -53,7 +53,7 @@ struct IPAActiveState {\n \n struct IPAFrameContext : public FrameContext {\n \tstruct {\n-\t\tuint32_t exposure;\n+\t\tint32_t exposure;\n \t\tdouble gain;\n \t} sensor;\n };\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex c8ad55a2..dfacd6aa 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -310,8 +310,8 @@ void IPASoftSimple::processStats(const uint32_t frame,\n \n \tControlList ctrls(sensorInfoMap_);\n \n-\tauto &againNew = context_.activeState.agc.again;\n-\tctrls.set(V4L2_CID_EXPOSURE, context_.activeState.agc.exposure);\n+\tauto &againNew = frameContext.sensor.gain;\n+\tctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure);\n \tctrls.set(V4L2_CID_ANALOGUE_GAIN,\n \t\t  static_cast<int32_t>(camHelper_ ? camHelper_->gainCode(againNew) : againNew));\n \n",
    "prefixes": [
        "1/2"
    ]
}