Show a patch.

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

{
    "id": 21765,
    "url": "https://patchwork.libcamera.org/api/patches/21765/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21765/",
    "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": "<20241028173659.247353-4-mike.rudenko@gmail.com>",
    "date": "2024-10-28T17:36:59",
    "name": "[RFC,3/3] ipa: rkisp1: Pass sensor delays from IPA to pipeline handler",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "84f087a5156d16462dde037c1d0340be7807e054",
    "submitter": {
        "id": 146,
        "url": "https://patchwork.libcamera.org/api/people/146/?format=api",
        "name": "Mikhail Rudenko",
        "email": "mike.rudenko@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21765/mbox/",
    "series": [
        {
            "id": 4750,
            "url": "https://patchwork.libcamera.org/api/series/4750/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4750",
            "date": "2024-10-28T17:36:56",
            "name": "Pass sensor delays from rkisp1 IPA to the pipeline handler",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4750/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21765/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21765/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 5E227C330B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Oct 2024 17:37:17 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1C5AB653A0;\n\tMon, 28 Oct 2024 18:37:16 +0100 (CET)",
            "from mail-lj1-x235.google.com (mail-lj1-x235.google.com\n\t[IPv6:2a00:1450:4864:20::235])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 154936539E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2024 18:37:14 +0100 (CET)",
            "by mail-lj1-x235.google.com with SMTP id\n\t38308e7fff4ca-2fb5638dd57so41497931fa.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2024 10:37:14 -0700 (PDT)",
            "from localhost.localdomain ([45.12.135.46])\n\tby smtp.gmail.com with ESMTPSA id\n\t38308e7fff4ca-2fcb453e3afsm12115511fa.57.2024.10.28.10.37.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 28 Oct 2024 10:37:11 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"DIsNB+O+\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20230601; t=1730137033; x=1730741833;\n\tdarn=lists.libcamera.org; \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=T9wQAQt3kQ8GXfSTN5Q58fUB0Jku6lzj5kKx0V1cfjs=;\n\tb=DIsNB+O+2rwWq5XfCta7PfVd6HS6AwVDb1yFLtsJhKw/Yi66+4J5nXs05N+Oi9jnqG\n\ttV+lWFeI4nkq5WhbsQ3Y2Uw/jlw8lw2ZKrQVPirMxA5C71wagGqs3lb+8Dd7a7tSr0VL\n\thDXbR9/pr5fZkOIDhURkc/w/XCsU2Q9BUmDeFO2RUedgcV6GTea9+yuGXVcGOylUlD67\n\tWedPpI1Ey1ZLps99e3YEwpvslMu2ItgCLKaFXuocU0fhA4XG1WTcR13XEdntGIpPIzQD\n\tv/VXh6f6j8hsgiazLCx0igXvlIG5m6F4ULPrjE/v0zX1eKk8pUk5NDneRYyvYGl2R7T2\n\tszFw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1730137033; x=1730741833;\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=T9wQAQt3kQ8GXfSTN5Q58fUB0Jku6lzj5kKx0V1cfjs=;\n\tb=vXRDUtSJ6F//nTjxVTlLpSqHWDIBD1OZJ0UvhGZSmIyju4MdM5GIPY1RVfkl+sSaWd\n\t+50q7SElM76XvktvncUESQ7iEgeWyINxmAEqgMnb0nIDuNRRlRkRF2sqstMqdsA/zKGa\n\tNvat1wkmyV8pCpBO3+0+dgPK3LP7yStZenbLO57EWKRrQhp95F2Pku1XsVcFLLn9IHKQ\n\tzV82MOdlCkuWhX6m0lyFSycLZeJbbp7ja6NE57oNtz1qiDnV8jl3VVnqf/ycg71Wj4+P\n\t5sleRo/maaLTSUYRJDtuF+1dpK+eaG8vNHkGF8rD9mJX0QDIOAe2qBYgcgDqtpPRJAuT\n\tLx/w==",
        "X-Gm-Message-State": "AOJu0YyjekHY0ghO4IWcyq4PQoFYlFsY2rrkcuH7KyoanXdgU58EjOKa\n\tbSJopIVEBZyX4UUmUZHkk7/q6AjIOVbiSaLBxFEeHbio3Sw0bHoaXJacJfRiEaQ=",
        "X-Google-Smtp-Source": "AGHT+IHlGBH2z74ovj+bOs8SKFEtZlpb+JSrGy2ypL3fDmPK90hfeCj9fqAdH78x+VWsZU0wupWdtw==",
        "X-Received": "by 2002:a05:651c:a0a:b0:2fb:6198:d230 with SMTP id\n\t38308e7fff4ca-2fcbdfc65d6mr39555901fa.18.1730137032430; \n\tMon, 28 Oct 2024 10:37:12 -0700 (PDT)",
        "From": "Mikhail Rudenko <mike.rudenko@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tMikhail Rudenko <mike.rudenko@gmail.com>",
        "Subject": "[PATCH RFC 3/3] ipa: rkisp1: Pass sensor delays from IPA to pipeline\n\thandler",
        "Date": "Mon, 28 Oct 2024 20:36:59 +0300",
        "Message-ID": "<20241028173659.247353-4-mike.rudenko@gmail.com>",
        "X-Mailer": "git-send-email 2.46.0",
        "In-Reply-To": "<20241028173659.247353-1-mike.rudenko@gmail.com>",
        "References": "<20241028173659.247353-1-mike.rudenko@gmail.com>",
        "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": "At present, rkisp1 uses hardcoded sensor control delays. In the case\nwhen they do not match real sensor delays, the AGC algorithm operates\nin a suboptimal mode, leading to gain/exposure oscillations on capture\nstart and slower convergence. So, pass the correct delays from IPA at\nthe init() time.\n\nSigned-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>\n---\n include/libcamera/ipa/rkisp1.mojom       |  3 ++-\n src/ipa/rkisp1/rkisp1.cpp                |  8 +++++--\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 27 ++++++++++--------------\n 3 files changed, 19 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex 80d54a03..aedd9461 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -19,7 +19,8 @@ interface IPARkISP1Interface {\n \t     uint32 hwRevision,\n \t     libcamera.IPACameraSensorInfo sensorInfo,\n \t     libcamera.ControlInfoMap sensorControls)\n-\t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\n+\t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls,\n+\t\t    libcamera.IPASensorDelays sensorDelays);\n \tstart() => (int32 ret);\n \tstop();\n \ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 9e161cab..b42ec976 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -54,7 +54,8 @@ public:\n \tint init(const IPASettings &settings, unsigned int hwRevision,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n-\t\t ControlInfoMap *ipaControls) override;\n+\t\t ControlInfoMap *ipaControls,\n+\t\t IPASensorDelays *sensorDelays) override;\n \tint start() override;\n \tvoid stop() override;\n \n@@ -136,7 +137,8 @@ std::string IPARkISP1::logPrefix() const\n int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t\t    const IPACameraSensorInfo &sensorInfo,\n \t\t    const ControlInfoMap &sensorControls,\n-\t\t    ControlInfoMap *ipaControls)\n+\t\t    ControlInfoMap *ipaControls,\n+\t\t    IPASensorDelays *sensorDelays)\n {\n \t/* \\todo Add support for other revisions */\n \tswitch (hwRevision) {\n@@ -168,6 +170,8 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t\treturn -ENODEV;\n \t}\n \n+\t*sensorDelays = context_.camHelper->sensorDelays();\n+\n \tcontext_.configuration.sensor.lineDuration =\n \t\tsensorInfo.minLineLength * 1.0s / sensorInfo.pixelRate;\n \ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex c7b0b392..0ece3c55 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -96,7 +96,7 @@ public:\n \t}\n \n \tPipelineHandlerRkISP1 *pipe();\n-\tint loadIPA(unsigned int hwRevision);\n+\tint loadIPA(unsigned int hwRevision, IPASensorDelays *sensorDelays);\n \n \tStream mainPathStream_;\n \tStream selfPathStream_;\n@@ -360,7 +360,7 @@ PipelineHandlerRkISP1 *RkISP1CameraData::pipe()\n \treturn static_cast<PipelineHandlerRkISP1 *>(Camera::Private::pipe());\n }\n \n-int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n+int RkISP1CameraData::loadIPA(unsigned int hwRevision, IPASensorDelays *sensorDelays)\n {\n \tipa_ = IPAManager::createIPA<ipa::rkisp1::IPAProxyRkISP1>(pipe(), 1, 1);\n \tif (!ipa_)\n@@ -391,7 +391,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n \t}\n \n \tret = ipa_->init({ ipaTuningFile, sensor_->model() }, hwRevision,\n-\t\t\t sensorInfo, sensor_->controls(), &ipaControls_);\n+\t\t\t sensorInfo, sensor_->controls(), &controlInfo_,\n+\t\t\t sensorDelays);\n \tif (ret < 0) {\n \t\tLOG(RkISP1, Error) << \"IPA initialization failure\";\n \t\treturn ret;\n@@ -1240,14 +1241,14 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \t/* Initialize the camera properties. */\n \tdata->properties_ = data->sensor_->properties();\n \n-\t/*\n-\t * \\todo Read delay values from the sensor itself or from a\n-\t * a sensor database. For now use generic values taken from\n-\t * the Raspberry Pi and listed as generic values.\n-\t */\n+\tIPASensorDelays sensorDelays;\n+\tret = data->loadIPA(media_->hwRevision(), &sensorDelays);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tstd::unordered_map<uint32_t, DelayedControls::ControlParams> params = {\n-\t\t{ V4L2_CID_ANALOGUE_GAIN, { 1, false } },\n-\t\t{ V4L2_CID_EXPOSURE, { 2, false } },\n+\t\t{ V4L2_CID_ANALOGUE_GAIN, { sensorDelays.gainDelay, false } },\n+\t\t{ V4L2_CID_EXPOSURE, { sensorDelays.exposureDelay, false } },\n \t};\n \n \tdata->delayedCtrls_ =\n@@ -1256,12 +1257,6 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \tisp_->frameStart.connect(data->delayedCtrls_.get(),\n \t\t\t\t &DelayedControls::applyControls);\n \n-\tret = data->loadIPA(media_->hwRevision());\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tupdateControls(data.get());\n-\n \tstd::set<Stream *> streams{\n \t\t&data->mainPathStream_,\n \t\t&data->selfPathStream_,\n",
    "prefixes": [
        "RFC",
        "3/3"
    ]
}