{"id":24256,"url":"https://patchwork.libcamera.org/api/patches/24256/?format=json","web_url":"https://patchwork.libcamera.org/patch/24256/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20250828-flash-support-v1-4-4c5dc674a05b@emfend.at>","date":"2025-08-28T13:09:41","name":"[4/5] libcamera: Add flash helpers for pipeline handlers","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"4b26c64c8a1a8b07d2a086f49f52c175104737f6","submitter":{"id":134,"url":"https://patchwork.libcamera.org/api/people/134/?format=json","name":"Matthias Fend","email":"matthias.fend@emfend.at"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24256/mbox/","series":[{"id":5410,"url":"https://patchwork.libcamera.org/api/series/5410/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5410","date":"2025-08-28T13:09:37","name":"Support for v4l2 flash devices","version":1,"mbox":"https://patchwork.libcamera.org/series/5410/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24256/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24256/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 C8D31BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Aug 2025 13:09:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3CEDB692FF;\n\tThu, 28 Aug 2025 15:09:53 +0200 (CEST)","from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EE61692FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Aug 2025 15:09:45 +0200 (CEST)","from 194-208-208-245.tele.net ([194.208.208.245]:56023\n\thelo=[127.0.1.1]) by lx20.hoststar.hosting with esmtpsa (TLS1.3) tls\n\tTLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93)\n\t(envelope-from <matthias.fend@emfend.at>)\n\tid 1urcNs-00BORr-A3; Thu, 28 Aug 2025 15:09:44 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=emfend.at header.i=@emfend.at\n\theader.b=\"EUMU6q6I\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=emfend.at;\n\ts=mail;\n\th=Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:\n\tContent-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=sdkycQQGxXilrDAODlo8QVoy3nUofpFkOR1OAY89pFo=;\n\tb=EUMU6q6IIpavCWgdCv3WR7uirN\n\tIYWuMW3VbZe8mSK90bEd1urfkA4E/KqwvATrpMHQlTRLl/BL+X7XdFTwS9S+SBJjto3cUzTWqPPF5\n\tHK50Q9gISd97RQcyRFkZRAV1WLQ9d0QhODP6i0hu2xKbl8+m0WEIAYarlGEggtQTHefQ=;","From":"Matthias Fend <matthias.fend@emfend.at>","Date":"Thu, 28 Aug 2025 15:09:41 +0200","Subject":"[PATCH 4/5] libcamera: Add flash helpers for pipeline handlers","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20250828-flash-support-v1-4-4c5dc674a05b@emfend.at>","References":"<20250828-flash-support-v1-0-4c5dc674a05b@emfend.at>","In-Reply-To":"<20250828-flash-support-v1-0-4c5dc674a05b@emfend.at>","To":"libcamera-devel@lists.libcamera.org","Cc":"Matthias Fend <matthias.fend@emfend.at>","X-Mailer":"b4 0.14.2","X-Spam-Score":"-0.7","X-Spam-Bar":"/","X-Spam-Report":"Spam detection software,\n\trunning on the system \"lx20.hoststar.hosting\", \n\thas NOT identified this incoming email as spam.  The original\n\tmessage has been attached to this so you can view it or label\n\tsimilar future email.  If you have any questions, see\n\tthe administrator of that system for details.\n\tContent preview: Document the requirements for the v4l2 flash device\n\tdrivers required by libcamera. Signed-off-by: Matthias Fend\n\t<matthias.fend@emfend.at>\n\t--- Documentation/documentation-contents.rst | 1 +\n\tDocumentation/flash_driver_requirements.rst\n\t| 40 +++++++++++++++++++++++++++++ Documentation/i [...] \n\tContent analysis details:   (-0.7 points, 5.0 required)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was\n\tblocked.  See\n\thttp://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block\n\tfor more information. [URIs: meson.build]\n\t0.0 URIBL_DBL_BLOCKED_OPENDNS ADMINISTRATOR NOTICE: The query to\n\tdbl.spamhaus.org was blocked due to usage\n\tof an open resolver. See https://www.spamhaus.org/returnc/pub/\n\t[URIs: meson.build]\n\t0.0 URIBL_ZEN_BLOCKED_OPENDNS ADMINISTRATOR NOTICE: The query to\n\tzen.spamhaus.org was blocked due to usage\n\tof an open resolver. See https://www.spamhaus.org/returnc/pub/\n\t[URIs: meson.build]\n\t-1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP\n\t0.0 TVD_RCVD_IP            Message was received from an IP address\n\t0.0 Local_hs1_NotHoststar  Sender is not from hoststar.ch|de|com\n\t0.0 KAM_DMARC_STATUS Test Rule for DKIM or SPF Failure with Strict\n\tAlignment\n\t0.2 KAM_LOTSOFHASH         Emails with lots of hash-like gibberish","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 a set of helpers that pipeline handlers can use to deal with camera\nflash devices. This mainly involves mapping controls to the flash device\nand vice versa.\n\nSigned-off-by: Matthias Fend <matthias.fend@emfend.at>\n---\n include/libcamera/internal/flash_control.h |  23 +++++++\n src/libcamera/flash_control.cpp            | 103 +++++++++++++++++++++++++++++\n src/libcamera/meson.build                  |   1 +\n 3 files changed, 127 insertions(+)","diff":"diff --git a/include/libcamera/internal/flash_control.h b/include/libcamera/internal/flash_control.h\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..d530dc24fd8ea2d5676d95ab5943a7dacee07617\n--- /dev/null\n+++ b/include/libcamera/internal/flash_control.h\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2025, matthias.fend@emfend.at\n+ *\n+ * Flash controls helpers for pipeline handlers\n+ */\n+\n+#pragma once\n+\n+#include <libcamera/controls.h>\n+\n+#include \"libcamera/internal/camera_flash.h\"\n+\n+namespace libcamera {\n+\n+class FlashControl\n+{\n+public:\n+\tstatic void updateFlashControls(CameraFlash *flash, ControlInfoMap::Map &controls);\n+\tstatic void handleFlashControls(CameraFlash *flash, ControlList &controls, ControlList &metadata);\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/flash_control.cpp b/src/libcamera/flash_control.cpp\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..0350bfb7c6600d0cba767726be17678ce792e5e5\n--- /dev/null\n+++ b/src/libcamera/flash_control.cpp\n@@ -0,0 +1,103 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2025, matthias.fend@emfend.at\n+ *\n+ * Flash controls helpers for pipeline handlers\n+ */\n+\n+#include \"libcamera/internal/flash_control.h\"\n+\n+#include <libcamera/control_ids.h>\n+#include <libcamera/controls.h>\n+\n+namespace libcamera {\n+\n+void FlashControl::updateFlashControls(CameraFlash *flash, ControlInfoMap::Map &controls)\n+{\n+\tif (!flash)\n+\t\treturn;\n+\n+\tcontrols[&controls::draft::FlashMode] = ControlInfo(controls::draft::FlashModeValues, controls::draft::FlashModeNone);\n+\tcontrols[&controls::draft::FlashIntensity] = flash->getFlashIntensityInfo();\n+\tcontrols[&controls::draft::FlashTimeout] = flash->getFlashTimeoutInfo();\n+\tcontrols[&controls::draft::FlashStrobeSource] = ControlInfo(controls::draft::FlashStrobeSourceValues, controls::draft::FlashStrobeSourceSoftware);\n+\tcontrols[&controls::draft::FlashStrobe] = ControlInfo(controls::draft::FlashStrobeValues);\n+\tcontrols[&controls::draft::FlashTorchIntensity] = flash->getTorchIntensityInfo();\n+}\n+\n+void FlashControl::handleFlashControls(CameraFlash *flash, ControlList &controls, ControlList &metadata)\n+{\n+\tif (!flash)\n+\t\treturn;\n+\n+\tconst auto &flashMode = controls.get(controls::draft::FlashMode);\n+\tif (flashMode) {\n+\t\tCameraFlash::Mode mode;\n+\n+\t\tswitch (*flashMode) {\n+\t\tcase controls::draft::FlashModeFlash:\n+\t\t\tmode = CameraFlash::Mode::Flash;\n+\t\t\tbreak;\n+\t\tcase controls::draft::FlashModeTorch:\n+\t\t\tmode = CameraFlash::Mode::Torch;\n+\t\t\tbreak;\n+\t\tcase controls::draft::FlashModeNone:\n+\t\tdefault:\n+\t\t\tmode = CameraFlash::Mode::None;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tflash->setMode(mode);\n+\t}\n+\n+\tconst auto &flashIntensity = controls.get<int32_t>(controls::draft::FlashIntensity);\n+\tif (flashIntensity)\n+\t\tflash->setFlashIntensity(*flashIntensity);\n+\n+\tconst auto &flashTimeout = controls.get<int32_t>(controls::draft::FlashTimeout);\n+\tif (flashTimeout)\n+\t\tflash->setFlashTimeout(*flashTimeout);\n+\n+\tconst auto &flashStrobeSource = controls.get(controls::draft::FlashStrobeSource);\n+\tif (flashStrobeSource) {\n+\t\tCameraFlash::StrobeSource source;\n+\n+\t\tswitch (*flashStrobeSource) {\n+\t\tcase controls::draft::FlashStrobeSourceExternal:\n+\t\t\tsource = CameraFlash::StrobeSource::External;\n+\t\t\tbreak;\n+\t\tcase controls::draft::FlashStrobeSourceSoftware:\n+\t\tdefault:\n+\t\t\tsource = CameraFlash::StrobeSource::Software;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tflash->setStrobeSource(source);\n+\t}\n+\n+\tconst auto &flashStrobe = controls.get(controls::draft::FlashStrobe);\n+\tif (flashStrobe) {\n+\t\tswitch (*flashStrobe) {\n+\t\tcase controls::draft::FlashStrobeEnum::FlashStrobeStart:\n+\t\t\tflash->startStrobe();\n+\t\t\tbreak;\n+\t\tcase controls::draft::FlashStrobeEnum::FlashStrobeStop:\n+\t\t\tflash->stopStrobe();\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tconst auto &flashTorchIntensity = controls.get<int32_t>(controls::draft::FlashTorchIntensity);\n+\tif (flashTorchIntensity)\n+\t\tflash->setTorchIntensity(*flashTorchIntensity);\n+\n+\tmetadata.set(controls::draft::FlashMode, flash->getMode());\n+\tmetadata.set(controls::draft::FlashIntensity, flash->getFlashIntensity());\n+\tmetadata.set(controls::draft::FlashTimeout, flash->getFlashTimeout());\n+\tmetadata.set(controls::draft::FlashStrobeSource, flash->getStrobeSource());\n+\tmetadata.set(controls::draft::FlashTorchIntensity, flash->getTorchIntensity());\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 0f125661a51e2431c1febc353cef30a1219f9ce7..a68a49637db12f9e66b5bb38ee859aaac8c2fd1a 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -31,6 +31,7 @@ libcamera_internal_sources = files([\n     'device_enumerator.cpp',\n     'device_enumerator_sysfs.cpp',\n     'dma_buf_allocator.cpp',\n+    'flash_control.cpp',\n     'formats.cpp',\n     'ipa_controls.cpp',\n     'ipa_data_serializer.cpp',\n","prefixes":["4/5"]}