From patchwork Thu Aug 15 21:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 20945 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 19A1BC32A9 for ; Thu, 15 Aug 2024 21:09:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7EC59633B9; Thu, 15 Aug 2024 23:09:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qD2zxVGI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DA3D63369 for ; Thu, 15 Aug 2024 23:09:29 +0200 (CEST) Received: from Monstersaurus.tail69b4.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 58457842; Thu, 15 Aug 2024 23:08:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723756110; bh=KRH7DLE8YUQMpDhhmLHXdUnhZQ8N8jgHd1lCNBPsKDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qD2zxVGIRyInyOB6AGJZA8X0MhNVBFYk798rMycbPsntIsdRNcYXAvx38aMfgyo/Z kHSdhPjMN6So8s6MBwmzjPQalbxnVXRrqweTNTo9P6W7dCaGzoao+kwVsL9KUZHF+y Sw5fjvCV4paoDXbg3vBUN6y2j7t+dCY04skl77bM= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 1/3] libcamera: media_object: Add MediaLink string representations Date: Thu, 15 Aug 2024 22:09:23 +0100 Message-Id: <20240815210925.4172287-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815210925.4172287-1-kieran.bingham@ideasonboard.com> References: <20240815210925.4172287-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] Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Stefan Klug --- 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..3ebef938bc49 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 1b191a1e4df8..fa2c44b0abb6 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, { } +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] r The MediaLink + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const MediaLink &link) +{ + out << "'" + << link.source()->entity()->name() << "'[" + << link.source()->index() << "] -> '" + << link.sink()->entity()->name() << "'[" + << link.sink()->index() << "]"; + + return out; +} + /** * \fn MediaLink::source() * \brief Retrieve the link's source pad From patchwork Thu Aug 15 21:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 20946 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 1A4C6C32D5 for ; Thu, 15 Aug 2024 21:09:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 501D8633BE; Thu, 15 Aug 2024 23:09:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ESzEdjeP"; 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 47BB363393 for ; Thu, 15 Aug 2024 23:09:29 +0200 (CEST) Received: from Monstersaurus.tail69b4.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D011AD8; Thu, 15 Aug 2024 23:08:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723756110; bh=IXrfyC7YOsjHp4baX5kqLCT9tQK55pcgW5Gwg3B15U4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ESzEdjePQbVmd/0Jg60EsKV23Xnz3n4tdTfu4lRGprNxeYKYnaTTc9YrZzLs5kVcx g3ilRAyPTD6lAXrdN6q0qKU7BlHcq+qus1zG+OicFU0YoR2tgvr4y/248hHqrDVgeS 8SIVcHFELrVbgHLXmeMryqB7zc4gwnbQN3TeaK2E= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 2/3] libcamera: media_device: Use MediaLink string helper Date: Thu, 15 Aug 2024 22:09:24 +0100 Message-Id: <20240815210925.4172287-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815210925.4172287-1-kieran.bingham@ideasonboard.com> References: <20240815210925.4172287-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. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Stefan Klug --- src/libcamera/media_device.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index bd054552a093..c1ea58996fa8 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -817,21 +817,15 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags) int ret = ioctl(fd_.get(), MEDIA_IOC_SETUP_LINK, &linkDesc); 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 Thu Aug 15 21:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 20947 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 8C867C32D6 for ; Thu, 15 Aug 2024 21:09:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5998D633C6; Thu, 15 Aug 2024 23:09:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l4cm8A0y"; 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 6CBE4633B3 for ; Thu, 15 Aug 2024 23:09:29 +0200 (CEST) Received: from Monstersaurus.tail69b4.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C34A6827; Thu, 15 Aug 2024 23:08:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1723756110; bh=YlsSyq+a+Tqs30qmAANM6uSIFDYOlYP5mKzfhlV1P98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4cm8A0yund3HrKs/pyWJeFPMnsFu4dyT5On1xn/lUMdW+Kp+31xgC3XkNIks1VLH nmkRQsZhoVOBIhFt/eMkTmn85DlGQLEE8/0Sogf30kn+L7yqYYql7fJEaUTIwdE8NM RD8+u1LJqRrma/JZR6Y3YFAV1Etlg8EbFOR9E2EQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 3/3] libcamera: pipeline: simple: Use MediaLink string helper Date: Thu, 15 Aug 2024 22:09:25 +0100 Message-Id: <20240815210925.4172287-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815210925.4172287-1-kieran.bingham@ideasonboard.com> References: <20240815210925.4172287-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 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;