{"id":15206,"url":"https://patchwork.libcamera.org/api/1.1/patches/15206/?format=json","web_url":"https://patchwork.libcamera.org/patch/15206/","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":"<20211221053304.2704780-3-paul.elder@ideasonboard.com>","date":"2021-12-21T05:33:04","name":"[libcamera-devel,2/2] android: Plumb hot pixel mode","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"7cc7cfcc956066c1aca7b777d0e9f18a6bd69b05","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/15206/mbox/","series":[{"id":2857,"url":"https://patchwork.libcamera.org/api/1.1/series/2857/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2857","date":"2021-12-21T05:33:03","name":"android: Hot pixel correction","version":1,"mbox":"https://patchwork.libcamera.org/series/2857/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15206/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15206/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 86025C3258\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Dec 2021 05:33:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B4D16090C;\n\tTue, 21 Dec 2021 06:33:18 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D5D6608EB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Dec 2021 06:33:14 +0100 (CET)","from pyrite.mediacom.info (unknown\n\t[IPv6:2604:2d80:ad90:fb00:96fd:8874:873:6c16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DD69FD2;\n\tTue, 21 Dec 2021 06:33:13 +0100 (CET)"],"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=\"L4MbhkTp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640064794;\n\tbh=nzR+iTqrvmeL9h3+bzgU0m2kB+Qfx6YoTmjhB8G+zqg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=L4MbhkTpvu8/0c7Kt4+Q4wgms1IlpsePGDaDbiylLMoDQUT6zHWGnfTEFIFX1MsbW\n\tLxtAnWs/RyAXa/+1V9wzyZJAlxpRb5fqPrxuHq98YQmllWyCAqZMK0VRz3Z305k0HE\n\t7ebesK5QeZ+yAyDxK5rUFmdGVD44ZHnzeqqp+Bbw=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 20 Dec 2021 23:33:04 -0600","Message-Id":"<20211221053304.2704780-3-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20211221053304.2704780-1-paul.elder@ideasonboard.com>","References":"<20211221053304.2704780-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/2] android: Plumb hot pixel mode","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":"Plumb hot pixel mode:\n- add check for hardware level FULL\n- static metadata: report the available modes, enable the keys\n- request, result: convert between libcamera control and android control\n- add to templates\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/android/camera_capabilities.cpp | 55 +++++++++++++++++++++++++++++\n src/android/camera_device.cpp       | 46 ++++++++++++++++++++++++\n 2 files changed, 101 insertions(+)","diff":"diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex 2ce465aa..c52b22be 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -492,6 +492,12 @@ void CameraCapabilities::computeHwLevel(\n \t\thwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;\n \t}\n \n+\tfound = availableResultKeys_.count(ANDROID_HOT_PIXEL_MODE);\n+\tif (!found) {\n+\t\tLOG(HAL, Info) << noFull << \"missing hot pixel mode\";\n+\t\thwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;\n+\t}\n+\n \thwLevel_ = hwLevel;\n }\n \n@@ -1132,6 +1138,37 @@ int CameraCapabilities::initializeStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,\n \t\t\t\t  availableStabilizationModes);\n \n+\tstd::vector<uint8_t> availableHotPixelModes;\n+\tconst auto &hotPixelInfo = controlsInfo.find(&controls::draft::HotPixelMode);\n+\tif (hotPixelInfo != controlsInfo.end()) {\n+\t\tfor (const auto &value : hotPixelInfo->second.values()) {\n+\t\t\tuint8_t mode;\n+\t\t\tswitch (value.get<int32_t>()) {\n+\t\t\tcase controls::draft::HotPixelModeOff:\n+\t\t\t\tmode = ANDROID_HOT_PIXEL_MODE_OFF;\n+\t\t\t\tbreak;\n+\t\t\tcase controls::draft::HotPixelModeFast:\n+\t\t\t\tmode = ANDROID_HOT_PIXEL_MODE_FAST;\n+\t\t\t\tbreak;\n+\t\t\tcase controls::draft::HotPixelModeHighQuality:\n+\t\t\t\tmode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY;\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\tLOG(HAL, Error) << \"Unknown hot pixel mode\";\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tavailableHotPixelModes.push_back(mode);\n+\t\t}\n+\n+\t\tstaticMetadata_->addEntry(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,\n+\t\t\t\t\t  availableHotPixelModes);\n+\n+\t\tavailableCharacteristicsKeys_.insert(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES);\n+\t\tavailableRequestKeys_.insert(ANDROID_HOT_PIXEL_MODE);\n+\t\tavailableResultKeys_.insert(ANDROID_HOT_PIXEL_MODE);\n+\t}\n+\n \t/*\n \t * \\todo Inspect the camera capabilities to report the available\n \t * AWB modes. Default to AUTO as CTS tests require it.\n@@ -1995,6 +2032,12 @@ std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplatePreview() con\n \t\trequestTemplate->addEntry(ANDROID_TONEMAP_MODE, tonemapMode);\n \t}\n \n+\tif (staticMetadata_->entryContains<uint8_t>(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,\n+\t\t\t\t\t\t    ANDROID_HOT_PIXEL_MODE_FAST)) {\n+\t\tuint8_t hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST;\n+\t\trequestTemplate->addEntry(ANDROID_HOT_PIXEL_MODE, hotPixelMode);\n+\t}\n+\n \treturn requestTemplate;\n }\n \n@@ -2029,6 +2072,12 @@ std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateStill() const\n \t\tstillTemplate->appendEntry(ANDROID_TONEMAP_MODE, tonemapMode);\n \t}\n \n+\tif (staticMetadata_->entryContains<uint8_t>(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,\n+\t\t\t\t\t\t    ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY)) {\n+\t\tuint8_t hotPixelMode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY;\n+\t\tstillTemplate->appendEntry(ANDROID_HOT_PIXEL_MODE, hotPixelMode);\n+\t}\n+\n \treturn stillTemplate;\n }\n \n@@ -2058,6 +2107,12 @@ std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateVideo() const\n \t\tpreviewTemplate->appendEntry(ANDROID_TONEMAP_MODE, tonemapMode);\n \t}\n \n+\tif (staticMetadata_->entryContains<uint8_t>(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,\n+\t\t\t\t\t\t    ANDROID_HOT_PIXEL_MODE_FAST)) {\n+\t\tuint8_t hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST;\n+\t\tpreviewTemplate->appendEntry(ANDROID_HOT_PIXEL_MODE, hotPixelMode);\n+\t}\n+\n \t/*\n \t * Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata\n \t * has been assembled as {{min, max} {max, max}}.\ndiff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 7cffb4b1..7cab878c 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -973,6 +973,27 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)\n \t\t}\n \t}\n \n+\tif (settings.getEntry(ANDROID_HOT_PIXEL_MODE, &entry)) {\n+\t\tconst int32_t data = static_cast<int32_t>(*entry.data.u8);\n+\t\tint32_t hotPixelMode;\n+\t\tswitch (data) {\n+\t\tcase ANDROID_HOT_PIXEL_MODE_OFF:\n+\t\t\thotPixelMode = controls::draft::HotPixelModeOff;\n+\t\t\tbreak;\n+\t\tcase ANDROID_HOT_PIXEL_MODE_FAST:\n+\t\t\thotPixelMode = controls::draft::HotPixelModeFast;\n+\t\t\tbreak;\n+\t\tcase ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY:\n+\t\t\thotPixelMode = controls::draft::HotPixelModeHighQuality;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Unknown hot pixel mode: \" << data;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tcontrols.set(controls::draft::HotPixelMode, hotPixelMode);\n+\t}\n+\n \tif (settings.getEntry(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, &entry)) {\n \t\tconst int32_t data = static_cast<int32_t>(*entry.data.u8);\n \t\tint32_t statsLensShadingMode;\n@@ -1793,6 +1814,31 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons\n \t\tresultMetadata->addEntry(ANDROID_EDGE_MODE, descriptor.edgeMode_);\n \t}\n \n+\tif (metadata.contains(controls::draft::HotPixelMode)) {\n+\t\tbool valid;\n+\t\tswitch (metadata.get(controls::draft::HotPixelMode)) {\n+\t\tcase controls::draft::HotPixelModeOff:\n+\t\t\tvalue = ANDROID_HOT_PIXEL_MODE_OFF;\n+\t\t\tvalid = true;\n+\t\t\tbreak;\n+\t\tcase controls::draft::HotPixelModeFast:\n+\t\t\tvalue = ANDROID_HOT_PIXEL_MODE_FAST;\n+\t\t\tvalid = true;\n+\t\t\tbreak;\n+\t\tcase controls::draft::HotPixelModeHighQuality:\n+\t\t\tvalue = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY;\n+\t\t\tvalid = true;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Invalid hot pixel mode\";\n+\t\t\tvalid = false;\n+\t\t}\n+\n+\t\t/* Can be null on non-FULL */\n+\t\tif (valid)\n+\t\t\tresultMetadata->addEntry(ANDROID_HOT_PIXEL_MODE, value);\n+\t}\n+\n \tif (metadata.contains(controls::ScalerCrop)) {\n \t\tRectangle crop = metadata.get(controls::ScalerCrop);\n \t\tint32_t cropRect[] = {\n","prefixes":["libcamera-devel","2/2"]}