Patch Detail
Show a patch.
GET /api/patches/14499/?format=api
{ "id": 14499, "url": "https://patchwork.libcamera.org/api/patches/14499/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14499/", "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": "<20211028111520.256612-2-jacopo@jmondi.org>", "date": "2021-10-28T11:15:11", "name": "[libcamera-devel,01/10] libcamera: request: Make Request class Extensible", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "266ad93cc1c13d367dfe566cd27ad14fda699322", "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/14499/mbox/", "series": [ { "id": 2674, "url": "https://patchwork.libcamera.org/api/series/2674/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2674", "date": "2021-10-28T11:15:10", "name": "libcamera: Introduce Fence support", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2674/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14499/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14499/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": [ "parsemail@patchwork.libcamera.org", "kbingham@ideasonboard.com" ], "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 33431BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 9 Nov 2021 17:42:53 +0000 (UTC)", "from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BEDC1DEE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 9 Nov 2021 18:42:52 +0100 (CET)", "from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id XharGCKGemFhEAAA4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 28 Oct 2021 13:14:42 +0200", "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[IPv6:2001:4b98:dc0:43:216:3eff:fe33:f827])\tby\n\tperceval.ideasonboard.com (Postfix) with ESMTPS id 42798513;\n\tThu, 28 Oct 2021 13:14:42 +0200 (CEST)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9BAEA60159;\n\tThu, 28 Oct 2021 13:14:41 +0200 (CEST)", "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 77070600BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 13:14:37 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id BC6ADFF802;\n\tThu, 28 Oct 2021 11:14:36 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 28 Oct 2021 13:15:11 +0200", "Message-Id": "<20211028111520.256612-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.33.1", "In-Reply-To": "<20211028111520.256612-1-jacopo@jmondi.org>", "References": "<20211028111520.256612-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 01/10] libcamera: request: Make Request\n\tclass Extensible", "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>", "X-TUID": "QFLPHLDQfT2F", "Resent-From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Resent-To": "parsemail@patchwork.libcamera.org" }, "content": "From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nImplement the D-Pointer design pattern in the Request class to allow\nchanging internal data without affecting the public ABI.\n\nMove a few internal fields that are not needed to implement the public\nAPI to the Request::Private class already. More fields may be moved\nlater.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/meson.build | 1 +\n include/libcamera/internal/request.h | 34 ++++++++++++++++++\n include/libcamera/request.h | 6 ++--\n src/libcamera/pipeline_handler.cpp | 7 ++--\n src/libcamera/request.cpp | 50 +++++++++++++++++++++-----\n 5 files changed, 84 insertions(+), 14 deletions(-)\n create mode 100644 include/libcamera/internal/request.h", "diff": "diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 665fd6de4ed3..cae65b0604ff 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -34,6 +34,7 @@ libcamera_internal_headers = files([\n 'pipeline_handler.h',\n 'process.h',\n 'pub_key.h',\n+ 'request.h',\n 'source_paths.h',\n 'sysfs.h',\n 'v4l2_device.h',\ndiff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\nnew file mode 100644\nindex 000000000000..df0cc014067e\n--- /dev/null\n+++ b/include/libcamera/internal/request.h\n@@ -0,0 +1,34 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * request.h - Request class private data\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_REQUEST_H__\n+#define __LIBCAMERA_INTERNAL_REQUEST_H__\n+\n+#include <libcamera/request.h>\n+\n+namespace libcamera {\n+\n+class Camera;\n+class FrameBuffer;\n+\n+class Request::Private : public Extensible::Private\n+{\n+\tLIBCAMERA_DECLARE_PUBLIC(Request)\n+\n+public:\n+\tPrivate(Camera *camera);\n+\t~Private();\n+\n+\tCamera *camera() const { return camera_; }\n+\n+private:\n+\tCamera *camera_;\n+\tbool cancelled_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_INTERNAL_REQUEST_H__ */\ndiff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex d16904e6b679..d6bd0ba2ac17 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -25,8 +25,10 @@ class CameraControlValidator;\n class FrameBuffer;\n class Stream;\n \n-class Request\n+class Request : public Extensible\n {\n+\tLIBCAMERA_DECLARE_PRIVATE()\n+\n public:\n \tenum Status {\n \t\tRequestPending,\n@@ -70,7 +72,6 @@ private:\n \n \tbool completeBuffer(FrameBuffer *buffer);\n \n-\tCamera *camera_;\n \tControlList *controls_;\n \tControlList *metadata_;\n \tBufferMap bufferMap_;\n@@ -79,7 +80,6 @@ private:\n \tuint32_t sequence_;\n \tconst uint64_t cookie_;\n \tStatus status_;\n-\tbool cancelled_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex f69c4f03b80f..cada864687ff 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -19,6 +19,7 @@\n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n+#include \"libcamera/internal/request.h\"\n #include \"libcamera/internal/tracepoints.h\"\n \n /**\n@@ -311,7 +312,7 @@ void PipelineHandler::queueRequest(Request *request)\n {\n \tLIBCAMERA_TRACEPOINT(request_queue, request);\n \n-\tCamera *camera = request->camera_;\n+\tCamera *camera = request->_d()->camera();\n \tCamera::Private *data = camera->_d();\n \tdata->queuedRequests_.push_back(request);\n \n@@ -360,7 +361,7 @@ void PipelineHandler::queueRequest(Request *request)\n */\n bool PipelineHandler::completeBuffer(Request *request, FrameBuffer *buffer)\n {\n-\tCamera *camera = request->camera_;\n+\tCamera *camera = request->_d()->camera();\n \tcamera->bufferCompleted.emit(request, buffer);\n \treturn request->completeBuffer(buffer);\n }\n@@ -381,7 +382,7 @@ bool PipelineHandler::completeBuffer(Request *request, FrameBuffer *buffer)\n */\n void PipelineHandler::completeRequest(Request *request)\n {\n-\tCamera *camera = request->camera_;\n+\tCamera *camera = request->_d()->camera();\n \n \trequest->complete();\n \ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 17fefab7ad0e..33fee1ac05ba 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -20,10 +20,11 @@\n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_controls.h\"\n #include \"libcamera/internal/framebuffer.h\"\n+#include \"libcamera/internal/request.h\"\n #include \"libcamera/internal/tracepoints.h\"\n \n /**\n- * \\file request.h\n+ * \\file libcamera/request.h\n * \\brief Describes a frame capture request to be processed by a camera\n */\n \n@@ -31,6 +32,37 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(Request)\n \n+/**\n+ * \\class Request::Private\n+ * \\brief Request private data\n+ *\n+ * The Request::Private class stores all private data associated with a\n+ * request. It implements the d-pointer design pattern to hide core\n+ * Request data from the public API, and exposes utility functions to\n+ * internal users of the request (namely the PipelineHandler class and its\n+ * subclasses).\n+ */\n+\n+/**\n+ * \\brief Create a Request::Private\n+ * \\param camera The Camera that creates the request\n+ */\n+Request::Private::Private(Camera *camera)\n+\t: camera_(camera), cancelled_(false)\n+{\n+}\n+\n+Request::Private::~Private()\n+{\n+}\n+\n+/**\n+ * \\fn Request::Private::camera()\n+ * \\brief Retrieve the camera this request has been queued to\n+ * \\return The Camera this request has been queued to, or nullptr if the\n+ * request hasn't been queued\n+ */\n+\n /**\n * \\enum Request::Status\n * Request completion status\n@@ -75,8 +107,8 @@ LOG_DEFINE_CATEGORY(Request)\n * completely opaque to libcamera.\n */\n Request::Request(Camera *camera, uint64_t cookie)\n-\t: camera_(camera), sequence_(0), cookie_(cookie),\n-\t status_(RequestPending), cancelled_(false)\n+\t: Extensible(std::make_unique<Private>(camera)), sequence_(0),\n+\t cookie_(cookie), status_(RequestPending)\n {\n \tcontrols_ = new ControlList(controls::controls,\n \t\t\t\t camera->_d()->validator());\n@@ -126,7 +158,7 @@ void Request::reuse(ReuseFlag flags)\n \n \tsequence_ = 0;\n \tstatus_ = RequestPending;\n-\tcancelled_ = false;\n+\t_d()->cancelled_ = false;\n \n \tcontrols_->clear();\n \tmetadata_->clear();\n@@ -282,7 +314,7 @@ void Request::complete()\n \tASSERT(status_ == RequestPending);\n \tASSERT(!hasPendingBuffers());\n \n-\tstatus_ = cancelled_ ? RequestCancelled : RequestComplete;\n+\tstatus_ = _d()->cancelled_ ? RequestCancelled : RequestComplete;\n \n \tLOG(Request, Debug) << toString();\n \n@@ -299,17 +331,19 @@ void Request::complete()\n */\n void Request::cancel()\n {\n+\tPrivate *const d = _d();\n+\n \tLIBCAMERA_TRACEPOINT(request_cancel, this);\n \n \tASSERT(status_ == RequestPending);\n \n \tfor (FrameBuffer *buffer : pending_) {\n \t\tbuffer->cancel();\n-\t\tcamera_->bufferCompleted.emit(this, buffer);\n+\t\td->camera_->bufferCompleted.emit(this, buffer);\n \t}\n \n \tpending_.clear();\n-\tcancelled_ = true;\n+\td->cancelled_ = true;\n }\n \n /**\n@@ -335,7 +369,7 @@ bool Request::completeBuffer(FrameBuffer *buffer)\n \tbuffer->_d()->setRequest(nullptr);\n \n \tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n-\t\tcancelled_ = true;\n+\t\t_d()->cancelled_ = true;\n \n \treturn !hasPendingBuffers();\n }\n", "prefixes": [ "libcamera-devel", "01/10" ] }