From patchwork Sun Jan 30 23:58:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15298 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 4A465BDCBF for ; Sun, 30 Jan 2022 23:59:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 040FE609D6; Mon, 31 Jan 2022 00:59:10 +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="nYgorl02"; 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 6EEB36017A for ; Mon, 31 Jan 2022 00:59:07 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id l25so21992977wrb.13 for ; Sun, 30 Jan 2022 15:59:07 -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=KKgmf5edtGbJ9h0LX6rTJGe7gf+2myJfiAdHSNMIYE4=; b=nYgorl02OBSDDoz2QxOJC326/TYULEbc85Zv6g28GOEBMSx3GXxLBU58R7vfoLOH5g rV8QrgkA0jVq+M9+xwDY+wpEroN2jdpiptPsihygQ3DF++4UqU47ewCcUwmoe+fJ64dZ EbhGt3Saxr6gnQYDdsDKVGjd1SzP6RXM/XYi8zmC0aJb24CdWGEo3/7r32Sq+zedfJi2 kmldQkOU62qPVo5mglljgwhW3YMj5TuluAPn54d7nM5QBwYzqiTLRZRzrvjANSEkYNp4 ovhsLy4a4E3xVJM7OzD6W6aGyMekp4x/1vGY+ltj4TVh1Q3rJRckcZWobVow9OJXHuV3 YxyQ== 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=KKgmf5edtGbJ9h0LX6rTJGe7gf+2myJfiAdHSNMIYE4=; b=bL9+kzpddYskkHICS/xpukEHK5QoqULZ9I4H3LLg+WIDiRT/Pvq2S+jUJraG5BWrZx C2QdhksxRY/D8s1nSuyupj0uHXQBQ+ZkU8WE82cJFoxvSwO55m31tG9v89i5y0YQ8sD0 jzC5MIjNReoLOX/uuEXgYVHHq1B20hftm6+jzmRorqo81p5raZQPfw5/txYu0KZoTkaX OjFcxBaDzhBOXZCfvuP+x0FmWb7U3Gi8C+pXblv11cJZILXfciCZnr3PTDsawi6Ivfyb 9FrzVj1vrLRzM4fMN7+TvE311sDLu9lI9vwhCLtIpp7l0sMyoYGeqsMV5lTS+PriyWpF 7Z8A== X-Gm-Message-State: AOAM531noBX82tFb347xA86dpWT8dcIR5cmzeGFdD1EHebkaaes9jNrs 7ByHIx7coOmz6zJPTUlGDK0Rb73cLfc= X-Google-Smtp-Source: ABdhPJy6S71fEhugp7GLdCYTygZWbK5lcBNNm0V6Ac0Tba1URoZGFjJWELe82FhEZDh+HHnuWLxBCw== X-Received: by 2002:adf:f312:: with SMTP id i18mr14806019wro.441.1643587147127; Sun, 30 Jan 2022 15:59:07 -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 11sm11993663wrb.30.2022.01.30.15.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:06 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:16 +0000 Message-Id: <20220130235821.48076-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/6] 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 --- 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 f40f41977142..2a6e16fb0048 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -313,6 +313,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 Sun Jan 30 23:58:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15299 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 52EF3BDCBF for ; Sun, 30 Jan 2022 23:59:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5EC5E609E4; Mon, 31 Jan 2022 00:59:11 +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="R+kuABtg"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 310BB60986 for ; Mon, 31 Jan 2022 00:59:08 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id m14so21835260wrg.12 for ; Sun, 30 Jan 2022 15:59:08 -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=w0T9EcKMpQUVHCpgvBm4+xMsufqtQ6UT10jHk3vORD0=; b=R+kuABtgCl3FMxDyxw9I8pPuCBuFIZqnzmqPi7FsQIW6P5Hg09ySwXKlTBnsXp9xlM pYBEfehgI/0jyxXOEKxQnpCGcT4Jkhi3jd3pPvGkyMXFCGz+4myzTtHm+m8vEtHkISGC h/gd+Ttk6jKDn8RQKY1+YvmWj9YrH3Dn/ZKc8cdvQ/9O5gFb5c1/XHGXqyjaFvoW30+0 w/iWId/zKjg2HRNJpXQ6FY+lhokvoC2ia0TXZkzfkzhdyoah1ZKZr2C7lRz924vLFzNt YLVI4jBPviByhK4aoqHYwlazfFAJ3mIM0v1UEVcP/875jAg8msV/74fXcg0Xt1iP7qlU Tiaw== 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=w0T9EcKMpQUVHCpgvBm4+xMsufqtQ6UT10jHk3vORD0=; b=p1xWemv8M6Rg0QOYFIN3OuWvXDIishCGQL6lSQRviXZ26U5JBSsAdMRcLvTW9/PxPM Gh/8ohjHYV5iN8OKWTe6D2ozu2zUtJDilb1/7+OtlC679ElpLJKqOau3q9I1lRUE52EA DclDcLOwPme8uxrErdTJJxO3Z1+FRE08vbUH4fH2cMKEvBNGSDqxQUvmIijv57RXrwj4 /e/x/VfgiKiS8XwukDlwhL4RwjoWtY3SYKjNfaQ3LwmcgvFGhzDKWpRwKmF7FYDZqaqq Qzf5qQMRat22QExoSLXFTExcZHLNN4IpWa9IcyaG2/aalulR/aFTkRualdUO84iJeCWy sO3w== X-Gm-Message-State: AOAM532yduNmxZT1ZBy+rb5Up203rzgzF8mY36QKAcvwu8II2Y+ZuQXB dsA44vCljB9ArO0Pks4OAo4= X-Google-Smtp-Source: ABdhPJybaDovEa+FfJYHdDFeryAbCdBtmsrr6X9qpt2t18dQ/hIqOImMamQVlLcBeBjC++7Ummelhw== X-Received: by 2002:a5d:64e5:: with SMTP id g5mr6828398wri.162.1643587148012; Sun, 30 Jan 2022 15:59:08 -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 11sm11993663wrb.30.2022.01.30.15.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:07 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:17 +0000 Message-Id: <20220130235821.48076-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] 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. Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- 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) include/uapi/linux/media.h | 1 + 1 file changed, 1 insertion(+) 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 Sun Jan 30 23:58:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15300 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 18780BDCBF for ; Sun, 30 Jan 2022 23:59:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F2D63609EA; Mon, 31 Jan 2022 00:59:11 +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="GSmf0mux"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F85B60986 for ; Mon, 31 Jan 2022 00:59:09 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso8190591wms.4 for ; Sun, 30 Jan 2022 15:59:09 -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=3jJ0g27dpE1FUu3MPy8YxNnCH8nvgWy6GR4rkrcef5o=; b=GSmf0muxy9deZ2hL+lVMfPRZ9wWaJDwAM7NcmHet2TImu1Y0ImdwB2qX6il+G6+C0c PpRMV1do1RnOhkTF3hrOv9nIButtvsI8m1zzvHOV7RBrF82gobVzP54IJZhozx+jicfn hI0TBoNdxjGJJqwWXaXzcfQqDgtCprqNho6Ji5tq5os2OSnuJRN8L0Uwfmcz3L6c5Ual 5xZiRSTt5N2tY70ns5rHK2rfWUPusuQQZsV6di6c2gsx+gd9k6w0hfALtw+VshGFm4NJ KixHFg5VUCGrHDO9nAClNuLrjzvkVlCxJPhBcimYS8i6FT6ZCSHghFWMtw9hMBrbEGlO ayEQ== 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=3jJ0g27dpE1FUu3MPy8YxNnCH8nvgWy6GR4rkrcef5o=; b=rzq50ih+KYutwnuLrvfQNDKnA0ZPqF74xxnP1uIFQCqCHJlMWMQKf6pfD6Lom/PR5l XV2OV4/qW/3+QhH58DKl7x0d1H/dx5mYkVVhdnACnSU3hSdKs6cdrvg2iXss4VqHJL4x oj6e6TMSDoGnX10jH8ILaFSj9xSQzGFb6QuFY5AxvjnMwO8ypcaeahxTZXi6s314EeW4 /saf+NqUfFgAzHsuHM09GXXaZyb4oKAn2jkXhIPMOyQjOqlk4NLnO4v/ddr6foy//OgV sYVu4CsJV6krSM4sCSn3V8nHb97/QiPAN2a1qz6myLDYAin/ZwGolZsdzQVADPwKfU+E iw/A== X-Gm-Message-State: AOAM531FbDcpCp6eWZLjb0C6/wmIbg5Z0lWH5mLBarctIglcGR92/BBA Wsu5HiI5wK8vpN64hQ+u21I= X-Google-Smtp-Source: ABdhPJzSV5eAjHoUiE6Tb04AF1J4I8wvc/pfMPqepm8Ru1a3nU6DkeuKalY3PAG2cPf8E1daEETexA== X-Received: by 2002:a7b:cbda:: with SMTP id n26mr25225403wmi.76.1643587148829; Sun, 30 Jan 2022 15:59:08 -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 11sm11993663wrb.30.2022.01.30.15.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:08 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:18 +0000 Message-Id: <20220130235821.48076-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] media: docs: Add entries documenting 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 some elements to the uAPI documentation to explain the new link type, their purpose and some aspects of their current implementation. Signed-off-by: Daniel Scally --- Changes since v1: - New patch .../media/mediactl/media-controller-model.rst | 6 ++++++ .../userspace-api/media/mediactl/media-types.rst | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/mediactl/media-controller-model.rst b/Documentation/userspace-api/media/mediactl/media-controller-model.rst index 222cb99debb5..f77cb9d952e5 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 describing a physical + relationship between two entities. 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..d69bae359e5b 100644 --- a/Documentation/userspace-api/media/mediactl/media-types.rst +++ b/Documentation/userspace-api/media/mediactl/media-types.rst @@ -413,7 +413,7 @@ must be set for every pad. * - ``MEDIA_LNK_FL_LINK_TYPE`` - This is a bitmask that defines the type of the link. Currently, - two types of links are supported: + three types of links are supported: .. _MEDIA-LNK-FL-DATA-LINK: @@ -423,3 +423,10 @@ must be set for every pad. ``MEDIA_LNK_FL_INTERFACE_LINK`` if the link is between an interface and an entity + + .. _MEDIA-LNK-FL-ANCILLARY-LINK: + + ``MEDIA_LNK_FL_ANCILLARY_LINK`` if the link is between two + different entities. This at present implies both MEDIA_LNK_FL_ENABLED + and MEDIA_LNK_FL_IMMUTABLE, however applications should not rely on + that being the case in the future. From patchwork Sun Jan 30 23:58:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15301 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 247D0BDCBF for ; Sun, 30 Jan 2022 23:59:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2AB4609F2; Mon, 31 Jan 2022 00:59:14 +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="mi2/QUg5"; 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 DF81D609DD for ; Mon, 31 Jan 2022 00:59:09 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id s9so22036845wrb.6 for ; Sun, 30 Jan 2022 15:59:09 -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=OPpoJnU/qyg2/VoeGoW1Rn4aPz6S0A9ibACKGoGZN18=; b=mi2/QUg5gWiGvQqVrMJ9tD3a+99R4h/pf625IaJ5ekxUwfe734jVrYfEvS85V7l82X Ki2ZNyC4CmrYAdOhONydYzPPH/nkEbr7yvZfJrBqWfi9EgYKJ2GcPq9S95q4z2TpH8lD +qvFsW2c5zoy52JHyL3IWnmxVzoKFUWDcsL668OxOy5CtbiRNRhgpuHJs4mF0T1BY9y5 xHnb9JAmFP8TSUD9I5LHLfjlsHDhczP1rVnFdq7iqoLZsFcvRnNVAn4+LK82R12OIKjD 7snvR3fzYVdRcjPD2t4m+eNDVf99bHr/EIL0nv77fY903gPOumGeARe1NQp1ZaT0cZ++ n36g== 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=OPpoJnU/qyg2/VoeGoW1Rn4aPz6S0A9ibACKGoGZN18=; b=4sd895W/g4MThcByKKWkQrJXyP3Fc30XitGWnaBE2XnDffmBj1n6XPrePZefKVzRJ1 D+/7MNVM2MtAeRYgYae1kLEzxK7TG+jjy+Sbl0aaCs6zjv0iAg1hYP05xUvMCTfEVgOC D0cSR3lIDA5/41baUXTUJuRILK7txelydSazUF42RRf35excrz9Ygsc8N2EjbY8fM9Nc X0RqTjPGVvOY8mNcr6wH4/iUs1XmYxflskapjT/VZKX+l7NfCcsdJBlemXT8rWBCjD/Z ZiaH4lvlnzqTqDY68C9P2wrzYzaCwkjfYBmcXVjcmQRA45WnwpoLwxzZgUz/+KWTA4Io cRRg== X-Gm-Message-State: AOAM532qp2b8FrIipnpUHlPkdUEsXVkY/bU/5wzukC/XbfO0vmQmcirZ lEHEkJR5qA6uRTgl2qMfvFo= X-Google-Smtp-Source: ABdhPJw/ZKDFFuQpy2pfkYk48xdzvk7TXgvZRkEm9DSG5fVyY1ZAxYR7N9RhYmUdcddXvCxA23DvNg== X-Received: by 2002:a5d:47cf:: with SMTP id o15mr15151828wrc.577.1643587149642; Sun, 30 Jan 2022 15:59:09 -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 11sm11993663wrb.30.2022.01.30.15.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:09 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:19 +0000 Message-Id: <20220130235821.48076-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] 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 --- 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 2a6e16fb0048..29d1285c805a 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -60,6 +60,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) { @@ -107,9 +121,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 Sun Jan 30 23:58:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15302 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 C8926BDCBF for ; Sun, 30 Jan 2022 23:59:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7597B609EF; Mon, 31 Jan 2022 00:59:15 +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="kvI+t8u3"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C6F4360986 for ; Mon, 31 Jan 2022 00:59:10 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id k6-20020a05600c1c8600b003524656034cso5139358wms.2 for ; Sun, 30 Jan 2022 15:59:10 -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=/aoh8o1GHLWarjipXS3EzkDQkIHXyhnCnloR5RFP+40=; b=kvI+t8u3jyndZQNunoe4nqv47WHuRbg4YPSv6Odo6OPiEv0im85w6vzCQGWxAkcvz7 fYxBerJdUuzJmgl+KiaNOtysT+v7v8vvKp1sjViqAyXvlJa9bqVw/HRJfKtVeOPciuF9 eFx5UsvDTw/Y8VXf5tp5DX2tFW+AfnG2vySSGDv9Woi9A83ZmFrBaT270fACqTkrXQrG fYdOf9a41mF8a5X8tIJhaFbtG6zwFMW73pX6czKS4jY6Q6sAgHUBRu498nJWPuwlk5LM qiqOK7HjmKOyDWDEGrgDLTH1UW4sWKfb23C8kagWJGJFfSoTTjoBJOLSqFByP4tLVx/f Exwg== 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=/aoh8o1GHLWarjipXS3EzkDQkIHXyhnCnloR5RFP+40=; b=MxJgfrLN5LY29M3MKdYI7/XHboQRd+fOy3msLBarXoHmIotQKOWuLm31BNWaYMzPmW HenRPtEcEqRUp++qI7IWsNEbhCEcJSSwXOMv44Ja+I4jYqLcvL0CNq1/AfpnsUzHXqG1 whxFygOdjpVaGV1AVxRDRjaZ8wKtJf1zeCdxFjXHiJU0nrg0j1ea6GgWGe8FDTEaJMEd 7KPvAH3NKmt+eatFHRGGdDIvVVB+E1UoAYpPmcYHfBNSGMOuRoBTE/7uBPgfF41DJboI kBNbvx6KwYmfpeQTUmr4rgTh0BSG2zMNaTrq8teJob4plZwzYM3lqQoddvL+xKLFA/Ae OuMQ== X-Gm-Message-State: AOAM532wZK3yEPSwdVPPrdBqeIt9+IKIvul1z2HLJN5QSMqZ0X3BGofF LL19f/GgbjXVbsuvO96tCbQ= X-Google-Smtp-Source: ABdhPJwB2XKV5p1z3Kvb7mNjKR3Vd7lXlpF4KogSPjUFaFQ8nYHq8v9r65qUazoAf/YqbaAlX+nXUA== X-Received: by 2002:a05:600c:2053:: with SMTP id p19mr24905342wmg.29.1643587150560; Sun, 30 Jan 2022 15:59:10 -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 11sm11993663wrb.30.2022.01.30.15.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:10 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:20 +0000 Message-Id: <20220130235821.48076-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] 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. Signed-off-by: Daniel Scally Reported-by: kernel test robot Reviewed-by: Laurent Pinchart --- 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 | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 29d1285c805a..7bf2c73a3886 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -1050,3 +1050,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..afeda41ece4c 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -1104,6 +1104,27 @@ void media_remove_intf_links(struct media_interface *intf); * it will issue a call to @operation\(@entity, @args\). */ +/** + * 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 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. This behaviour may be subject to change in the future, so + * userspace applications using ancillary links should ensure that ancillary + * links are enabled when in use. + */ +struct media_link * +media_create_ancillary_link(struct media_entity *primary, + struct media_entity *ancillary); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) From patchwork Sun Jan 30 23:58:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15303 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 575CDBDCBF for ; Sun, 30 Jan 2022 23:59:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0606B609F0; Mon, 31 Jan 2022 00:59:16 +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="aohO9Go1"; 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 A97BB609DD for ; Mon, 31 Jan 2022 00:59:11 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id c23so22070673wrb.5 for ; Sun, 30 Jan 2022 15:59:11 -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=TsRQ3SVohkOtQPdF+FWJeJ2VqSG/vDGg0tiEtAOREIM=; b=aohO9Go1mMW0DmLUPrYqXyicUFMJyZx4iDGeZkMMH8GF1eUI891taRf+dpuYnTxhEX ZFRrGidCc9f73wRKfXxEhsjQS0qStKvs17lQwTHDBiEy8fI3K8PuS2qSFmgyw/sRJGdC Zm2rx+Kj2uhaOtV03ubWuiu3LVs2QKTchhGZ1bXO8WD+VkaEgBOCpvjdqghPrenpEysp KUMhdmDBMZRvjCv8bwRrf+M2A5eU0uJouxa3FlY72PHTjKKz6ElsQ5GQ9Ka6aeOuKMB5 HUtsfgsFtsMtQfpgty6LXJLLUoOBhINN7GHBNpRAOidPljzo6NT9SknApF3l9J6wTqDn c+KA== 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=TsRQ3SVohkOtQPdF+FWJeJ2VqSG/vDGg0tiEtAOREIM=; b=LMkB7KpJuo1wQz/194wnGgWCRxf4r28XaSzCxFJadp4E1J9EsqMi66mV9NuPEWYHpa CRFKL6oaX2VPwbqOzrwVo60FDvzenrDZrBNsNU5hphseAWdqkje1houT7uEgMLkUhR7+ pLEv0li3XIaraF0vlhdX68tXnmGjH9P0wTbIWSfM9BcUdaE2ALoetl8h4pa0FztpYVOH oWCoBX7K0QVQSxTq7RrqGCNZSR9lbek15SXROosAWo/MtzsJbnyVmxA7IkLV7tNWqOVX /Y57G43RX4aVQt+My9gxpBD6rN+TUaT9WYMcE2b2003Vr61c+K8gTuExV+qOv7jYLCiZ OR0w== X-Gm-Message-State: AOAM532Fk2wy4DPc63N53db2oQviP+incBquZsa7BBF4kVYB45TMF0mh YAPOqapjN+6PA8x1KhMwtFI= X-Google-Smtp-Source: ABdhPJwo/8lAg1VcbfXGIKrXktZ/0c3eyIE8YP3e9uMMRaMJeJw2RBTuNYgQGzIvJ8PpwWybXlIm4w== X-Received: by 2002:a5d:4889:: with SMTP id g9mr14979816wrq.400.1643587151468; Sun, 30 Jan 2022 15:59:11 -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 11sm11993663wrb.30.2022.01.30.15.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:59:11 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Sun, 30 Jan 2022 23:58:21 +0000 Message-Id: <20220130235821.48076-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130235821.48076-1-djrscally@gmail.com> References: <20220130235821.48076-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/6] 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 --- 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 | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 0404267f1ae4..8980534e755e 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -275,6 +275,50 @@ 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_link(struct v4l2_async_notifier *notifier, + 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 -EINVAL; + + link = media_create_ancillary_link(¬ifier->sd->entity, &sd->entity); + +#endif + + return IS_ERR(link) ? PTR_ERR(link) : 0; +} + +/* + * Create links on behalf of the notifier and subdev, where it's obvious what + * should be done. At the moment, we only support cases where the notifier + * is a camera sensor and the subdev is a lens controller. + * + * TODO: Create data links if the notifier's function is + * MEDIA_ENT_F_VID_IF_BRIDGE and the subdev's is MEDIA_ENT_F_CAM_SENSOR. + */ +static int v4l2_async_try_create_links(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd) +{ +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) + + if (!notifier->sd) + return 0; + + switch (notifier->sd->entity.function) { + case MEDIA_ENT_F_CAM_SENSOR: + return __v4l2_async_create_ancillary_link(notifier, sd); + } + +#endif + return 0; +} + static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, struct v4l2_device *v4l2_dev, struct v4l2_subdev *sd, @@ -293,6 +337,18 @@ 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_try_create_links(notifier, sd); + if (ret) { + v4l2_device_unregister_subdev(sd); + return ret; + } + /* Remove from the waiting list */ list_del(&asd->list); sd->asd = asd;