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: 538365 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 EAD76C433FE for ; Sun, 30 Jan 2022 23:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239158AbiA3X7J (ORCPT ); Sun, 30 Jan 2022 18:59:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236438AbiA3X7I (ORCPT ); Sun, 30 Jan 2022 18:59:08 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2989C061714 for ; Sun, 30 Jan 2022 15:59:08 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id c23so22070464wrb.5 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=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=UnrcsAbzPoY8JlQKl2o7XHCYVYE/6EWEWFiN74slj3HllnYjMXJXJqNiGBR3t3J7N6 pKicSqSKW1L9LJuR2VB5Sv7pOlqz/aSeGQYzSJuz3v+W7S3e/cf/U6Ku/+w7vE6XbQUX FjJt9Zu4G0rtLaN0ivNGPZerZsK83++ZkEuaJLXpWrWGkBofqVRkZSATgRdxd2XO+c06 Xz3nGXYgIlwlESz8eIQYFrpw+z5qhVQP7cbobrM3HjgQTCYsmw5QN9cKx5kRzky4URNF cecHtKvM5m1POJHjUahM+LlsjNr05dgdbHycR9DExc5a0p1x36X8304poQz6KnazUfLS 70Ug== X-Gm-Message-State: AOAM532uNIXapZxzJ84lL2OZz6i5tGCqFPOtsjWtQK4zwIcaUoz3D0OO ZSUAocbhydfELFEv0ckY9g/5+oP0zi4= 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 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 v2 1/6] media: entity: Skip non-data links in graph iteration 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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: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: 538364 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 E9722C4332F for ; Sun, 30 Jan 2022 23:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243787AbiA3X7K (ORCPT ); Sun, 30 Jan 2022 18:59:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241651AbiA3X7K (ORCPT ); Sun, 30 Jan 2022 18:59:10 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24EFFC061714 for ; Sun, 30 Jan 2022 15:59:10 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id k6-20020a05600c1c8600b003524656034cso5139295wms.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=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=pBmN44RcQDD8DeX4VrHD0Myqho3yTErOqFZJAAh9GJWicPPNHmER7/72Vjoo4HbZfs lyfJwVePUELIvPt59QU21A2NhN56Y+6ovcUYLnysXam8lQaTioiMxAofRhUN1INmMAAW Mpm8fDWHw8Yy64n8+UVe+p9eX89WwcyL0F+1ee3OqCKvlG/wXQ6ftxOV0yb6MDIeUpp5 +gPAZ/Y8wuZmKPQVHHvDbObvVZYvBfXtIFY2wEPO+bXt3jPfTf3iwXNASvetaxhVrKFj 5po5DyyIeQYk+J3a++ivVDON6l6Qaa803BNqvVWpBGEwv51cVhiEVmPwoKwZDbfZYFMl zA2Q== X-Gm-Message-State: AOAM532P8eFUfv/IUYyukNbmcmcJdZTtKTgucp03TPUMkc/OcupBkQWG 4Fs622KKGnWVkKAI1oHI80MUfOIupz4= 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 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 v2 3/6] media: docs: Add entries documenting ancillary links 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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: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: 538363 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 6C62FC433EF for ; Sun, 30 Jan 2022 23:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243874AbiA3X7N (ORCPT ); Sun, 30 Jan 2022 18:59:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243865AbiA3X7M (ORCPT ); Sun, 30 Jan 2022 18:59:12 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E761EC061714 for ; Sun, 30 Jan 2022 15:59:11 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso8190626wms.4 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=/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=wZjqRv2/rxh96rpvZZbghuSDZvbd5UC3nPb4Eu8ZNDzk8dulT6CwQmm9AN+ssXSZ8O JSbRmmHaREibkC3KLcij7Mo7Vc/NAGB/+ZdBnUEzlTFpyJmB/z2mH7EykWgKxlzX6UYj dfqrVwX1UxilNsSZ8qKCe601ArtfQGIf2i1LZS/vEFBjeGu4jwpgt4YJRlXmRR55Pacc 4EA3h1fpAgj7ev0eSQ3v5o5qRJrzZ3bi9I+pKmUrp5dFg0wYgJCBXooglB4r6sXy/7Ee 42oDmBm29kteOBtDfzzK+F/JEvwNLk5eB+/oyWLzJHHEd4678hry3xNT614j6gZrS/Tc yzNw== X-Gm-Message-State: AOAM533ex2zULJohsp+SdF0F/pzFr1wfvhrR6xpgHgIqE34Pn74M0pei YEXofY+lCg/B92bPFjfLkKjcQbdX6G4= 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 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 v2 5/6] media: entity: Add support for ancillary links 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 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. Signed-off-by: Daniel Scally --- 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)