From patchwork Mon Dec 13 23:28:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 523562 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 4BA03C433EF for ; Mon, 13 Dec 2021 23:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242527AbhLMX3I (ORCPT ); Mon, 13 Dec 2021 18:29:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241570AbhLMX3H (ORCPT ); Mon, 13 Dec 2021 18:29:07 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD239C061574 for ; Mon, 13 Dec 2021 15:29:06 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso15141041wms.2 for ; Mon, 13 Dec 2021 15:29:06 -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=px9+XC6KILpCFM/OBYzEGce6h7w6qpwXedz3WqQ/Q80=; b=VZod9lOQ40o1ezWVX5HyjyqmpmA8PWijZ6IzFH4CN6RghiQMhZK8vw6JDF0dWKCEsu FjBBkscMre4fu1mki2OOf7pfwKyhW3gOic+8dWgU+Vl9V3HYTfUxg7bv9gvzDtO2zk+3 ep6kHOFZmqmt/spw3cets6Tx+shhO7Ti9F/tNn/mtxvM0m8C/SMuN9JRSIKRcFQSwDPT JVKKHnRor7dF/fAuoKWnWsknVR3bBUnw5gXhcSnlpU0UOXGAKK4tXIzBfKE4jgWbz/MZ bo+O87sWlHuBH/MnAgce8dAnyQUmycE0vW0SfCUoUUOq+eYJiGRSfw3pJWMTwgp+ZVdL OK0g== 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=px9+XC6KILpCFM/OBYzEGce6h7w6qpwXedz3WqQ/Q80=; b=ZXTcf8uQigx0jIm8OhU+CsJ03xH7Gi8en+dZNZrwmgbjIs0wCty+uWi3lzFZBr9Bx6 h1IByWjlSNyyd9SJ+qKXhohxb2sm1AElMZ+FIfc37xwcNuT7ggelYHnx44HARkaw8PW4 D3vbWn5ASO6l3IRxtKWoZZw8pGxHmmTgM+4Exn/8XH+sDuXKTmX4Z8rJ4YFZ12w4S2vR fT5/UucZjZ7QWbbC0jLfmCyFScTAg+zOZkC8seR3WiOTwei1JgiSQ9Onu7ztmWtQo6Mu wsUcYLzEIMiDQRCsAiqkIcR/UKbZ/RqStNY02I1XG413b0KBfSAF/4XN6VepoKacskMY 7Lgg== X-Gm-Message-State: AOAM530Ao+3VyFLTz6X61gFh4eUYXva+4You0Syf96jZhypjCDw5riH2 fiwXl1crLQCNeCYz5hHdhbIycSJKSpc= X-Google-Smtp-Source: ABdhPJz0KF9cuTi+crVmS7GsbqpsTa7cz32Fux5g2fB7CyUR6msG62eWJ1Vxv4nXxICFvIz/FwlkGA== X-Received: by 2002:a1c:7517:: with SMTP id o23mr40854236wmc.172.1639438145465; Mon, 13 Dec 2021 15:29:05 -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 38sm12551643wrc.1.2021.12.13.15.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 15:29:05 -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 1/5] media: media.h: Add new media link type Date: Mon, 13 Dec 2021 23:28:45 +0000 Message-Id: <20211213232849.40071-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213232849.40071-1-djrscally@gmail.com> References: <20211213232849.40071-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. Signed-off-by: Daniel Scally --- 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 Mon Dec 13 23:28:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 523561 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 65C0EC433F5 for ; Mon, 13 Dec 2021 23:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244197AbhLMX3K (ORCPT ); Mon, 13 Dec 2021 18:29:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244195AbhLMX3J (ORCPT ); Mon, 13 Dec 2021 18:29:09 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A56C061574 for ; Mon, 13 Dec 2021 15:29:08 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id j3so29690128wrp.1 for ; Mon, 13 Dec 2021 15:29: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=YXsT7zHvatos7XfOBq5N+1fMVdHFdvEUedxZf+J7ouc=; b=fxhgQRcO3QjWRe/SJ1N8l/dwU94LkdYqBNc73Z3DonjM/hF0CBPS6bIUTinqONJnXI Fj5JsTofGIe+mNUj6MQXrhokJ2L1DAfmIgbzO/WhCbm/uwn3CHeW3TXGJl7UtqoNK/iF 7kVRRs3FARTEZys1ICGAWvwTag8auTAosg3Qf0J/BTFoSBBEuobmLZX41x4uzJD6gUh2 FIxSe/OLhu40D6B440Xgza0J7zTMhEeYrIuWepq3S4c4valO3XRg6q1roCx58dQC7ksn Btd+CWgDx96LGsAJ467f2/fUXnsdy0Tl5mFTmovBRiwD6z3P/OwoEAU6GP0BB8aEtrWf zuOw== 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=YXsT7zHvatos7XfOBq5N+1fMVdHFdvEUedxZf+J7ouc=; b=PEE9q4N3G85zW6KWy4ZP4nIN0vUfnWcaFCTJ3Ge1t8azbtAUAf/XxugIro5jlHXAnD 1Hl+DFgJwbBX4TyIMTxStoodg/YL7MQ5/AMDCmL9Z0QMz+pC+TV3s5wMw5jWpwaOHiEY MN/5dYTIFRfiywbQm/VYC2tkTSB8aA3Szq9wPiq0LcJY4ThGLZfQw2TfWUUOSTk3n401 kmm0UX94zr7dS6ggljpp4LyK+GUvwMKXrpx/lQSWY9iS7imEvXGfdP/OVYcEaT3iziqa czQDb1MK5xBA3SR+6PXLSQEISBY8ISFYGVMcz2WeyQewVCb9J6ndzibR/cz1RJlcGoiS hJNg== X-Gm-Message-State: AOAM532N6PB+Zql1ULni90xpsTH0HXp8FxLBVt1f7bdLjFUtsxIZOdH1 u4W1IJzCbfx6Kpe7FBhWYP0haJDlFbM= X-Google-Smtp-Source: ABdhPJxeFbxUyR8zW1g6fsTTqYu59SfX5eNdc/kncZmO/Gws0iR95QnRUxeRMq/ihdiJnI3MIsHU4Q== X-Received: by 2002:adf:f504:: with SMTP id q4mr1724215wro.698.1639438147393; Mon, 13 Dec 2021 15:29: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 38sm12551643wrc.1.2021.12.13.15.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 15:29:07 -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 3/5] media: entity: Skip non-data links in graph iteration Date: Mon, 13 Dec 2021 23:28:47 +0000 Message-Id: <20211213232849.40071-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213232849.40071-1-djrscally@gmail.com> References: <20211213232849.40071-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 pad-to-pad links. Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- Changes since the rfc: - new patch drivers/media/mc/mc-entity.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index d79eb88bc167..aeddc3f6310e 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -325,6 +325,14 @@ 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 pad-to-pad 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; + dev_dbg(entity->graph_obj.mdev->dev, "walk: skipping %s link\n", + link_type(link)); + 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 Mon Dec 13 23:28:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 523560 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 63D32C433FE for ; Mon, 13 Dec 2021 23:29:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244200AbhLMX3N (ORCPT ); Mon, 13 Dec 2021 18:29:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244154AbhLMX3K (ORCPT ); Mon, 13 Dec 2021 18:29:10 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7DCC061574 for ; Mon, 13 Dec 2021 15:29:09 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id u1so29550090wru.13 for ; Mon, 13 Dec 2021 15:29: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=WPmh++1yGOyffVNvBSBuVqzTMZyztDE2gAwt3atAco0=; b=jZw8QXwrR4JYgOck8siYAetE+xqhNFOOHpiMs4vysQyrym/KsUzR5sDe34pI2nrOy7 X4WokiJPeGPmrcu2RD6VOr66Fhlkc0K9HtcXHvaoC+vQZGG5vOi3WPM079kUKDiZWysc 2OP8Ox+DGgHkdNcMReO7h6lewL+9MnX4hq04789HxRUHYESPDoKEJ+V0Yfw+GDkBLHT3 EG3xzDTxCcAxj9PxLUv1k0SlWsJ+Jvz2BKB2WEwn4CbhHBP5AiTDZBgfkTq07/Ir0iOW lRASh0cQ670rur9OZ3rj81y8Cu+dewMBysnjYnnvsgtNCthIp4+rM0klQ7mahb9frrmR ceeQ== 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=WPmh++1yGOyffVNvBSBuVqzTMZyztDE2gAwt3atAco0=; b=4YHhNFE95KlfReVao5OUlPmR+ja7HuFp9kQZBpSDJQUhXOyATncgJijB3QpD2wlSfG ze2yiUSeIMLVnB/LkHE69DnNeQvmw5kSmeM8XBo6ubRTe5XeMprj/NNcM1JcwpCcs5eU PCtledZB01aHcQRqG6fwt5NTatJiKKHHcRPz4F3K8+mr/sHJ1tT881hdSzscF0mt0t9E Ws9LZdlXKzmXesBVJSqaeGaaPzASIQSoiB4uH3ZUeJ+VglKRn9QGQH2sCZxS9j60Psw0 7/bJy2CdrjONIKDWRdx2afzXIp8NQ8MBPazOD3LMHwyg1q/2MNvjZDi27eZu9S/xEm57 WOiw== X-Gm-Message-State: AOAM530MoVhWnIFz9eFNC3hYxxBiI56kEw9ftUPWFCanaeAIV6RLv75U U5pRzM0qLuar65H4LcK9Abpzpcq3pIE= X-Google-Smtp-Source: ABdhPJz/eyzP7nXkcRU67Nqk5nWkb5g2NtYqBejosKNlZW51Y0l8ElFV4zOVxORJrzW052JZ+wv+rQ== X-Received: by 2002:adf:cf11:: with SMTP id o17mr1767621wrj.554.1639438148418; Mon, 13 Dec 2021 15:29: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 38sm12551643wrc.1.2021.12.13.15.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 15:29:07 -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 4/5] media: entity: Add support for ancillary links Date: Mon, 13 Dec 2021 23:28:48 +0000 Message-Id: <20211213232849.40071-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213232849.40071-1-djrscally@gmail.com> References: <20211213232849.40071-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add functions to create and destroy ancillary links, so that they don't need to be manually created by users. Signed-off-by: Daniel Scally Reported-by: kernel test robot --- 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 | 30 ++++++++++++++++++++++++++++++ include/media/media-entity.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index aeddc3f6310e..4e39e100ea03 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -1052,3 +1052,33 @@ 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, + u32 flags) +{ + 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 = flags | MEDIA_LNK_FL_ANCILLARY_LINK; + + /* Initialize graph object embedded at 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); + +void media_remove_ancillary_link(struct media_link *link) +{ + list_del(&link->list); + media_gobj_destroy(&link->graph_obj); + kfree(link); +} +EXPORT_SYMBOL_GPL(media_remove_ancillary_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index fea489f03d57..f7b1738cef88 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -1104,6 +1104,35 @@ void media_remove_intf_links(struct media_interface *intf); * it will issue a call to @operation\(@entity, @args\). */ +/** + * media_create_ancillary_link() - creates a link between two entities + * + * @primary: pointer to the primary &media_entity + * @ancillary: pointer to the ancillary &media_entity + * @flags: Link flags, as defined in + * :ref:`include/uapi/linux/media.h ` + * ( seek for ``MEDIA_LNK_FL_*``) + * + * + * Valid values for flags: + * + * %MEDIA_LNK_FL_ENABLED + * Indicates that the two entities are 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. + * + * %MEDIA_LNK_FL_IMMUTABLE + * Indicates that the link enabled state can't be modified at runtime. If + * %MEDIA_LNK_FL_IMMUTABLE is set, then %MEDIA_LNK_FL_ENABLED must also be + * set, since an immutable link is always enabled. + */ +struct media_link * +media_create_ancillary_link(struct media_entity *primary, + struct media_entity *ancillary, + u32 flags); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)