From patchwork Wed Sep 11 21:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 21239 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 2AB28C324C for ; Wed, 11 Sep 2024 21:18:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22150634FB; Wed, 11 Sep 2024 23:18:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Aqq9XBjQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 114B2618FB for ; Wed, 11 Sep 2024 23:18:27 +0200 (CEST) Received: from charm.tail69b4.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B903BEB; Wed, 11 Sep 2024 23:17:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726089429; bh=Id4vMYqI1c9QGcCATKKJjSKJvL/AixamOqvOzqZxSgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aqq9XBjQfrYR7cVQCOS3ui38unXyywY/H9u8umZ9PlAz1jINUg2CC/xFp3jSE+WFH japu4/AD6cF37qSGyQRhtB15oTWu9TSbHolvgpuP1VKZJHHlgNiBGk6/8HshfXBKPT g1RlJT5qClgdM/GYMV/ViKb0zhmXTCqd3PRK5+78= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v2 1/4] libcamera: media_object: Add MediaPad string representations Date: Wed, 11 Sep 2024 23:18:13 +0200 Message-ID: <20240911211816.73763-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> References: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" Facilitate easy representations of a MediaPad object by preparing it as a string and supporting output streams. A MediaPad will be report in the following style: 'imx283 1-001a'[0] Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - New patch include/libcamera/internal/media_object.h | 4 ++++ src/libcamera/media_object.cpp | 25 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index c9d77511a991..d80d5f4574c7 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -71,6 +71,8 @@ public: void addLink(MediaLink *link); + std::string toString() const; + private: LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad) @@ -85,6 +87,8 @@ private: std::vector links_; }; +std::ostream &operator<<(std::ostream &out, const MediaPad &pad); + class MediaEntity : public MediaObject { public: diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index 1b191a1e4df8..25f16707ab73 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -235,6 +235,31 @@ void MediaPad::addLink(MediaLink *link) links_.push_back(link); } +/** + * \brief Generate a string representation of the MediaPad + * \return A string representing the MediaPad + */ +std::string MediaPad::toString() const +{ + std::stringstream ss; + ss << *this; + + return ss.str(); +} + +/** + * \brief Insert a text representation of a MediaPad into an output stream + * \param[in] out The output stream + * \param[in] pad The MediaPad + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const MediaPad &pad) +{ + out << "'" << pad.entity()->name() << "'[" << pad.index() << "]"; + + return out; +} + /** * \class MediaEntity * \brief The MediaEntity represents an entity in the media graph From patchwork Wed Sep 11 21:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 21240 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 E14A6C324C for ; Wed, 11 Sep 2024 21:18:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4882863505; Wed, 11 Sep 2024 23:18:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UYqZkRVI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E660618F2 for ; Wed, 11 Sep 2024 23:18:27 +0200 (CEST) Received: from charm.tail69b4.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9793C83D; Wed, 11 Sep 2024 23:17:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726089429; bh=WG5DhPygWqfGsd6Ucmhf7drKBBA9r7zNXV+1M5jXYMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYqZkRVI0czcJ63mvDJSdJQTe4qfC7AzkoeziOasja62NB9h2PzvEb0lQo4fdTr86 4MaOZtXvFy1lWU6DnFCT6D567d6Y3X9A1x1TLldIfrMbWZ2UTIkET0V6IDAjNnd9Pk YVHGmnxjATSSLDuZEuJ4FofUXiiBhNKTgIvKcfHA= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham , Laurent Pinchart Subject: [PATCH v2 2/4] libcamera: media_object: Add MediaLink string representations Date: Wed, 11 Sep 2024 23:18:14 +0200 Message-ID: <20240911211816.73763-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> References: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" Various parts of libcamera print the representation of a MediaLink by inline joining the parts to make a string representation. This repeated use case can be supported with a common helper to print the MediaLink in a common manner using the existing toString() and operator<< overload style to make it easier to report on MediaLink types. This implementation will report in the following style: 'imx283 1-001a'[0] -> 'video-mux'[0] Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Stefan Klug --- v2: - Fix documentation - Use MediaPad helper include/libcamera/internal/media_object.h | 4 ++++ src/libcamera/media_object.cpp | 25 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index d80d5f4574c7..9356d204d6e5 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -48,6 +48,8 @@ public: unsigned int flags() const { return flags_; } int setEnabled(bool enable); + std::string toString() const; + private: LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink) @@ -61,6 +63,8 @@ private: unsigned int flags_; }; +std::ostream &operator<<(std::ostream &out, const MediaLink &link); + class MediaPad : public MediaObject { public: diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp index 25f16707ab73..3e3772a628c2 100644 --- a/src/libcamera/media_object.cpp +++ b/src/libcamera/media_object.cpp @@ -146,6 +146,31 @@ MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source, { } +/** + * \brief Generate a string representation of the MediaLink + * \return A string representing the MediaLink + */ +std::string MediaLink::toString() const +{ + std::stringstream ss; + ss << *this; + + return ss.str(); +} + +/** + * \brief Insert a text representation of a Link into an output stream + * \param[in] out The output stream + * \param[in] link The MediaLink + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const MediaLink &link) +{ + out << *link.source() << " -> " << *link.sink(); + + return out; +} + /** * \fn MediaLink::source() * \brief Retrieve the link's source pad From patchwork Wed Sep 11 21:18:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 21241 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 CF77CC324C for ; Wed, 11 Sep 2024 21:18:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3987F63506; Wed, 11 Sep 2024 23:18:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="S0G08kSK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2009A634FB for ; Wed, 11 Sep 2024 23:18:27 +0200 (CEST) Received: from charm.tail69b4.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A32BBEB; Wed, 11 Sep 2024 23:17:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726089430; bh=KMPtBgA6ElkSiiL4dlJFYbbzxlxGy6+uguxmeIzSY/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0G08kSKrxk1AkGvKXamEORBvxMHFuJ0wQYjtyC4+vuuwXh+4TwYNfoxXKH06YBFF lIszsnfJhBLugaYDMKgbpdZ92HBI5+XKx5sqsBNqaY6dqyW+cbGmFc//HgFOGPDvo7 E4ZTv5cdztYXNe6gZ6EeKaP030RR189V3xzpGG5c= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham , Laurent Pinchart Subject: [PATCH v2 3/4] libcamera: media_device: Use MediaLink string helper Date: Wed, 11 Sep 2024 23:18:15 +0200 Message-ID: <20240911211816.73763-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> References: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" Replace the two open-coded implementations of a link representation with the operator<< overload string representation to simplify the code and unify appearance of reporting MediaLinks. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Stefan Klug --- src/libcamera/media_device.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index bd054552a093..d71dad74df70 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -818,20 +818,12 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags) if (ret) { ret = -errno; LOG(MediaDevice, Error) - << "Failed to setup link " - << source->entity()->name() << "[" - << source->index() << "] -> " - << sink->entity()->name() << "[" - << sink->index() << "]: " + << "Failed to setup link " << *link << ": " << strerror(-ret); return ret; } - LOG(MediaDevice, Debug) - << source->entity()->name() << "[" - << source->index() << "] -> " - << sink->entity()->name() << "[" - << sink->index() << "]: " << flags; + LOG(MediaDevice, Debug) << *link << ": " << flags; return 0; } From patchwork Wed Sep 11 21:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 21242 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 7B37BC324C for ; Wed, 11 Sep 2024 21:18:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE7C863504; Wed, 11 Sep 2024 23:18:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rf7wvaqq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82161618FB for ; Wed, 11 Sep 2024 23:18:28 +0200 (CEST) Received: from charm.tail69b4.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AE02E83D; Wed, 11 Sep 2024 23:17:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726089430; bh=8nXkTcGf9vdwvW3F6/FAMBsw3uFOD7oG4nZ2jAC0Ps0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rf7wvaqqEAMQnlIgxgqP7SClAd+DwEwl2d5yo3tORyxaBO6xL/uugvS/i5owU8GCy yWs1o0+zr3kygtnq9XX3ZLr+uf31C/ID/A7FuonwloLunjBq5XyGp7NWeIzIHV1F80 P2MQerjCYuJoCSW+mqt8bqfmso28z/2JYXFSPB+U= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham , Laurent Pinchart Subject: [PATCH v2 4/4] libcamera: pipeline: simple: Use MediaLink string helper Date: Wed, 11 Sep 2024 23:18:16 +0200 Message-ID: <20240911211816.73763-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> References: <20240911211816.73763-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" Replace the open-coded implementation of a link representation with the operator<< overload string representation to simplify the code and unify appearance of reporting MediaLinks. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Stefan Klug --- src/libcamera/pipeline/simple/simple.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 1e7ec7d97255..2d205e9925ef 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -774,11 +774,8 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, } LOG(SimplePipeline, Debug) - << "Link '" << source->entity()->name() - << "':" << source->index() - << " -> '" << sink->entity()->name() - << "':" << sink->index() - << " configured with format " << *format; + << "Link " << *link << ": configured with format " + << *format; } return 0;