{"id":12070,"url":"https://patchwork.libcamera.org/api/patches/12070/?format=json","web_url":"https://patchwork.libcamera.org/patch/12070/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210422094102.371772-4-paul.elder@ideasonboard.com>","date":"2021-04-22T09:40:53","name":"[libcamera-devel,RFC,v2,03/12] android: CameraDevice: Report proper min and max frame durations","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f3e30f41643556a25982c4c268c57b900edfb2ce","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":{"id":17,"url":"https://patchwork.libcamera.org/api/users/17/?format=json","username":"epaul","first_name":"Paul","last_name":"Elder","email":"paul.elder@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/12070/mbox/","series":[{"id":1962,"url":"https://patchwork.libcamera.org/api/series/1962/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1962","date":"2021-04-22T09:40:50","name":"FULL hardware level fixes","version":2,"mbox":"https://patchwork.libcamera.org/series/1962/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12070/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12070/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 6CC68BDB17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Apr 2021 09:41:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2631C6885C;\n\tThu, 22 Apr 2021 11:41:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1866468843\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Apr 2021 11:41:19 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 684E6499;\n\tThu, 22 Apr 2021 11:41:17 +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=\"HvqD1LqM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619084478;\n\tbh=B66VJivwACtZivlHNm1WqJco1w7s9P6hYewZ52CnKiw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=HvqD1LqMEaJ8tlvwIXhqHhNTqQYm+104ZoFJmRZCQjlAknc4oXLrJV0Hvsg4k6k6l\n\tCcVYkhL9TwzQRo8EYs4TR2peT5O0oUVVvEHJPfqW27rMimHThg7awD+RpUJTxFenje\n\taR/fCoGhD9srXWk8T7eZeMw6Q1dONk/wlAD80q3A=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 22 Apr 2021 18:40:53 +0900","Message-Id":"<20210422094102.371772-4-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20210422094102.371772-1-paul.elder@ideasonboard.com>","References":"<20210422094102.371772-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH v2 03/12] android: CameraDevice:\n\tReport proper min and max frame durations","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The HAL layer was getting the min and max frame durations from from the\ncamera, then rounding it to fps to report as available fps ranges. The\nsame min and max frame durations were then being reported as min and max\nframe durations. Since the fps are integer values while the frame\ndurations are in ns, this caused a rounding error making it seem like we\nwere reporting an available max fps that was higher than was was allowed\nby the minimum frame duration.\n\nAn example is if the minimum frame duration is reported as 33366700ns.\nThe HAL layer would then convert it to fps, which is 29.97, but it would\nbe rounded and reported as 30 fps. When 30 fps is converted to a frame\nduration it is 33333333ns, which is less than the minimum frame duration\nthat we report. Thus the minimum frame duration that we report\ncontradicts the fps rage that we report.\n\nFix this by recalculating the frame durations based on the rounded fps\nvalues.\n\nThis allows the following CTS test to pass:\n- android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 4 ++++\n 1 file changed, 4 insertions(+)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 76863877..a11ad848 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -900,6 +900,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\tint32_t minFps = std::round(1e9 / maxFrameDurationNsec);\n \t\tminFps = std::max(1, minFps);\n \n+\t\t/* Avoid rounding errors when we reuse these variables later */\n+\t\tminFrameDurationNsec = 1e9 / maxFps;\n+\t\tmaxFrameDurationNsec = 1e9 / minFps;\n+\n \t\t/*\n \t\t * Register to the camera service {min, max} and {max, max}\n \t\t * intervals as requested by the metadata documentation.\n","prefixes":["libcamera-devel","RFC","v2","03/12"]}