From 4e78147df919b6cbc4f117d6a0229819647d503e Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Thu, 3 Jan 2019 16:33:19 +0100 Subject: 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 --- src/libcamera/media_object.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/libcamera/media_object.cpp') 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 #include "log.h" +#include "media_device.h" #include "media_object.h" /** @@ -95,6 +96,34 @@ namespace libcamera { * Each link is referenced in the link array of both of the pads it connect. */ +/** + * \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 -- cgit v1.2.1