From patchwork Thu Apr 1 10:13:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11808 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 A40B8C0DA4 for ; Thu, 1 Apr 2021 10:13:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D17C6877C; Thu, 1 Apr 2021 12:13:58 +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="rnZUWyjc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 726DB6877C for ; Thu, 1 Apr 2021 12:13:57 +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 E917CF7; Thu, 1 Apr 2021 12:13:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272037; bh=Rt2fUsGmgRsrmQj4W1bmEZDWInTDjnToWsB5lFEwIPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rnZUWyjciCsdTNABfa5Fu+dv765IXFfAFqLmOYjpsfUsJWOZH4Qrnm3Eno7auy8WS X3DESXIYB1YEPgSG8TxrByz5R3LPS4JErLMcpxvLd6PIQjV/TfcWUbJ2sTRDao//Y2 G/i742dz/FL6MqpTW7EW/Ty4Fgj1Frg0s2dHtsgY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:34 +0900 Message-Id: <20210401101340.160590-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 2/8] 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 --- 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 2a685507..30ea3ade 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.