Show a patch.

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

{
    "id": 2583,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2583/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2583/",
    "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": "<20200112010212.2609025-2-niklas.soderlund@ragnatech.se>",
    "date": "2020-01-12T01:01:41",
    "name": "[libcamera-devel,v4,01/32] libcamera: request: remove prepare()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "55655d29a227597df933a6647483784e515ef527",
    "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": null,
    "mbox": "https://patchwork.libcamera.org/patch/2583/mbox/",
    "series": [
        {
            "id": 617,
            "url": "https://patchwork.libcamera.org/api/1.1/series/617/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=617",
            "date": "2020-01-12T01:01:40",
            "name": "libcamera: Rework buffer API",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/617/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2583/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2583/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 001726067C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Jan 2020 02:02:58 +0100 (CET)",
            "from bismarck.berto.se (p54ac5d7b.dip0.t-ipconnect.de\n\t[84.172.93.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 43fcbf79-34d7-11ea-b6d8-005056917f90;\n\tSun, 12 Jan 2020 02:02:55 +0100 (CET)"
        ],
        "X-Halon-ID": "43fcbf79-34d7-11ea-b6d8-005056917f90",
        "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": "Sun, 12 Jan 2020 02:01:41 +0100",
        "Message-Id": "<20200112010212.2609025-2-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200112010212.2609025-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 01/32] libcamera: request: remove\n\tprepare()",
        "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>",
        "X-List-Received-Date": "Sun, 12 Jan 2020 01:02:59 -0000"
    },
    "content": "The association of buffers to a request can be done directly in\naddBuffer() instead of when the request is queued to the camera. Keep\nthe check that a request contains buffers by moving it to\nCamera::queueRequest() where prepare() was previously called.\n\nAs a bonus we can remove a friend statement in Request.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/request.h |  2 --\n src/libcamera/buffer.cpp    |  4 ++--\n src/libcamera/camera.cpp    | 11 +++++------\n src/libcamera/request.cpp   | 26 ++------------------------\n 4 files changed, 9 insertions(+), 34 deletions(-)",
    "diff": "diff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 2d5a5964e99eb75f..728f380de4f010c3 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -48,10 +48,8 @@ public:\n \tbool hasPendingBuffers() const { return !pending_.empty(); }\n \n private:\n-\tfriend class Camera;\n \tfriend class PipelineHandler;\n \n-\tint prepare();\n \tvoid complete();\n \n \tbool completeBuffer(Buffer *buffer);\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex 960eeb8f7d193ddd..5305e3c391da6a69 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -360,7 +360,7 @@ Buffer::Buffer(unsigned int index, const Buffer *metadata)\n  * The intended callers of this method are buffer completion handlers that\n  * need to associate a buffer to the request it belongs to.\n  *\n- * A Buffer is associated to a request by Request::prepare() and the\n+ * A Buffer is associated to a request by Request::addBuffer() and the\n  * association is valid until the buffer completes. The returned request\n  * pointer is valid only during that interval.\n  *\n@@ -397,7 +397,7 @@ void Buffer::cancel()\n  * \\fn Buffer::setRequest()\n  * \\brief Set the request this buffer belongs to\n  *\n- * The intended callers are Request::prepare() and Request::completeBuffer().\n+ * The intended callers are Request::addBuffer() and Request::completeBuffer().\n  */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex e810fb725d81350d..5d294b10647db8da 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -810,6 +810,11 @@ int Camera::queueRequest(Request *request)\n \tif (!stateIs(CameraRunning))\n \t\treturn -EACCES;\n \n+\tif (request->buffers().empty()) {\n+\t\tLOG(Camera, Error) << \"Request contains no buffers\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \tfor (auto const &it : request->buffers()) {\n \t\tStream *stream = it.first;\n \t\tBuffer *buffer = it.second;\n@@ -832,12 +837,6 @@ int Camera::queueRequest(Request *request)\n \t\tbuffer->mem_ = &stream->buffers()[buffer->index_];\n \t}\n \n-\tint ret = request->prepare();\n-\tif (ret) {\n-\t\tLOG(Camera, Error) << \"Failed to prepare request\";\n-\t\treturn ret;\n-\t}\n-\n \treturn pipe_->queueRequest(this, request);\n }\n \ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex c14ed1a4d3ce55d0..84a5f55879ccf5b5 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -139,6 +139,8 @@ int Request::addBuffer(std::unique_ptr<Buffer> buffer)\n \t\treturn -EEXIST;\n \t}\n \n+\tbuffer->setRequest(this);\n+\tpending_.insert(buffer.get());\n \tbufferMap_[stream] = buffer.release();\n \n \treturn 0;\n@@ -203,30 +205,6 @@ Buffer *Request::findBuffer(Stream *stream) const\n  * otherwise\n  */\n \n-/**\n- * \\brief Validate the request and prepare it for the completion handler\n- *\n- * Requests that contain no buffers are invalid and are rejected.\n- *\n- * \\return 0 on success or a negative error code otherwise\n- * \\retval -EINVAL The request is invalid\n- */\n-int Request::prepare()\n-{\n-\tif (bufferMap_.empty()) {\n-\t\tLOG(Request, Error) << \"Invalid request due to missing buffers\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tfor (auto const &pair : bufferMap_) {\n-\t\tBuffer *buffer = pair.second;\n-\t\tbuffer->setRequest(this);\n-\t\tpending_.insert(buffer);\n-\t}\n-\n-\treturn 0;\n-}\n-\n /**\n  * \\brief Complete a queued request\n  *\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "01/32"
    ]
}