Show a patch.

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

{
    "id": 11315,
    "url": "https://patchwork.libcamera.org/api/patches/11315/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11315/",
    "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": "<20210217080241.1492143-1-naush@raspberrypi.com>",
    "date": "2021-02-17T08:02:41",
    "name": "[libcamera-devel] pipeline: ipa: raspberrypi: Various fixups after IPAInterface changes",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "0b39c5aecbabf4d6bf1fd6c67e12e3f266f22283",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11315/mbox/",
    "series": [
        {
            "id": 1698,
            "url": "https://patchwork.libcamera.org/api/series/1698/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1698",
            "date": "2021-02-17T08:02:41",
            "name": "[libcamera-devel] pipeline: ipa: raspberrypi: Various fixups after IPAInterface changes",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1698/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11315/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11315/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 BDDD4BD1F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Feb 2021 08:02:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1DABF637F1;\n\tWed, 17 Feb 2021 09:02:49 +0100 (CET)",
            "from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F964602FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Feb 2021 09:02:47 +0100 (CET)",
            "by mail-wr1-x429.google.com with SMTP id n4so13346556wrx.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Feb 2021 00:02:47 -0800 (PST)",
            "from naush-laptop.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tq15sm2620045wrr.58.2021.02.17.00.02.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 17 Feb 2021 00:02:45 -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=\"ezxwAvqB\"; 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:mime-version\n\t:content-transfer-encoding;\n\tbh=VPn50grLwEyGeUbBP5c0hDHBCj9ikgPqmTyWMoqiTps=;\n\tb=ezxwAvqBV1+pZNJymZsQWsuHdrtVTxgBemv4BPqABej+0S6AHMymrdOEZwTiFc2K8O\n\tj22F+DCKqdZfkmIWFs/tCAABwqOg2i2HfpWkrZH8YFvO5kxwLGjV/XwqEvuujlZLkvgk\n\t8bDeTC4uJXa1t+JeqC7BPhnwk1TxXff9wc1nj8vWfUUhsbms0LJ3brYgS7ZR2hroqYK9\n\td7PUnEIzeYjzYjN8c28wbToedTdf7eVCoVk1KGA6Z05dIinZnxy4cof4Lv//qOcQnuCH\n\t5zifwPRl8dLBb75PUyk/Klw+TKGu9p2zpgYNrkj4C94oPXq5UT3qIa+BoLaWKAxYe7Dx\n\tLyTw==",
        "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:mime-version\n\t:content-transfer-encoding;\n\tbh=VPn50grLwEyGeUbBP5c0hDHBCj9ikgPqmTyWMoqiTps=;\n\tb=a59UhpNeYTZxeWzu+lMHS4O/RPEPeGxNUVesSzT6+odVtwh9W/KpPdBLjETk/hK5fT\n\tz+XAs+aBjFB2s/VlZ8Xd5+DmUf+iM3/lFRM6eqV8GKKp4hJ8zx1m3AUmk8LvK6Wzj5ay\n\tBUxKxZvQVikjzioGLwOoIhTT4Y1popu/WO3kaLAdip5auGtEKVOmHoKxALmKmCoJ9kk0\n\tQkMcRwBgB49qpDi7Suml0przBi+/B8vbNPLcH4FTHsX6ALimVPtwoMTyzO/BNvQxgq58\n\tYBtacEZuWxzzH7sCjaPc3HYsMlOrf4ydwaVIK1JOFQOh/eM5fnu4YQcsY/Unu5LhcunZ\n\thM6A==",
        "X-Gm-Message-State": "AOAM533BctqIeihsbkfuOpa3kXQV7ZR6QRRGIdrYUCDauL/34ol0tXKL\n\t0NRh6Z0xZbJlWM/Cj8qFfAxpB/gLcSW/obQc",
        "X-Google-Smtp-Source": "ABdhPJzeamkzBJSIev/xEI45dfmUXsMA0W4JqpvV3OcefoySOEwJ9LNB3V0OzMKFvTthMrtuWsop+g==",
        "X-Received": "by 2002:adf:97d3:: with SMTP id\n\tt19mr28985571wrb.164.1613548966236; \n\tWed, 17 Feb 2021 00:02:46 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 17 Feb 2021 08:02:41 +0000",
        "Message-Id": "<20210217080241.1492143-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH] pipeline: ipa: raspberrypi: Various\n\tfixups after IPAInterface changes",
        "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": "This commit addresses a few fixes and tidy-ups after the IPAInterface\nrework:\n- Rename ConfigStaggeredWrite -> ConfigSensorParams\n- Rename setIsp -> setIspControls\n- Signal handlers statsMetadataComplete(), runISP(), embeddedComplete()\nshould only run when state != Stopped. This matches the behavior of\nthe original code. Without this, start/stop cycles may cause errors.\n- In setIspControls(), only update the LS config (with the fd) when a LS\ncontrol is present.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nFixes: e201cb4f5450 (\"libcamera: IPAInterface: Replace C API with the new C++-only API\")\n---\n include/libcamera/ipa/raspberrypi.mojom       |  4 +-\n src/ipa/raspberrypi/raspberrypi.cpp           |  4 +-\n .../pipeline/raspberrypi/raspberrypi.cpp      | 91 ++++++++++---------\n 3 files changed, 50 insertions(+), 49 deletions(-)",
    "diff": "diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex bab19a946e18..8a256d022270 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -16,7 +16,7 @@ enum BufferMask {\n const uint32 MaxLsGridSize = 0x8000;\n \n enum ConfigOutputParameters {\n-\tConfigStaggeredWrite = 0x01,\n+\tConfigSensorParams = 0x01,\n };\n \n struct SensorConfig {\n@@ -126,6 +126,6 @@ interface IPARPiEventInterface {\n \tstatsMetadataComplete(uint32 bufferId, ControlList controls);\n \trunIsp(uint32 bufferId);\n \tembeddedComplete(uint32 bufferId);\n-\tsetIsp(ControlList controls);\n+\tsetIspControls(ControlList controls);\n \tsetDelayedControls(ControlList controls);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 81a3195c82e9..0bf88bcc5f72 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -344,7 +344,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\thelper_->GetDelays(exposureDelay, gainDelay);\n \t\tsensorMetadata = helper_->SensorEmbeddedDataPresent();\n \n-\t\tresult->params |= ipa::rpi::ConfigStaggeredWrite;\n+\t\tresult->params |= ipa::rpi::ConfigSensorParams;\n \t\tresult->sensorConfig.gainDelay = gainDelay;\n \t\tresult->sensorConfig.exposureDelay = exposureDelay;\n \t\tresult->sensorConfig.vblank = exposureDelay;\n@@ -968,7 +968,7 @@ void IPARPi::prepareISP(unsigned int bufferId)\n \t\t\tapplyDPC(dpcStatus, ctrls);\n \n \t\tif (!ctrls.empty())\n-\t\t\tsetIsp.emit(ctrls);\n+\t\t\tsetIspControls.emit(ctrls);\n \t}\n }\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 15aa600ed581..d0ca015a01dc 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -152,7 +152,7 @@ public:\n \tvoid statsMetadataComplete(uint32_t bufferId, const ControlList &controls);\n \tvoid runIsp(uint32_t bufferId);\n \tvoid embeddedComplete(uint32_t bufferId);\n-\tvoid setIsp(const ControlList &controls);\n+\tvoid setIspControls(const ControlList &controls);\n \tvoid setDelayedControls(const ControlList &controls);\n \n \t/* bufferComplete signal handlers. */\n@@ -1172,7 +1172,7 @@ int RPiCameraData::loadIPA()\n \tipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete);\n \tipa_->runIsp.connect(this, &RPiCameraData::runIsp);\n \tipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete);\n-\tipa_->setIsp.connect(this, &RPiCameraData::setIsp);\n+\tipa_->setIspControls.connect(this, &RPiCameraData::setIspControls);\n \tipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls);\n \n \tIPASettings settings(ipa_->configurationFile(sensor_->model() + \".json\"));\n@@ -1241,7 +1241,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \t\treturn -EPIPE;\n \t}\n \n-\tif (result.params & ipa::rpi::ConfigStaggeredWrite) {\n+\tif (result.params & ipa::rpi::ConfigSensorParams) {\n \t\t/*\n \t\t * Setup our delayed control writer with the sensor default\n \t\t * gain and exposure delays.\n@@ -1280,75 +1280,76 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \n void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls)\n {\n-\tif (state_ == State::Stopped)\n-\t\thandleState();\n+\tif (state_ != State::Stopped) {\n+\t\tFrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId);\n \n-\tFrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId);\n+\t\thandleStreamBuffer(buffer, &isp_[Isp::Stats]);\n \n-\thandleStreamBuffer(buffer, &isp_[Isp::Stats]);\n+\t\t/* Fill the Request metadata buffer with what the IPA has provided */\n+\t\tRequest *request = requestQueue_.front();\n+\t\trequest->metadata() = std::move(controls);\n \n-\t/* Fill the Request metadata buffer with what the IPA has provided */\n-\tRequest *request = requestQueue_.front();\n-\trequest->metadata() = std::move(controls);\n+\t\t/*\n+\t\t* Also update the ScalerCrop in the metadata with what we actually\n+\t\t* used. But we must first rescale that from ISP (camera mode) pixels\n+\t\t* back into sensor native pixels.\n+\t\t*\n+\t\t* Sending this information on every frame may be helpful.\n+\t\t*/\n+\t\tif (updateScalerCrop_) {\n+\t\t\tupdateScalerCrop_ = false;\n+\t\t\tscalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n+\t\t\t\t\t\t\tsensorInfo_.outputSize);\n+\t\t\tscalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n+\t\t}\n+\t\trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n \n-\t/*\n-\t * Also update the ScalerCrop in the metadata with what we actually\n-\t * used. But we must first rescale that from ISP (camera mode) pixels\n-\t * back into sensor native pixels.\n-\t *\n-\t * Sending this information on every frame may be helpful.\n-\t */\n-\tif (updateScalerCrop_) {\n-\t\tupdateScalerCrop_ = false;\n-\t\tscalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n-\t\t\t\t\t\tsensorInfo_.outputSize);\n-\t\tscalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n+\t\tstate_ = State::IpaComplete;\n \t}\n-\trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n-\n-\tstate_ = State::IpaComplete;\n \n \thandleState();\n }\n \n void RPiCameraData::runIsp(uint32_t bufferId)\n {\n-\tif (state_ == State::Stopped)\n-\t\thandleState();\n+\tif (state_ != State::Stopped) {\n+\t\tFrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId);\n \n-\tFrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId);\n+\t\tLOG(RPI, Debug) << \"Input re-queue to ISP, buffer id \" << bufferId\n+\t\t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n \n-\tLOG(RPI, Debug) << \"Input re-queue to ISP, buffer id \" << bufferId\n-\t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n+\t\tisp_[Isp::Input].queueBuffer(buffer);\n+\t\tispOutputCount_ = 0;\n+\t}\n \n-\tisp_[Isp::Input].queueBuffer(buffer);\n-\tispOutputCount_ = 0;\n \thandleState();\n }\n \n void RPiCameraData::embeddedComplete(uint32_t bufferId)\n {\n-\tif (state_ == State::Stopped)\n-\t\thandleState();\n+\tif (state_ != State::Stopped) {\n+\t\tFrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId);\n+\t\thandleStreamBuffer(buffer, &unicam_[Unicam::Embedded]);\n+\t}\n \n-\tFrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId);\n-\thandleStreamBuffer(buffer, &unicam_[Unicam::Embedded]);\n \thandleState();\n }\n \n-void RPiCameraData::setIsp(const ControlList &controls)\n+void RPiCameraData::setIspControls(const ControlList &controls)\n {\n \tControlList ctrls = controls;\n \n-\tSpan<const uint8_t> s =\n-\t\tctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data();\n-\tbcm2835_isp_lens_shading ls =\n-\t\t*reinterpret_cast<const bcm2835_isp_lens_shading *>(s.data());\n-\tls.dmabuf = lsTable_.fd();\n+\tif (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) {\n+\t\tSpan<const uint8_t> s =\n+\t\t\tctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data();\n+\t\tbcm2835_isp_lens_shading ls =\n+\t\t\t*reinterpret_cast<const bcm2835_isp_lens_shading *>(s.data());\n+\t\tls.dmabuf = lsTable_.fd();\n \n-\tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&ls),\n-\t\t\t\t\t    sizeof(ls) });\n-\tctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c);\n+\t\tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&ls),\n+\t\t\t\t\t\t    sizeof(ls) });\n+\t\tctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c);\n+\t}\n \n \tisp_[Isp::Input].dev()->setControls(&ctrls);\n \thandleState();\n",
    "prefixes": [
        "libcamera-devel"
    ]
}