From patchwork Tue Aug 3 13:32:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13180 X-Patchwork-Delegate: umang.jain@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 BCD2BC3235 for ; Tue, 3 Aug 2021 13:32:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BA7D687EB; Tue, 3 Aug 2021 15:32:32 +0200 (CEST) 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="wbgFbsiY"; 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 E2DBF687CE for ; Tue, 3 Aug 2021 15:32:31 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.238.109.12]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B8C1B3F0; Tue, 3 Aug 2021 15:32:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627997551; bh=rlDFcRXJQC8DrRziJUYhUuPYmCzT2LxvxNcrBDMTuQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbgFbsiYo0+H94MmJ0SsSbV0NADbiEtTCu8Sw/urRgECOcg1SnYnUJEFRlNpCr97e fjD3h3NFY4aqVyFGFSG6tP5bF1bfA7zs/bfzoOnu47Up7PVkn1eLuPOF9h5EBTuLlK O3zOOy3ms7QN+gSvngNReZjTxjPA12L+6IPT3kH8= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Tue, 3 Aug 2021 19:02:04 +0530 Message-Id: <20210803133205.6599-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803133205.6599-1-umang.jain@ideasonboard.com> References: <20210803133205.6599-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] ipu3: cio2: Change sensor size selection policy 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 current implementation of getSensorFormat() prioritizes sensor sizes that match the output size FOV ratio. Modify the frame size selection procedure to prioritize resolutions with the same FOV as the sensor's native one, to avoid cropping in the sensor pixel array. In example, with the current implementation : - on a Soraka device equipped with ov13858 as back sensor, with a native resolution of 4224x3136 (4:3), when requested to select the sensor output size to produce 1080p (16:9) a frame size of 2112x1188 (16:9) is selected causing the ImgU configuration procedure to fail. If a resolution with the same FOV as the sensor's native size, such as 2112x1568 (4:3), is selected the pipeline works correctly. Signed-off-by: Jacopo Mondi Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/cio2.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index be063613..9980b8bd 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -239,8 +239,8 @@ StreamConfiguration CIO2Device::generateConfiguration(Size size) const * * - The desired \a size shall fit in the sensor output size to avoid the need * to up-scale. - * - The sensor output size shall match the desired aspect ratio to avoid the - * need to crop the field of view. + * - The aspect ratio of sensor output size shall be as close as possible to + * the sensor's native resolution field of view. * - The sensor output size shall be as small as possible to lower the required * bandwidth. * - The desired \a size shall be supported by one of the media bus code listed @@ -264,7 +264,9 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector { unsigned int desiredArea = size.width * size.height; unsigned int bestArea = UINT_MAX; - float desiredRatio = static_cast(size.width) / size.height; + const Size &resolution = sensor_->resolution(); + float desiredRatio = static_cast(resolution.width) / + resolution.height; float bestRatio = FLT_MAX; Size bestSize; uint32_t bestCode = 0;