From patchwork Fri Jul 2 10:37:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12767 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 B4ED3C3222 for ; Fri, 2 Jul 2021 10:38:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FE59684F5; Fri, 2 Jul 2021 12:38:18 +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="lcFeDnjz"; 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 8486A684F4 for ; Fri, 2 Jul 2021 12:38:16 +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 1D8384AB; Fri, 2 Jul 2021 12:38:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625222296; bh=suJnK99d9R8uCjtGTWwDvgmBLODHQYMksj5ADPhFG8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcFeDnjzyRfF+HjtozDUjpZtLXb8Kv88DXQf2FqhwUKtakIpL3uUUEF6ziT4p1n3C +SY3cMQjv/4Sb12E9Em9kh3d+yp2HNx7e/XB2vPpFwT17Tw0xEd4Zd8JMutt1OjN+7 fa9iRo9z6+goMrMYScZbW5jbzZFLcspaiBVfar5E= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 19:37:46 +0900 Message-Id: <20210702103800.41291-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210702103800.41291-1-paul.elder@ideasonboard.com> References: <20210702103800.41291-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v4 02/16] android: Add infrastructure for determining capabilities and hardware level 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" Add the infrastructure for checking and reporting capabilities. Use these capabilities to determine the hardware level as well. Since the raw capability is set to true when support is determined to be available, leave that as default false and set to true, since copying the pattern of the other capabilities would cause redundant code. Note that this will cause CTS to fail, as we don't yet declare the lack of support for FULL based on the available controls. Bug: https://bugs.libcamera.org/show_bug.cgi?id=55 Signed-off-by: Paul Elder --- Changes in v4: - rebase on camera capabilities refactoring - switch to std::set from std::map - make hwlevel similar to capabilities Changes in v3: - fix some compiler errors - go ahead and initialize the capabilities to true, update the commit message accordingly Changes in v2: - add a flag for FULL, since there are a few requirements that are not obtained from capabilities alone - add burst capture capability, since that is required for FULL as well This is my vision of how we would support the various capabilities. Although we don't have anything for FULL yet; I imagine that we would start the flags for manual sensor and manual post processing with true, and then if a required control is unavailable, then we would set the flag to false. I considered declaring an enum in CameraDevice to mirror the android ones, just for shorthand, but it seemed like a lot of code for not much gain. Unless the shorthand would be valuable because these constant names are so long? I think the available keys lists will have to be moved to the head of the function, and then as available controls are discovered add them to that list. --- src/android/camera_capabilities.cpp | 50 +++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6b5edb66..54bd71da 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -114,6 +115,15 @@ const std::map camera3FormatsMap = { }, }; +const std::map +hwLevelStrings = { + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, "LIMITED" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL, "FULL" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, "LEGACY" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3, "LEVEL_3" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL, "EXTERNAL" }, +}; + } /* namespace */ int CameraCapabilities::initialize(std::shared_ptr camera, @@ -376,6 +386,19 @@ int CameraCapabilities::initializeStaticMetadata() const ControlInfoMap &controlsInfo = camera_->controls(); const ControlList &properties = camera_->properties(); + std::set + capabilities = { + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE, + }; + + std::set + hwLevels = { + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL, + }; + /* Color correction static metadata. */ { std::vector data; @@ -834,11 +857,6 @@ int CameraCapabilities::initializeStaticMetadata() uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY; staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, croppingType); - /* Info static metadata. */ - uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; - staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, - supportedHWLevel); - /* Request static metadata. */ int32_t partialResultCount = 1; staticMetadata_->addEntry(ANDROID_REQUEST_PARTIAL_RESULT_COUNT, @@ -859,10 +877,6 @@ int CameraCapabilities::initializeStaticMetadata() staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, maxNumInputStreams); - std::vector availableCapabilities = { - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, - }; - /* Report if camera supports RAW. */ bool rawStreamAvailable = false; std::unique_ptr cameraConfig = @@ -874,7 +888,7 @@ int CameraCapabilities::initializeStaticMetadata() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW && info.bitsPerPixel == 16) { rawStreamAvailable = true; - availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); + capabilities.insert(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); } } @@ -883,9 +897,25 @@ int CameraCapabilities::initializeStaticMetadata() staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, numOutStreams); + /* Check capabilities */ + std::vector availableCapabilities(capabilities.begin(), + capabilities.end()); staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, availableCapabilities); + uint8_t hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + if (capabilities.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR) && + capabilities.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING) && + capabilities.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE) && + hwLevels.count(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL)) + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; + staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, + hwLevel); + + LOG(HAL, Info) + << "Hardware level: " + << hwLevelStrings.find((camera_metadata_enum_android_info_supported_hardware_level)hwLevel)->second; + std::vector availableCharacteristicsKeys = { ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,