{"id":12627,"url":"https://patchwork.libcamera.org/api/1.1/patches/12627/?format=json","web_url":"https://patchwork.libcamera.org/patch/12627/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210617072246.1455382-1-paul.elder@ideasonboard.com>","date":"2021-06-17T07:22:46","name":"[libcamera-devel] android: Add infrastructure for determining capabilities and hardware level","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1386906102e50c01f8844d7223aef2a660112614","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/users/17/?format=json","username":"epaul","first_name":"Paul","last_name":"Elder","email":"paul.elder@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/12627/mbox/","series":[{"id":2148,"url":"https://patchwork.libcamera.org/api/1.1/series/2148/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2148","date":"2021-06-17T07:22:46","name":"[libcamera-devel] android: Add infrastructure for determining capabilities and hardware level","version":1,"mbox":"https://patchwork.libcamera.org/series/2148/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12627/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12627/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D1A12C3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Jun 2021 07:23:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2C30868940;\n\tThu, 17 Jun 2021 09:23:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 149D460298\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Jun 2021 09:23:03 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F3AFE53;\n\tThu, 17 Jun 2021 09:23:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"hMTBoOJ8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1623914582;\n\tbh=32nW5JlleFmPkkRZQMzvmyd3TQiEVJlKb1j8Ou/bMJY=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=hMTBoOJ8CIYD8fcvjxDcD0xNVoVUSix1L7GVlznblBaW2MST3WIor1pEP0pvnkGuQ\n\twDnzEH0O9nL0uN3O86DU/Tx0zj5QAlo7mNxbeaGhqta4QrYM4so8K+ucgV88QYaHnL\n\tUIxSSpIrL2vEGReL8vNYQkBD+r1M9x+x0fe06VJ0=","From":"Paul Elder <paul.elder@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] android: Add infrastructure for\n\tdetermining capabilities and hardware level","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add the infrastructure for checking and reporting capabilities. Use\nthese capabilities to determine the hardware level as well.\n\nSince the raw capability is set to true when support is determined to be\navailable, leave that as default false and set to true, since copying\nthe pattern of the other capabilities would cause redundant code.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=55\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nThis is my vision of how we would support the various capabilities.\nAlthough we don't have anything for FULL yet; I imagine that we would\nstart the flags for manual sensor and manual post processing with true,\nand then if a required control is unavailable, then we would set the\nflag to false.\n\nI considered declaring an enum in CameraDevice to mirror the android\nones, just for shorthand, but it seemed like a lot of code for not much\ngain. Unless the shorthand would be valuable because these constant\nnames are so long?\n\nI think the available keys lists will have to be moved to the head of\nthe function, and then as available controls are discovered add them to\nthat list.\n---\n src/android/camera_device.cpp | 39 ++++++++++++++++++++++++++---------\n 1 file changed, 29 insertions(+), 10 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 8c71fd06..1e437907 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -13,6 +13,7 @@\n #include <array>\n #include <cmath>\n #include <fstream>\n+#include <map>\n #include <sys/mman.h>\n #include <tuple>\n #include <unistd.h>\n@@ -840,6 +841,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tconst ControlInfoMap &controlsInfo = camera_->controls();\n \tconst ControlList &properties = camera_->properties();\n \n+\tstd::map<camera_metadata_enum_android_request_available_capabilities, bool>\n+\tcapabilities = {\n+\t\t{ ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, true },\n+\t\t/* \\todo Change these two to true when we have checks for them */\n+\t\t{ ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR, false },\n+\t\t{ ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING, false },\n+\t\t{ ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW, false },\n+\t};\n+\n \t/* Color correction static metadata. */\n \t{\n \t\tstd::vector<uint8_t> data;\n@@ -1298,11 +1308,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tuint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY;\n \tstaticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, croppingType);\n \n-\t/* Info static metadata. */\n-\tuint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;\n-\tstaticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,\n-\t\t\t\t  supportedHWLevel);\n-\n \t/* Request static metadata. */\n \tint32_t partialResultCount = 1;\n \tstaticMetadata_->addEntry(ANDROID_REQUEST_PARTIAL_RESULT_COUNT,\n@@ -1323,10 +1328,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,\n \t\t\t\t  maxNumInputStreams);\n \n-\tstd::vector<uint8_t> availableCapabilities = {\n-\t\tANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,\n-\t};\n-\n \t/* Report if camera supports RAW. */\n \tbool rawStreamAvailable = false;\n \tstd::unique_ptr<CameraConfiguration> cameraConfig =\n@@ -1338,7 +1339,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW &&\n \t\t    info.bitsPerPixel == 16) {\n \t\t\trawStreamAvailable = true;\n-\t\t\tavailableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW);\n+\t\t\tcapabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW] = true;\n \t\t}\n \t}\n \n@@ -1347,9 +1348,27 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,\n \t\t\t\t  numOutStreams);\n \n+\t/* Check capabilities */\n+\tstd::vector<uint8_t> availableCapabilities;\n+\tfor (auto cap : capabilities) {\n+\t\tif (cap.second)\n+\t\t\tavailableCapabilities.push_back(CapabilityTable.at(cap.first));\n+\t}\n \tstaticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES,\n \t\t\t\t  availableCapabilities);\n \n+\tuint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;\n+\tif (capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR] &&\n+\t    capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING])\n+\t\tsupportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL;\n+\tstaticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,\n+\t\t\t\t  supportedHWLevel);\n+\n+\tLOG(HAL, Info)\n+\t\t<< \"Hardware level: \"\n+\t\t<< supportedHWLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL\n+\t\t   ? \"FULL\" : \"LIMITED\";\n+\n \tstd::vector<int32_t> availableCharacteristicsKeys = {\n \t\tANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,\n \t\tANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,\n","prefixes":["libcamera-devel"]}