diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-04-14 00:43:29 +0200 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-05-17 01:33:57 +0200 |
commit | 1a813a5c3ab71a91e327d538d0df5d945e50561e (patch) | |
tree | 2ac615e5dacbb8d36a6408d59994eb7e448a45a9 /src/libcamera/pipeline/ipu3/ipu3.cpp | |
parent | ef30be09eb0faba6739b4efee450d0c9751c121b (diff) |
libcamera: media_device: Handle media device fd in acquire() and release()
To gain better control of when a file descriptor is open to the media
device and reduce the work needed in pipeline handler implementations,
handle the file descriptor in acquire() and release().
This changes the current behavior where a file descriptor is only open
when requested by the pipeline handler to that one is always open as
long a media device is acquired. This new behavior is desired to allow
implementing exclusive access to a pipeline handler between processes.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/ipu3/ipu3.cpp')
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 75e878af..8a6a0e27 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -631,22 +631,9 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) /* * Disable all links that are enabled by default on CIO2, as camera * creation enables all valid links it finds. - * - * Close the CIO2 media device after, as links are enabled and should - * not need to be changed after. */ - if (cio2MediaDev_->open()) - return false; - - if (cio2MediaDev_->disableLinks()) { - cio2MediaDev_->close(); - return false; - } - - if (imguMediaDev_->open()) { - cio2MediaDev_->close(); + if (cio2MediaDev_->disableLinks()) return false; - } /* * FIXME: enabled links in one ImgU instance interfere with capture @@ -674,14 +661,10 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) */ ret = imguMediaDev_->disableLinks(); if (ret) - goto error; + return ret; ret = registerCameras(); -error: - cio2MediaDev_->close(); - imguMediaDev_->close(); - return ret == 0; } @@ -1139,29 +1122,19 @@ int ImgUDevice::enableLinks(bool enable) std::string inputName = name_ + " input"; int ret; - /* \todo Establish rules to handle media devices open/close. */ - ret = media_->open(); - if (ret) - return ret; - ret = linkSetup(inputName, 0, name_, PAD_INPUT, enable); if (ret) - goto done; + return ret; ret = linkSetup(name_, PAD_OUTPUT, outputName, 0, enable); if (ret) - goto done; + return ret; ret = linkSetup(name_, PAD_VF, viewfinderName, 0, enable); if (ret) - goto done; - - ret = linkSetup(name_, PAD_STAT, statName, 0, enable); - -done: - media_->close(); + return ret; - return ret; + return linkSetup(name_, PAD_STAT, statName, 0, enable); } /*------------------------------------------------------------------------------ |