Show a patch.

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

{
    "id": 912,
    "url": "https://patchwork.libcamera.org/api/patches/912/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/912/",
    "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": "<20190403150735.27580-8-jacopo@jmondi.org>",
    "date": "2019-04-03T15:07:34",
    "name": "[libcamera-devel,v3,7/8] libcamera: pipeline: Add method to retrieve Request from Buffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "735f9443c34965099751b72970bd69ede4d87791",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/912/mbox/",
    "series": [
        {
            "id": 239,
            "url": "https://patchwork.libcamera.org/api/series/239/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=239",
            "date": "2019-04-03T15:07:27",
            "name": "libcamera: ipu3: Multiple streams support",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/239/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/912/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/912/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08E4E610C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Apr 2019 17:07:00 +0200 (CEST)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 903A5FF80B;\n\tWed,  3 Apr 2019 15:06:59 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  3 Apr 2019 17:07:34 +0200",
        "Message-Id": "<20190403150735.27580-8-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190403150735.27580-1-jacopo@jmondi.org>",
        "References": "<20190403150735.27580-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 7/8] libcamera: pipeline: Add method to\n\tretrieve Request from Buffer",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Wed, 03 Apr 2019 15:07:00 -0000"
    },
    "content": "Add a method to CameraData base class to retrieve a pointer to the\nRequest that contains a given buffer. Intended users are buffer\ncompletion slots that needs to associate a Request to a just completed\nBuffer.\n\nIn preparation to support multiple requests from different streams,\nupdate all the pipeline handler implementations to use this method\ninstead of using the last queued request.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/request.h              |  2 ++\n src/libcamera/include/pipeline_handler.h |  3 +++\n src/libcamera/pipeline/ipu3/ipu3.cpp     |  3 ++-\n src/libcamera/pipeline/uvcvideo.cpp      |  3 ++-\n src/libcamera/pipeline/vimc.cpp          |  3 ++-\n src/libcamera/pipeline_handler.cpp       | 29 ++++++++++++++++++++++++\n src/libcamera/request.cpp                |  7 ++++++\n 7 files changed, 47 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 5ac4d20d1d9f..8f5892fd3111 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -38,6 +38,8 @@ public:\n \n \tconst std::list<Stream *> streams() const;\n \n+\tconst std::unordered_set<Buffer *> &pending() const { return pending_; }\n+\n \tStatus status() const { return status_; }\n \n private:\ndiff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex 920b57609470..6cdadcbdc3ea 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -39,6 +39,9 @@ public:\n \tPipelineHandler *pipe_;\n \tstd::list<Request *> queuedRequests_;\n \n+protected:\n+\tRequest *requestFromBuffer(Buffer *buffer);\n+\n private:\n \tCameraData(const CameraData &) = delete;\n \tCameraData &operator=(const CameraData &) = delete;\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 8c67cf985d1e..17e3e8677e28 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -801,7 +801,8 @@ void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)\n  */\n void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)\n {\n-\tRequest *request = queuedRequests_.front();\n+\tRequest *request = requestFromBuffer(buffer);\n+\tASSERT(request);\n \n \tpipe_->completeBuffer(camera_, request, buffer);\n \tpipe_->completeRequest(camera_, request);\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 128f0c49dba3..d571b8b4ea83 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -226,7 +226,8 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \n void PipelineHandlerUVC::UVCCameraData::bufferReady(Buffer *buffer)\n {\n-\tRequest *request = queuedRequests_.front();\n+\tRequest *request = requestFromBuffer(buffer);\n+\tASSERT(request);\n \n \tpipe_->completeBuffer(camera_, request, buffer);\n \tpipe_->completeRequest(camera_, request);\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 6735940799d8..e83416effad8 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -223,7 +223,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \n void PipelineHandlerVimc::VimcCameraData::bufferReady(Buffer *buffer)\n {\n-\tRequest *request = queuedRequests_.front();\n+\tRequest *request = requestFromBuffer(buffer);\n+\tASSERT(request);\n \n \tpipe_->completeBuffer(camera_, request, buffer);\n \tpipe_->completeRequest(camera_, request);\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 9a8a4fde57e6..830ff354ed3e 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -86,6 +86,35 @@ LOG_DEFINE_CATEGORY(Pipeline)\n  * PipelineHandler::completeRequest()\n  */\n \n+/**\n+ * \\brief Retrieve the pending request that contains \\a buffer\n+ * \\param[in] buffer The buffer contained in the returned request\n+ *\n+ * Return the request that contains \\a buffer, or nullptr if no such request\n+ * is found. The intended callers of this method are buffer completion slots\n+ * implemented in CameraData sub-classes which needs to associated a request\n+ * to the just completed buffer. It is up to the caller of this function to\n+ * deal with the case the buffer does not belong to any previously queued\n+ * request or the request has already completed, possibly because of a\n+ * duplicated buffer completion notification. This is generally considered\n+ * a fatal error, and callers are expected to assert the validity of the\n+ * returned request.\n+ *\n+ * \\return A pointer to the pending Request that contains the Buffer \\a buffer,\n+ * or nullptr if no such request is found\n+ */\n+Request *CameraData::requestFromBuffer(Buffer *buffer)\n+{\n+\tfor (Request *req : queuedRequests_) {\n+\t\tfor (Buffer *b : req->pending()) {\n+\t\t\tif (b == buffer)\n+\t\t\t\treturn req;\n+\t\t}\n+\t}\n+\n+\treturn nullptr;\n+}\n+\n /**\n  * \\class PipelineHandler\n  * \\brief Create and manage cameras based on a set of media devices\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 3a7841fb2bb3..c555752b2c0b 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -108,6 +108,13 @@ const std::list<Stream *> Request::streams() const\n \treturn streams;\n }\n \n+/**\n+ * \\fn Request::pending()\n+ * \\brief Retrieve the list of not-yet-completed buffers\n+ *\n+ * \\return The set of pending buffers\n+ */\n+\n /**\n  * \\fn Request::status()\n  * \\brief Retrieve the request completion status\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "7/8"
    ]
}