diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-01-03 16:33:19 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2019-01-09 09:16:47 +0100 |
commit | 4e78147df919b6cbc4f117d6a0229819647d503e (patch) | |
tree | 697d052f0963af2f99254e828343deb62714ef6b /src/libcamera/media_object.cpp | |
parent | b65feafe3244e6a4c794b73260a9dc790daa0f47 (diff) |
libcamera: Add link handling functions
Add a function to the MediaLink class to set the state of a link to
enabled or disabled. The function makes use of an internal MediaDevice
method, which is defined private and only accessible by the MediaLink
setEnabled() function itself.
Also add to MediaDevice a function to reset all links registered in the
media graph.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/media_object.cpp')
-rw-r--r-- | src/libcamera/media_object.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index 4ff9620d..cb3af85e 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -15,6 +15,7 @@ #include <linux/media.h> #include "log.h" +#include "media_device.h" #include "media_object.h" /** @@ -96,6 +97,34 @@ namespace libcamera { */ /** + * \brief Enable or disable a link + * \param enable True to enable the link, false to disable it + * + * Set the status of a link according to the value of \a enable. + * Links between two pads can be set to the enabled or disabled state freely, + * unless they're immutable links, whose status cannot be changed. + * Enabling an immutable link is not considered an error, while trying to + * disable it is. + * + * Enabling a link establishes a data connection between two pads, while + * disabling it interrupts that connection. + * + * \return 0 on success, or a negative error code otherwise + */ +int MediaLink::setEnabled(bool enable) +{ + unsigned int flags = enable ? MEDIA_LNK_FL_ENABLED : 0; + + int ret = dev_->setupLink(this, flags); + if (ret) + return ret; + + flags_ = flags; + + return 0; +} + +/** * \brief Construct a MediaLink * \param link The media link kernel data * \param source The source pad at the origin of the link |