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)