{"id":15302,"url":"https://patchwork.libcamera.org/api/1.1/patches/15302/?format=json","web_url":"https://patchwork.libcamera.org/patch/15302/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220130235821.48076-6-djrscally@gmail.com>","date":"2022-01-30T23:58:20","name":"[libcamera-devel,v2,5/6] media: entity: Add support for ancillary links","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"e990619092a8ceb03b1f7dba405b5a9c78d86e8a","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/1.1/people/90/?format=json","name":"Daniel Scally","email":"djrscally@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15302/mbox/","series":[{"id":2904,"url":"https://patchwork.libcamera.org/api/1.1/series/2904/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2904","date":"2022-01-30T23:58:15","name":"Introduce ancillary links","version":2,"mbox":"https://patchwork.libcamera.org/series/2904/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15302/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15302/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C8926BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 30 Jan 2022 23:59:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7597B609EF;\n\tMon, 31 Jan 2022 00:59:15 +0100 (CET)","from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6F4360986\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Jan 2022 00:59:10 +0100 (CET)","by mail-wm1-x331.google.com with SMTP id\n\tk6-20020a05600c1c8600b003524656034cso5139358wms.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jan 2022 15:59:10 -0800 (PST)","from localhost.localdomain\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\t11sm11993663wrb.30.2022.01.30.15.59.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 30 Jan 2022 15:59:10 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kvI+t8u3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=/aoh8o1GHLWarjipXS3EzkDQkIHXyhnCnloR5RFP+40=;\n\tb=kvI+t8u3jyndZQNunoe4nqv47WHuRbg4YPSv6Odo6OPiEv0im85w6vzCQGWxAkcvz7\n\tfYxBerJdUuzJmgl+KiaNOtysT+v7v8vvKp1sjViqAyXvlJa9bqVw/HRJfKtVeOPciuF9\n\teFx5UsvDTw/Y8VXf5tp5DX2tFW+AfnG2vySSGDv9Woi9A83ZmFrBaT270fACqTkrXQrG\n\tfYdOf9a41mF8a5X8tIJhaFbtG6zwFMW73pX6czKS4jY6Q6sAgHUBRu498nJWPuwlk5LM\n\tqiqOK7HjmKOyDWDEGrgDLTH1UW4sWKfb23C8kagWJGJFfSoTTjoBJOLSqFByP4tLVx/f\n\tExwg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=/aoh8o1GHLWarjipXS3EzkDQkIHXyhnCnloR5RFP+40=;\n\tb=MxJgfrLN5LY29M3MKdYI7/XHboQRd+fOy3msLBarXoHmIotQKOWuLm31BNWaYMzPmW\n\tHenRPtEcEqRUp++qI7IWsNEbhCEcJSSwXOMv44Ja+I4jYqLcvL0CNq1/AfpnsUzHXqG1\n\twhxFygOdjpVaGV1AVxRDRjaZ8wKtJf1zeCdxFjXHiJU0nrg0j1ea6GgWGe8FDTEaJMEd\n\t7KPvAH3NKmt+eatFHRGGdDIvVVB+E1UoAYpPmcYHfBNSGMOuRoBTE/7uBPgfF41DJboI\n\tkBNbvx6KwYmfpeQTUmr4rgTh0BSG2zMNaTrq8teJob4plZwzYM3lqQoddvL+xKLFA/Ae\n\tOuMQ==","X-Gm-Message-State":"AOAM532wZK3yEPSwdVPPrdBqeIt9+IKIvul1z2HLJN5QSMqZ0X3BGofF\n\tLL19f/GgbjXVbsuvO96tCbQ=","X-Google-Smtp-Source":"ABdhPJwB2XKV5p1z3Kvb7mNjKR3Vd7lXlpF4KogSPjUFaFQ8nYHq8v9r65qUazoAf/YqbaAlX+nXUA==","X-Received":"by 2002:a05:600c:2053:: with SMTP id\n\tp19mr24905342wmg.29.1643587150560; \n\tSun, 30 Jan 2022 15:59:10 -0800 (PST)","From":"Daniel Scally <djrscally@gmail.com>","To":"linux-media@vger.kernel.org,\n\tlibcamera-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 5/6] media: entity: Add support for\n\tancillary links","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"sakari.ailus@linux.intel.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add functions to create ancillary links, so that they don't need to\nbe manually created by users.\n\nSigned-off-by: Daniel Scally <djrscally@gmail.com>\n---\n\nChanges since v1:\n\n\t- Hardcoded MEDIA_LINK_FL_IMMUTABLE and MEDIA_LINK_FL_ENABLED (Laurent)\n\nChanges since the rfc:\n\n\t- (Laurent) Set gobj0 and gobj1 directly instead of the other union\n\tmembers\n\t- (Laurent) Added MEDIA_LNK_FL_IMMUTABLE to the kerneldoc for the new\n\tcreate function\n\n drivers/media/mc/mc-entity.c | 22 ++++++++++++++++++++++\n include/media/media-entity.h | 21 +++++++++++++++++++++\n 2 files changed, 43 insertions(+)","diff":"diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c\nindex 29d1285c805a..7bf2c73a3886 100644\n--- a/drivers/media/mc/mc-entity.c\n+++ b/drivers/media/mc/mc-entity.c\n@@ -1050,3 +1050,25 @@ void media_remove_intf_links(struct media_interface *intf)\n \tmutex_unlock(&mdev->graph_mutex);\n }\n EXPORT_SYMBOL_GPL(media_remove_intf_links);\n+\n+struct media_link *media_create_ancillary_link(struct media_entity *primary,\n+\t\t\t\t\t       struct media_entity *ancillary)\n+{\n+\tstruct media_link *link;\n+\n+\tlink = media_add_link(&primary->links);\n+\tif (!link)\n+\t\treturn ERR_PTR(-ENOMEM);\n+\n+\tlink->gobj0 = &primary->graph_obj;\n+\tlink->gobj1 = &ancillary->graph_obj;\n+\tlink->flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED |\n+\t\t      MEDIA_LNK_FL_ANCILLARY_LINK;\n+\n+\t/* Initialize graph object embedded in the new link */\n+\tmedia_gobj_create(primary->graph_obj.mdev, MEDIA_GRAPH_LINK,\n+\t\t\t  &link->graph_obj);\n+\n+\treturn link;\n+}\n+EXPORT_SYMBOL_GPL(media_create_ancillary_link);\ndiff --git a/include/media/media-entity.h b/include/media/media-entity.h\nindex fea489f03d57..afeda41ece4c 100644\n--- a/include/media/media-entity.h\n+++ b/include/media/media-entity.h\n@@ -1104,6 +1104,27 @@ void media_remove_intf_links(struct media_interface *intf);\n  * it will issue a call to @operation\\(@entity, @args\\).\n  */\n \n+/**\n+ * media_create_ancillary_link() - create an ancillary link between two\n+ *\t\t\t\t   instances of &media_entity\n+ *\n+ * @primary:\tpointer to the primary &media_entity\n+ * @ancillary:\tpointer to the ancillary &media_entity\n+ *\n+ * Create an ancillary link between two entities, indicating that they\n+ * represent two connected pieces of hardware that form a single logical unit.\n+ * A typical example is a camera lens being linked to the sensor that it is\n+ * supporting.\n+ *\n+ * The function sets both MEDIA_LNK_FL_ENABLED and MEDIA_LNK_FL_IMMUTABLE for\n+ * the new link. This behaviour may be subject to change in the future, so\n+ * userspace applications using ancillary links should ensure that ancillary\n+ * links are enabled when in use.\n+ */\n+struct media_link *\n+media_create_ancillary_link(struct media_entity *primary,\n+\t\t\t    struct media_entity *ancillary);\n+\n #define media_entity_call(entity, operation, args...)\t\t\t\\\n \t(((entity)->ops && (entity)->ops->operation) ?\t\t\t\\\n \t (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)\n","prefixes":["libcamera-devel","v2","5/6"]}