From patchwork Thu Apr 22 09:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12070 X-Patchwork-Delegate: paul.elder@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 6CC68BDB17 for ; Thu, 22 Apr 2021 09:41:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2631C6885C; Thu, 22 Apr 2021 11:41:21 +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="HvqD1LqM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1866468843 for ; Thu, 22 Apr 2021 11:41:19 +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 684E6499; Thu, 22 Apr 2021 11:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1619084478; bh=B66VJivwACtZivlHNm1WqJco1w7s9P6hYewZ52CnKiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvqD1LqMEaJ8tlvwIXhqHhNTqQYm+104ZoFJmRZCQjlAknc4oXLrJV0Hvsg4k6k6l CcVYkhL9TwzQRo8EYs4TR2peT5O0oUVVvEHJPfqW27rMimHThg7awD+RpUJTxFenje aR/fCoGhD9srXWk8T7eZeMw6Q1dONk/wlAD80q3A= From: Paul Elder 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: 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 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 was 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 rage 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 --- src/android/camera_device.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 76863877..a11ad848 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -900,6 +900,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() int32_t minFps = std::round(1e9 / maxFrameDurationNsec); minFps = std::max(1, minFps); + /* Avoid rounding errors 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.