Patch Detail
Show a patch.
GET /api/patches/530/?format=api
{ "id": 530, "url": "https://patchwork.libcamera.org/api/patches/530/?format=api", "web_url": "https://patchwork.libcamera.org/patch/530/", "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": "<20190206060818.13907-16-laurent.pinchart@ideasonboard.com>", "date": "2019-02-06T06:08:06", "name": "[libcamera-devel,15/27] libcamera: Provide a Request object", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8dfaa97cf16066957a17b6407c8334e588eb6e0a", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/530/mbox/", "series": [ { "id": 170, "url": "https://patchwork.libcamera.org/api/series/170/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=170", "date": "2019-02-06T06:07:51", "name": "Capture frames throught requests", "version": 1, "mbox": "https://patchwork.libcamera.org/series/170/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/530/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/530/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E5E561020\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 6 Feb 2019 07:08:27 +0100 (CET)", "from pendragon.ideasonboard.com (d51A4137F.access.telenet.be\n\t[81.164.19.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CAAE22DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 6 Feb 2019 07:08:26 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549433306;\n\tbh=Uj/kyqoFHyMJhqhmritCjWC5aEfPSffUiyNFq64um0c=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=uX1LY6LWACCRqS/y+keXBJfbhTSkNSTEsxQqVuzRCpFGm9S7taKkMJavhVLdfuxCc\n\tbknKEenE7fGK52s95nHgPLDKVlkY2y+HolaxXuuf0odjj0LXVgUYjExyJQkkCYVkpX\n\tUmsSZyVgLO9gk9CMzkusKZPRc7E/d3heZeLMbfbs=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 6 Feb 2019 08:08:06 +0200", "Message-Id": "<20190206060818.13907-16-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>", "References": "<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 15/27] libcamera: Provide a Request object", "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, 06 Feb 2019 06:08:29 -0000" }, "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nImplement a Request object used by applications to queue image capture\nrequests to a camera.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h | 3 +\n include/libcamera/libcamera.h | 1 +\n include/libcamera/meson.build | 1 +\n include/libcamera/request.h | 44 ++++++++++++\n src/libcamera/camera.cpp | 5 ++\n src/libcamera/meson.build | 1 +\n src/libcamera/request.cpp | 122 ++++++++++++++++++++++++++++++++++\n 7 files changed, 177 insertions(+)\n create mode 100644 include/libcamera/request.h\n create mode 100644 src/libcamera/request.cpp", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4940c344440e..bbe2696e837b 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -11,10 +11,12 @@\n #include <memory>\n #include <string>\n \n+#include <libcamera/request.h>\n #include <libcamera/signal.h>\n \n namespace libcamera {\n \n+class Buffer;\n class PipelineHandler;\n class Stream;\n class StreamConfiguration;\n@@ -31,6 +33,7 @@ public:\n \n \tconst std::string &name() const;\n \n+\tSignal<Request *, const std::map<Stream *, Buffer *> &> requestCompleted;\n \tSignal<Camera *> disconnected;\n \n \tint acquire();\ndiff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h\nindex 8167e8099ac0..dda576e906fb 100644\n--- a/include/libcamera/libcamera.h\n+++ b/include/libcamera/libcamera.h\n@@ -12,6 +12,7 @@\n #include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/event_notifier.h>\n+#include <libcamera/request.h>\n #include <libcamera/signal.h>\n #include <libcamera/stream.h>\n #include <libcamera/timer.h>\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 8c14423bc444..5788e9bbdf3e 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -5,6 +5,7 @@ libcamera_api = files([\n 'event_dispatcher.h',\n 'event_notifier.h',\n 'libcamera.h',\n+ 'request.h',\n 'signal.h',\n 'stream.h',\n 'timer.h',\ndiff --git a/include/libcamera/request.h b/include/libcamera/request.h\nnew file mode 100644\nindex 000000000000..ef081177309f\n--- /dev/null\n+++ b/include/libcamera/request.h\n@@ -0,0 +1,44 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * request.h - Capture request handling\n+ */\n+#ifndef __LIBCAMERA_REQUEST_H__\n+#define __LIBCAMERA_REQUEST_H__\n+\n+#include <map>\n+#include <unordered_set>\n+\n+#include <libcamera/signal.h>\n+\n+namespace libcamera {\n+\n+class Buffer;\n+class Camera;\n+class Stream;\n+\n+class Request\n+{\n+public:\n+\texplicit Request(Camera *camera);\n+\tRequest(const Request &) = delete;\n+\tRequest &operator=(const Request &) = delete;\n+\n+\tint setBuffers(const std::map<Stream *, Buffer *> &streamMap);\n+\tBuffer *findBuffer(Stream *stream) const;\n+\n+private:\n+\tfriend class Camera;\n+\n+\tint prepare();\n+\tvoid bufferCompleted(Buffer *buffer);\n+\n+\tCamera *camera_;\n+\tstd::map<Stream *, Buffer *> bufferMap_;\n+\tstd::unordered_set<Buffer *> pending_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_REQUEST_H__ */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex bcf3d54ab1c3..e8dab6f0bab2 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -97,6 +97,11 @@ const std::string &Camera::name() const\n \treturn name_;\n }\n \n+/**\n+ * \\var Camera::requestCompleted\n+ * \\brief Signal emitted when a request queued to the camera has completed\n+ */\n+\n /**\n * \\var Camera::disconnected\n * \\brief Signal emitted when the camera is disconnected from the system\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex ac991dc59d18..c5354c136563 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -11,6 +11,7 @@ libcamera_sources = files([\n 'media_device.cpp',\n 'media_object.cpp',\n 'pipeline_handler.cpp',\n+ 'request.cpp',\n 'signal.cpp',\n 'stream.cpp',\n 'timer.cpp',\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nnew file mode 100644\nindex 000000000000..922682a32188\n--- /dev/null\n+++ b/src/libcamera/request.cpp\n@@ -0,0 +1,122 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * request.cpp - Capture request handling\n+ */\n+\n+#include <map>\n+\n+#include <libcamera/buffer.h>\n+#include <libcamera/camera.h>\n+#include <libcamera/request.h>\n+#include <libcamera/stream.h>\n+\n+#include \"log.h\"\n+\n+/**\n+ * \\file request.h\n+ * \\brief Describes a frame capture request to be processed by a camera\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Request)\n+\n+/**\n+ * \\class Request\n+ * \\brief A frame capture request\n+ *\n+ * A Request allows an application to associate buffers and controls on a\n+ * per-frame basis to be queued to the camera device for processing.\n+ */\n+\n+/**\n+ * \\brief Create a capture request for a camera\n+ * \\param[in] camera The camera that creates the request\n+ */\n+Request::Request(Camera *camera)\n+\t: camera_(camera)\n+{\n+}\n+\n+/**\n+ * \\brief Set the streams to capture with associated buffers\n+ * \\param[in] streamMap The map of streams to buffers\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EBUSY Buffers have already been set\n+ */\n+int Request::setBuffers(const std::map<Stream *, Buffer *> &streamMap)\n+{\n+\tif (!bufferMap_.empty()) {\n+\t\tLOG(Request, Error) << \"Buffers already set\";\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tbufferMap_ = streamMap;\n+\treturn 0;\n+}\n+\n+/**\n+ * \\var Request::bufferMap_\n+ * \\brief Mapping of streams to buffers for this request\n+ *\n+ * The bufferMap_ tracks the buffers associated with each stream. If a stream is\n+ * not utilised in this request there will be no buffer for that stream in the\n+ * map.\n+ */\n+\n+/**\n+ * \\brief Return the buffer associated with a stream\n+ * \\param[in] stream The stream the buffer is associated to\n+ *\n+ * \\return The buffer associated with the stream, or nullptr if the stream is\n+ * not part of this request\n+ */\n+Buffer *Request::findBuffer(Stream *stream) const\n+{\n+\tauto it = bufferMap_.find(stream);\n+\tif (it == bufferMap_.end())\n+\t\treturn nullptr;\n+\n+\treturn it->second;\n+}\n+\n+/**\n+ * \\brief Prepare the resources for the completion handler\n+ */\n+int Request::prepare()\n+{\n+\tfor (auto const &pair : bufferMap_) {\n+\t\tBuffer *buffer = pair.second;\n+\t\tbuffer->completed.connect(this, &Request::bufferCompleted);\n+\t\tpending_.insert(buffer);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Slot for the buffer completed signal\n+ *\n+ * The bufferCompleted method serves as slot where to connect the\n+ * Buffer::completed signal that is emitted when a buffer has available\n+ * data.\n+ *\n+ * The request completes when all the buffers it contains are ready to be\n+ * presented to the application.\n+ */\n+void Request::bufferCompleted(Buffer *buffer)\n+{\n+\tbuffer->completed.disconnect(this, &Request::bufferCompleted);\n+\n+\tint ret = pending_.erase(buffer);\n+\tASSERT(ret == 1);\n+\n+\tif (pending_.empty()) {\n+\t\tstd::map<Stream *, Buffer *> buffers(std::move(bufferMap_));\n+\t\tcamera_->requestCompleted.emit(this, buffers);\n+\t}\n+}\n+\n+} /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "15/27" ] }