diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-04-14 00:43:38 +0200 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-05-17 20:35:09 +0200 |
commit | 1657291f5820713c0f1859f1e311fe47cfbcdc53 (patch) | |
tree | fe0b29931d7dcc72e4a26e82c2a1ba05760dd955 /src | |
parent | 9c1fe51ebc33684a2205dfb92dde469f436c855c (diff) |
libcamera: media_device: Make open() and close() private
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 <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/include/media_device.h | 6 | ||||
-rw-r--r-- | 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 88398505..e513a2fe 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<unsigned int, MediaObject *> 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 b1cc37e8..62c59e7e 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -127,55 +127,6 @@ void MediaDevice::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 * * This function retrieves the media device information and enumerates all @@ -441,6 +392,55 @@ int MediaDevice::disableLinks() */ /** + * \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 * object id. |