From patchwork Tue Dec 21 04:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 15185 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 5087DBE080 for ; Tue, 21 Dec 2021 04:36:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEB8060903; Tue, 21 Dec 2021 05:36:30 +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="aUEv6oX/"; 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 147A2608E8 for ; Tue, 21 Dec 2021 05:36:28 +0100 (CET) Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EBFC881; Tue, 21 Dec 2021 05:36:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640061387; bh=NCGU+UFk0uU5BG8rtRhiVTrbDKwMgSL6EDVWg26Nt2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUEv6oX/lA4H36mD17bjW1qV3LVlvxBA6fzQuwg5FGtYYJU4ssQo9ULP53tdCdOqT mtRbMDExt4WQEuZwBlOPnZrhGop1pA6T6uhW4sT/omqCA5fuqvv5thPqAW/z6G0a+u XjCiGCrNZhMVk9ato9SaV8RFY4+JZfzCCHVnzCww= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Dec 2021 22:36:09 -0600 Message-Id: <20211221043610.2512334-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211221043610.2512334-1-paul.elder@ideasonboard.com> References: <20211221043610.2512334-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 7/8] android: Check exposure time range for manual sensor capability 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" In the manual sensor capability validator, add a check for the presence of the exposure time range key, and for the maximum exposure time. The minimum exposure time is a requirement for adding the key in the first place; add a check for this as well. If either requirement is not met, the manual sensor capability validation will fail, therefore disabling the FULL hardware level. The exposure time range key is optional in non-FULL hardware levels. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- Changes in v4: - s/i32/i64 Changes in v3: - squash "android: capabilities: Add exposure time keys only if available" - fix the minumum exposure time check - only make the exposure time range key available if this check passes. additionally, if the max exposure time passes its check, tick the box for manual sensor and FULL - update commit message accordingly Changes in v2: - fix comparator order (cosmetic) - change comparators and comments to "equal or", as that is what is specificied in the hal docs - add check for minimum exposure time when initializing static metadata --- src/android/camera_capabilities.cpp | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 318ab666..1bea15ca 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -217,6 +217,8 @@ std::vector setMetadata(CameraMetadata *metadata, uint32_t tag, bool CameraCapabilities::validateManualSensorCapability() { + camera_metadata_ro_entry_t entry; + const char *noMode = "Manual sensor capability unavailable: "; if (!staticMetadata_->entryContains(ANDROID_CONTROL_AE_AVAILABLE_MODES, @@ -231,6 +233,19 @@ bool CameraCapabilities::validateManualSensorCapability() return false; } + if (!staticMetadata_->hasEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE)) { + LOG(HAL, Info) << noMode << "missing exposure time range"; + return false; + } + + staticMetadata_->getEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, &entry); + if (entry.data.i64[1] <= 100000000) { + LOG(HAL, Info) + << noMode + << "exposure time range maximum must be larger than 100ms"; + return false; + } + /* * \todo Return true here after we satisfy all the requirements: * https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR @@ -808,7 +823,6 @@ int CameraCapabilities::initializeStaticMetadata() ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, - ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, ANDROID_SENSOR_INFO_PHYSICAL_SIZE, ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, @@ -886,7 +900,6 @@ int CameraCapabilities::initializeStaticMetadata() ANDROID_NOISE_REDUCTION_MODE, ANDROID_REQUEST_PIPELINE_DEPTH, ANDROID_SCALER_CROP_REGION, - ANDROID_SENSOR_EXPOSURE_TIME, ANDROID_SENSOR_FRAME_DURATION, ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, ANDROID_SENSOR_TEST_PATTERN_MODE, @@ -1148,8 +1161,20 @@ int CameraCapabilities::initializeStaticMetadata() exposureInfo->second.min().get() * 1000LL, exposureInfo->second.max().get() * 1000LL, }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, - exposureTimeRange, 2); + + if (exposureTimeRange[0] < 100000) { + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + exposureTimeRange, 2); + + availableCharacteristicsKeys_.insert(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE); + availableRequestKeys_.insert(ANDROID_SENSOR_EXPOSURE_TIME); + availableResultKeys_.insert(ANDROID_SENSOR_EXPOSURE_TIME); + } else { + LOG(HAL, Info) + << "Minimum exposure time " + << exposureTimeRange[0] + << "ns is too big (should be smaller than 100us)"; + } } staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, orientation_);