From patchwork Fri Dec 3 07:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15001 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 F3BB6BDB13 for ; Fri, 3 Dec 2021 07:15:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49A21607DE; Fri, 3 Dec 2021 08:15:20 +0100 (CET) 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="hju8hPZL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB02B60118 for ; Fri, 3 Dec 2021 08:15:18 +0100 (CET) Received: from perceval.ideasonboard.com (unknown [103.251.226.170]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE38BA59; Fri, 3 Dec 2021 08:15:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638515718; bh=PTWXuGBqsfZrrFJGvETV2Ga/hbh5pg+37eTBbPK12YQ=; h=From:To:Cc:Subject:Date:From; b=hju8hPZLWYRmO9/Vfdeh1I29MKoW7+098uE9GVO87qWxwNW51aFyE82/aI5PrJa3C j0wQJ38z4WoOahR8VNqTI+A6PaOQKPZWqbDwiXgq8/NI2jk5fK9jsDS49outwrV4Jw qQ0WBnugp01q1LyevEbjLHF29N71ObKbj9Eb6Q+0= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Dec 2021 12:45:12 +0530 Message-Id: <20211203071512.1197248-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: Apply 1% tolerance to minFrameDuration capping 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" We have some stream resolution which can provide slightly better frame duration than what we cap (i.e. 1/30 fps). The problem with this is CTS complains if the camera goes faster during the test than minFrameDuration reported for that resolution. For instance, 1080p minFrameDuration: - Nautilus : 33282000ns - Soraka : 33147000ns Both are less than capped minFrameDuration 1/30 fps (33333333.33ns). This patch considers this situation and doesn't cap the minFrameDuration if the hardware can provide frame durations slightly better. The tolerance considered is 1% only from the cap. Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder --- On LIMITED level - no regressions were found : 230/231 pass rate On FULL level - this fixes the test: android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange --- src/android/camera_capabilities.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index f357902e..c4c26089 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -648,7 +648,7 @@ int CameraCapabilities::initializeStreamConfigurations() int64_t maxFrameDuration = frameDurations->second.max().get() * 1000; /* - * Cap min frame duration to 30 FPS. + * Cap min frame duration to 30 FPS with 1% tolerance. * * 30 frames per second has been validated as the most * opportune frame rate for quality tuning, and power @@ -667,8 +667,18 @@ int CameraCapabilities::initializeStreamConfigurations() * control to be specified for each Request. Defer this * to the in-development configuration API rework. */ - if (minFrameDuration < 1e9 / 30.0) - minFrameDuration = 1e9 / 30.0; + int64_t minFrameDurationCap = 1e9 / 30.0; + if (minFrameDuration < minFrameDurationCap) { + float tolerance = + (minFrameDurationCap - minFrameDuration) * 100.0 / minFrameDurationCap; + + /* + * If the tolerance is less than 1%, do not cap + * the frame duration. + */ + if (tolerance > 1.0) + minFrameDuration = minFrameDurationCap; + } streamConfigurations_.push_back({ res, androidFormat, minFrameDuration, maxFrameDuration,