{"id":973,"url":"https://patchwork.libcamera.org/api/patches/973/?format=json","web_url":"https://patchwork.libcamera.org/patch/973/","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":"<20190414013506.10515-6-niklas.soderlund@ragnatech.se>","date":"2019-04-14T01:35:00","name":"[libcamera-devel,RFC,05/11] libcamera: media_device: Make open() and close() private","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a7da29114f6822e678e75e13dc872dc2c069fad3","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/973/mbox/","series":[{"id":249,"url":"https://patchwork.libcamera.org/api/series/249/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=249","date":"2019-04-14T01:34:55","name":"libcamerea: Add support for exclusive access to cameras between processes","version":1,"mbox":"https://patchwork.libcamera.org/series/249/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/973/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/973/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 1179760DC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Apr 2019 03:35:18 +0200 (CEST)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 8e84d4c6-5e55-11e9-8e2c-005056917f90;\n\tSun, 14 Apr 2019 03:35:17 +0200 (CEST)"],"X-Halon-ID":"8e84d4c6-5e55-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":"Sun, 14 Apr 2019 03:35:00 +0200","Message-Id":"<20190414013506.10515-6-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190414013506.10515-1-niklas.soderlund@ragnatech.se>","References":"<20190414013506.10515-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 05/11] libcamera: media_device: Make open()\n\tand 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":"Sun, 14 Apr 2019 01:35:18 -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                | 78 +++++++------------\n test/media_device/media_device_print_test.cpp | 11 ---\n 3 files changed, 32 insertions(+), 63 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 644c6143fb15e1fa..0138be526f886c90 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -124,55 +124,6 @@ void MediaDevice::release()\n  * \\sa acquire(), release()\n  */\n \n-/**\n- * \\brief Open a media device and retrieve device information\n- *\n- * If the device is already open the function returns -EBUSY.\n- *\n- * \\return 0 on success or a negative error code otherwise\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 media graph with media objects\n  *\n@@ -440,6 +391,35 @@ int MediaDevice::disableLinks()\n  * driver unloading for most devices. The media device is passed as a parameter.\n  */\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+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\ndiff --git a/test/media_device/media_device_print_test.cpp b/test/media_device/media_device_print_test.cpp\nindex ceffd538e13fca73..30d929b8c76387a7 100644\n--- a/test/media_device/media_device_print_test.cpp\n+++ b/test/media_device/media_device_print_test.cpp\n@@ -113,17 +113,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)\n \tMediaDevice dev(deviceNode);\n \tint ret;\n \n-\t/* Fuzzy open/close sequence. */\n-\tret = dev.open();\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tret = dev.open();\n-\tif (!ret)\n-\t\treturn ret;\n-\n-\tdev.close();\n-\n \tret = dev.populate();\n \tif (ret)\n \t\treturn ret;\n","prefixes":["libcamera-devel","RFC","05/11"]}