From patchwork Thu Jun 17 07:22: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: 12627 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 D1A12C3218 for ; Thu, 17 Jun 2021 07:23:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2C30868940; Thu, 17 Jun 2021 09:23:04 +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="hMTBoOJ8"; 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 149D460298 for ; Thu, 17 Jun 2021 09:23:03 +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 8F3AFE53; Thu, 17 Jun 2021 09:23:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1623914582; bh=32nW5JlleFmPkkRZQMzvmyd3TQiEVJlKb1j8Ou/bMJY=; h=From:To:Cc:Subject:Date:From; b=hMTBoOJ8CIYD8fcvjxDcD0xNVoVUSix1L7GVlznblBaW2MST3WIor1pEP0pvnkGuQ wDnzEH0O9nL0uN3O86DU/Tx0zj5QAlo7mNxbeaGhqta4QrYM4so8K+ucgV88QYaHnL UIxSSpIrL2vEGReL8vNYQkBD+r1M9x+x0fe06VJ0= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 17 Jun 2021 16:22:46 +0900 Message-Id: <20210617072246.1455382-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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. Bug: https://bugs.libcamera.org/show_bug.cgi?id=55 Signed-off-by: Paul Elder --- 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_device.cpp | 39 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8c71fd06..1e437907 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -840,6 +841,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() const ControlInfoMap &controlsInfo = camera_->controls(); const ControlList &properties = camera_->properties(); + std::map + capabilities = { + { ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, true }, + /* \todo Change these two to true when we have checks for them */ + { ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR, false }, + { ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING, false }, + { ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW, false }, + }; + /* Color correction static metadata. */ { std::vector data; @@ -1298,11 +1308,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() 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, @@ -1323,10 +1328,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() 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 = @@ -1338,7 +1339,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW && info.bitsPerPixel == 16) { rawStreamAvailable = true; - availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); + capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW] = true; } } @@ -1347,9 +1348,27 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, numOutStreams); + /* Check capabilities */ + std::vector availableCapabilities; + for (auto cap : capabilities) { + if (cap.second) + availableCapabilities.push_back(CapabilityTable.at(cap.first)); + } staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, availableCapabilities); + uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + if (capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR] && + capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING]) + supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; + staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, + supportedHWLevel); + + LOG(HAL, Info) + << "Hardware level: " + << supportedHWLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL + ? "FULL" : "LIMITED"; + std::vector availableCharacteristicsKeys = { ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,