Show a patch.

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

{
    "id": 14158,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14158/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14158/",
    "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": "<20211015151004.291295-1-kieran.bingham@ideasonboard.com>",
    "date": "2021-10-15T15:10:04",
    "name": "[libcamera-devel,IPU3-IPA] ipu3: Update camera controls in configure()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "915beaeba5c35f12b192383d3ebd99136ac80c06",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14158/mbox/",
    "series": [
        {
            "id": 2633,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2633/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2633",
            "date": "2021-10-15T15:10:04",
            "name": "[libcamera-devel,IPU3-IPA] ipu3: Update camera controls in configure()",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2633/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14158/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14158/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 14EBDC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 15:10:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 40A6D68F4F;\n\tFri, 15 Oct 2021 17:10:09 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3788568546\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 17:10:08 +0200 (CEST)",
            "from Monstersaurus.ksquared.org.uk.beta.tailscale.net\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A3BA32E3;\n\tFri, 15 Oct 2021 17:10:07 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ozM1/2u2\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634310607;\n\tbh=sTIFn3x9VnLzMUL0P3wKkvtEZCDJaTS6NP/uvNQ06fI=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=ozM1/2u2mN5t6EuJLRoqUQH//3Mcmwh4KJRgPxBzkena3eTBAJM9wYeaxKE8u+TFx\n\t8eSsshjYPwGt1+fxCz4z6RFE8uV5xpItqU56WbAkYSqpAzNpdS0miX3wkhhUSdpF0Z\n\tDOBCnIsMHk1sU4GNvxrYzUX3QswYDwrP4a4SOops=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Fri, 15 Oct 2021 16:10:04 +0100",
        "Message-Id": "<20211015151004.291295-1-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [IPU3-IPA PATCH] ipu3: Update camera controls in\n\tconfigure()",
        "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\nThis commit corresponds to the libcamera commit 4ed22985a846 (\"ipa:\nipu3: Update camera controls in configure()\") and applies the same\nchanges to this IPA.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n ipu3.cpp | 127 ++++++++++++++++++++++++++++++++++---------------------\n 1 file changed, 78 insertions(+), 49 deletions(-)",
    "diff": "diff --git a/ipu3.cpp b/ipu3.cpp\nindex 7589eecbb64c..8126e9d659df 100644\n--- a/ipu3.cpp\n+++ b/ipu3.cpp\n@@ -44,13 +44,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 &metadata);\n \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n \tvoid parseStatistics(unsigned int frame,\n@@ -86,6 +90,68 @@ private:\n \tBinaryData aiqd_;\n };\n \n+/*\n+ * Compute camera controls using the sensor information and the sensor\n+ * v4l2 controls.\n+ *\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, for example, the exposure\n+ * time and the frame duration.\n+ *\n+ * This function computes:\n+ * - controls::ExposureTime\n+ * - controls::FrameDurationLimits\n+ */\n+void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t     const ControlInfoMap &sensorControls,\n+\t\t\t     ControlInfoMap *ipaControls)\n+{\n+\tControlInfoMap::Map controls{};\n+\n+\t/*\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+\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n+\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n+\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n+\tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n+\t\t\t\t\t\t\tdefExposure);\n+\n+\t/*\n+\t * Compute the frame duration limits.\n+\t *\n+\t * The frame length is computed assuming a fixed line length combined\n+\t * with the vertical frame sizes.\n+\t */\n+\tconst ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second;\n+\tuint32_t hblank = v4l2HBlank.def().get<int32_t>();\n+\tuint32_t lineLength = sensorInfo.outputSize.width + hblank;\n+\n+\tconst ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second;\n+\tstd::array<uint32_t, 3> frameHeights{\n+\t\tv4l2VBlank.min().get<int32_t>() + sensorInfo.outputSize.height,\n+\t\tv4l2VBlank.max().get<int32_t>() + sensorInfo.outputSize.height,\n+\t\tv4l2VBlank.def().get<int32_t>() + sensorInfo.outputSize.height,\n+\t};\n+\n+\tstd::array<int64_t, 3> frameDurations;\n+\tfor (unsigned int i = 0; i < frameHeights.size(); ++i) {\n+\t\tuint64_t frameSize = lineLength * frameHeights[i];\n+\t\tframeDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);\n+\t}\n+\n+\tcontrols[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],\n+\t\t\t\t\t\t\t       frameDurations[1],\n+\t\t\t\t\t\t\t       frameDurations[2]);\n+\n+\t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n+}\n+\n int IPAIPU3::init(const IPASettings &settings,\n \t\t  const IPACameraSensorInfo &sensorInfo,\n \t\t  const ControlInfoMap &sensorControls,\n@@ -141,53 +207,8 @@ int IPAIPU3::init(const IPASettings &settings,\n \n \taiqInputParams_.init();\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 */\n-\tdouble lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n-\tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n-\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n-\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n-\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n-\tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n-\t\t\t\t\t\t\tdefExposure);\n-\n-\t/*\n-\t * Compute the frame duration limits.\n-\t *\n-\t * The frame length is computed assuming a fixed line length combined\n-\t * with the vertical frame sizes.\n-\t */\n-\tconst ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second;\n-\tuint32_t hblank = v4l2HBlank.def().get<int32_t>();\n-\tuint32_t lineLength = sensorInfo.outputSize.width + hblank;\n-\n-\tconst ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second;\n-\tstd::array<uint32_t, 3> frameHeights{\n-\t\tv4l2VBlank.min().get<int32_t>() + sensorInfo.outputSize.height,\n-\t\tv4l2VBlank.max().get<int32_t>() + sensorInfo.outputSize.height,\n-\t\tv4l2VBlank.def().get<int32_t>() + sensorInfo.outputSize.height,\n-\t};\n-\n-\tstd::array<int64_t, 3> frameDurations;\n-\tfor (unsigned int i = 0; i < frameHeights.size(); ++i) {\n-\t\tuint64_t frameSize = lineLength * frameHeights[i];\n-\t\tframeDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);\n-\t}\n-\n-\tcontrols[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],\n-\t\t\t\t\t\t\t       frameDurations[1],\n-\t\t\t\t\t\t\t       frameDurations[2]);\n-\n-\t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n+\t/* Initialize controls. */\n+\tupdateControls(sensorInfo, sensorControls, ipaControls);\n \n \treturn 0;\n }\n@@ -199,7 +220,8 @@ int IPAIPU3::start()\n \treturn 0;\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.sensorControls.empty()) {\n \t\tLOG(IPAIPU3, Error) << \"No sensor controls provided\";\n@@ -208,6 +230,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.sensorControls;\n \n \tconst auto itExp = ctrls_.find(V4L2_CID_EXPOSURE);\n@@ -253,6 +279,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \t/* Set AE/AWB defaults, this typically might not belong here */\n \taiqInputParams_.setAeAwbAfDefaults();\n \n+\t/* Upate the camera controls using the new sensor settings. */\n+\tupdateControls(sensorInfo_, ctrls_, ipaControls);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "IPU3-IPA"
    ]
}