From patchwork Wed May 8 15:18:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1172 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C4A960E6E for ; Wed, 8 May 2019 17:18:55 +0200 (CEST) X-Halon-ID: 96725036-71a4-11e9-8fa2-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 96725036-71a4-11e9-8fa2-005056917a89; Wed, 08 May 2019 17:18:52 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 17:18:27 +0200 Message-Id: <20190508151831.12274-8-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508151831.12274-1-niklas.soderlund@ragnatech.se> References: <20190508151831.12274-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/11] libcamera: media_device: Make open() and close() private X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 15:18:55 -0000 All external callers to open() and close() have been refactored and there is no need to expose these functions anymore, make them private. Signed-off-by: Niklas Söderlund --- src/libcamera/include/media_device.h | 6 +- src/libcamera/media_device.cpp | 98 ++++++++++++++-------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h index 883985055eb419dd..e513a2fee1b91a1b 100644 --- a/src/libcamera/include/media_device.h +++ b/src/libcamera/include/media_device.h @@ -30,9 +30,6 @@ public: void release(); bool busy() const { return acquired_; } - int open(); - void close(); - int populate(); bool valid() const { return valid_; } @@ -62,6 +59,9 @@ private: bool valid_; bool acquired_; + int open(); + void close(); + std::map objects_; MediaObject *object(unsigned int id); bool addObject(MediaObject *object); diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index ca260c9ea991dd53..cd6a01ed452073e2 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -126,55 +126,6 @@ void MediaDevice::release() * \sa acquire(), release() */ -/** - * \brief Open the media device - * - * \return 0 on success or a negative error code otherwise - * \retval -EBUSY Media device already open - * \sa close() - */ -int MediaDevice::open() -{ - if (fd_ != -1) { - LOG(MediaDevice, Error) << "MediaDevice already open"; - return -EBUSY; - } - - int ret = ::open(deviceNode_.c_str(), O_RDWR); - if (ret < 0) { - ret = -errno; - LOG(MediaDevice, Error) - << "Failed to open media device at " - << deviceNode_ << ": " << strerror(-ret); - return ret; - } - fd_ = ret; - - return 0; -} - -/** - * \brief Close the media device - * - * This function closes the media device node. It does not invalidate the media - * graph and all cached media objects remain valid and can be accessed normally. - * Once closed no operation interacting with the media device node can be - * performed until the device is opened again. - * - * Closing an already closed device is allowed and will not perform any - * operation. - * - * \sa open() - */ -void MediaDevice::close() -{ - if (fd_ == -1) - return; - - ::close(fd_); - fd_ = -1; -} - /** * \brief Populate the MediaDevice with device information and media objects * @@ -440,6 +391,55 @@ int MediaDevice::disableLinks() * driver unloading for most devices. The media device is passed as a parameter. */ +/** + * \brief Open the media device + * + * \return 0 on success or a negative error code otherwise + * \retval -EBUSY Media device already open + * \sa close() + */ +int MediaDevice::open() +{ + if (fd_ != -1) { + LOG(MediaDevice, Error) << "MediaDevice already open"; + return -EBUSY; + } + + int ret = ::open(deviceNode_.c_str(), O_RDWR); + if (ret < 0) { + ret = -errno; + LOG(MediaDevice, Error) + << "Failed to open media device at " + << deviceNode_ << ": " << strerror(-ret); + return ret; + } + fd_ = ret; + + return 0; +} + +/** + * \brief Close the media device + * + * This function closes the media device node. It does not invalidate the media + * graph and all cached media objects remain valid and can be accessed normally. + * Once closed no operation interacting with the media device node can be + * performed until the device is opened again. + * + * Closing an already closed device is allowed and will not perform any + * operation. + * + * \sa open() + */ +void MediaDevice::close() +{ + if (fd_ == -1) + return; + + ::close(fd_); + fd_ = -1; +} + /** * \var MediaDevice::objects_ * \brief Global map of media objects (entities, pads, links) keyed by their