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>
This commit is contained in:
Niklas Söderlund
2019-04-14 00:43:38 +02:00
parent 9c1fe51ebc
commit 1657291f58
2 changed files with 52 additions and 52 deletions
+49 -49
View File
@@ -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