{"id":439,"url":"https://patchwork.libcamera.org/api/patches/439/?format=json","web_url":"https://patchwork.libcamera.org/patch/439/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190129020048.16774-7-niklas.soderlund@ragnatech.se>","date":"2019-01-29T02:00:48","name":"[libcamera-devel,v4,6/6] libcamera: camera: extend camera object to support configuration of streams","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9fd4dfb7276cb313c3e9727a096b82fd1dc24cf2","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/439/mbox/","series":[{"id":153,"url":"https://patchwork.libcamera.org/api/series/153/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=153","date":"2019-01-29T02:00:43","name":"libcamera: add basic support for streams and format configuration","version":4,"mbox":"https://patchwork.libcamera.org/series/153/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/439/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/439/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 E252860DB7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jan 2019 03:01:00 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid b8a41607-2369-11e9-874f-005056917f90;\n\tTue, 29 Jan 2019 03:00:58 +0100 (CET)"],"X-Halon-ID":"b8a41607-2369-11e9-874f-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":"Tue, 29 Jan 2019 03:00:48 +0100","Message-Id":"<20190129020048.16774-7-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190129020048.16774-1-niklas.soderlund@ragnatech.se>","References":"<20190129020048.16774-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 6/6] libcamera: camera: extend camera\n\tobject to support configuration of streams","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, 29 Jan 2019 02:01:01 -0000"},"content":"Extend the camera to support reading and configuring formats for\ngroups of streams. The implementation in the Camera are minimalistic as\nthe heavy lifting are done by the pipeline handler implementations.\n\nThe most important functionality the camera provides in this context is\nvalidation of data structures passed to it from the application and\naccess control to the pipeline handler.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h |  4 +++\n src/libcamera/camera.cpp   | 61 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 3ebb8e96cc63b98a..7a0357f3a2919752 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_CAMERA_H__\n #define __LIBCAMERA_CAMERA_H__\n \n+#include <map>\n #include <memory>\n #include <string>\n \n@@ -16,6 +17,7 @@ namespace libcamera {\n \n class PipelineHandler;\n class Stream;\n+class StreamConfiguration;\n \n class Camera final\n {\n@@ -35,6 +37,8 @@ public:\n \tvoid release();\n \n \tstd::vector<Stream *> streams() const;\n+\tstd::map<Stream*, StreamConfiguration> streamConfiguration(std::vector<Stream*> &streams);\n+\tint configureStreams(std::map<Stream*, StreamConfiguration> &config);\n \n private:\n \tCamera(PipelineHandler *pipe, const std::string &name);\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex c8604ec8a8e6eaf4..69d28a10f1f73d0d 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -190,4 +190,65 @@ std::vector<Stream *> Camera::streams() const\n \treturn streams_;\n }\n \n+/**\n+ * \\brief Retrieve a group of stream configurations\n+ * \\param[in] streams A map of stream IDs and configurations to setup\n+ *\n+ * Retrieve the camera's configuration for a specified group of streams. The\n+ * caller can specifies which of the camera's streams to retrieve configuration\n+ * from by populating \\a streams.\n+ *\n+ * The easiest way to populate the array of streams to fetch configuration from\n+ * is to first retrieve the camera's full array of stream by with streams() and\n+ * then potentially trim it down to only contain the streams the caller\n+ * are interested in.\n+ *\n+ * \\return A map of successfully retrieved stream IDs and configurations or an\n+ * empty list on error.\n+ */\n+std::map<Stream*, StreamConfiguration>\n+Camera::streamConfiguration(std::vector<Stream*> &streams)\n+{\n+\tif (disconnected_ || !streams.size())\n+\t\tstd::map<unsigned int, StreamConfiguration>{};\n+\n+\treturn pipe_->streamConfiguration(this, streams);\n+}\n+\n+/**\n+ * \\brief Configure the camera's streams prior to capture\n+ * \\param[in] config A map of stream IDs and configurations to setup\n+ *\n+ * Prior to starting capture, the camera must be configured to select a\n+ * group of streams to be involved in the capture and their configuration.\n+ * The caller specifies which streams are to be involved and their configuration\n+ * by populating \\a config.\n+ *\n+ * The easiest way to populate the array of config is to fetch an initial\n+ * configuration from the camera with streamConfiguration() and then change the\n+ * parameters to fit the caller's need and once all the streams parameters are\n+ * configured hand that over to configureStreams() to actually setup the camera.\n+ *\n+ * Exclusive access to the camera shall be ensured by a call to acquire() prior\n+ * to calling this function, otherwise an -EACCES error is be returned.\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 have not acquired exclusive access to the camera\n+ * \\retval -EINVAL The configuration is not valid\n+ */\n+int Camera::configureStreams(std::map<Stream*, StreamConfiguration> &config)\n+{\n+\tif (disconnected_)\n+\t\treturn -ENODEV;\n+\n+\tif (!acquired_)\n+\t\treturn -EACCES;\n+\n+\tif (!config.size())\n+\t\treturn -EINVAL;\n+\n+\treturn pipe_->configureStreams(this, config);\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v4","6/6"]}