From patchwork Tue Mar 30 09:49:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11789 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 3F145C0DA3 for ; Tue, 30 Mar 2021 09:50:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5B22868784; Tue, 30 Mar 2021 11:50:05 +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="AMYSkfJb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FB826877C for ; Tue, 30 Mar 2021 11:50:04 +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 918B9102; Tue, 30 Mar 2021 11:50:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617097803; bh=cPPQz3aQ69LRgyoDcvY84Dix8Z29CXiFuhR+KkyS2oM=; h=From:To:Cc:Subject:Date:From; b=AMYSkfJbGnQCDWDQaj34F//KZikuVqwcAG9ooIq3ljqOqhgdRjfJ7zLHWamWGBccQ /1vtXYp6PsPKnhBO9Rs2FNX+KyNqkCPNxIIgNCqdPSk0p27U3lB3MpGPPKMDJHz3RU B3nEyfnDj+xew6l9XrmDGEC+ksQioM5uJlDsllXU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Mar 2021 18:49:41 +0900 Message-Id: <20210330094941.127664-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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. 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 --- 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 931e9f37..91d4e8d4 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -799,6 +799,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.