From patchwork Tue May 25 09:12:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12399 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 797D0C3202 for ; Tue, 25 May 2021 09:13:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB53E68921; Tue, 25 May 2021 11:13:07 +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="Dwe0Qlm8"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C300A602AF for ; Tue, 25 May 2021 11:13:05 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7BA4B344; Tue, 25 May 2021 11:13:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1621933985; bh=s/Vo7puZVOWpqNWOYxREO/rGhdjMH5Glyuw0ejqovVw=; h=From:To:Cc:Subject:Date:From; b=Dwe0Qlm8V3Koh3o0DVZBMwbBgMPjY0XJQQjSI4Ps2DpEp7IUQRlyEvKeORndwS816 mkcyxkj1FcEgYRPE6l3t1qO9DtDALnffVzBV/DzDkrO010tMXZdlvae2wQwRvnfYgB EA7h5ICE3b+W4jF54FwKSCZEgbD7aOro2Hn/7JAM= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 25 May 2021 18:12:49 +0900 Message-Id: <20210525091249.1224608-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3] android: CameraDevice: Report proper min and max frame durations 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" The HAL layer was getting the min and max frame durations from the camera, then rounding it to fps to report as available fps ranges. The same min and max frame durations were then being reported as min and max frame durations. Since the fps are integer values while the frame durations are in ns, this caused a rounding error making it seem like we were reporting an available max fps that was higher than what was allowed by the minimum frame duration. An example is if the minimum frame duration is reported as 33366700ns. The HAL layer would then convert it to fps, which is 29.97, but it would be rounded and reported as 30 fps. When 30 fps is converted to a frame duration it is 33333333ns, which is less than the minimum frame duration that we report. Thus the minimum frame duration that we report contradicts the fps range that we report. Fix this by recalculating the frame durations based on the rounded fps values. This allows the following CTS test to pass: - android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange Signed-off-by: Paul Elder Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- Changes in v3: - reword the comment - break this patch out of the FULL series --- src/android/camera_device.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 74bba4a4..41db51f7 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -854,6 +854,13 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() int32_t minFps = std::round(1e9 / maxFrameDurationNsec); minFps = std::max(1, minFps); + /* + * Force rounding errors so that we have the proper frame + * durations for when we reuse these variables later + */ + minFrameDurationNsec = 1e9 / maxFps; + maxFrameDurationNsec = 1e9 / minFps; + /* * Register to the camera service {min, max} and {max, max} * intervals as requested by the metadata documentation.