From patchwork Fri Nov 15 10:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21917 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 D1ED6C32CE for ; Fri, 15 Nov 2024 10:14:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E08DB65890; Fri, 15 Nov 2024 11:14:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P/KtW7Iz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A73A6587A for ; Fri, 15 Nov 2024 11:13:52 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F1DCB1590; Fri, 15 Nov 2024 11:13:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731665618; bh=4j1rsI/VC751cgoYwUXU/Ry6Htj9ynzYyDZUJLDbliM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/KtW7IzTL0wGg2EiKqCES/ikzyig9LYKxdKyDlbndITGhj9ulVHxFoYdJjcuElnU Q+jaDUuKO8pZo3hN6Smf0Ywv7rbMGkEWp2kEDSpTKTB9gUmDpbQSvf9DNW15q2m+d5 OSuSjsOUOFfLIPvX/gDQTomP+e5fZy+krmNrqIkQ= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Anthony.McGivern@arm.com, Jacopo Mondi , Kieran Bingham , Daniel Scally Subject: [PATCH v6 13/14] libcamera: mali-c55: Enable usage of scaler Date: Fri, 15 Nov 2024 10:13:33 +0000 Message-Id: <20241115101334.453104-14-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115101334.453104-1-dan.scally@ideasonboard.com> References: <20241115101334.453104-1-dan.scally@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" From: Jacopo Mondi The Mali C55 ISP has a resizing pipeline that allows to crop and scale images. So far the mali-c55 pipeline has only supported cropping without using the scaling functionalities. Now that the kernel has gained support for the scaling operations, make the libcamera pipeline use it by combining it with a first cropping step to align the input and output images FOV ratio, and then scale to the desired output size. Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally Signed-off-by: Jacopo Mondi Signed-off-by: Daniel Scally --- Changes in v6: - None Changes in v5: - None src/libcamera/pipeline/mali-c55/mali-c55.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index c0206ea2..d0218349 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -756,16 +756,28 @@ int PipelineHandlerMaliC55::configureProcessedStream(MaliC55CameraData *data, if (ret) return ret; - /* \todo Configure the resizer crop/compose rectangles. */ - Rectangle ispCrop = { 0, 0, config.size }; + /* + * Compute the scaler-in to scaler-out ratio: first center-crop to align + * the FOV to the desired resolution, then scale to the desired size. + */ + Size scalerIn = subdevFormat.size.boundedToAspectRatio(config.size); + int xCrop = (subdevFormat.size.width - scalerIn.width) / 2; + int yCrop = (subdevFormat.size.height - scalerIn.height) / 2; + Rectangle ispCrop = { xCrop, yCrop, scalerIn }; ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_CROP, &ispCrop); if (ret) return ret; - ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_COMPOSE, &ispCrop); + Rectangle ispCompose = { 0, 0, config.size }; + ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_COMPOSE, &ispCompose); if (ret) return ret; + /* + * The source pad format size comes directly from the sink + * compose rectangle. + */ + subdevFormat.size = ispCompose.size(); subdevFormat.code = maliC55FmtToCode.find(config.pixelFormat)->second; return pipe->resizer->setFormat(1, &subdevFormat); }