From patchwork Tue Jan 26 17:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11020 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 15369BD808 for ; Tue, 26 Jan 2021 17:29:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 048BA68334; Tue, 26 Jan 2021 18:29:58 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C1BD6831B for ; Tue, 26 Jan 2021 18:29:54 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 66E57E000A for ; Tue, 26 Jan 2021 17:29:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:06 +0100 Message-Id: <20210126173008.446321-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] fixup! android: camera_device: Compute 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" --- src/android/camera_device.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Reviewed-by: Laurent Pinchart diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e3d43bea4700..5a8072a8a007 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -768,6 +768,26 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() minFrameDurationUsec = frameDurationsInfo->second.min().get(); maxFrameDurationUsec = frameDurationsInfo->second.max().get(); + /* + * Adjust the minimum frame duration to comply with Android + * requirements. The camera service mandates all preview/record + * streams to have a minimum frame duration < 33,366 milliseconds + * (see MAX_PREVIEW_RECORD_DURATION_NS in the camera service + * implementation). + * + * If we're close enough (+- 500 useconds) to that value round + * the minimum frame duration of the camera to an accepted + * value. + */ + static constexpr double MIN_PREVIEW_RECORD_FPS = 29.97; + static constexpr int64_t MAX_PREVIEW_RECORD_DURATION_US = 1e6 / MIN_PREVIEW_RECORD_FPS; + if (minFrameDurationUsec > MAX_PREVIEW_RECORD_DURATION_US) { + double frameDurationDelta = minFrameDurationUsec - + MAX_PREVIEW_RECORD_DURATION_US; + if (frameDurationDelta < 500) + minFrameDurationUsec = MAX_PREVIEW_RECORD_DURATION_US - 1; + } + /* * The AE routine frame rate limits are computed using the frame * duration limits, as libcamera clips the AE routine to the