From patchwork Fri Nov 26 00:31:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 14784 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 E62DEBDB13 for ; Fri, 26 Nov 2021 00:31:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ECCCE604FB; Fri, 26 Nov 2021 01:31:31 +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="eAkvW3gV"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 504CF6011D for ; Fri, 26 Nov 2021 01:31:28 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id m25-20020a7bcb99000000b0033aa12cdd33so1684933wmi.1 for ; Thu, 25 Nov 2021 16:31:28 -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=fSBgCp0X8JPVM+FaRxWoz/LqsQf7vjdyPzNhZaKS5rY=; b=eAkvW3gVxIM9PeX6CamuIVZCW1mlaQlIvg717set+7u7MaTLRExJ64MCw6AyAOIolK gHgE3YzvuYktX3QkDj+tKgl877wq9hxJ21zSXysOpfdXjhfWmNrwWf7Xvo/Kc91R1h2U 671mZcu3of0e2jsKaQECYehfSnbn+aeTb5hXNLRFayrvEwrpeBI55wNc4WjPdGMvGZOa uzLHTJqBC5cw70EaLRPc98WoU31Dqje1nCH2COoBI7+EtugPirKJcatHEuWx7/gFMxJw pnOpJeqlYZwO0Q8q9ZFOuWxrsre0U0u/YjqFK9a8bzgSdTFvwmCrQp+f9+yVQqFlLu5o 0rGQ== 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=fSBgCp0X8JPVM+FaRxWoz/LqsQf7vjdyPzNhZaKS5rY=; b=5rvgnLMkoNurXcUWZBB7VavpP9USjtk3Nv5pGXOHmY8x3tbhszLe4TvT8TJqXG45hp 48OsGt/xF5FfpRcLFY2JiZuPljvXNJH56lg6ll399J9zKS5pkBfE2O9cPIQsUbPQ1Mwq eOLy9TNPNjs5Fb9M0gefzL+GAwpZhCV+7nY27nE6NQf6FLdoO1pBeDgBQxy/zuSjpLY0 3MuXuPPYyKI9P3i2YVE0681XfTbAPkY9ItYDmw3T7vyz1p1SQQRSo0f7Ufixi6ktwmrA IuZ8+iyM4aMtOptkB82d022efzQUJ11rdo1ITXY3L4cRRCpYo6iQgXvF09Kl+IMbSqGJ 67Nw== X-Gm-Message-State: AOAM530m2tSI1SFECCe99EjOWIteVidSOivXSLo/nyvc3ZtOjHAGPkMv 8RXB00lQrNdFVQPgrn2JE/P6i417aj4= X-Google-Smtp-Source: ABdhPJwbQN7PeTtXpTZrG498qwAdGN2ZyzokyRaMC7lWbpnVtzzpJkcgYbJOIeeS2X6GPkJy+AxjeA== X-Received: by 2002:a05:600c:1993:: with SMTP id t19mr12354806wmq.21.1637886688102; Thu, 25 Nov 2021 16:31:28 -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 b188sm4381455wmd.45.2021.11.25.16.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 16:31:27 -0800 (PST) From: Daniel Scally To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Nov 2021 00:31:14 +0000 Message-Id: <20211126003118.42356-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126003118.42356-1-djrscally@gmail.com> References: <20211126003118.42356-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: Add support for ancillary links to MediaLink 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update the MediaLink class to include members suitable for the new type of media_v2_link, connecting two instances of MediaEntity rather than MediaPads Signed-off-by: Daniel Scally --- Adding new members and a new constructor here seemed in the end like the least impactful and probably cleanest method of doing this, as otherwise the source and sink would need to become MediaObjects and be cast everywhere. include/libcamera/internal/media_object.h | 10 ++++++++++ src/libcamera/media_object.cpp | 24 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index 6ae22c67..79c71325 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -45,6 +45,8 @@ class MediaLink : public MediaObject public: MediaPad *source() const { return source_; } MediaPad *sink() const { return sink_; } + MediaEntity *primary() const { return primary_; }; + MediaEntity *ancillary() const { return ancillary_; }; unsigned int flags() const { return flags_; } int setEnabled(bool enable); @@ -55,9 +57,13 @@ private: MediaLink(const struct media_v2_link *link, MediaPad *source, MediaPad *sink); + MediaLink(const struct media_v2_link *link, + MediaEntity *primary, MediaEntity *ancillary); MediaPad *source_; MediaPad *sink_; + MediaEntity *primary_; + MediaEntity *ancillary_; unsigned int flags_; }; @@ -104,12 +110,15 @@ public: unsigned int deviceMinor() const { return minor_; } const std::vector &pads() const { return pads_; } + const std::vector &ancillary_links() const { return ancillary_links_; } const MediaPad *getPadByIndex(unsigned int index) const; const MediaPad *getPadById(unsigned int id) const; int setDeviceNode(const std::string &deviceNode); + void addLink(MediaLink *link); + private: LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity) @@ -129,6 +138,7 @@ private: unsigned int minor_; std::vector pads_; + std::vector ancillary_links_; }; } /* namespace libcamera */ diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index f425d044..e903d5ef 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -134,7 +134,7 @@ int MediaLink::setEnabled(bool enable) } /** - * \brief Construct a MediaLink + * \brief Construct a MediaLink between two pads * \param[in] link The media link kernel data * \param[in] source The source pad at the origin of the link * \param[in] sink The sink pad at the destination of the link @@ -146,6 +146,19 @@ MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source, { } +/** + * \brief Construct a MediaLink between two entities + * \param[in] link The media link kernel data + * \param[in] primary The primary entity at the origin of the link + * \param[in] ancillary The ancillary entity at the destination of the link + */ +MediaLink::MediaLink(const struct media_v2_link *link, MediaEntity *primary, + MediaEntity *ancillary) + : MediaObject(primary->device(), link->id), primary_(primary), + ancillary_(ancillary), flags_(link->flags) +{ +} + /** * \fn MediaLink::source() * \brief Retrieve the link's source pad @@ -378,6 +391,15 @@ int MediaEntity::setDeviceNode(const std::string &deviceNode) return 0; } +/** + * \brief Add an ancillary link to the MediaEntity + * \param[in] link Pointer to the MediaLink class + */ +void MediaEntity::addLink(MediaLink *link) +{ + ancillary_links_.push_back(link); +} + /** * \brief Construct a MediaEntity * \param[in] dev The media device this entity belongs to