From patchwork Tue Aug 10 07:58:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13276 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 4663FBD87D for ; Tue, 10 Aug 2021 07:59:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0995A68886; Tue, 10 Aug 2021 09:59:13 +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="W/YH3nnk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E1F168826 for ; Tue, 10 Aug 2021 09:59:11 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.238.109.8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D13A4466; Tue, 10 Aug 2021 09:59:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628582350; bh=uQXQGCNIbtRwW/wywRTu1eBmJWomvFWYMe38wBqLDy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W/YH3nnkSJlYfrcUea6rK4BtC5JiUXXRgI7L+9fA4ruzEW2Xb+UGK066bsjerYjUJ Zo+h94R7Ap9JQXYk10ueNgZ1wxjtDU1ZA+PkWm2MNXTZEp1a5jrAFOuU8hNtKOiYMN iIZ617VyDdQp02S4vy1tv0B7A0olzNwXxYVf99bw= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Tue, 10 Aug 2021 13:28:54 +0530 Message-Id: <20210810075854.86191-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210810075854.86191-1-umang.jain@ideasonboard.com> References: <20210810075854.86191-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] ipu3: cio2: Tweak 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" Do not compare higher precision of the ratios, as it might lead to absurd selection of sensor size for a relatively low requested resolution size. For example: The imx258 driver supports the following sensor resolutions: - 4208x3118 = 1.349583066 - 2104x1560 = 1.348717949 - 1048x780 = 1.343589744 It can be inferred that, that the aspect ratio only differs by a small factor with each other. It does not makes sense to select a 4208x3118 for a requested size of say 640x480 or 1280x720, which is what is happening currently. ($) cam -c1 -swidth=640,height=480,role=raw - CIO2 configuration: 4208x3118-SGRBG10_IPU3 In order to address this constraint, only compare the ratio with single precision to make a better decision on the sensor resolution policy selection. ($) cam -c1 -srole=raw,width=640,height=480 - CIO2 configuration: 1048x780-SGRBG10_IPU3 Signed-off-by: Umang Jain Tested-by: Umang Jain Tested-by: Jacopo Mondi Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/cio2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 3c9331e3..6ccef301 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -290,6 +290,11 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector continue; float ratio = static_cast(sz.width) / sz.height; + /* + * Comparing ratios with a single precision digit + * is enough. + */ + ratio = static_cast(ratio * 10) / 10.0; float ratioDiff = fabsf(ratio - desiredRatio); unsigned int area = sz.width * sz.height; unsigned int areaDiff = area - desiredArea;