Patch Detail
Show a patch.
GET /api/1.1/patches/17087/?format=api
{ "id": 17087, "url": "https://patchwork.libcamera.org/api/1.1/patches/17087/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17087/", "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": "<20220812090838.1784703-2-hanlinchen@chromium.org>", "date": "2022-08-12T09:08:32", "name": "[libcamera-devel,v2,1/7] libcamera: Camera: Add RequestCompletionMode to configure the completion order", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c2efff9dd506e609a1ae3ff57d87cc745fa19e21", "submitter": { "id": 98, "url": "https://patchwork.libcamera.org/api/1.1/people/98/?format=api", "name": "Hanlin Chen", "email": "hanlinchen@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17087/mbox/", "series": [ { "id": 3408, "url": "https://patchwork.libcamera.org/api/1.1/series/3408/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3408", "date": "2022-08-12T09:08:31", "name": "Implement Android Partial Result Featrue", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3408/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17087/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17087/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 A8700C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Aug 2022 09:08:51 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C3E463328;\n\tFri, 12 Aug 2022 11:08:51 +0200 (CEST)", "from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com\n\t[IPv6:2607:f8b0:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC04463326\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Aug 2022 11:08:49 +0200 (CEST)", "by mail-pf1-x42d.google.com with SMTP id f28so443676pfk.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Aug 2022 02:08:49 -0700 (PDT)", "from localhost ([2401:fa00:1:17:1705:d284:d114:2e24])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tb72-20020a621b4b000000b0052d3d08cd96sm1100372pfb.67.2022.08.12.02.08.47\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tFri, 12 Aug 2022 02:08:47 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660295331;\n\tbh=dgT2f5xmNTCegEs3xgGu28WwhPYhRhb8x2LyxCNaXZg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=wOGs1j1pisSi9G6ildhOGegPCoAnp+dGUJ5qv9d3IUZPVJkyqDf2S4/noPa/FtvDT\n\tgHYUh19Sj9rjfn6DaYxxRCEsGWKigshwsYlwmE7XEYNVjRplRuesioIshhX+g6V8O5\n\tSbC2El0DxinESckz42roqNCx5o7xclkKLlMZntfBpurvWx+f+4SwOtx62kFbEBhwag\n\t1gzLZc2qnkkkDjopNYqIF9qkcfEcz8ooGyayShLc0HKW469DFQ7Mu7W4AS0+Oi0W5I\n\tbRwcnQrDIICyVxjufRsWwZ0p+mAwV6jHGiG4yEPU54Nlf8OhJMb6FS22pg6vfzlPOV\n\tXm/W3qzKromAw==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc;\n\tbh=S1Ep1tF4EF/a5ouUHjKr/XM2U9J6mN0Ei5b1dI1AzoM=;\n\tb=a+uPj3AiIxIOgcUGGQ1+HDsGMkcVKOjTJDTw22K7a568gsu+BMutTIm/yRw2rd1wW+\n\tnSiVOLp6myXg8PZLROEwnv/jBUy0/N3av4VVFBqpGPnqJSdjWdL88K6BmLPAuvYSWSSH\n\tE1i6Q9hkMt3sE1qTY+oTKviAKa3QBfm+iS1BI=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"a+uPj3Ai\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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\tbh=S1Ep1tF4EF/a5ouUHjKr/XM2U9J6mN0Ei5b1dI1AzoM=;\n\tb=hUjkyYEC+463khwKJAp+NQXoHbDQ7kF8sZ8q1v+RvQCEc7F0CyA1gy/qZkDcAiMVqW\n\tC0hyJyqejto9r1htky+GqTlMVKX0iYp6NsR1t3kuaos1PhTudzjn8sK2S6Vysipjmh7x\n\tzVdcXIj15+dVU4PZYHSmdaZpQEuk4LpcH/Pk47XlgxChlNRwvG16/UgAz9iM4MdZSsrH\n\tVaQ8JDiKKPfaWIkT5V3tILXbsZ4BYMe2dzH6H76rXARm2cy2i0WzSNuyDoXKRy9Dyjh8\n\tatyogAXsZi6jU+2shqAwn5dmQ977EyLC8T2aJsfHiSxZOnIkVJQcxrE7FNx8fgrRTsvm\n\tzp0w==", "X-Gm-Message-State": "ACgBeo3pL4NL3DTEIm4Yg0vGzyfVAAl69uhu97DFHS5ynEU3SxUgdLD3\n\t9pgvlngqZCHTodXazDbvpzT25xdncT7R8g==", "X-Google-Smtp-Source": "AA6agR6vSqlU4fLgd+Uw7toluSwzV3Uvw5zlxg6I+qUKthflswoyYxtEXUPYYUBBr8F7+z+fRPecSw==", "X-Received": "by 2002:a05:6a00:d74:b0:52f:575c:2d69 with SMTP id\n\tn52-20020a056a000d7400b0052f575c2d69mr2977935pfv.77.1660295328103; \n\tFri, 12 Aug 2022 02:08:48 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 12 Aug 2022 17:08:32 +0800", "Message-Id": "<20220812090838.1784703-2-hanlinchen@chromium.org>", "X-Mailer": "git-send-email 2.37.1.595.g718a3a8f04-goog", "In-Reply-To": "<20220812090838.1784703-1-hanlinchen@chromium.org>", "References": "<20220812090838.1784703-1-hanlinchen@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/7] libcamera: Camera: Add\n\tRequestCompletionMode to configure the completion order", "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>", "From": "Han-Lin Chen via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Han-Lin Chen <hanlinchen@chromium.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add enum RequestCompletionMode to Camera with two value: InSubmissionOrder and\nImmediately. The purpose is to allow the application configure the order of\nsignaling requestCompleted. The InSubmissionOrder mode is the default mode which\nsignals according to the request submission order. The Immediately mode allows\nthe pipeline handler to signal as soon as a request is completed. Applications\nneed to reconstruct the order by self.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n include/libcamera/camera.h | 8 ++++\n include/libcamera/internal/camera.h | 4 ++\n src/libcamera/camera.cpp | 68 ++++++++++++++++++++++++++++-\n src/libcamera/pipeline_handler.cpp | 20 ++++++---\n 4 files changed, 92 insertions(+), 8 deletions(-)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 5bb06584..5aa4bf69 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -88,6 +88,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@@ -101,6 +106,9 @@ public:\n \tint acquire();\n \tint release();\n \n+\tint setRequestCompletionMode(RequestCompletionMode order);\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 597426a6..68e8d952 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -33,6 +33,9 @@ public:\n \n \tPipelineHandler *pipe() { return pipe_.get(); }\n \n+\tvoid setRequestCompletionMode(RequestCompletionMode mode);\n+\tRequestCompletionMode requestCompletionMode() const;\n+\n \tstd::list<Request *> queuedRequests_;\n \tControlInfoMap controlInfo_;\n \tControlList properties_;\n@@ -67,6 +70,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 2a8ef60e..4d3523e2 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -435,7 +435,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@@ -573,6 +574,28 @@ void Camera::Private::setState(State state)\n \tstate_.store(state, std::memory_order_release);\n }\n \n+/**\n+ * \\brief Set the request completion mode\n+ * \\param[in] mode The RequestCompletionMode\n+ *\n+ * This function set the request completion mode.\n+ * InSubmissionOrder is the default mode.\n+ */\n+void Camera::Private::setRequestCompletionMode(RequestCompletionMode mode)\n+{\n+\trequestCompletionMode_ = mode;\n+}\n+\n+/**\n+ * \\brief Get the request completion mode\n+ *\n+ * \\return The current RequestCompletionMode.\n+ */\n+Camera::RequestCompletionMode Camera::Private::requestCompletionMode() const\n+{\n+\treturn requestCompletionMode_;\n+}\n+\n /**\n * \\class Camera\n * \\brief Camera device\n@@ -702,6 +725,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 Camera::RequestCompletionMode::InSubmissionOrder\n+ * \\brief requestCompleted will be emited according to the request submission order\n+ * \\var Camera::RequestCompletionMode::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@@ -1237,6 +1269,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 set 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->setRequestCompletionMode(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 67540533..7c180a8e 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -494,14 +494,20 @@ void PipelineHandler::completeRequest(Request *request)\n \n \tCamera::Private *data = camera->_d();\n \n-\twhile (!data->queuedRequests_.empty()) {\n-\t\tRequest *req = data->queuedRequests_.front();\n-\t\tif (req->status() == Request::RequestPending)\n-\t\t\tbreak;\n+\tauto iter = data->queuedRequests_.begin();\n+\twhile (iter != data->queuedRequests_.end()) {\n+\t\tif ((*iter)->status() != Request::RequestPending) {\n+\t\t\tASSERT(!(*iter)->hasPendingBuffers());\n+\t\t\tcamera->requestComplete((*iter));\n+\t\t\titer = data->queuedRequests_.erase(iter);\n+\t\t\tcontinue;\n+\t\t}\n \n-\t\tASSERT(!req->hasPendingBuffers());\n-\t\tdata->queuedRequests_.pop_front();\n-\t\tcamera->requestComplete(req);\n+\t\t/* Break at the pending result to reflect the submission order */\n+\t\tif (camera->requestCompletionMode() == Camera::InSubmissionOrder) {\n+\t\t\tbreak;\n+\t\t}\n+\t\titer++;\n \t}\n }\n \n", "prefixes": [ "libcamera-devel", "v2", "1/7" ] }