From patchwork Wed Aug 26 16:05:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 9402 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 45400BE173 for ; Wed, 26 Aug 2020 16:05:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A638D628E2; Wed, 26 Aug 2020 18:05:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="rcb+m6Ji"; dkim-atps=neutral Received: from mail-40135.protonmail.ch (mail-40135.protonmail.ch [185.70.40.135]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C41B6037F for ; Wed, 26 Aug 2020 18:05:54 +0200 (CEST) Date: Wed, 26 Aug 2020 16:05:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1598457953; bh=SdcK5cLsoc4f8jj7FnJRoYBMLBxqiZFjN3PuFHb8ssM=; h=Date:To:From:Reply-To:Subject:From; b=rcb+m6Ji/TO+5v6Fk5qgMhEhQ6DnO9szLnRPJ+ARRKxIMqVMPr4f6RlsA9FP7ZvMr kmtUAWhTQ/DpREamdwxA4I6PcQr87rSUB1CEVgoFpnV1E0/p4rS4IUah+uqtiW2TyY WLqDkinzQpTWp5KePD3CnbrJpK6B047pRKktD5lw= To: "libcamera-devel@lists.libcamera.org" From: Dan Scally Message-ID: <1PjHuckjnFWu-P_WVFjNhBem43Z22IbEVss8hepg7PwpuDCy1ZuXDSQ9Ju3lrMLaOWrjWpnFcGziK2_JaaoOP_H09ER37luwAqnPQqv4VMU=@protonmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Subject: [libcamera-devel] [PATCH V2] libcamera: MediaDevice: Make MediaDevice::setupLink account for existing link flags X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Dan Scally Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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. ref https://git.linuxtv.org/v4l-utils.git/tree/utils/media-ctl/libmediactl.c#n210 Changelog: v2 - Simplified by removing the call to link() to fetch a link that's already passed as a parameter to the function. Signed-off-by: Dan Scally Reviewed-by: Kieran Bingham --- src/libcamera/media_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) int ret = ioctl(fd_, MEDIA_IOC_SETUP_LINK, &linkDesc); if (ret) { diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index de18d57..007a45b 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -794,7 +794,7 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags) linkDesc.sink.index = sink->index(); linkDesc.sink.flags = MEDIA_PAD_FL_SINK; - linkDesc.flags = flags; + linkDesc.flags = flags | (link->flags() & MEDIA_LNK_FL_IMMUTABLE);