From patchwork Fri Sep 12 07:13:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24345 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 93B73C324E for ; Fri, 12 Sep 2025 07:13:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F368A6937A; Fri, 12 Sep 2025 09:13:35 +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="TKVdzPWY"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C0EC6936A for ; Fri, 12 Sep 2025 09:13:30 +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=EwBfnVjs8gwXjhFU4nHGbso0t68zyoBk0zLqJRKLR+E=; b=TKVdzPWY0hoa+wmFV/7zmkdn8x EfAn9kyx6Z+3e+78hqJLV7DMXZ1FuZ9iUpSBsNI56fsKck5AGs1nk4p6P9WiNRHQysZ6Y+Og4NntO hkXxEMQHCMMADjWkdvH/Su0YPDd9xbwEj1vKQzCAu1iEqsPeg6X4r3eJjMJNIkI0UClQ=; Received: from 194-208-208-245.tele.net ([194.208.208.245]:58477 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 1uwxyL-008cBW-0k; Fri, 12 Sep 2025 09:13:29 +0200 From: Matthias Fend Date: Fri, 12 Sep 2025 09:13:23 +0200 Subject: [PATCH v2 4/5] libcamera: Add flash helpers for pipeline handlers MIME-Version: 1.0 Message-Id: <20250912-flash_reco-v2-4-d5bb80a2e619@emfend.at> References: <20250912-flash_reco-v2-0-d5bb80a2e619@emfend.at> In-Reply-To: <20250912-flash_reco-v2-0-d5bb80a2e619@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 Local_hs1_NotHoststar Sender is not from hoststar.ch|de|com 0.0 TVD_RCVD_IP Message was received from an IP address 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 | 148 +++++++++++++++++++++++++++++ src/libcamera/meson.build | 1 + 3 files changed, 172 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..0a032b5d50c8c04696aea211f05222357432e7ed --- /dev/null +++ b/src/libcamera/flash_control.cpp @@ -0,0 +1,148 @@ +/* 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::FlashMode] = ControlInfo(controls::FlashModeValues, controls::FlashModeNone); + controls[&controls::FlashIntensity] = flash->getFlashIntensityInfo(); + controls[&controls::FlashTimeout] = flash->getFlashTimeoutInfo(); + controls[&controls::FlashStrobeSource] = ControlInfo(controls::FlashStrobeSourceValues, controls::FlashStrobeSourceSoftware); + controls[&controls::FlashStrobe] = ControlInfo(controls::FlashStrobeValues); + controls[&controls::FlashTorchIntensity] = flash->getTorchIntensityInfo(); +} + +void FlashControl::handleFlashControls(CameraFlash *flash, ControlList &controls, ControlList &metadata) +{ + if (!flash) + return; + + /* Handle controls */ + + const auto &flashMode = controls.get(controls::FlashMode); + if (flashMode) { + CameraFlash::Mode mode; + + switch (*flashMode) { + case controls::FlashModeFlash: + mode = CameraFlash::Mode::Flash; + break; + case controls::FlashModeTorch: + mode = CameraFlash::Mode::Torch; + break; + case controls::FlashModeNone: + default: + mode = CameraFlash::Mode::None; + break; + } + + flash->setMode(mode); + } + + const auto &flashIntensity = controls.get(controls::FlashIntensity); + if (flashIntensity) + flash->setFlashIntensity(*flashIntensity); + + const auto &flashTimeout = controls.get(controls::FlashTimeout); + if (flashTimeout) + flash->setFlashTimeout(*flashTimeout); + + const auto &flashStrobeSource = controls.get(controls::FlashStrobeSource); + if (flashStrobeSource) { + CameraFlash::StrobeSource source; + + switch (*flashStrobeSource) { + case controls::FlashStrobeSourceExternal: + source = CameraFlash::StrobeSource::External; + break; + case controls::FlashStrobeSourceSoftware: + default: + source = CameraFlash::StrobeSource::Software; + break; + } + + flash->setStrobeSource(source); + } + + const auto &flashStrobe = controls.get(controls::FlashStrobe); + if (flashStrobe) { + switch (*flashStrobe) { + case controls::FlashStrobeStart: + flash->startStrobe(); + break; + case controls::FlashStrobeStop: + flash->stopStrobe(); + break; + default: + break; + } + } + + const auto &flashTorchIntensity = controls.get(controls::FlashTorchIntensity); + if (flashTorchIntensity) + flash->setTorchIntensity(*flashTorchIntensity); + + /* Fill metadata */ + + const auto metaFlashMode = flash->getMode(); + if (metaFlashMode) { + controls::FlashModeEnum mode; + + switch (*metaFlashMode) { + case CameraFlash::Mode::Flash: + mode = controls::FlashModeFlash; + break; + case CameraFlash::Mode::Torch: + mode = controls::FlashModeTorch; + break; + case CameraFlash::Mode::None: + default: + mode = controls::FlashModeNone; + break; + } + metadata.set(controls::FlashMode, mode); + } + + const auto metaFlashIntensity = flash->getFlashIntensity(); + if (metaFlashIntensity) + metadata.set(controls::FlashIntensity, *metaFlashIntensity); + + auto metaFlashTimeout = flash->getFlashTimeout(); + if (metaFlashTimeout) + metadata.set(controls::FlashTimeout, *metaFlashTimeout); + + auto metaStrobeSource = flash->getStrobeSource(); + if (metaStrobeSource) { + controls::FlashStrobeSourceEnum source; + + switch (*metaStrobeSource) { + case CameraFlash::StrobeSource::External: + source = controls::FlashStrobeSourceExternal; + break; + case CameraFlash::StrobeSource::Software: + default: + source = controls::FlashStrobeSourceSoftware; + break; + } + metadata.set(controls::FlashStrobeSource, source); + } + + auto metaTorchIntensity = flash->getTorchIntensity(); + if (metaTorchIntensity) + metadata.set(controls::FlashTorchIntensity, *metaTorchIntensity); +} + +} /* 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',