Show a patch.

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

{
    "id": 13735,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13735/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13735/",
    "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": "<20210907194107.803730-5-jacopo@jmondi.org>",
    "date": "2021-09-07T19:40:54",
    "name": "[libcamera-devel,v2,04/17] ipa: ipu3: Update camera controls in configure()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "245d2bb67e2a5fc810b7ff507ac621bfb95a189b",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13735/mbox/",
    "series": [
        {
            "id": 2492,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2492/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2492",
            "date": "2021-09-07T19:40:50",
            "name": "IPU3 control info update and HAL frame durations",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2492/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13735/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13735/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 014C3BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Sep 2021 19:40:35 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6414569182;\n\tTue,  7 Sep 2021 21:40:34 +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 E6F2169170\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 21:40:30 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 1F9F1240006;\n\tTue,  7 Sep 2021 19:40:29 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  7 Sep 2021 21:40:54 +0200",
        "Message-Id": "<20210907194107.803730-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20210907194107.803730-1-jacopo@jmondi.org>",
        "References": "<20210907194107.803730-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 04/17] ipa: ipu3: Update camera\n\tcontrols in configure()",
        "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": "When a new CameraConfiguration is applied to the Camera the IPA is\nconfigured as well, using the newly applied sensor configuration and its\nupdated V4L2 controls.\n\nAlso update the Camera controls at IPA::configure() time by re-computing\nthe controls::ExposureTime and controls::FrameDurationLimits limits and\nupdate the controls on the pipeline handler side after having configured\nthe IPA.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n include/libcamera/ipa/ipu3.mojom     |  3 +-\n src/ipa/ipu3/ipu3.cpp                | 82 +++++++++++++++++++---------\n src/libcamera/pipeline/ipu3/ipu3.cpp |  4 +-\n 3 files changed, 60 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/ipu3.mojom b/include/libcamera/ipa/ipu3.mojom\nindex d561c2244907..714f58ab8a42 100644\n--- a/include/libcamera/ipa/ipu3.mojom\n+++ b/include/libcamera/ipa/ipu3.mojom\n@@ -45,7 +45,8 @@ interface IPAIPU3Interface {\n \tstart() => (int32 ret);\n \tstop();\n \n-\tconfigure(IPAConfigInfo configInfo) => (int32 ret);\n+\tconfigure(IPAConfigInfo configInfo)\n+\t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\n \n \tmapBuffers(array<libcamera.IPABuffer> buffers);\n \tunmapBuffers(array<uint32> ids);\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex c925cf642611..ec75b3ffa305 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -156,13 +156,17 @@ public:\n \tint start() override;\n \tvoid stop() override {}\n \n-\tint configure(const IPAConfigInfo &configInfo) override;\n+\tint configure(const IPAConfigInfo &configInfo,\n+\t\t      ControlInfoMap *ipaControls) override;\n \n \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n \tvoid unmapBuffers(const std::vector<unsigned int> &ids) override;\n \tvoid processEvent(const IPU3Event &event) override;\n \n private:\n+\tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t    const ControlInfoMap &sensorControls,\n+\t\t\t    ControlInfoMap *ipaControls);\n \tvoid processControls(unsigned int frame, const ControlList &controls);\n \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n \tvoid parseStatistics(unsigned int frame,\n@@ -197,36 +201,30 @@ private:\n \tstruct IPAContext context_;\n };\n \n-/**\n- * Initialize the IPA module and its controls.\n+\n+/*\n+ * Compute camera controls using the sensor information and the sensor\n+ * v4l2 controls.\n  *\n- * This function receives the camera sensor information from the pipeline\n- * handler, computes the limits of the controls it handles and returns\n- * them in the \\a ipaControls output parameter.\n+ * Some of the camera controls are computed by the pipeline handler, some others\n+ * by the IPA module which is in charge of handling, in example, the exposure\n+ * time and the frame duration.\n+ *\n+ * This functions computes:\n+ * - controls::ExposureTime\n+ * - controls::FrameDurationLimits\n  */\n-int IPAIPU3::init(const IPASettings &settings,\n-\t\t  const IPACameraSensorInfo &sensorInfo,\n-\t\t  const ControlInfoMap &sensorControls,\n-\t\t  ControlInfoMap *ipaControls)\n+void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t     const ControlInfoMap &sensorControls,\n+\t\t\t     ControlInfoMap *ipaControls)\n {\n-\tcamHelper_ = CameraSensorHelperFactory::create(settings.sensorModel);\n-\tif (camHelper_ == nullptr) {\n-\t\tLOG(IPAIPU3, Error)\n-\t\t\t<< \"Failed to create camera sensor helper for \"\n-\t\t\t<< settings.sensorModel;\n-\t\treturn -ENODEV;\n-\t}\n-\n-\t/* Initialize Controls. */\n \tControlInfoMap::Map controls{};\n \n \t/*\n-\t * Compute exposure time limits.\n-\t *\n-\t * Initialize the control using the line length and pixel rate of the\n-\t * current configuration converted to microseconds. Use the\n-\t * V4L2_CID_EXPOSURE control to get exposure min, max and default and\n-\t * convert it from lines to microseconds.\n+\t * Compute exposure time limits by using line length and pixel rate\n+\t * converted to microseconds. Use the V4L2_CID_EXPOSURE control to get\n+\t * exposure min, max and default and convert it from lines to\n+\t * microseconds.\n \t */\n \tdouble lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n \tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n@@ -264,12 +262,36 @@ int IPAIPU3::init(const IPASettings &settings,\n \t\t\t\t\t\t\t       frameDurations[2]);\n \n \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n+}\n+\n+/**\n+ * Initialize the IPA module and its controls.\n+ *\n+ * This function receives the camera sensor information from the pipeline\n+ * handler, computes the limits of the controls it handles and returns\n+ * them in the \\a ipaControls output parameter.\n+ */\n+int IPAIPU3::init(const IPASettings &settings,\n+\t\t  const IPACameraSensorInfo &sensorInfo,\n+\t\t  const ControlInfoMap &sensorControls,\n+\t\t  ControlInfoMap *ipaControls)\n+{\n+\tcamHelper_ = CameraSensorHelperFactory::create(settings.sensorModel);\n+\tif (camHelper_ == nullptr) {\n+\t\tLOG(IPAIPU3, Error)\n+\t\t\t<< \"Failed to create camera sensor helper for \"\n+\t\t\t<< settings.sensorModel;\n+\t\treturn -ENODEV;\n+\t}\n \n \t/* Construct our Algorithms */\n \talgorithms_.push_back(std::make_unique<algorithms::Agc>());\n \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n \talgorithms_.push_back(std::make_unique<algorithms::ToneMapping>());\n \n+\t/* Initialize controls. */\n+\tupdateControls(sensorInfo, sensorControls, ipaControls);\n+\n \treturn 0;\n }\n \n@@ -335,7 +357,8 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)\n \t\t\t    << (int)bdsGrid.height << \" << \" << (int)bdsGrid.block_height_log2 << \")\";\n }\n \n-int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n+int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n+\t\t       ControlInfoMap *ipaControls)\n {\n \tif (configInfo.entityControls.empty()) {\n \t\tLOG(IPAIPU3, Error) << \"No controls provided\";\n@@ -344,6 +367,10 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \n \tsensorInfo_ = configInfo.sensorInfo;\n \n+\t/*\n+\t * Compute the sensor V4L2 controls to be used by the algorithms and\n+\t * to be set on the sensor.\n+\t */\n \tctrls_ = configInfo.entityControls.at(0);\n \n \tconst auto itExp = ctrls_.find(V4L2_CID_EXPOSURE);\n@@ -385,6 +412,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \t\t\treturn ret;\n \t}\n \n+\t/* Update the camera controls using the new sensor settings. */\n+\tupdateControls(sensorInfo_, ctrls_, ipaControls);\n+\n \treturn 0;\n }\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 1c383336e45f..de0adffc965f 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -660,14 +660,14 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \tconfigInfo.bdsOutputSize = config->imguConfig().bds;\n \tconfigInfo.iif = config->imguConfig().iif;\n \n-\tret = data->ipa_->configure(configInfo);\n+\tret = data->ipa_->configure(configInfo, &data->ipaControls_);\n \tif (ret) {\n \t\tLOG(IPU3, Error) << \"Failed to configure IPA: \"\n \t\t\t\t << strerror(-ret);\n \t\treturn ret;\n \t}\n \n-\treturn 0;\n+\treturn updateControls(data);\n }\n \n int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "04/17"
    ]
}