From patchwork Thu Aug 28 13:09:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24256 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 C8D31BD87C for ; Thu, 28 Aug 2025 13:09:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3CEDB692FF; Thu, 28 Aug 2025 15:09:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=emfend.at header.i=@emfend.at header.b="EUMU6q6I"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EE61692FF for ; Thu, 28 Aug 2025 15:09:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=emfend.at; s=mail; h=Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=sdkycQQGxXilrDAODlo8QVoy3nUofpFkOR1OAY89pFo=; b=EUMU6q6IIpavCWgdCv3WR7uirN IYWuMW3VbZe8mSK90bEd1urfkA4E/KqwvATrpMHQlTRLl/BL+X7XdFTwS9S+SBJjto3cUzTWqPPF5 HK50Q9gISd97RQcyRFkZRAV1WLQ9d0QhODP6i0hu2xKbl8+m0WEIAYarlGEggtQTHefQ=; Received: from 194-208-208-245.tele.net ([194.208.208.245]:56023 helo=[127.0.1.1]) by lx20.hoststar.hosting with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1urcNs-00BORr-A3; Thu, 28 Aug 2025 15:09:44 +0200 From: Matthias Fend Date: Thu, 28 Aug 2025 15:09:41 +0200 Subject: [PATCH 4/5] libcamera: Add flash helpers for pipeline handlers MIME-Version: 1.0 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 X-Mailer: b4 0.14.2 X-Spam-Score: -0.7 X-Spam-Bar: / X-Spam-Report: Spam detection software, running on the system "lx20.hoststar.hosting", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Document the requirements for the v4l2 flash device drivers required by libcamera. Signed-off-by: Matthias Fend --- Documentation/documentation-contents.rst | 1 + Documentation/flash_driver_requirements.rst | 40 +++++++++++++++++++++++++++++ Documentation/i [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: meson.build] 0.0 URIBL_DBL_BLOCKED_OPENDNS ADMINISTRATOR NOTICE: The query to dbl.spamhaus.org was blocked due to usage of an open resolver. See https://www.spamhaus.org/returnc/pub/ [URIs: meson.build] 0.0 URIBL_ZEN_BLOCKED_OPENDNS ADMINISTRATOR NOTICE: The query to zen.spamhaus.org was blocked due to usage of an open resolver. See https://www.spamhaus.org/returnc/pub/ [URIs: meson.build] -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address 0.0 Local_hs1_NotHoststar Sender is not from hoststar.ch|de|com 0.0 KAM_DMARC_STATUS Test Rule for DKIM or SPF Failure with Strict Alignment 0.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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a set of helpers that pipeline handlers can use to deal with camera flash devices. This mainly involves mapping controls to the flash device and vice versa. Signed-off-by: Matthias Fend --- include/libcamera/internal/flash_control.h | 23 +++++++ src/libcamera/flash_control.cpp | 103 +++++++++++++++++++++++++++++ src/libcamera/meson.build | 1 + 3 files changed, 127 insertions(+) diff --git a/include/libcamera/internal/flash_control.h b/include/libcamera/internal/flash_control.h new file mode 100644 index 0000000000000000000000000000000000000000..d530dc24fd8ea2d5676d95ab5943a7dacee07617 --- /dev/null +++ b/include/libcamera/internal/flash_control.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, matthias.fend@emfend.at + * + * Flash controls helpers for pipeline handlers + */ + +#pragma once + +#include + +#include "libcamera/internal/camera_flash.h" + +namespace libcamera { + +class FlashControl +{ +public: + static void updateFlashControls(CameraFlash *flash, ControlInfoMap::Map &controls); + static void handleFlashControls(CameraFlash *flash, ControlList &controls, ControlList &metadata); +}; + +} /* namespace libcamera */ diff --git a/src/libcamera/flash_control.cpp b/src/libcamera/flash_control.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0350bfb7c6600d0cba767726be17678ce792e5e5 --- /dev/null +++ b/src/libcamera/flash_control.cpp @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, matthias.fend@emfend.at + * + * Flash controls helpers for pipeline handlers + */ + +#include "libcamera/internal/flash_control.h" + +#include +#include + +namespace libcamera { + +void FlashControl::updateFlashControls(CameraFlash *flash, ControlInfoMap::Map &controls) +{ + if (!flash) + return; + + controls[&controls::draft::FlashMode] = ControlInfo(controls::draft::FlashModeValues, controls::draft::FlashModeNone); + controls[&controls::draft::FlashIntensity] = flash->getFlashIntensityInfo(); + controls[&controls::draft::FlashTimeout] = flash->getFlashTimeoutInfo(); + controls[&controls::draft::FlashStrobeSource] = ControlInfo(controls::draft::FlashStrobeSourceValues, controls::draft::FlashStrobeSourceSoftware); + controls[&controls::draft::FlashStrobe] = ControlInfo(controls::draft::FlashStrobeValues); + controls[&controls::draft::FlashTorchIntensity] = flash->getTorchIntensityInfo(); +} + +void FlashControl::handleFlashControls(CameraFlash *flash, ControlList &controls, ControlList &metadata) +{ + if (!flash) + return; + + const auto &flashMode = controls.get(controls::draft::FlashMode); + if (flashMode) { + CameraFlash::Mode mode; + + switch (*flashMode) { + case controls::draft::FlashModeFlash: + mode = CameraFlash::Mode::Flash; + break; + case controls::draft::FlashModeTorch: + mode = CameraFlash::Mode::Torch; + break; + case controls::draft::FlashModeNone: + default: + mode = CameraFlash::Mode::None; + break; + } + + flash->setMode(mode); + } + + const auto &flashIntensity = controls.get(controls::draft::FlashIntensity); + if (flashIntensity) + flash->setFlashIntensity(*flashIntensity); + + const auto &flashTimeout = controls.get(controls::draft::FlashTimeout); + if (flashTimeout) + flash->setFlashTimeout(*flashTimeout); + + const auto &flashStrobeSource = controls.get(controls::draft::FlashStrobeSource); + if (flashStrobeSource) { + CameraFlash::StrobeSource source; + + switch (*flashStrobeSource) { + case controls::draft::FlashStrobeSourceExternal: + source = CameraFlash::StrobeSource::External; + break; + case controls::draft::FlashStrobeSourceSoftware: + default: + source = CameraFlash::StrobeSource::Software; + break; + } + + flash->setStrobeSource(source); + } + + const auto &flashStrobe = controls.get(controls::draft::FlashStrobe); + if (flashStrobe) { + switch (*flashStrobe) { + case controls::draft::FlashStrobeEnum::FlashStrobeStart: + flash->startStrobe(); + break; + case controls::draft::FlashStrobeEnum::FlashStrobeStop: + flash->stopStrobe(); + break; + default: + break; + } + } + + const auto &flashTorchIntensity = controls.get(controls::draft::FlashTorchIntensity); + if (flashTorchIntensity) + flash->setTorchIntensity(*flashTorchIntensity); + + metadata.set(controls::draft::FlashMode, flash->getMode()); + metadata.set(controls::draft::FlashIntensity, flash->getFlashIntensity()); + metadata.set(controls::draft::FlashTimeout, flash->getFlashTimeout()); + metadata.set(controls::draft::FlashStrobeSource, flash->getStrobeSource()); + metadata.set(controls::draft::FlashTorchIntensity, flash->getTorchIntensity()); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 0f125661a51e2431c1febc353cef30a1219f9ce7..a68a49637db12f9e66b5bb38ee859aaac8c2fd1a 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -31,6 +31,7 @@ libcamera_internal_sources = files([ 'device_enumerator.cpp', 'device_enumerator_sysfs.cpp', 'dma_buf_allocator.cpp', + 'flash_control.cpp', 'formats.cpp', 'ipa_controls.cpp', 'ipa_data_serializer.cpp',