diff options
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 |