From patchwork Wed Mar 2 22:03:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 547718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8241BC433F5 for ; Wed, 2 Mar 2022 22:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242213AbiCBWEC (ORCPT ); Wed, 2 Mar 2022 17:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236829AbiCBWEC (ORCPT ); Wed, 2 Mar 2022 17:04:02 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68EC3C9920 for ; Wed, 2 Mar 2022 14:03:17 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id p9so4870722wra.12 for ; Wed, 02 Mar 2022 14:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YKGA5UWMc55hY8HA5b3tbE4nKkQsSj8ptMeMEZUkbOw=; b=FyNOhyuG177UMLONMDCkT7x1indfKOMwgZGDMdOAPOfUD0Ll9euA0UUs2CazupxXrS /NWQWn2s+9QmZTeIasfnn3NsJqnnCFsTS+4FSqAoz+vR4UPddTSLiGUqGFxrS32ydk9e VAyfCLsoqGbhStNAtB2w4nk5Bs45IXGCuBl6UM9cyOExslfHmLEfHldoH4bpmxhMNWgf Yf3TESV3ARtc7pPz6K/zy+B9ZWWjywRZbiu/dSffhmFrTbKogoZFU9XdRxDLqyuE1k58 FKm34QApLLThQdxaIdhOwvaz24T3/E61Ul86gR8ukF5+08tNyFdkqRUAPyCwdWnJlUIP JIZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YKGA5UWMc55hY8HA5b3tbE4nKkQsSj8ptMeMEZUkbOw=; b=Nr/lmnZ7c9AbE1YPA1SHIZghOm7x6RjVUNQRPw/NBjfc+AvGQvWun2QsuPcy0KA2Z1 yw3Lnc2aehfX1wwfVZ4iQXcQN8hqgRp6Y1M4BnkhE0aOfBsraf04vhl3VU3RYymqs9jW +ElqH1HBdIoIvEmyOFaQTA0NEhrJ6WY8iUAlcATCVyzDGnh+sOO0kH9vQwa30pD7ZmjY AjLJOocU0VM0SXQHOd5iOszXU4JLASZ0+n9tfAyr0+HdUMei9jAQFRqqDHfZYl3Oq7lL HL1OeLAUU9/zMdRxr3UntJM8LhCHtkLlBXXA8ST4I5DdP5od3slD+uki9HdOUGedsWUZ q8RQ== X-Gm-Message-State: AOAM532Amqr+xJbUjoLxzjvykb+m2cmUnemCWLF9NfxyFyBUxux7EnUt yJb0WR2Mu1z6WYXOzoS8jOQ17NOxij86wQ== X-Google-Smtp-Source: ABdhPJxMIKajnWlXcuk2d3gJQvUNhBChqqzdVAPi4G9BEEW5cx63o05khjLd0WO6nNYWfzYFjL4tuw== X-Received: by 2002:adf:d1c2:0:b0:1f0:435a:14ae with SMTP id b2-20020adfd1c2000000b001f0435a14aemr3242140wrd.404.1646258595890; Wed, 02 Mar 2022 14:03:15 -0800 (PST) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c4f1000b0033383cdeea1sm229258wmq.10.2022.03.02.14.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:03:15 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, hanlinchen@chromium.org, tfiga@chromium.org, hdegoede@redhat.com, kieran.bingham@ideasonboard.com, hpa@redhat.com Subject: [PATCH v3 2/5] media: media.h: Add new media link type Date: Wed, 2 Mar 2022 22:03:01 +0000 Message-Id: <20220302220304.1327896-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302220304.1327896-1-djrscally@gmail.com> References: <20220302220304.1327896-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To describe in the kernel the connection between devices and their supporting peripherals (for example, a camera sensor and the vcm driving the focusing lens for it), add a new type of media link to introduce the concept of these ancillary links. Add some elements to the uAPI documentation to explain the new link type, their purpose and some aspects of their current implementation. Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally --- Changes since v1: - None changes since the rfc: - Split out into its own patch (mostly so it can be followed by patch #3, which corrects some media-core code that is otherwise broken by the new links) .../media/mediactl/media-controller-model.rst | 6 ++++++ .../media/mediactl/media-types.rst | 17 ++++++++++++----- include/uapi/linux/media.h | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/userspace-api/media/mediactl/media-controller-model.rst b/Documentation/userspace-api/media/mediactl/media-controller-model.rst index 222cb99debb5..78bfdfb2a322 100644 --- a/Documentation/userspace-api/media/mediactl/media-controller-model.rst +++ b/Documentation/userspace-api/media/mediactl/media-controller-model.rst @@ -33,3 +33,9 @@ are: - An **interface link** is a point-to-point bidirectional control connection between a Linux Kernel interface and an entity. + +- An **ancillary link** is a point-to-point connection denoting that two + entities form a single logical unit. For example this could represent the + fact that a particular camera sensor and lens controller form a single + physical module, meaning this lens controller drives the lens for this + camera sensor. \ No newline at end of file diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst b/Documentation/userspace-api/media/mediactl/media-types.rst index 0a26397bd01d..60747251d409 100644 --- a/Documentation/userspace-api/media/mediactl/media-types.rst +++ b/Documentation/userspace-api/media/mediactl/media-types.rst @@ -412,14 +412,21 @@ must be set for every pad. is set by drivers and is read-only for applications. * - ``MEDIA_LNK_FL_LINK_TYPE`` - - This is a bitmask that defines the type of the link. Currently, - two types of links are supported: + - This is a bitmask that defines the type of the link. The following + link types are currently supported: .. _MEDIA-LNK-FL-DATA-LINK: - ``MEDIA_LNK_FL_DATA_LINK`` if the link is between two pads + ``MEDIA_LNK_FL_DATA_LINK`` for links that represent a data connection + between two pads. .. _MEDIA-LNK-FL-INTERFACE-LINK: - ``MEDIA_LNK_FL_INTERFACE_LINK`` if the link is between an - interface and an entity + ``MEDIA_LNK_FL_INTERFACE_LINK`` for links that associate an entity to its + interface. + + .. _MEDIA-LNK-FL-ANCILLARY-LINK: + + ``MEDIA_LNK_FL_ANCILLARY_LINK`` for links that represent a physical + relationship between two entities. The link may or may not be ummutable, so + applications must not assume either case. \ No newline at end of file diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 200fa8462b90..afbae7213d35 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -226,6 +226,7 @@ struct media_pad_desc { #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28) # define MEDIA_LNK_FL_DATA_LINK (0 << 28) # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28) +# define MEDIA_LNK_FL_ANCILLARY_LINK (2 << 28) struct media_link_desc { struct media_pad_desc source; From patchwork Wed Mar 2 22:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 547717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E4BCC433FE for ; Wed, 2 Mar 2022 22:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242331AbiCBWEG (ORCPT ); Wed, 2 Mar 2022 17:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242251AbiCBWED (ORCPT ); Wed, 2 Mar 2022 17:04:03 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D12FC9930 for ; Wed, 2 Mar 2022 14:03:19 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id j17so4969959wrc.0 for ; Wed, 02 Mar 2022 14:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iKVMZBiFy16mG3Dfyafd/mMa87sEc9/DrYdseAp/SmA=; b=KkKr+64tlreZsZtfb+EYXbCd1f9PA5ds203rOrD0Vc97CwQy0d8sZjx4GMiY0sSNte PvreF3MN5DANeMYbCQpvhd2RBx5nqIHbsr/5hWGw3PBOQ2Nq62k1OmLXeh9giXwVjG3d islNFDUc/4SElPlCl+zcWugamE0A9YpHy7lpeE9W7/d3TwQx/N8Ozvd3v1du3y68n0kh 6j4hj4JM0mJ7GrXZYFhwKsJsmi+Ul40mrmfIpaV/87xc6pTNfp4ZhmVSIsFVmExfTTyE GdT1nPD5NYX9BI15uqhXFnfzWZHnmZ9DOKxrkJw7yrh4TsIisuKdaOFqgTdUF0ugX2FA GQAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iKVMZBiFy16mG3Dfyafd/mMa87sEc9/DrYdseAp/SmA=; b=l6AXWCKxOijSB0hA7d/u27k4lesKhpHyR/fAmD3XE3Or6+BqPEA8QQ3zyH3w7dfmVB bpCc+fEtftBnXOz48BTraD6fqLeWBJorvl6VnEN8aK3PMT4yXCs5AEnrHMTw32scIUf9 1EmZBObgWkjOCUCXA0zwmTUSL/MNjxEWin3kJRuvS/dvwEp349xygSa0NzDqjn4gutyn ZYwfUZV93jHJ/x1ASly8cPx+n+hiBJOc1PUor3U9zQc2RzhHkX2AUnjS3nst6CTrUZK0 M/MgomxyHPEoK/JW0F/aWZBz5TZMtcsxh+tJY5+92j+CTQ23R7oTLetaC+dGmj4cRCbW AANw== X-Gm-Message-State: AOAM531ZU3MnRwyD32Nib5byBri+fe3UCNfS8KNokG87MD6vEDx65wGI yu4ELAuQKX72/7ioDbIqhDhUuiN6rLp5DQ== X-Google-Smtp-Source: ABdhPJysv6qzhhcHXob1XlKrY+1H3kUXWeq6zWkvJOiGorg2Fm1Y0767bWfPjeBmwER/3EXpWoBbUw== X-Received: by 2002:a05:6000:1a89:b0:1f0:4b5b:e0ce with SMTP id f9-20020a0560001a8900b001f04b5be0cemr781355wry.425.1646258597807; Wed, 02 Mar 2022 14:03:17 -0800 (PST) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c4f1000b0033383cdeea1sm229258wmq.10.2022.03.02.14.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:03:17 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, hanlinchen@chromium.org, tfiga@chromium.org, hdegoede@redhat.com, kieran.bingham@ideasonboard.com, hpa@redhat.com Subject: [PATCH v3 4/5] media: entity: Add support for ancillary links Date: Wed, 2 Mar 2022 22:03:03 +0000 Message-Id: <20220302220304.1327896-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302220304.1327896-1-djrscally@gmail.com> References: <20220302220304.1327896-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add functions to create ancillary links, so that they don't need to be manually created by users. Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally Reviewed-by: Jean-Michel Hautbois --- Changes since v2: - Fixed some typos and comment phrasing (Laurent) - Changed the position of the new function to go after media_entity_call() (Laurent) Changes since v1: - Hardcoded MEDIA_LINK_FL_IMMUTABLE and MEDIA_LINK_FL_ENABLED (Laurent) Changes since the rfc: - (Laurent) Set gobj0 and gobj1 directly instead of the other union members - (Laurent) Added MEDIA_LNK_FL_IMMUTABLE to the kerneldoc for the new create function drivers/media/mc/mc-entity.c | 22 ++++++++++++++++++++++ include/media/media-entity.h | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 1a7d0a4fb9e8..d7e2f78a83cc 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -1032,3 +1032,25 @@ void media_remove_intf_links(struct media_interface *intf) mutex_unlock(&mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_remove_intf_links); + +struct media_link *media_create_ancillary_link(struct media_entity *primary, + struct media_entity *ancillary) +{ + struct media_link *link; + + link = media_add_link(&primary->links); + if (!link) + return ERR_PTR(-ENOMEM); + + link->gobj0 = &primary->graph_obj; + link->gobj1 = &ancillary->graph_obj; + link->flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_ANCILLARY_LINK; + + /* Initialize graph object embedded in the new link */ + media_gobj_create(primary->graph_obj.mdev, MEDIA_GRAPH_LINK, + &link->graph_obj); + + return link; +} +EXPORT_SYMBOL_GPL(media_create_ancillary_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index fea489f03d57..2a58defc4886 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -1108,4 +1108,23 @@ void media_remove_intf_links(struct media_interface *intf); (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) +/** + * media_create_ancillary_link() - create an ancillary link between two + * instances of &media_entity + * + * @primary: pointer to the primary &media_entity + * @ancillary: pointer to the ancillary &media_entity + * + * Create an ancillary link between two entities, indicating that they + * represent two connected pieces of hardware that form a single logical unit. + * A typical example is a camera lens controller being linked to the sensor that + * it is supporting. + * + * The function sets both MEDIA_LNK_FL_ENABLED and MEDIA_LNK_FL_IMMUTABLE for + * the new link. + */ +struct media_link * +media_create_ancillary_link(struct media_entity *primary, + struct media_entity *ancillary); + #endif