summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Scally <djrscally@googlemail.com>2020-08-28 07:25:20 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-08-29 00:56:34 +0300
commite59713c68678f3eb6b6ebe97cabdc88c7042567f (patch)
tree9aae6ce4f6a25c92e2bd098f0e38c2cf99641c7d
parent6de4772f1e86e4e009d9dda441249c2139b3af85 (diff)
libcamera: media_object: Make MediaLink::setEnabled() account for existing flags
The MediaDevice::setupLink() function fails (ioctl returns EINVAL) when it passes only the MEDIA_LNK_FL_ENABLE flag to a link that is already flagged with MEDIA_LNK_FL_ENABLE and MEDIA_LNK_FL_IMMUTABLE. Contrast to media-ctl's equivalent media_setup_link() which ORs the new flags with the existing values. Fix this by preserving all flags but MEDIA_LNK_FL_ENABLED in MediaLink::setEnabled(). Signed-off-by: Dan Scally <djrscally@gmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/media_object.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
index ce77a727..b7bf048c 100644
--- a/src/libcamera/media_object.cpp
+++ b/src/libcamera/media_object.cpp
@@ -115,7 +115,8 @@ LOG_DECLARE_CATEGORY(MediaDevice)
*/
int MediaLink::setEnabled(bool enable)
{
- unsigned int flags = enable ? MEDIA_LNK_FL_ENABLED : 0;
+ unsigned int flags = (flags_ & ~MEDIA_LNK_FL_ENABLED)
+ | (enable ? MEDIA_LNK_FL_ENABLED : 0);
int ret = dev_->setupLink(this, flags);
if (ret)