{"id":96,"url":"https://patchwork.libcamera.org/api/1.1/patches/96/?format=json","web_url":"https://patchwork.libcamera.org/patch/96/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20181229032855.26249-2-niklas.soderlund@ragnatech.se>","date":"2018-12-29T03:28:44","name":"[libcamera-devel,v2,01/12] libcamera: Add Camera class","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"6d20c618248f32b21960396d4f4c0f3a53f5f10b","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/96/mbox/","series":[{"id":41,"url":"https://patchwork.libcamera.org/api/1.1/series/41/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=41","date":"2018-12-29T03:28:43","name":"Add basic camera enumeration","version":2,"mbox":"https://patchwork.libcamera.org/series/41/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/96/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/96/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 A4F4060B31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Dec 2018 04:29:52 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid f94473f9-0b19-11e9-911a-0050569116f7;\n\tSat, 29 Dec 2018 04:29:39 +0100 (CET)"],"X-Halon-ID":"f94473f9-0b19-11e9-911a-0050569116f7","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":"Sat, 29 Dec 2018 04:28:44 +0100","Message-Id":"<20181229032855.26249-2-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20181229032855.26249-1-niklas.soderlund@ragnatech.se>","References":"<20181229032855.26249-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 01/12] libcamera: Add Camera class","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":"Sat, 29 Dec 2018 03:29:53 -0000"},"content":"Provide a Camera class which represents our main interface to handling\ncamera devices. This is a rework of Kieran's initial proposal and\nLaurent's documentation of the file changed to fit the device\nenumerators needs.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\n* Changes v1\n- Fix missing /* namespace libcamera */ comment, thanks Jacopo.\n- Removed Debug messages from Camera class constructor and destructor.\n- Reworded documentation for Camera::get() and Camera::put(), thanks\n  Laurent.\n---\n include/libcamera/camera.h    | 31 ++++++++++++\n include/libcamera/libcamera.h |  2 +\n include/libcamera/meson.build |  1 +\n src/libcamera/camera.cpp      | 89 +++++++++++++++++++++++++++++++++++\n src/libcamera/meson.build     |  1 +\n 5 files changed, 124 insertions(+)\n create mode 100644 include/libcamera/camera.h\n create mode 100644 src/libcamera/camera.cpp","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nnew file mode 100644\nindex 0000000000000000..9a7579d61fa331ee\n--- /dev/null\n+++ b/include/libcamera/camera.h\n@@ -0,0 +1,31 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * camera.h - Camera object interface\n+ */\n+#ifndef __LIBCAMERA_CAMERA_H__\n+#define __LIBCAMERA_CAMERA_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+class Camera\n+{\n+public:\n+\tCamera(const std::string &name);\n+\n+\tconst std::string &name() const;\n+\tvoid get();\n+\tvoid put();\n+\n+private:\n+\tvirtual ~Camera() { };\n+\tint ref_;\n+\tstd::string name_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_CAMERA_H__ */\ndiff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h\nindex 790771b61e41e123..44c094d92feed5ba 100644\n--- a/include/libcamera/libcamera.h\n+++ b/include/libcamera/libcamera.h\n@@ -7,6 +7,8 @@\n #ifndef __LIBCAMERA_LIBCAMERA_H__\n #define __LIBCAMERA_LIBCAMERA_H__\n \n+#include <libcamera/camera.h>\n+\n namespace libcamera {\n \n class libcamera\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 8c82675a25d29913..9b266ad926681db9 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_api = files([\n+    'camera.h',\n     'libcamera.h',\n ])\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nnew file mode 100644\nindex 0000000000000000..6da2b20137d45da2\n--- /dev/null\n+++ b/src/libcamera/camera.cpp\n@@ -0,0 +1,89 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * camera.cpp - Camera device\n+ */\n+\n+#include <libcamera/camera.h>\n+\n+#include \"log.h\"\n+\n+/**\n+ * \\file camera.h\n+ * \\brief Camera device handling\n+ *\n+ * At the core of libcamera is the camera device, combining one image source\n+ * with processing hardware able to provide one or multiple image streams. The\n+ * Camera class represents a camera device.\n+ *\n+ * A camera device contains a single image source, and separate camera device\n+ * instances relate to different image sources. For instance, a phone containing\n+ * front and back image sensors will be modelled with two camera devices, one\n+ * for each sensor. When multiple streams can be produced from the same image\n+ * source, all those streams are guaranteed to be part of the same camera\n+ * device.\n+ *\n+ * While not sharing image sources, separate camera devices can share other\n+ * system resources, such as an ISP. For this reason camera device instances may\n+ * not be fully independent, in which case usage restrictions may apply. For\n+ * instance, a phone with a front and a back camera device may not allow usage\n+ * of the two devices simultaneously.\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class Camera\n+ * \\brief Camera device\n+ *\n+ * The Camera class models a camera capable of producing one or more image\n+ * streams from a single image source. It provides the main interface to\n+ * configuring and controlling the device, and capturing image streams. It is\n+ * the central object exposed by libcamera.\n+ */\n+\n+/**\n+ * \\brief Construct a named camera device\n+ *\n+ * \\param[in] name The name to set on the camera device\n+ *\n+ * The caller is responsible for guaranteeing unicity of the camera\n+ * device name.\n+ */\n+Camera::Camera(const std::string &name)\n+\t: ref_(1), name_(name)\n+{\n+}\n+\n+/**\n+ * \\brief Retrieve the name of the camera\n+ *\n+ * \\return Name of the camera device\n+ */\n+const std::string &Camera::name() const\n+{\n+\treturn name_;\n+}\n+\n+/**\n+ * \\brief Acquire a reference to the camera\n+ */\n+void Camera::get()\n+{\n+\tref_++;\n+}\n+\n+/**\n+ * \\brief Release a reference to the camera\n+ *\n+ * When the last reference is released the camera device is deleted. Callers\n+ * shall not access the camera device after calling this function.\n+ */\n+void Camera::put()\n+{\n+\tif (--ref_ == 0)\n+\t\tdelete this;\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex f632eb5dd7791ad2..46591069aa5f8beb 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -1,4 +1,5 @@\n libcamera_sources = files([\n+    'camera.cpp',\n     'log.cpp',\n     'main.cpp',\n ])\n","prefixes":["libcamera-devel","v2","01/12"]}