From patchwork Wed Mar 2 22:03:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15398 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 87BFEBE08A for ; Wed, 2 Mar 2022 22:03:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3D20861174; Wed, 2 Mar 2022 23:03:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="I44u/jpu"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F18E601F5 for ; Wed, 2 Mar 2022 23:03:15 +0100 (CET) Received: by mail-wr1-x42e.google.com with SMTP id d3so4936943wrf.1 for ; Wed, 02 Mar 2022 14:03:15 -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=GHoWxwMyzuEiKYiB4tkgakdxydoJTJ1L6memTFq7bQY=; b=I44u/jpupuxrSxPrnEOPh8ns21kZ9UZQ5Fy9vLxB5XxM26XnG7gCk9Po5De1VeBfzg wwoMS+uggL+SJNdR6GpwRq7Fbi84IL5WvMmiy+GOtXm+wSv0no3NgVW0IaHRkxtfFvVP 09ghhpiXSRds8U3eggpxbNFELwL1WDBp+b+s6hn0nm2gdHI9bTkMjEurS8Yv5om98+P7 ReQJHjxcJtOYb9LxF2W2GUx7VfadwUsG7MdbaobofDz+cdiDf+VV8dxdA9sr7ayNuZv4 LSB2y+6F6/He+jHNn5aLkD9kHzwjl1hCxfsZQh3cBuVV+c/5t6SDsBzMWdsi0EsNwANA rBHw== 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=GHoWxwMyzuEiKYiB4tkgakdxydoJTJ1L6memTFq7bQY=; b=ucxmL0EkfEj+9uf92KuwWcG+jb2PE+pEpFp3g9MrFPNpxVXeczz+QSevCUuzKhHDfZ ei4UuFcqywMjqf0nDXnHMPcxino6kslAW1xBGQ3cHvhoDcPgVTXLjMb3cI5cTMRVvHZv eaiMM7U0GtXj7yvWlRVCuU8AkJP3zyGreItRFFoMwJWgJyo/kAgbsLKBQeqb67OGPpgc 3GtCIRfTvNt4+ErPoCpDCyVrKOzYLgb4IRFAU+XqpdUc4KCzI2ZEFUOv7MphS1t0wMqO WmdSSlAmB8B7fJ8t96bd4zrUVHIkydOSzPTMSdTLjiLCIgAJiHqn6sUJq+5b3Oo7H/MR 8qcQ== X-Gm-Message-State: AOAM532tgbymhucBLSxsiyZ2Ib2i7T7LI3DGTMHlpMbrhY2UoAuY+lTJ VZZRx9hvKubhyjHwCTgozHI= X-Google-Smtp-Source: ABdhPJxI+8FVaH+gF7/u1qQtIoi5tjku8H+S2JdkiyDFf7cktaVaYVQJuV9HhMc5hKyGUlmf9nwpKg== X-Received: by 2002:adf:d1e3:0:b0:1ea:7e17:6cff with SMTP id g3-20020adfd1e3000000b001ea7e176cffmr24545717wrd.415.1646258594962; Wed, 02 Mar 2022 14:03:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:03:14 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Wed, 2 Mar 2022 22:03:00 +0000 Message-Id: <20220302220304.1327896-2-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 Subject: [libcamera-devel] [PATCH v3 1/5] media: entity: Skip non-data links in graph iteration 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: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When iterating over the media graph, don't follow links that are not data links. Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally Reviewed-by: Jean-Michel Hautbois --- Changes since v2: - None Changes since v1: - Moved to the head of the series - s/pad-to-pad/data (Sakari) - Dropped the debug message (Laurent) Changes since the rfc: - new patch drivers/media/mc/mc-entity.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index b411f9796191..d0563ee4b28b 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -295,6 +295,12 @@ static void media_graph_walk_iter(struct media_graph *graph) link = list_entry(link_top(graph), typeof(*link), list); + /* If the link is not a data link, don't follow it */ + if ((link->flags & MEDIA_LNK_FL_LINK_TYPE) != MEDIA_LNK_FL_DATA_LINK) { + link_top(graph) = link_top(graph)->next; + return; + } + /* The link is not enabled so we do not follow. */ if (!(link->flags & MEDIA_LNK_FL_ENABLED)) { link_top(graph) = link_top(graph)->next; 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: 15399 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 83414BE08A for ; Wed, 2 Mar 2022 22:03:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A6CF961171; Wed, 2 Mar 2022 23:03:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FyNOhyuG"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4685F6047A for ; Wed, 2 Mar 2022 23:03:16 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id i8so4898684wrr.8 for ; Wed, 02 Mar 2022 14:03:16 -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=ll/gNguxlYnjutFfsUNZVPGQ+O1id0wG2bUcus8FBdZJBEOFUta68oWZEgtA5O4SuA ZgSY7YQGr4vjGbkBpTZHI/F8QQ0s49M8oXyVYb27k4+FXaUXCw6+L3LU1+zZ3RYrpYTU AgD3qA+EiPE7lZFERMLUI9BOl/S2qql7iM/6R7nEXELIyK0ZDw2fPfTf35lcaYbHvxpE YXCB1k9rlmW0qEKtAMPTKnt3wf24bkYBT53WjH/rxmr9MF9r4kGlaEQJt3VGiZkFfJwP vO6DNxyLY5bTU0AM0ONivOB4yu0q5FyR2baE8I+UEmwoCtOgqxgTlE9PX1+xRtX4gclL Q5mg== X-Gm-Message-State: AOAM533Xz21E0oM25zq2EEe3n5MGKxrE0fEn49jNyBeCwyqqwI1sx7bQ 0zepN0ip26m+bZfFah7kDTI= 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 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 Subject: [libcamera-devel] [PATCH v3 2/5] media: media.h: Add new media link type 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: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Jean-Michel Hautbois --- 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:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15400 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 7FD35BE08A for ; Wed, 2 Mar 2022 22:03:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9148F61187; Wed, 2 Mar 2022 23:03:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WR0utUqO"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 170C76047A for ; Wed, 2 Mar 2022 23:03:17 +0100 (CET) Received: by mail-wr1-x42e.google.com with SMTP id ay10so4903260wrb.6 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=ZZuRb6vJ4xL/T85VnKjF8jjubHhc9DkEkfgVG9uggJ4=; b=WR0utUqOYB7ZuyINcK/dNLS0PEbpJCuBuL4jurQW5+C1ApyrN3YJklICb+1aASRiIL khiDGY62G/cE+1kZBySmNmwLxCey30zqxuLrX2LpqkQaSYQTE544eFatwTJcBlH1gWWF wG8DbfB34kXC+N/y0gYF/4IHjonxbOUTC0uXR+1cgnWM9jhK+uzUb6gHBvTMgWXMGVK1 393a8bkurpawowYeDTMbRUk9sffEty3wF7WamsIMEg6PGNBDTB5DqrQuUfkyfFm5loZf evTQ/uJ+w7mu3MIqAIleu87IURx9z1WpCUy1VHUS3uyy035XNnclUUnoOewulryWoC5w SEgw== 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=ZZuRb6vJ4xL/T85VnKjF8jjubHhc9DkEkfgVG9uggJ4=; b=ObFOYVR81WPyO1Pu3/dLcA+ZXxz+WOZnmgviIKyV8V0mW5b3b3MR9+VZjLo9og52kD KJJvrldipXtI+gea/hskGTVBhZv411vNk3V4Vp2Be2yoOB3TrKkufcztWUr9aVpC0Jb4 RZp6gYzO1dBKgboBBT758R0oJ8m+OVwVQvxzcbnIMKEtRws+xQz0ZV6ZuQP2CLgMJBeM ptAWzhe7h55W9d0a4a7Nby0wOgnDgQVQNrZzsNHWs5hOgxCHIgEI7eOsUabe+YeFQM4h 3Vf+YLacjNStz3/FLrd4Rdpg4yZQ/b4ZWl2oMRdpU/Q+XwGdhZdIyLUhQY+if5uTrSHr NG6w== X-Gm-Message-State: AOAM5306sEnJSNUVvzehlp4UV+PY/9/FNScxJLVYC9k9Wj+7IFhHSxRI pxIzIq9rEFBYAS1IDusqH+LuqcKV52bYXQ== X-Google-Smtp-Source: ABdhPJwyIst7piDstEx9M7MU7dqS8Jcpe10l0k3knw9tQODBYPx5ugkivtEZE6GyRL7cJlO1TgQYRQ== X-Received: by 2002:a05:6000:15c7:b0:1f0:45e0:e40d with SMTP id y7-20020a05600015c700b001f045e0e40dmr2921118wry.343.1646258596840; Wed, 02 Mar 2022 14:03:16 -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:16 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Wed, 2 Mar 2022 22:03:02 +0000 Message-Id: <20220302220304.1327896-4-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 Subject: [libcamera-devel] [PATCH v3 3/5] media: entity: Add link_type_name() helper 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: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Now we have three types of media link, printing the right name during debug output is slightly more complicated. Add a helper function to make it easier. Reviewed-by: Laurent Pinchart Signed-off-by: Daniel Scally Reviewed-by: Jean-Michel Hautbois --- Changes since v2: - None Changes since v1: - renamed function to link_type_name() (Laurent) Changes since the rfc: - new patch drivers/media/mc/mc-entity.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index d0563ee4b28b..1a7d0a4fb9e8 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -44,6 +44,20 @@ static inline const char *intf_type(struct media_interface *intf) } }; +static inline const char *link_type_name(struct media_link *link) +{ + switch (link->flags & MEDIA_LNK_FL_LINK_TYPE) { + case MEDIA_LNK_FL_DATA_LINK: + return "data"; + case MEDIA_LNK_FL_INTERFACE_LINK: + return "interface"; + case MEDIA_LNK_FL_ANCILLARY_LINK: + return "ancillary"; + default: + return "unknown"; + } +} + __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max) { @@ -89,9 +103,7 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) dev_dbg(gobj->mdev->dev, "%s id %u: %s link id %u ==> id %u\n", - event_name, media_id(gobj), - media_type(link->gobj0) == MEDIA_GRAPH_PAD ? - "data" : "interface", + event_name, media_id(gobj), link_type_name(link), media_id(link->gobj0), media_id(link->gobj1)); break; 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: 15401 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 244EEC3261 for ; Wed, 2 Mar 2022 22:03:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31B956117D; Wed, 2 Mar 2022 23:03:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KkKr+64t"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E4226116B for ; Wed, 2 Mar 2022 23:03:18 +0100 (CET) Received: by mail-wr1-x436.google.com with SMTP id u1so4882698wrg.11 for ; Wed, 02 Mar 2022 14:03:18 -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=1p4Gc3dBM5NZZ/HBJ8or5GyJkdZjQg3trnAoYVnJ1nB3+0gJpzI+6me8I8IA6JZHD7 duzUAE3goUiphbTWH9JjwGnBkGpw/gUw8iuX8wYzK+KunbAIl2vo0G7eBPK65p4QVGvy p371sLhp0T7x5iwhUXYRGxqDZAixBenMbKYvSZ5pD0jJZjU7CHfgefQdkLNVGQrjhFBd v2kF0tXb2sH7Vvy9ySLhpPz5C+Wlf9WpzIcPVvXd1lk0wLrNZPqUpY7pd4Pp1wwEaC8/ +e3eZ8+5RKXvVjAdZ9+VMD8HQXpEQwR1TQbYPWesuQdWflSyYQ+6eV8XVbSSidImGbAT daMw== X-Gm-Message-State: AOAM533X7KGiE2Js/8URNwPKZ9N2lRFA27EDNMjQpIu3QpQIyyd3At6g GZj2gzxE6s2ZO/kb3I7RhqU= 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 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 Subject: [libcamera-devel] [PATCH v3 4/5] media: entity: Add support for ancillary links 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: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 From patchwork Wed Mar 2 22:03:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15402 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 21A89BE08A for ; Wed, 2 Mar 2022 22:03:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C918861185; Wed, 2 Mar 2022 23:03:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XUyuvemJ"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 05BE661176 for ; Wed, 2 Mar 2022 23:03:19 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id b5so4927730wrr.2 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=7+FTeVrGz7SDdPY4UPOaMR4mAYUB8c53cmn+nXuAyMQ=; b=XUyuvemJYa0uAPOj7k1G9IzitT9VXfDcKWXDcEhdYDSJCfn/HU7OkbxGM5iO6MemUb lV3mCqItMcPQB0EK6wYMqh7ToMdUlCmyNIhbOWG1fJ/aru63wO0k/xKZwjJS2/QDq4dk RopjcHiTUEMSXcJhj/x9l16gFI7wpJ7hI/zdL++voTzJR3Gy18mSFaXypTqxOcByPaao XzD4+mib6HCoy6psPvbeTt4gr8KJ6sMpsmMSN8i5ccTPLm3R6h6K/iHrT3v03XaaSJKo e20Gjg7+bHyOjUWXiSB0dF5XWNH0ftXbJ1PdvkypVpJCMhg5aAM6efH1HSus13BfdXOV PuiA== 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=7+FTeVrGz7SDdPY4UPOaMR4mAYUB8c53cmn+nXuAyMQ=; b=FEIUURXgSgsiHl0xlad1d6k0DOTa1fItURr0dJworN0zbOyj3x+MU/IOiGMvsX4YNq rZTLu/rFR/tKaRE2BEdfyeORAOOa58vIu/bTfWQFO/IZcAxTXelC1EKxBhM4FGyhTtwd 8MDlj1FOHjnai6ZrWq+42uxpreEcJYEKGCSZagoRS4cQJ6DqjzRIoriT6Ut2Yqg81ufU kz5pZqfh1b1LYu2hUOFttiA7ym3sPYBZCHIwIY4p7LDxV/1E4S0patZTWGBMyMOHW+St XLg+KdnjdMuCyT9oOvSYfNF5z0CxrNeaheYgx/gdYw8bHuCVRE1lxFKz4SK1lqOQoSal zOjQ== X-Gm-Message-State: AOAM533qOC8R6+dQNQYq+hlcKcW1+KBcHVdjC1+VQb9Ghv+BewROkVEg 3wN0sMZdSqX4Sx3FQO4FB58= X-Google-Smtp-Source: ABdhPJz1z6DPBD7bhcCCeO9fFebsmUH9yJLSFoHKDSYe79QR+HkAQD7iFfp63LfGerWLD27PjJv+Hg== X-Received: by 2002:a5d:4310:0:b0:1ef:fb60:e1d8 with SMTP id h16-20020a5d4310000000b001effb60e1d8mr9095465wrq.92.1646258598715; Wed, 02 Mar 2022 14:03:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:03:18 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Wed, 2 Mar 2022 22:03:04 +0000 Message-Id: <20220302220304.1327896-6-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 Subject: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create links during v4l2_async_match_notify() 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: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Upon an async fwnode match, there's some typical behaviour that the notifier and matching subdev will want to do. For example, a notifier representing a sensor matching to an async subdev representing its VCM will want to create an ancillary link to expose that relationship to userspace. To avoid lots of code in individual drivers, try to build these links within v4l2 core. Signed-off-by: Daniel Scally Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart --- Changes since v2: - Stopped checking the notifier entity's function when creating the new links, and just create them whenever the subdev entity's function is either a lens controller or a flash. (Sakari) Changes since v1: - Added #ifdef guards for CONFIG_MEDIA_CONTROLLER - Some spelling and nomenclature cleanup (Laurent) Changes since the rfc: - None drivers/media/v4l2-core/v4l2-async.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 0404267f1ae4..436bd6900fd8 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -275,6 +275,24 @@ v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier) static int v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier); +static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, + struct v4l2_subdev *sd) +{ + struct media_link *link = NULL; + +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) + + if (sd->entity.function != MEDIA_ENT_F_LENS && + sd->entity.function != MEDIA_ENT_F_FLASH) + return 0; + + link = media_create_ancillary_link(&n->sd->entity, &sd->entity); + +#endif + + return IS_ERR(link) ? PTR_ERR(link) : 0; +} + static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, struct v4l2_device *v4l2_dev, struct v4l2_subdev *sd, @@ -293,6 +311,19 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, return ret; } + /* + * Depending of the function of the entities involved, we may want to + * create links between them (for example between a sensor and its lens + * or between a sensor's source pad and the connected device's sink + * pad). + */ + ret = v4l2_async_create_ancillary_links(notifier, sd); + if (ret) { + v4l2_async_nf_call_unbind(notifier, sd, asd); + v4l2_device_unregister_subdev(sd); + return ret; + } + /* Remove from the waiting list */ list_del(&asd->list); sd->asd = asd;