Show a patch.

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

{
    "id": 16478,
    "url": "https://patchwork.libcamera.org/api/patches/16478/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16478/",
    "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": "<20220630133902.321099-21-jacopo@jmondi.org>",
    "date": "2022-06-30T13:38:59",
    "name": "[libcamera-devel,v3,20/23] ipa: ipu3: Make algorithms use libcamera controls",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "11e6b52269da685d5c9ef43864e8a9aeb414af92",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16478/mbox/",
    "series": [
        {
            "id": 3238,
            "url": "https://patchwork.libcamera.org/api/series/3238/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3238",
            "date": "2022-06-30T13:38:39",
            "name": "Internal controls, sensor delays and IPA rework",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3238/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16478/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16478/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 B17C8BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 13:39:55 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5DE2F656B5;\n\tThu, 30 Jun 2022 15:39:55 +0200 (CEST)",
            "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72B75656B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 15:39:48 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 412D3240003;\n\tThu, 30 Jun 2022 13:39:45 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656596395;\n\tbh=McMzxIfktJ6BpbvEaIQ6eK0gr6MearwMemeQxYmrzYk=;\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=jAGIT4XFkICFJPSpSp+439Nn0ddHJUAgOG/jUYn2atGeOmC5hWL4lWzmO+ecClHEd\n\tqcm4UQwzok7Iua/AFqRwzs+PHoaO29lCCdDAzGl9HDG/SFlI0RmN55Hf5NihZALIp5\n\tZJoZ9WUNA4GiAlrQH0vwoADiOdN+4zkNepExMxdrZf6KqHp9pFIUAPBneub8zHzqje\n\tCctLrwyLyx7NBAxxDIXQYFa5o91Xkxzc2zhZ+TZHYf/EHKr0eYofdkPD9qlrS0hzKz\n\tTnZKf3ihkNQLSiRyXuNFPJiSbvAKnKPqfB5h9muW5uK0bCu1Zzt8npa4MAXLXHNrjK\n\tDYusbTSKOEThA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 30 Jun 2022 15:38:59 +0200",
        "Message-Id": "<20220630133902.321099-21-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.36.1",
        "In-Reply-To": "<20220630133902.321099-1-jacopo@jmondi.org>",
        "References": "<20220630133902.321099-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 20/23] ipa: ipu3: Make algorithms use\n\tlibcamera 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": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo@jmondi.org>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Move the IPU3 IPA module and the AGC algorithm to use libcamera controls\ninstead of computing V4L2 control values.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 12 +++---------\n src/ipa/ipu3/ipu3.cpp           | 15 ++++++---------\n 2 files changed, 9 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex f16be534dd71..d1bbf2a753e9 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -186,11 +186,6 @@ utils::Duration Agc::filterExposure(utils::Duration exposureValue)\n void Agc::computeExposure(IPAContext &context, IPAFrameContext *frameContext,\n \t\t\t  double yGain, double iqMeanGain)\n {\n-\tconst IPASessionConfiguration &configuration = context.configuration;\n-\t/* Get the effective exposure and gain applied on the sensor. */\n-\tuint32_t exposure = frameContext->sensor.exposure;\n-\tdouble analogueGain = frameContext->sensor.gain;\n-\n \t/* Use the highest of the two gain estimates. */\n \tdouble evGain = std::max(yGain, iqMeanGain);\n \n@@ -201,13 +196,12 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext *frameContext,\n \n \t/* extracted from Rpi::Agc::computeTargetExposure */\n \n-\t/* Calculate the shutter time in seconds */\n-\tutils::Duration currentShutter = exposure * configuration.sensor.lineDuration;\n-\n \t/*\n \t * Update the exposure value for the next computation using the values\n \t * of exposure and gain really used by the sensor.\n \t */\n+\tdouble analogueGain = frameContext->sensor.gain;\n+\tutils::Duration currentShutter = frameContext->sensor.exposure * 1.0us;\n \tutils::Duration effectiveExposureValue = currentShutter * analogueGain;\n \n \tLOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentShutter * analogueGain\n@@ -250,7 +244,7 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext *frameContext,\n \n \tIPAActiveState &activeState = context.activeState;\n \t/* Update the estimated exposure and gain. */\n-\tactiveState.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n+\tactiveState.agc.exposure = shutterTime.get<std::micro>();\n \tactiveState.agc.gain = stepGain;\n }\n \ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex f2e28c06a2c2..6d622b4c290b 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -476,8 +476,8 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tif (frameContext.frame != frame)\n \t\tLOG(IPAIPU3, Warning) << \"Frame \" << frame << \" does not match its frame context\";\n \n-\tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n-\tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n+\tframeContext.sensor.exposure = sensorControls.get(controls::internal::ExposureTime);\n+\tframeContext.sensor.gain = sensorControls.get(controls::internal::AnalogueGain);\n \n \t/* Run algorithms on the statistics and per-frame context. */\n \tSpan<uint8_t> mem = it->second.planes()[0];\n@@ -500,7 +500,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tmetadata.set(controls::FrameDuration, frameDuration);\n \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n \tmetadata.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);\n-\tmetadata.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);\n+\tmetadata.set(controls::ExposureTime, frameContext.sensor.exposure);\n \n \t/*\n \t * \\todo The Metadata provides a path to getting extended data\n@@ -538,12 +538,9 @@ void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)\n  */\n void IPAIPU3::setControls(unsigned int frame, const IPAActiveState &state)\n {\n-\tint32_t exposure = state.agc.exposure;\n-\tint32_t gain = camHelper_->gainCode(state.agc.gain);\n-\n-\tControlList ctrls(controls::controls);\n-\tctrls.set(V4L2_CID_EXPOSURE, exposure);\n-\tctrls.set(V4L2_CID_ANALOGUE_GAIN, gain);\n+\tControlList ctrls(controls::internal::controls);\n+\tctrls.set(controls::internal::ExposureTime, state.agc.exposure);\n+\tctrls.set(controls::internal::AnalogueGain, static_cast<float>(state.agc.gain));\n \n \tControlList lensCtrls(controls::controls);\n \tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "20/23"
    ]
}