From patchwork Fri Dec 13 09:26:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22312 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 DC4E2C32EA for ; Fri, 13 Dec 2024 09:48:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7553367EE6; Fri, 13 Dec 2024 10:48:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lyVMKkw1"; 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 88114618AD for ; Fri, 13 Dec 2024 10:48:08 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:4f4b:687b:9f5f:1d0d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 32114520; Fri, 13 Dec 2024 10:47:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734083254; bh=0+bmhJNxQFPVdA7EFrxpol2cl/jo5rQKnmKaDbHRyYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyVMKkw15LcxZfww0vKIKa+nKRjQSwJZakw572oDf5LXxcdYP7xXV1JCdTtaqzA0F PF5sN0R/xSOAL5v4QCz1+xN4uRgOhLsRpOOhHEgAGta8gIPL+kPCWesgibZvDAb3/N +VnIWftivJsIb/WsceFtI/r71AKde3YYXCcn5Hsc= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Stefan Klug Subject: [PATCH v3.1] fixup! libcamera: converter_v4l2_m2m: Improve crop bounds support Date: Fri, 13 Dec 2024 10:26:05 +0100 Message-ID: <20241213094551.74584-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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" Changes semantics of inputCropBounds to return null bounds if an unconfigured stream is provided. Return the device crop bounds if a nullptr is provided. Signed-off-by: Stefan Klug --- Hi Jacopo, I forgot to handle your comment in the v3. Sorry for that. This is my proposal. It is somewhere in the middle of your suggestions, but I think it makes the intent clearer. I would like to keep the getCropBound() a static function as we discussed before. The commit message will also be updated for v4. Is this change ok for you? Best regards, Stefan include/libcamera/internal/converter.h | 4 +++- .../internal/converter/converter_v4l2_m2m.h | 1 + src/libcamera/converter.cpp | 12 +++++++++++- .../converter/converter_v4l2_m2m.cpp | 19 ++++++++++++++++--- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 6 +++++- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index 9213ae5b9c33..465b0b0596d9 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -73,6 +73,7 @@ public: virtual int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs) = 0; + virtual bool isConfigured(const Stream *stream) const = 0; virtual int exportBuffers(const Stream *stream, unsigned int count, std::vector> *buffers) = 0; @@ -83,7 +84,8 @@ public: const std::map &outputs) = 0; virtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0; - virtual std::pair inputCropBounds(const Stream *stream) = 0; + virtual std::pair inputCropBounds( + const Stream *stream = nullptr) = 0; Signal inputBufferReady; Signal outputBufferReady; diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index 89bd2878b190..175f0e1109a6 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -54,6 +54,7 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfg); + bool isConfigured(const Stream *stream) const override; int exportBuffers(const Stream *stream, unsigned int count, std::vector> *buffers); diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index c3da162b7de7..74cea46cc709 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -169,6 +169,13 @@ Converter::~Converter() * \return 0 on success or a negative error code otherwise */ +/** + * \fn Converter::isConfigured() + * \brief Check if a given stream is configured + * \param[in] stream The output stream + * \return True if the \a stream is configured or false otherwise + */ + /** * \fn Converter::exportBuffers() * \brief Export buffers from the converter device @@ -238,9 +245,12 @@ Converter::~Converter() * this function should be called after the \a stream has been configured using * configure(). * - * When called with an invalid \a stream, the function returns the default crop + * When called with nullptr \a stream this function returns the default crop * bounds of the converter. * + * When called with an invalid \a stream, this function returns a pair of null + * rectangles + * * \return A pair containing the minimum and maximum crop bound in that order */ diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index 6857472b29f2..4df253749feb 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -559,6 +559,14 @@ int V4L2M2MConverter::configure(const StreamConfiguration &inputCfg, return 0; } +/** + * \copydoc libcamera::Converter::isConfigured + */ +bool V4L2M2MConverter::isConfigured(const Stream *stream) const +{ + return streams_.find(stream) != streams_.end(); +} + /** * \copydoc libcamera::Converter::exportBuffers */ @@ -595,11 +603,16 @@ int V4L2M2MConverter::setInputCrop(const Stream *stream, Rectangle *rect) std::pair V4L2M2MConverter::inputCropBounds(const Stream *stream) { + if (stream == nullptr) + return inputCropBounds_; + auto iter = streams_.find(stream); - if (iter != streams_.end()) - return iter->second->inputCropBounds(); + if (iter == streams_.end()) { + LOG(Converter, Error) << "Invalid output stream"; + return {}; + } - return inputCropBounds_; + return iter->second->inputCropBounds(); } /** diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 4dcc5a4fa6a1..ad162164df1a 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1281,8 +1281,12 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data) ControlInfoMap::Map controls; if (dewarper_) { + const Stream *stream = nullptr; + if (dewarper_->isConfigured(&data->mainPathStream_)) + stream = &data->mainPathStream_; + std::pair cropLimits = - dewarper_->inputCropBounds(&data->mainPathStream_); + dewarper_->inputCropBounds(stream); /* * ScalerCrop is specified to be in Sensor coordinates.