Show a patch.

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

{
    "id": 10277,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10277/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10277/",
    "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": "<20201028010051.3830668-5-niklas.soderlund@ragnatech.se>",
    "date": "2020-10-28T01:00:46",
    "name": "[libcamera-devel,4/9] libcamera: raspberrypi: Switch to DelayedControls",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d0d5bb05b9f0d6ead4a4724d5c99bb17d86a45d3",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": {
        "id": 16,
        "url": "https://patchwork.libcamera.org/api/1.1/users/16/?format=api",
        "username": "neg",
        "first_name": "Niklas",
        "last_name": "Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10277/mbox/",
    "series": [
        {
            "id": 1423,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1423/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1423",
            "date": "2020-10-28T01:00:42",
            "name": "libcamera: Add helper for controls that take effect with a delay",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1423/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10277/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10277/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 00F37C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Oct 2020 01:01:17 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 73E5E62265;\n\tWed, 28 Oct 2020 02:01:16 +0100 (CET)",
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B7956220D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Oct 2020 02:01:14 +0100 (CET)",
            "from bismarck.berto.se (p4fca2458.dip0.t-ipconnect.de\n\t[79.202.36.88])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 12f73b83-18b9-11eb-954c-0050569116f7;\n\tWed, 28 Oct 2020 02:01:13 +0100 (CET)"
        ],
        "X-Halon-ID": "12f73b83-18b9-11eb-954c-0050569116f7",
        "Authorized-sender": "niklas.soderlund@fsdn.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org, david.plowman@raspberrypi.com,\n\tnaush@raspberrypi.com",
        "Date": "Wed, 28 Oct 2020 02:00:46 +0100",
        "Message-Id": "<20201028010051.3830668-5-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.29.1",
        "In-Reply-To": "<20201028010051.3830668-1-niklas.soderlund@ragnatech.se>",
        "References": "<20201028010051.3830668-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 4/9] libcamera: raspberrypi: Switch to\n\tDelayedControls",
        "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=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Use the libcamera core helper DelayedControls instead of the local\nStaggeredCtrl. The new helper is modeled after the StaggeredCtrl\nimplementation and behaves the same.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 44 +++++++++----------\n 1 file changed, 20 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex a48013d8c27b98eb..4087985f1e66c940 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -25,6 +25,7 @@\n \n #include \"libcamera/internal/bayer_format.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n+#include \"libcamera/internal/delayed_controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/ipa_manager.h\"\n #include \"libcamera/internal/media_device.h\"\n@@ -35,7 +36,6 @@\n \n #include \"dma_heaps.h\"\n #include \"rpi_stream.h\"\n-#include \"staggered_ctrl.h\"\n \n namespace libcamera {\n \n@@ -169,8 +169,7 @@ public:\n \tRPi::DmaHeap dmaHeap_;\n \tFileDescriptor lsTable_;\n \n-\tRPi::StaggeredCtrl staggeredCtrl_;\n-\tuint32_t expectedSequence_;\n+\tstd::unique_ptr<DelayedControls> delayedCtrls_;\n \tbool sensorMetadata_;\n \n \t/*\n@@ -773,10 +772,7 @@ int PipelineHandlerRPi::start(Camera *camera)\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+\tdata->delayedCtrls_->reset();\n \n \tdata->state_ = RPiCameraData::State::Idle;\n \n@@ -1107,7 +1103,7 @@ void RPiCameraData::frameStarted(uint32_t sequence)\n \tLOG(RPI, Debug) << \"frame start \" << sequence;\n \n \t/* Write any controls for the next frame as soon as we can. */\n-\tstaggeredCtrl_.write();\n+\tdelayedCtrls_->frameStart(sequence);\n }\n \n int RPiCameraData::loadIPA()\n@@ -1185,18 +1181,22 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \t\t * Setup our staggered control writer with the sensor default\n \t\t * gain and exposure delays.\n \t\t */\n-\t\tif (!staggeredCtrl_) {\n-\t\t\tstaggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n-\t\t\t\t\t    { { V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n-\t\t\t\t\t      { V4L2_CID_EXPOSURE, result.data[resultIdx++] } });\n+\n+\t\tif (!delayedCtrls_) {\n+\t\t\tstd::unordered_map<uint32_t, unsigned int> delays = {\n+\t\t\t\t{ V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n+\t\t\t\t{ V4L2_CID_EXPOSURE, result.data[resultIdx++] }\n+\t\t\t};\n+\n+\t\t\tdelayedCtrls_ = std::make_unique<DelayedControls>(unicam_[Unicam::Image].dev(), delays);\n+\n \t\t\tsensorMetadata_ = result.data[resultIdx++];\n \t\t}\n \t}\n \n \tif (result.operation & RPi::IPA_CONFIG_SENSOR) {\n-\t\tconst ControlList &ctrls = result.controls[0];\n-\t\tif (!staggeredCtrl_.set(ctrls))\n-\t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n+\t\tControlList ctrls = result.controls[0];\n+\t\tdelayedCtrls_->reset(&ctrls);\n \t}\n \n \tif (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {\n@@ -1230,8 +1230,8 @@ void RPiCameraData::queueFrameAction([[maybe_unused]] unsigned int frame,\n \tswitch (action.operation) {\n \tcase RPi::IPA_ACTION_V4L2_SET_STAGGERED: {\n \t\tconst ControlList &controls = action.controls[0];\n-\t\tif (!staggeredCtrl_.set(controls))\n-\t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n+\t\tif (!delayedCtrls_->push(controls))\n+\t\t\tLOG(RPI, Error) << \"V4L2 delay set failed\";\n \t\tgoto done;\n \t}\n \n@@ -1335,11 +1335,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \t} else {\n \t\tembeddedQueue_.push(buffer);\n \n-\t\tstd::unordered_map<uint32_t, int32_t> ctrl;\n-\t\tint offset = buffer->metadata().sequence - expectedSequence_;\n-\t\tstaggeredCtrl_.get(ctrl, offset);\n-\n-\t\texpectedSequence_ = buffer->metadata().sequence + 1;\n+\t\tControlList ctrl = delayedCtrls_->get(buffer->metadata().sequence);\n \n \t\t/*\n \t\t * Sensor metadata is unavailable, so put the expected ctrl\n@@ -1352,8 +1348,8 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \t\t\t\t\t\t\t\t       PROT_READ | PROT_WRITE,\n \t\t\t\t\t\t\t\t       MAP_SHARED,\n \t\t\t\t\t\t\t\t       fb.planes()[0].fd.fd(), 0));\n-\t\t\tmem[0] = ctrl[V4L2_CID_EXPOSURE];\n-\t\t\tmem[1] = ctrl[V4L2_CID_ANALOGUE_GAIN];\n+\t\t\tmem[0] = ctrl.get(V4L2_CID_EXPOSURE).get<int32_t>();\n+\t\t\tmem[1] = ctrl.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();\n \t\t\tmunmap(mem, fb.planes()[0].length);\n \t\t}\n \t}\n",
    "prefixes": [
        "libcamera-devel",
        "4/9"
    ]
}