From patchwork Sun Jan 31 22:46:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11086 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com 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 9ECDDBD808 for ; Sun, 31 Jan 2021 22:47:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4B511683F5; Sun, 31 Jan 2021 23:47:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="E8zaFpn/"; 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 7EEF2683E7 for ; Sun, 31 Jan 2021 23:47:30 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F4017145B; Sun, 31 Jan 2021 23:47:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1612133250; bh=G9q7k/ellxmM5flEfJJTPlrdY8qbq6/u+UXrzKmEW5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8zaFpn/yAh65Uol+dv8Nqt3HAUwT2gCkE88V4J7copkLQICUXj6ab33mZv3RTKyH FiD4FWEqgYAFpJYyFXM2jwdLDV9KYaKPLkBYXFvcGY5dm7TymJiDxAeg8vo2j41zzh e3TFuyySqANTcdhZJYTBtk9vqdlOzHQ3MjGjf3Kg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Feb 2021 00:46:49 +0200 Message-Id: <20210131224702.8838-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> References: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/20] libcamera: pipeline: simple: converter: Replace open() with isValid() 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: Phi-Bang Nguyen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Simplify the SimpleConverter interface by opening the M2M device in the constructor. The explicit call to open() is replaced by a check through a new isValid() function, and the unused close() function is removed. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/libcamera/pipeline/simple/converter.cpp | 20 ++++++-------------- src/libcamera/pipeline/simple/converter.h | 3 +-- src/libcamera/pipeline/simple/simple.cpp | 4 ++-- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index 6b3249ea92b0..f782fbc63b09 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -39,24 +39,16 @@ SimpleConverter::SimpleConverter(MediaDevice *media) m2m_ = std::make_unique((*it)->deviceNode()); + int ret = m2m_->open(); + if (ret < 0) { + m2m_.reset(); + return; + } + m2m_->output()->bufferReady.connect(this, &SimpleConverter::outputBufferReady); m2m_->capture()->bufferReady.connect(this, &SimpleConverter::captureBufferReady); } -int SimpleConverter::open() -{ - if (!m2m_) - return -ENODEV; - - return m2m_->open(); -} - -void SimpleConverter::close() -{ - if (m2m_) - m2m_->close(); -} - std::vector SimpleConverter::formats(PixelFormat input) { if (!m2m_) diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h index a1503a6099ff..780bfa8f7832 100644 --- a/src/libcamera/pipeline/simple/converter.h +++ b/src/libcamera/pipeline/simple/converter.h @@ -30,8 +30,7 @@ class SimpleConverter public: SimpleConverter(MediaDevice *media); - int open(); - void close(); + bool isValid() const { return m2m_ != nullptr; } std::vector formats(PixelFormat input); SizeRange sizes(const Size &input); diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8c0bca36bbfb..20a4ebca94fd 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -763,9 +763,9 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) /* Open the converter, if any. */ if (converter) { converter_ = std::make_unique(converter); - if (converter_->open() < 0) { + if (!converter_->isValid()) { LOG(SimplePipeline, Warning) - << "Failed to open converter, disabling format conversion"; + << "Failed to create converter, disabling format conversion"; converter_.reset(); } else { converter_->bufferReady.connect(this, &SimplePipelineHandler::converterDone);