{"id":13568,"url":"https://patchwork.libcamera.org/api/1.1/patches/13568/?format=json","web_url":"https://patchwork.libcamera.org/patch/13568/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210830082150.42514-5-umang.jain@ideasonboard.com>","date":"2021-08-30T08:21:50","name":"[libcamera-devel,v3,4/4] ipu3: cio2: Tweak sensor size selection policy","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c4b311c9cb9c0f30368cbe74bcc85b5d4d896287","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/13568/mbox/","series":[{"id":2420,"url":"https://patchwork.libcamera.org/api/1.1/series/2420/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2420","date":"2021-08-30T08:21:46","name":"ipu3: Change sensor size selection policy","version":3,"mbox":"https://patchwork.libcamera.org/series/2420/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13568/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13568/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 33B3FC3244\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Aug 2021 08:22:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D15976916A;\n\tMon, 30 Aug 2021 10:22:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C65FB6916B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Aug 2021 10:22:04 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.0])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 826D53D7;\n\tMon, 30 Aug 2021 10:22:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SmTlEqMx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630311724;\n\tbh=DZdOO9d+1tL1RprFAb1NXD1KQHyteYGkEn2egEwHcaI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SmTlEqMx8MeKAxGw2mO+iD7j6W5ahnHTWXLIT/x9JfitMQgfq/6QFuObxOLfRZGzy\n\thkmMvVC96IecP9dC37PYQxYei6GCPZUrpajPBB+bhRgWKfcGMaHnlzlBmGHgzRBYzg\n\tXiGGb/QD+4jo2cKvP4y/WQb/rClf/mFV77EI5lgQ=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 30 Aug 2021 13:51:50 +0530","Message-Id":"<20210830082150.42514-5-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210830082150.42514-1-umang.jain@ideasonboard.com>","References":"<20210830082150.42514-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 4/4] ipu3: cio2: Tweak sensor size\n\tselection policy","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Do not compare higher precision of the ratios, as it might lead to\nabsurd selection of sensor size for a relatively low requested\nresolution size.\n\nFor example:\nThe imx258 driver supports the following sensor resolutions:\n\n - 4208x3118 = 1.349583066\n - 2104x1560 = 1.348717949\n - 1048x780  = 1.343589744\n\nIt can be inferred that, that the aspect ratio only differs by a small\nfactor with each other. It does not makes sense to select a 4208x3118\nfor a requested size of say 640x480 or 1280x720, which is what is\nhappening currently.\n($) cam -c1 -swidth=640,height=480,role=raw\n    - CIO2 configuration: 4208x3118-SGRBG10_IPU3\n\nIn order to address this constraint, only compare the ratio with single\nprecision to make a better decision on the sensor resolution policy\nselection.\n\n($) cam -c1 -srole=raw,width=640,height=480\n    - CIO2 configuration: 1048x780-SGRBG10_IPU3\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nTested-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp | 8 ++++++++\n 1 file changed, 8 insertions(+)","diff":"diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex ceaf665e..9cedcb5b 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -295,6 +295,14 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector<unsigned int>\n \t\t\t\tcontinue;\n \n \t\t\tfloat ratio = static_cast<float>(sz.width) / sz.height;\n+\t\t\t/*\n+\t\t\t * Ratios can differ by small mantissa difference which\n+\t\t\t * can affect the selection of the sensor output size\n+\t\t\t * wildly. We are interested in selection of the closest\n+\t\t\t * size with respect to the desired output size, hence\n+\t\t\t * comparing it with a single precision digit is enough.\n+\t\t\t */\n+\t\t\tratio = static_cast<unsigned int>(ratio * 10) / 10.0;\n \t\t\tfloat ratioDiff = fabsf(ratio - desiredRatio);\n \t\t\tunsigned int area = sz.width * sz.height;\n \t\t\tunsigned int areaDiff = area - desiredArea;\n","prefixes":["libcamera-devel","v3","4/4"]}