Show a patch.

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

{
    "id": 21007,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/21007/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21007/",
    "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": "<20240823163251.2979324-2-chenghaoyang@google.com>",
    "date": "2024-08-23T16:22:45",
    "name": "[v1,1/1] libcamera: Camera: Add RequestCompletionMode to configure the completion order",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "55e252ed2a71edd6a88b18e8c03eab4af104a9c6",
    "submitter": {
        "id": 117,
        "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21007/mbox/",
    "series": [
        {
            "id": 4537,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4537/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4537",
            "date": "2024-08-23T16:22:44",
            "name": "Add RequestCompleteMode in Camera",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4537/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21007/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21007/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 48466BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Aug 2024 16:33:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0844D633CB;\n\tFri, 23 Aug 2024 18:33:05 +0200 (CEST)",
            "from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com\n\t[IPv6:2a00:1450:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3749F63393\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Aug 2024 18:33:02 +0200 (CEST)",
            "by mail-wr1-x42c.google.com with SMTP id\n\tffacd0b85a97d-37196229343so1336807f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Aug 2024 09:33:02 -0700 (PDT)",
            "from chenghaoyang-germany.c.googlers.com.com\n\t(161.126.77.34.bc.googleusercontent.com. [34.77.126.161])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-3730826196bsm4482151f8f.102.2024.08.23.09.33.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 23 Aug 2024 09:33:00 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"LOKxGCJ3\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1724430781; x=1725035581;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=5GrXuGgAZeoER1lybbUNwH3VosMCgpgbhpPWheMcniI=;\n\tb=LOKxGCJ32QQlxPtw2C2srCAlEud3gJY4nW9AIQX6B06WChLQqW/fpzJbINH4iIXqXV\n\tEnXtn57MJWX3lXDbnOBqGzT5rzXaq/eK4ic//UUPWfOAwB1Cwn2ZwMQWc8LTTAi5n1vp\n\tQk59Syxg+h6Hb32vTGaVD6IVpKE/jHpEIIn4c=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1724430781; x=1725035581;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=5GrXuGgAZeoER1lybbUNwH3VosMCgpgbhpPWheMcniI=;\n\tb=vhuaiFQK3ABAzqfGB150PvBikSaqwvyuftsCo+z8/fZQzE/sCSnGtnPCZY+Ya99GXn\n\tRfCAOCT29ahBTdWpRz5doN2MuCwTn0Xs2MRoAqP0TVG7dCWw4wsyirfBzO07vSvYYcFR\n\tvDirfUA5jwF+vCXqYrCOM0jpQ5YB+TDk+12QtsF1mrIpwv7UdAScBTkft0VCrnws4imx\n\ttO+SdgFYlStunxaN27b/NQ3pujX1we9si3v8a0UN1WN4Zul2IQPjCYm46bSW+Ikvf6wt\n\taA6rjw+q/3b2y1YXS5Awutx0TG1inIHotd4jtzviTCegsqWKc6I2tZoei4Hhcsx5wLvE\n\tnbVQ==",
        "X-Gm-Message-State": "AOJu0YzFJ6FVme6cWtzRNilrYxAQyFZkoz4kENHCZVx6ykIF3D031Qix\n\txkT4svgSs+dE+gZesbfzFhm84VZA5K9+DytEsxNyZGHEMGHMhIGn5plDxd2dHYf21LDIB4+VF7j\n\teow==",
        "X-Google-Smtp-Source": "AGHT+IG8J40frUkLqGCvSw/Yo8haQyjFMvheA3KBsUsWNraBjGUbaP/5Zvap5a/PTVyuQAcUSurElg==",
        "X-Received": "by 2002:adf:f3c8:0:b0:371:7e19:b9c8 with SMTP id\n\tffacd0b85a97d-373118eec09mr1949298f8f.58.1724430781141; \n\tFri, 23 Aug 2024 09:33:01 -0700 (PDT)",
        "From": "Harvey Yang <chenghaoyang@chromium.org>",
        "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Han-Lin Chen <hanlinchen@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>",
        "Subject": "[PATCH v1 1/1] libcamera: Camera: Add RequestCompletionMode to\n\tconfigure the completion order",
        "Date": "Fri, 23 Aug 2024 16:22:45 +0000",
        "Message-ID": "<20240823163251.2979324-2-chenghaoyang@google.com>",
        "X-Mailer": "git-send-email 2.46.0.295.g3b9ea8a38a-goog",
        "In-Reply-To": "<20240823163251.2979324-1-chenghaoyang@google.com>",
        "References": "<20240823163251.2979324-1-chenghaoyang@google.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "From: Han-Lin Chen <hanlinchen@chromium.org>\n\nAdd enum RequestCompletionMode to Camera with two values:\nInSubmissionOrder andImmediately. The purpose is to allow the\napplication to configure the order of signaling requestCompleted.\nThe InSubmissionOrder mode is the default mode, which signals according\nto the request submission order.\nThe Immediately mode allows the pipeline handler to signal as soon as a\nrequest is completed. Applications need to reconstruct the order by\nthemselves.\n\nIn the real use cases, it allows a camera app to continue the preview\nstream flowing, while certain ISPs/algorithms are still processing a\ncomplex flow like a still capture request, instead of being blocked\nby the still capture request.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n Documentation/guides/pipeline-handler.rst |  3 +-\n include/libcamera/camera.h                |  8 ++++\n include/libcamera/internal/camera.h       |  1 +\n src/libcamera/camera.cpp                  | 50 +++++++++++++++++++++--\n src/libcamera/pipeline_handler.cpp        |  7 ++++\n 5 files changed, 65 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst\nindex 26aea4334..f8e64e2f0 100644\n--- a/Documentation/guides/pipeline-handler.rst\n+++ b/Documentation/guides/pipeline-handler.rst\n@@ -1453,7 +1453,8 @@ completion of that buffer to the Camera by using the PipelineHandler base class\n have been completed, the pipeline handler must again notify the ``Camera`` using\n the PipelineHandler base class ``completeRequest`` function. The PipelineHandler\n class implementation makes sure the request completion notifications are\n-delivered to applications in the same order as they have been submitted.\n+delivered to applications in the same order as they have been submitted, unless\n+the Camera's ``RequestCompletionMode`` is set to ``Immediately``.\n \n .. _connecting: https://libcamera.org/api-html/classlibcamera_1_1Signal.html#aa04db72d5b3091ffbb4920565aeed382\n \ndiff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 94cee7bd8..5226d94ef 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -116,6 +116,11 @@ class Camera final : public Object, public std::enable_shared_from_this<Camera>,\n \tLIBCAMERA_DECLARE_PRIVATE()\n \n public:\n+\tenum RequestCompletionMode {\n+\t\tInSubmissionOrder,\n+\t\tImmediately,\n+\t};\n+\n \tstatic std::shared_ptr<Camera> create(std::unique_ptr<Private> d,\n \t\t\t\t\t      const std::string &id,\n \t\t\t\t\t      const std::set<Stream *> &streams);\n@@ -129,6 +134,9 @@ public:\n \tint acquire();\n \tint release();\n \n+\tint setRequestCompletionMode(RequestCompletionMode mode);\n+\tRequestCompletionMode requestCompletionMode() const;\n+\n \tconst ControlInfoMap &controls() const;\n \tconst ControlList &properties() const;\n \ndiff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex 0add0428b..cb3bbf4f6 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -68,6 +68,7 @@ private:\n \n \tbool disconnected_;\n \tstd::atomic<State> state_;\n+\tRequestCompletionMode requestCompletionMode_;\n \n \tstd::unique_ptr<CameraControlValidator> validator_;\n };\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 382a68f7b..02decc87e 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -5,7 +5,7 @@\n  * Camera device\n  */\n \n-#include <libcamera/camera.h>\n+#include \"libcamera/internal/camera.h\"\n \n #include <array>\n #include <atomic>\n@@ -14,12 +14,12 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/thread.h>\n \n+#include <libcamera/camera.h>\n #include <libcamera/color_space.h>\n #include <libcamera/framebuffer_allocator.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n-#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_controls.h\"\n #include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n@@ -584,7 +584,8 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF\n  */\n Camera::Private::Private(PipelineHandler *pipe)\n \t: requestSequence_(0), pipe_(pipe->shared_from_this()),\n-\t  disconnected_(false), state_(CameraAvailable)\n+\t  disconnected_(false), state_(CameraAvailable),\n+\t  requestCompletionMode_(Camera::InSubmissionOrder)\n {\n }\n \n@@ -858,6 +859,15 @@ std::shared_ptr<Camera> Camera::create(std::unique_ptr<Private> d,\n \treturn std::shared_ptr<Camera>(camera, Deleter());\n }\n \n+/**\n+ * \\enum Camera::RequestCompletionMode\n+ * \\brief The mode of request completion behavior\n+ * \\var libcamera::Camera::InSubmissionOrder\n+ * \\brief requestCompleted will be emited according to the request submission order\n+ * \\var libcamera::Camera::Immediately\n+ * \\brief requestCompleted will be emited immediately when a request is completed\n+ */\n+\n /**\n  * \\brief Retrieve the ID of the camera\n  *\n@@ -1405,6 +1415,40 @@ int Camera::stop()\n \treturn 0;\n }\n \n+/**\n+ * \\brief Set the request completion mode\n+ * \\param[in] mode The RequestCompletionMode\n+ *\n+ * This function sets the request completion mode.\n+ * InSubmissionOrder is the default mode.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EACCES The camera is running so can't change the behavior\n+ */\n+int Camera::setRequestCompletionMode(RequestCompletionMode mode)\n+{\n+\tPrivate *const d = _d();\n+\n+\tint ret = d->isAccessAllowed(Private::CameraAvailable,\n+\t\t\t\t     Private::CameraConfigured);\n+\tif (ret < 0)\n+\t\treturn -EACCES;\n+\n+\td->requestCompletionMode_ = mode;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Get the request completion mode\n+ *\n+ * \\return The current RequestCompletionMode\n+ */\n+Camera::RequestCompletionMode Camera::requestCompletionMode() const\n+{\n+\treturn _d()->requestCompletionMode_;\n+}\n+\n /**\n  * \\brief Handle request completion and notify application\n  * \\param[in] request The request that has completed\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 5a6de685b..767e224e9 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -525,6 +525,13 @@ void PipelineHandler::completeRequest(Request *request)\n \n \tCamera::Private *data = camera->_d();\n \n+\tif (camera->requestCompletionMode() == Camera::Immediately) {\n+\t\tcamera->requestComplete(request);\n+\t\tdata->queuedRequests_.remove(request);\n+\t\treturn;\n+\t}\n+\n+\t/* camera->requestCompletionMode() == Camera::InSubmissionOrder */\n \twhile (!data->queuedRequests_.empty()) {\n \t\tRequest *req = data->queuedRequests_.front();\n \t\tif (req->status() == Request::RequestPending)\n",
    "prefixes": [
        "v1",
        "1/1"
    ]
}