[libcamera-devel] [PATCH v3] MediaLink: Make MediaLink::setEnabled account for existing

Daniel Scally djrscally at googlemail.com
Fri Aug 28 08:32:38 CEST 2020


Forgot to CC the list in reply to Laurent, but I agree his proposed change
is better - and still fixes the problem I was having.

Wasn't sure if you wanted me to resubmit but I wanted to try git
send-email, hopefully this time it'll apply cleanly.

Dan

On Fri, 28 Aug 2020, 07:27 Dan Scally, <djrscally at googlemail.com> wrote:

> The setupLink function fails (ioctl returns EINVAL) when it passes 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. This patch modifies the behaviour of setupLink() to behave the
> same as media_setup_link() in media-ctl.
>
> Signed-off-by: Dan Scally <djrscally at gmail.com>
> ---
>
> Changelog:
>
>         v3 - Moved the change to MediaLink::setEnabled()
>
>         v2 - Simplified by removing the call to link() to fetch a link
> that's
>                 already passed as a parameter to the function.
>
>  src/libcamera/media_object.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/media_object.cpp
> b/src/libcamera/media_object.cpp
> index ce77a72..a2e6a0d 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)
> --
> 2.25.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20200828/ad8b5225/attachment.htm>


More information about the libcamera-devel mailing list