{"id":1135,"url":"https://patchwork.libcamera.org/api/patches/1135/?format=json","web_url":"https://patchwork.libcamera.org/patch/1135/","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":"<20190429191729.29697-8-niklas.soderlund@ragnatech.se>","date":"2019-04-29T19:17:25","name":"[libcamera-devel,07/11] libcamera: media_device: Make open() and close() private","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e1a2eac365a9f4497314464a5c5cc70791c876e6","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/1135/mbox/","series":[{"id":284,"url":"https://patchwork.libcamera.org/api/series/284/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=284","date":"2019-04-29T19:17:18","name":"libcamerea: Add support for exclusive access to cameras between processes","version":1,"mbox":"https://patchwork.libcamera.org/series/284/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1135/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1135/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A846060E5A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Apr 2019 21:17:52 +0200 (CEST)","from wyvern.station (unknown [37.182.44.227])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 7afec997-6ab3-11e9-8e2c-005056917f90;\n\tMon, 29 Apr 2019 21:17:50 +0200 (CEST)"],"X-Halon-ID":"7afec997-6ab3-11e9-8e2c-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":"Mon, 29 Apr 2019 21:17:25 +0200","Message-Id":"<20190429191729.29697-8-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190429191729.29697-1-niklas.soderlund@ragnatech.se>","References":"<20190429191729.29697-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 07/11] libcamera: media_device: Make\n\topen() and close() private","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":"Mon, 29 Apr 2019 19:17:53 -0000"},"content":"All external callers to open() and close() have been refactored and\nthere is no need to expose these functions anymore, make them private.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/media_device.h |  6 +-\n src/libcamera/media_device.cpp       | 98 ++++++++++++++--------------\n 2 files changed, 52 insertions(+), 52 deletions(-)","diff":"diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h\nindex 883985055eb419dd..e513a2fee1b91a1b 100644\n--- a/src/libcamera/include/media_device.h\n+++ b/src/libcamera/include/media_device.h\n@@ -30,9 +30,6 @@ public:\n \tvoid release();\n \tbool busy() const { return acquired_; }\n \n-\tint open();\n-\tvoid close();\n-\n \tint populate();\n \tbool valid() const { return valid_; }\n \n@@ -62,6 +59,9 @@ private:\n \tbool valid_;\n \tbool acquired_;\n \n+\tint open();\n+\tvoid close();\n+\n \tstd::map<unsigned int, MediaObject *> objects_;\n \tMediaObject *object(unsigned int id);\n \tbool addObject(MediaObject *object);\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex ca260c9ea991dd53..cd6a01ed452073e2 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -126,55 +126,6 @@ void MediaDevice::release()\n  * \\sa acquire(), release()\n  */\n \n-/**\n- * \\brief Open the media device\n- *\n- * \\return 0 on success or a negative error code otherwise\n- * \\retval -EBUSY Media device already open\n- * \\sa close()\n- */\n-int MediaDevice::open()\n-{\n-\tif (fd_ != -1) {\n-\t\tLOG(MediaDevice, Error) << \"MediaDevice already open\";\n-\t\treturn -EBUSY;\n-\t}\n-\n-\tint ret = ::open(deviceNode_.c_str(), O_RDWR);\n-\tif (ret < 0) {\n-\t\tret = -errno;\n-\t\tLOG(MediaDevice, Error)\n-\t\t\t<< \"Failed to open media device at \"\n-\t\t\t<< deviceNode_ << \": \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\tfd_ = ret;\n-\n-\treturn 0;\n-}\n-\n-/**\n- * \\brief Close the media device\n- *\n- * This function closes the media device node. It does not invalidate the media\n- * graph and all cached media objects remain valid and can be accessed normally.\n- * Once closed no operation interacting with the media device node can be\n- * performed until the device is opened again.\n- *\n- * Closing an already closed device is allowed and will not perform any\n- * operation.\n- *\n- * \\sa open()\n- */\n-void MediaDevice::close()\n-{\n-\tif (fd_ == -1)\n-\t\treturn;\n-\n-\t::close(fd_);\n-\tfd_ = -1;\n-}\n-\n /**\n  * \\brief Populate the MediaDevice with device information and media objects\n  *\n@@ -440,6 +391,55 @@ int MediaDevice::disableLinks()\n  * driver unloading for most devices. The media device is passed as a parameter.\n  */\n \n+/**\n+ * \\brief Open the media device\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EBUSY Media device already open\n+ * \\sa close()\n+ */\n+int MediaDevice::open()\n+{\n+\tif (fd_ != -1) {\n+\t\tLOG(MediaDevice, Error) << \"MediaDevice already open\";\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tint ret = ::open(deviceNode_.c_str(), O_RDWR);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(MediaDevice, Error)\n+\t\t\t<< \"Failed to open media device at \"\n+\t\t\t<< deviceNode_ << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\tfd_ = ret;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Close the media device\n+ *\n+ * This function closes the media device node. It does not invalidate the media\n+ * graph and all cached media objects remain valid and can be accessed normally.\n+ * Once closed no operation interacting with the media device node can be\n+ * performed until the device is opened again.\n+ *\n+ * Closing an already closed device is allowed and will not perform any\n+ * operation.\n+ *\n+ * \\sa open()\n+ */\n+void MediaDevice::close()\n+{\n+\tif (fd_ == -1)\n+\t\treturn;\n+\n+\t::close(fd_);\n+\tfd_ = -1;\n+}\n+\n /**\n  * \\var MediaDevice::objects_\n  * \\brief Global map of media objects (entities, pads, links) keyed by their\n","prefixes":["libcamera-devel","07/11"]}