Show a patch.

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

{
    "id": 507,
    "url": "https://patchwork.libcamera.org/api/patches/507/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/507/",
    "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": "<20190205000702.15370-5-niklas.soderlund@ragnatech.se>",
    "date": "2019-02-05T00:06:59",
    "name": "[libcamera-devel,RFC,4/7] libcamera: camera: add request support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "07a6d0e666622a34515550b5db68177b1dbefc8f",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": {
        "id": 16,
        "url": "https://patchwork.libcamera.org/api/users/16/?format=api",
        "username": "neg",
        "first_name": "Niklas",
        "last_name": "Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "mbox": "https://patchwork.libcamera.org/patch/507/mbox/",
    "series": [
        {
            "id": 168,
            "url": "https://patchwork.libcamera.org/api/series/168/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=168",
            "date": "2019-02-05T00:06:55",
            "name": "libcamera: extend camera and pipeline to support requests",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/168/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/507/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/507/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 018CA60DC2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Feb 2019 01:07:57 +0100 (CET)",
            "from localhost.localdomain (unknown [81.164.19.127])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 15faf8e0-28da-11e9-b530-005056917a89;\n\tTue, 05 Feb 2019 01:07:55 +0100 (CET)"
        ],
        "X-Halon-ID": "15faf8e0-28da-11e9-b530-005056917a89",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  5 Feb 2019 01:06:59 +0100",
        "Message-Id": "<20190205000702.15370-5-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190205000702.15370-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190205000702.15370-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC 4/7] libcamera: camera: add request support",
        "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": "Tue, 05 Feb 2019 00:07:58 -0000"
    },
    "content": "Add support to the camera to create and queue requests. The application\nneeds methods to get hold of buffers and creating requests. Once a\nrequest is created it can be queued to the camera and the application\nwill asynchronously be notified once the request is completed and be\nable to process all the buffers involved in the request.\n\nAt this point the request objects contains no controls be configured,\nthis needs to be extended in the future once the library supports v4l2\ncontrols and requests.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h |   7 +++\n src/libcamera/camera.cpp   | 102 ++++++++++++++++++++++++++++++++++++-\n 2 files changed, 108 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex de338c616641c074..f6991a50900e6956 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -16,7 +16,9 @@\n namespace libcamera {\n \n class Buffer;\n+class BufferPool;\n class PipelineHandler;\n+class Request;\n class Stream;\n class StreamConfiguration;\n \n@@ -42,6 +44,10 @@ public:\n \tstreamConfiguration(std::vector<Stream *> &streams);\n \tint configureStreams(std::map<Stream *, StreamConfiguration> &config);\n \n+\tBufferPool *bufferPool(Stream *);\n+\tRequest *createRequest(std::map<Stream *, Buffer *> &resources);\n+\tint queueRequest(Request *request);\n+\n \tint start();\n \tint stop();\n \n@@ -55,6 +61,7 @@ private:\n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::string name_;\n \tstd::vector<Stream *> streams_;\n+\tstd::map<Stream *, BufferPool *> bufferPools_;\n \n \tbool acquired_;\n \tbool disconnected_;\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex bf09acfdb9cd0007..de78536993601ee3 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -246,7 +246,107 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)\n \tif (!config.size())\n \t\treturn -EINVAL;\n \n-\treturn pipe_->configureStreams(this, config);\n+\tint ret = pipe_->configureStreams(this, config);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tbufferPools_ = pipe_->allocateBuffers(this, config);\n+\tif (!bufferPools_.size())\n+\t\treturn -EINVAL;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Retrieve the buffer pool for a stream\n+ * \\param[in] stream Stream to retrieve buffer pool from\n+ *\n+ * Retrieve the buffer pool for a specific stream, if one exists. To be able to\n+ * queue request to the camera the application needs to create requests and\n+ * attache buffers to the request. To get hold of buffers to associate with the\n+ * request the streams buffer pool needs to be retrieved. This interface allows\n+ * the application to get hold of the streams buffer pool.\n+ *\n+ * The buffer pools are created when the application configures the camera,\n+ * prior to configuration of the camera no buffer pools exists this calling\n+ * this function at that time will return a nullptr.\n+ *\n+ * \\return pointer to the buffer pool, nullptr on error\n+ */\n+BufferPool *Camera::bufferPool(Stream *stream)\n+{\n+\tif (disconnected_)\n+\t\treturn nullptr;\n+\n+\tif (!acquired_)\n+\t\treturn nullptr;\n+\n+\tif (bufferPools_.find(stream) == bufferPools_.end())\n+\t\treturn nullptr;\n+\n+\treturn bufferPools_[stream];\n+}\n+\n+/**\n+ * \\brief Create a request object for the camera\n+ * \\param[in] resources Array of streams and buffer to create a request from\n+ *\n+ * Before an application can queue a request to the camera it needs to be\n+ * created, this interface allows the application to create such requests. The\n+ * application needs to supply a map of streams and buffers that the request\n+ * should process once it's queued to the camera.\n+ *\n+ * Once a request object have been created the application can set controls\n+ * that are to be used to capture the particular frame before queuing it to\n+ * the camera.\n+ *\n+ * \\return pointer to the buffer pool, nullptr on error\n+ */\n+Request *Camera::createRequest(std::map<Stream *, Buffer *> &resources)\n+{\n+\tif (disconnected_)\n+\t\treturn nullptr;\n+\n+\tif (!acquired_)\n+\t\treturn nullptr;\n+\n+\tif (resources.size() == 0)\n+\t\treturn nullptr;\n+\n+\treturn new Request(resources);\n+}\n+\n+/**\n+ * \\brief Queue a request to the camera\n+ * \\param[in] request The request to queue to the camera\n+ *\n+ * The application can once its got hold of a request queue it to a running\n+ * camera at any point. The application get hold of a request by either creating\n+ * it or reusing a old request once it's been completed and the application have\n+ * no further use of the buffers it contained.\n+ *\n+ * Once a request have been queued to the camera it will be notified once the\n+ * request is complete and the associated buffers can be consumed.\n+ *\n+ * \\return 0 on success or a negative error code on error.\n+ * \\retval -ENODEV The camera is not connected to any hardware\n+ * \\retval -EACCES The user has not acquired exclusive access to the camera\n+ */\n+int Camera::queueRequest(Request *request)\n+{\n+\tif (disconnected_)\n+\t\treturn -ENODEV;\n+\n+\tif (!acquired_)\n+\t\treturn -EACCES;\n+\n+\tint ret = request->prepare();\n+\tif (ret) {\n+\t\tLOG(Camera, Error) << \"Failed to connect request resources\";\n+\t\treturn ret;\n+\t}\n+\n+\treturn pipe_->queueRequest(this, request);\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "4/7"
    ]
}