Show a patch.

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

{
    "id": 10414,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10414/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10414/",
    "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": "<20201112085915.3053-4-naush@raspberrypi.com>",
    "date": "2020-11-12T08:59:15",
    "name": "[libcamera-devel,3/3] pipeline: ipa: raspberrypi: Pass controls to IPA on start",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "cffbdaabe834c923d6fa89fd9f689dbac72fd259",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10414/mbox/",
    "series": [
        {
            "id": 1457,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1457/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1457",
            "date": "2020-11-12T08:59:12",
            "name": "Pass controls on camera:start()",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1457/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10414/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10414/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 E8672BE082\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Nov 2020 08:59:25 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6F896313E;\n\tThu, 12 Nov 2020 09:59:25 +0100 (CET)",
            "from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C516563145\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Nov 2020 09:59:22 +0100 (CET)",
            "by mail-wr1-x436.google.com with SMTP id l1so5113918wrb.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Nov 2020 00:59:22 -0800 (PST)",
            "from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tf17sm5641599wmf.41.2020.11.12.00.59.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 12 Nov 2020 00:59:21 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"JiHmh9gB\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=UNy699uzrpM55Ufh+haDnUB3bGaPk4IndaNCU1cXDPI=;\n\tb=JiHmh9gBWsYcr9OLzFreUglCCwX50ayjH8BgXaRp9a5WQSGTjjx9AesO1TTvk11rqz\n\tWOowI1Nv7eOH3A18ywnTIGu62MCSA7guRtxVdRqCzyiofV7secNM83qU7f6kFOV33lcz\n\twSzAUFRXu0uNBWV1PY1llRu9h3xhadPEBFyBkoLHPDHJMR/O9iYa7sthM7fOVfzOba8q\n\tTpRyoA/HYsGngCf6dcy506cho3WryuR6VDIFqejrlopjLMVHYcDPxKQ6MU2EVIpOxUj4\n\tMDXERN+m/wliEli8avWvntX//IB8rZtsaXD80ZtRaz0u1ogr3LAP8P+Ii3EuJ/iOdUVj\n\tBwqw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=UNy699uzrpM55Ufh+haDnUB3bGaPk4IndaNCU1cXDPI=;\n\tb=fWukPpLRfsoRYDYPmAlM6JhSkuz4u6RpGqIFdtvGZEg7dM/EMzZChv29KBm0bWKGeD\n\tR12/WtS4guJLfNvU/ioBogqdIKVdrAKYLJFwCY4rphb77+74y9z9WtU+BvpmbknxVwc1\n\tfLsyZevUk1aHpCp3qwOxzn+yLnfd9y+u0XBU+3rB+ZV0bQuZo6RziXYXtSutCrlUCDIW\n\tnvG2V7Zb6Vq8zn3eAu6GOeTfeC8Ur8VogVCfJWkGyujN0G9jybOhhVehCmlwpMuhtIpV\n\tRzP4NT38Gg7kY0Pz9f2kZJmjcg5qMT9/QuCRqmBFrRwGnBrHjqvu0QeXvsrmRFsSpFjC\n\t6jIw==",
        "X-Gm-Message-State": "AOAM531HC/q4vmn8LBIetgtkbALemWohzgiebJeirVvKthtY7SD//tAM\n\tWwj1/j51HwLY5rSyW0LVZvWdrOVXHcOH6w==",
        "X-Google-Smtp-Source": "ABdhPJxsgD29xQonTu1KY90VDw3CTq0LFvL4de8LAdYPYrPgwhMfUhsECCPQV7Rft4bNyiEHFhQdNA==",
        "X-Received": "by 2002:a5d:618b:: with SMTP id\n\tj11mr1160637wru.161.1605171562145; \n\tThu, 12 Nov 2020 00:59:22 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 12 Nov 2020 08:59:15 +0000",
        "Message-Id": "<20201112085915.3053-4-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20201112085915.3053-1-naush@raspberrypi.com>",
        "References": "<20201112085915.3053-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 3/3] pipeline: ipa: raspberrypi: Pass\n\tcontrols to IPA on start",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Forward any controls passed into the pipeline handler to the IPA.\nThe IPA then sets up the Raspberry Pi controller with these settings\nappropriately, and passes back any V4L2 sensor controls that need\nto be applied.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/ipa/raspberrypi.h           |  1 +\n src/ipa/raspberrypi/raspberrypi.cpp           | 51 ++++++++++++-------\n .../pipeline/raspberrypi/raspberrypi.cpp      | 14 ++++-\n 3 files changed, 46 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex 2b55dbfc..c91a14bd 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -21,6 +21,7 @@ enum ConfigParameters {\n \tIPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n \tIPA_CONFIG_SENSOR = (1 << 2),\n \tIPA_CONFIG_DROP_FRAMES = (1 << 3),\n+\tIPA_CONFIG_STARTUP = (1 << 4)\n };\n \n enum Operations {\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 7a07b477..d4471f02 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -77,8 +77,7 @@ public:\n \t}\n \n \tint init(const IPASettings &settings) override;\n-\tint start([[maybe_unused]] const IPAOperationData &ipaConfig,\n-\t\t  [[maybe_unused]] IPAOperationData *result) override { return 0; }\n+\tint start(const IPAOperationData &ipaConfig, IPAOperationData *result) override;\n \tvoid stop() override {}\n \n \tvoid configure(const CameraSensorInfo &sensorInfo,\n@@ -154,6 +153,35 @@ int IPARPi::init(const IPASettings &settings)\n \treturn 0;\n }\n \n+int IPARPi::start(const IPAOperationData &ipaConfig, IPAOperationData *result)\n+{\n+\tRPiController::Metadata metadata;\n+\n+\tresult->operation = 0;\n+\tif (ipaConfig.operation & RPi::IPA_CONFIG_STARTUP) {\n+\t\t/* We have been given some controls to action before start. */\n+\t\tqueueRequest(ipaConfig.controls[0]);\n+\t}\n+\n+\tcontroller_.SwitchMode(mode_, &metadata);\n+\n+\t/* SwitchMode may supply updated exposure/gain values to use. */\n+\tAgcStatus agcStatus;\n+\tagcStatus.shutter_time = 0.0;\n+\tagcStatus.analogue_gain = 0.0;\n+\n+\t/* SwitchMode may supply updated exposure/gain values to use. */\n+\tmetadata.Get(\"agc.status\", agcStatus);\n+\tif (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) {\n+\t\tControlList ctrls(unicamCtrls_);\n+\t\tapplyAGC(&agcStatus, ctrls);\n+\t\tresult->controls.push_back(ctrls);\n+\t\tresult->operation |= RPi::IPA_CONFIG_SENSOR;\n+\t}\n+\n+\treturn 0;\n+}\n+\n void IPARPi::setMode(const CameraSensorInfo &sensorInfo)\n {\n \tmode_.bitdepth = sensorInfo.bitsPerPixel;\n@@ -229,7 +257,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\tresult->data.push_back(gainDelay);\n \t\tresult->data.push_back(exposureDelay);\n \t\tresult->data.push_back(sensorMetadata);\n-\n \t\tresult->operation |= RPi::IPA_CONFIG_STAGGERED_WRITE;\n \t}\n \n@@ -285,11 +312,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tresult->data.push_back(dropFrame);\n \tresult->operation |= RPi::IPA_CONFIG_DROP_FRAMES;\n \n-\t/* These zero values mean not program anything (unless overwritten). */\n-\tstruct AgcStatus agcStatus;\n-\tagcStatus.shutter_time = 0.0;\n-\tagcStatus.analogue_gain = 0.0;\n-\n \tif (!controllerInit_) {\n \t\t/* Load the tuning file for this sensor. */\n \t\tcontroller_.Read(tuningFile_.c_str());\n@@ -297,20 +319,13 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\tcontrollerInit_ = true;\n \n \t\t/* Supply initial values for gain and exposure. */\n+\t\tControlList ctrls(unicamCtrls_);\n+\t\tAgcStatus agcStatus;\n \t\tagcStatus.shutter_time = DefaultExposureTime;\n \t\tagcStatus.analogue_gain = DefaultAnalogueGain;\n-\t}\n-\n-\tRPiController::Metadata metadata;\n-\tcontroller_.SwitchMode(mode_, &metadata);\n-\n-\t/* SwitchMode may supply updated exposure/gain values to use. */\n-\tmetadata.Get(\"agc.status\", agcStatus);\n-\tif (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) {\n-\t\tControlList ctrls(unicamCtrls_);\n \t\tapplyAGC(&agcStatus, ctrls);\n-\t\tresult->controls.push_back(ctrls);\n \n+\t\tresult->controls.push_back(ctrls);\n \t\tresult->operation |= RPi::IPA_CONFIG_SENSOR;\n \t}\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex a8e4997a..6efe2403 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -748,7 +748,10 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont\n \n \t/* Start the IPA. */\n \tIPAOperationData ipaConfig, result;\n-\tipaConfig.controls.emplace_back(*controls);\n+\tif (controls) {\n+\t\tipaConfig.operation = RPi::IPA_CONFIG_STARTUP;\n+\t\tipaConfig.controls.emplace_back(*controls);\n+\t}\n \tret = data->ipa_->start(ipaConfig, &result);\n \tif (ret) {\n \t\tLOG(RPI, Error)\n@@ -757,6 +760,14 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont\n \t\treturn ret;\n \t}\n \n+\t/* Apply any gain/exposure settings that the IPA may have passed back. */\n+\tASSERT(data->staggeredCtrl_);\n+\tif (result.operation & RPi::IPA_CONFIG_SENSOR) {\n+\t\tconst ControlList &ctrls = result.controls[0];\n+\t\tif (!data->staggeredCtrl_.set(ctrls))\n+\t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n+\t}\n+\n \t/*\n \t * IPA configure may have changed the sensor flips - hence the bayer\n \t * order. Get the sensor format and set the ISP input now.\n@@ -777,7 +788,6 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont\n \t * starting. First check that the staggered ctrl has been initialised\n \t * by configure().\n \t */\n-\tASSERT(data->staggeredCtrl_);\n \tdata->staggeredCtrl_.reset();\n \tdata->staggeredCtrl_.write();\n \tdata->expectedSequence_ = 0;\n",
    "prefixes": [
        "libcamera-devel",
        "3/3"
    ]
}