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: 15156 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 85AF6C324B for ; Mon, 13 Dec 2021 23:29:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 17D8960897; Tue, 14 Dec 2021 00:29:08 +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="VZod9lOQ"; 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 B455060822 for ; Tue, 14 Dec 2021 00:29:05 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id o29so13113904wms.2 for ; Mon, 13 Dec 2021 15:29:05 -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=FO3IFgmS9QhY4m33QFlU6L82ULsui08tnMaqpIUxMST5chF78RgQlZ39Dc2Zp8b8LB JvLJG0x7yt198JooKrhpI33qcCGsT3UlBOsgpZRVdHKPTfwbQEGCS5U5jWQVKFYpfNBT ezJbcaxWgXteDE1F3jD4kZI7KGIjnDyD2uNGFxtE3ND7JLiu8HtmInUUTpotgOM1NI44 UlAaR4tZzaBR5G12V4PqAVJAcBiyXgKJNsXUUJUce12bfy+XhQN0+aaoVlocjtYjyvN6 ieQnoaF4cFHITdSt9dzuTLAO3kbF5y85QS7QEg0C5WwsTMCv0r9P+Fl1bNgS5py1CSBT Q0jw== X-Gm-Message-State: AOAM5338Siqwf7K+A/Yyialp1Kxm+RRxED65JBVNAUOxG+GAk0eGsDKE dgrE/H4IBQwJ/S/enIaKMwk= 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 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 Subject: [libcamera-devel] [PATCH 1/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. 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:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15157 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 733ADBF415 for ; Mon, 13 Dec 2021 23:29:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EDBD56089F; Tue, 14 Dec 2021 00:29:09 +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="fpit3Yup"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C1FEE6087E for ; Tue, 14 Dec 2021 00:29:06 +0100 (CET) Received: by mail-wr1-x42f.google.com with SMTP id u1so29549978wru.13 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=MgCtKC+Gd7kApujFsuR5TW5hz/ErAzIhf2rX5Pgmy5o=; b=fpit3YupVLRQCsiBB98paZPY/vws70ChOL/XADsgVF+afDYelu3wOsyXvfZp07Yf7o ndFBw+WRAtNMGJBYbZFUGgwLGzlp4qHkCjIYn04iy9f72bbyrJd/AUrbcGn2TM7XLNyU +cDf7APM95/8gyD9ibCDD59KxHrOJBokmhdBLlGPOOZy576lD2EEOZLKx2RggT01inI6 OsxdBUsGarGkvz9cqyR8hDzHL/ZGYDj+GFjPyEPdjDACCx9tyH8pVdmlI4OUaH4hD2UG NL5vpAuXU613PQv6iRCmiz81P7QZdJMaVrVJCvhxUVJaHeuCC/mNtOHGDFCMrkGJh/mM NIXA== 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=MgCtKC+Gd7kApujFsuR5TW5hz/ErAzIhf2rX5Pgmy5o=; b=LGkp5Ak+59HX5kcIFIdXHknrl56pr7ztEH2gtEyV1ZAxYe5MCrCtzxwxPgpL0tpfYX uH4DdlsmM/AxgHieWIaN8YKLtmww/lROQ+rIqZVsXe7nFipFL8j+754roTFok6dI+qCy uQGHItiX/l1VeNd8Uwj/LBGdlNB2RkVW38Ohvt+qacK2ZTOm8OzS6ecxkq4mxJ+u/dtZ LgyD+wtxwcu2wTEx0H1kKA19PyWCzxwjAXd3kYukSUHq0FgdCFa8wK9YXIkszWHkxn39 bqOr9tUOthTHz3YKvxUJW6sm5kaIpif78lOKlArXmkW6zRmE6CrE8x2MxIwGkjWpdXfK slwg== X-Gm-Message-State: AOAM533jD7r1oHIa/wjyjVlApGTufuleEMkC1dQUF1ymfxYTe2IV6b32 7vp/BfUrfdM5zF8Frc20Gl4= X-Google-Smtp-Source: ABdhPJx3yb6CKioC+of69sRZt9ZhFjNno0BY3/9Z+rr7mxoEowwx35RVewqpHNlQ6z/8uOlnrGS03g== X-Received: by 2002:adf:900f:: with SMTP id h15mr1736128wrh.562.1639438146517; Mon, 13 Dec 2021 15:29:06 -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.05 (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 Date: Mon, 13 Dec 2021 23:28:46 +0000 Message-Id: <20211213232849.40071-3-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 Subject: [libcamera-devel] [PATCH 2/5] media: entity: Add link_type() 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. Signed-off-by: Daniel Scally Reviewed-by: Laurent Pinchart --- 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 f40f41977142..d79eb88bc167 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(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(link), media_id(link->gobj0), media_id(link->gobj1)); break; 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: 15158 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 6A3F7C324B for ; Mon, 13 Dec 2021 23:29:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5E046088C; Tue, 14 Dec 2021 00:29: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="fxhgQRcO"; 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 B9A5E60822 for ; Tue, 14 Dec 2021 00:29:07 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id d24so29772502wra.0 for ; Mon, 13 Dec 2021 15:29: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=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=GpiHWBRP5OPa1M068KkX/ltd5mwxRk6nBXCOxbIaFGoISV83WKRmDzNwrTs6T9GI2Y pWqtiAYiF1t9bx+cjsDDPqxVNIDFWqLxCkkqk9rkdabiYjZSlRjH/DPKUYTiaMZ4Ndm9 Pwx2paziglgNfVbd8Pb/Op/vKPzf1Jft9492OgSomuY7uU2uuQctaxhQ6y8sDY0smwme EjU84H1Q2OYTcOO0OkKZ12Uj2sYDaNKLEw+H+1AAiA9dHIBZuT66hhorQUUJ6ZuDJdEn Nd2E4i8xhsGP28cLbyJW3bnF+PBfwwl2DeBZeMEIoUNxXEzsEts4E/rsLoc9XTX/Qwvc XSjw== X-Gm-Message-State: AOAM533c5/CQQ3U0Q5+9AyO+MPRIupxbkot1uL/dN42/E1/c69KetqwQ dlZBsR1gfFsz0YjtHg1o5Rs= 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 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 Subject: [libcamera-devel] [PATCH 3/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 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: 15159 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 1CE5AC3258 for ; Mon, 13 Dec 2021 23:29:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A016D60876; Tue, 14 Dec 2021 00:29: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="jZw8QXwr"; 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 ACF2660822 for ; Tue, 14 Dec 2021 00:29:08 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id v11so29606622wrw.10 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=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=T8Te9SMwWL6xzZDdStNrvZCxyxb2sw46A/KspgBmNm+Q/tiOWE039D/V4cLQ8EthJn xyAbje5iLGaewlbtjm0e74OzosAZ21di1lPAEodQHKaAHI5OdZ8KT2CBZ+1oCRBsOH/P cvUfoBSCsRMrfHFV514A5fP9feQT35qMMNqsAqHeEKUaxYfIQTVLzynvYn3HsC/3ol1l 0BOuy5SYqFvElJZoLMjAoCRntwk1yAzJtDiXcARAe8uoQjW8TrJZTKUWAG5WsoffIppm 4dDTUQFASajzSVKQ2Ou7XNZJcqX5Co6lwxp6Phof0Hm8IypAL5md6u+I/qHFRTctp1n4 J1pg== X-Gm-Message-State: AOAM530vWWQ8yGhJ02xjZagbKvSKW4WG3LTe4wVMW+EswovUrTYcmnkw 3xeFKqwoHbVWaTk/UPizQ9Y= 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 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 Subject: [libcamera-devel] [PATCH 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 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) From patchwork Mon Dec 13 23:28:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15160 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 8F9AEBF415 for ; Mon, 13 Dec 2021 23:29:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19BA3608A5; Tue, 14 Dec 2021 00:29:12 +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="aOtZvsZu"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 872D96089A for ; Tue, 14 Dec 2021 00:29:09 +0100 (CET) Received: by mail-wr1-x432.google.com with SMTP id v11so29606658wrw.10 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=zPcgwKf+mxuvjKfph3hk9rnBdcEBzs1sgAB4FsNazWI=; b=aOtZvsZuASZ8nN15qXvrkYoGXMz++nvFlabc3Tqvs1q/Qe00IAACWvhcef4XiKdZ4x MMgyPxuyiB0bhlIGGFx12I3CjVJMzDOc1VFOtfm0xiHBF7h3xhU8zt5rlBDhOxdYM+QM 6d0aU/DDa97+9TY9yLQCqBm8cVc/Xxu5+Q8aH1VFU+LwIMPULOyPhw/y1URN6jQMc5p+ Bxxx2VV/Fe0rRfSuIRO5iqv8uq5J082aU5RbK1USCXe86qsWWA1kLU9fymvG/enIoOZe ojk13skpn/WGCVs1wi5dTbRbVQv+mQIRjf4skzJe9CXBa5yKAeXXPbjcRzhweePZ2g8x FRjw== 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=zPcgwKf+mxuvjKfph3hk9rnBdcEBzs1sgAB4FsNazWI=; b=JiSESxPR158GpgPbXIOTKaeTW07raXj40FHKNgZLmtYDMVIiaxw4cMFArs15xGminO 4QRTUMWNMb8dFFMSD7lL46ZOly3p1jHF/n2U4Bwm8HWjWsFPVrhM7YGvN5heuAxKstbZ 9SqYt2KnEOv402lNWgddm+YuP0SFRYjQPeJ5ab9/+w/s97ppnyCR8KrOrkrZLuRvWH1P 0C23S4dssi7Vsi5wzCyY42Zghc29bDCVDq3SIjgjlOzPR+Ip7+0LzbYQB3gRfr9qME68 /JTaYsdgXoeLEOBmjNqyBogqJSautRh+cHcPkQWPx9EhcJpvnOzTqFjKh/9GemKywUb0 Zclg== X-Gm-Message-State: AOAM531HkYG7u9tDC7SZ8Iyck6r1kixZhLDHsoz8b/YPeRmQOyku84g9 lkUa6e0QMZpaTFJzH4exeh0= X-Google-Smtp-Source: ABdhPJwhIpe9gU+vpL+2cw8coxTBn7ak04EInINQaeKsxpW+bKWAFZN3VmhUaRERQaTFEgRJxoXUGg== X-Received: by 2002:adf:fb09:: with SMTP id c9mr1678813wrr.223.1639438149280; Mon, 13 Dec 2021 15:29: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 38sm12551643wrc.1.2021.12.13.15.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 15:29:08 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Mon, 13 Dec 2021 23:28:49 +0000 Message-Id: <20211213232849.40071-6-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 Subject: [libcamera-devel] [PATCH 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 Reported-by: kernel test robot --- Changes since the rfc: - None drivers/media/v4l2-core/v4l2-async.c | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 0404267f1ae4..6575b1cbe95f 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -275,6 +275,45 @@ 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; + + 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, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + + return IS_ERR(link) ? PTR_ERR(link) : 0; +} + +/* + * Setup 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 sensor and the subdev is a lens. + * + * TODO: Setup pad 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 (!notifier->sd) + return 0; + + switch (notifier->sd->entity.function) { + case MEDIA_ENT_F_CAM_SENSOR: + return __v4l2_async_create_ancillary_link(notifier, sd); + default: + return 0; + } +} + static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, struct v4l2_device *v4l2_dev, struct v4l2_subdev *sd, @@ -293,6 +332,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;