From patchwork Fri Sep 12 07:13:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24342 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 87AA3C324E for ; Fri, 12 Sep 2025 07:13:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBC1F6937C; Fri, 12 Sep 2025 09:13:30 +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="immUFJvK"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA00A69367 for ; Fri, 12 Sep 2025 09:13:27 +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=KQsC75uuP4DwcLLrq18CcYCoHNSKbcjVDM5DUBjfD3k=; b=immUFJvKHHxq6r8NfloLNHeP84 aCXXu20xpuVMZ7lmR+5kaxHiqwcvr+0uDELczED1ZEHK7uEaAgORdhSfS+FbjYgVEuAlLiiSZzaBH 2pTTPNLVI5VvBzHDcHMMc3+RRuJViq1AFh5SmjuCF3DotNyg40fkPgP0/3qJVVyfG5kM=; 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 1uwxyI-008cBW-Ts; Fri, 12 Sep 2025 09:13:27 +0200 From: Matthias Fend Date: Fri, 12 Sep 2025 09:13:20 +0200 Subject: [PATCH v2 1/5] libcamera: control_ids_core: Add flash controls MIME-Version: 1.0 Message-Id: <20250912-flash_reco-v2-1-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: -1.0 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: Hi, even though the API contained here is considered too low-level and the series will therefore probably never be merged, I have nevertheless decided to include the feedback I have already received and s [...] Content analysis details: (-1.0 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 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" Define a set of controls to control camera flash devices. Signed-off-by: Matthias Fend --- src/libcamera/control_ids_core.yaml | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index eec4b4f937ee6a2d751bb747e3b2d79dc16b7a3a..ff002accd771918b2618694ab14cda386997bc12 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -1284,4 +1284,82 @@ controls: The FrameWallClock control can only be returned in metadata. + - FlashMode: + type: int32_t + direction: inout + description: | + Flash operation mode. + enum: + - name: FlashModeNone + value: 0 + description: | + Flash is off and inactive. + - name: FlashModeFlash + value: 1 + description: | + The flash is active, but will only be switched on for a short time + by means of a trigger (software or external strobe). The maximum + switch-on time is limited by the FlashTimeout setting. + - name: FlashModeTorch + value: 2 + description: | + The flash is continuously on and active. Commonly referred to as + torch or video light mode. + + - FlashIntensity: + type: int32_t + direction: inout + description: | + Flash intensity in mA. Used when the flash is operated in flash mode. + + - FlashTimeout: + type: int32_t + direction: inout + description: | + Flash timeout in us. Determines the maximum flash switch-on time. After + this time has elapsed, the flash is switched off by the hardware, even + if a strobe is still active. + + - FlashStrobeSource: + type: int32_t + direction: inout + description: | + Flash strobe source. + enum: + - name: FlashStrobeSourceSoftware + value: 0 + description: | + The strobe signal is controlled via software using the FlashStrobe + control. + - name: FlashStrobeSourceExternal + value: 1 + description: | + The strobe signal is controlled by an external source. Typically, + this is done on the hardware by connecting the strobe source + directly to the flash controller. + + - FlashStrobe: + type: int32_t + direction: in + description: | + Start/stop flash strobe. Only possible if FlashStrobeSourceSoftware is + selcted as FlashStrobeSource. + + enum: + - name: FlashStrobeStart + value: 0 + description: | + Start flash strobe. + + - name: FlashStrobeStop + value: 1 + description: | + Stop flash strobe. + + - FlashTorchIntensity: + type: int32_t + direction: inout + description: | + Torch intensity in mA. Used when the flash is operated in torch mode. + ... From patchwork Fri Sep 12 07:13:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24343 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 B13E8C324E for ; Fri, 12 Sep 2025 07:13:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D31F6936E; Fri, 12 Sep 2025 09:13:32 +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="Aert2LBo"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EE696936E for ; Fri, 12 Sep 2025 09:13:29 +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=GagT+0KaniNMwlu9XlSP4iapYWrcu26VFeoGcHDKnw0=; b=Aert2LBoqgEcOgln+P3PjWpGnE rxwzyRbDbYnKWYMhBByXKkXVJ4MiwCjELU2MBAYYj6QD6VvU2/2f1CiezoM/Ny0psGwfPOM+7acEY 9doc9SdfOThuoUVhcvX0w22JhPU+qrZt0uxikUnv8UOP0qRehwltchGg4ITZKKVFUrlg=; 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 1uwxyJ-008cBW-Cl; Fri, 12 Sep 2025 09:13:28 +0200 From: Matthias Fend Date: Fri, 12 Sep 2025 09:13:21 +0200 Subject: [PATCH v2 2/5] libcamera: Add support for camera flash devices MIME-Version: 1.0 Message-Id: <20250912-flash_reco-v2-2-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: -1.0 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: Define a set of controls to control camera flash devices. Signed-off-by: Matthias Fend --- src/libcamera/control_ids_core.yaml | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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 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 class to model camera flash devices. Currently, only v4l2 flash devices are supported. The v4l2 flash devices are implemented similar to the camera lenses. Signed-off-by: Matthias Fend Reviewed-by: Isaac Scott --- include/libcamera/internal/camera_flash.h | 72 ++++++++ include/libcamera/internal/camera_sensor.h | 2 + src/libcamera/camera_flash.cpp | 249 ++++++++++++++++++++++++++ src/libcamera/meson.build | 1 + src/libcamera/sensor/camera_sensor_legacy.cpp | 13 ++ src/libcamera/sensor/camera_sensor_raw.cpp | 13 ++ 6 files changed, 350 insertions(+) diff --git a/include/libcamera/internal/camera_flash.h b/include/libcamera/internal/camera_flash.h new file mode 100644 index 0000000000000000000000000000000000000000..70234ca96d98dd88a084e2c6804a66e455d87ef8 --- /dev/null +++ b/include/libcamera/internal/camera_flash.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, matthias.fend@emfend.at + * + * Camera flash support + */ +#pragma once + +#include +#include +#include + +#include +#include + +#include + +namespace libcamera { + +class MediaEntity; +class V4L2Subdevice; + +class CameraFlash : protected Loggable +{ +public: + enum class Mode { + None, + Flash, + Torch, + }; + + enum class StrobeSource { + Software, + External, + }; + + explicit CameraFlash(const MediaEntity *entity); + ~CameraFlash(); + int init(); + std::optional getMode() const; + int setMode(Mode mode); + const ControlInfo &getFlashIntensityInfo() const; + std::optional getFlashIntensity() const; + int setFlashIntensity(int32_t intensity); + const ControlInfo &getFlashTimeoutInfo() const; + std::optional getFlashTimeout() const; + int setFlashTimeout(int32_t timeout_us); + std::optional getStrobeSource() const; + int setStrobeSource(StrobeSource source); + int startStrobe(); + int stopStrobe(); + const ControlInfo &getTorchIntensityInfo() const; + std::optional getTorchIntensity() const; + int setTorchIntensity(int32_t intensity); + +protected: + std::string logPrefix() const override; + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraFlash) + + std::optional getSubdevControl(uint32_t id) const; + int setSubdevControl(uint32_t id, int32_t value); + int validateDriver(); + + const MediaEntity *entity_; + std::unique_ptr subdev_; + std::string model_; + const ControlInfoMap *controlInfoMap_ = nullptr; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index f6ef4df170d43500bc652762e9a575010a6c1cbd..faeecf244c8d42a43eca52ae04813e0c2f80e516 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -28,6 +28,7 @@ namespace libcamera { +class CameraFlash; class CameraLens; class MediaEntity; class SensorConfiguration; @@ -48,6 +49,7 @@ public: virtual V4L2Subdevice *device() = 0; virtual CameraLens *focusLens() = 0; + virtual CameraFlash *flash() = 0; virtual const std::vector &mbusCodes() const = 0; virtual std::vector sizes(unsigned int mbusCode) const = 0; diff --git a/src/libcamera/camera_flash.cpp b/src/libcamera/camera_flash.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d3b9fbf78f063ae0cb67635c4cda667508479534 --- /dev/null +++ b/src/libcamera/camera_flash.cpp @@ -0,0 +1,249 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, matthias.fend@emfend.at + * + * Camera flash support + */ + +#include "libcamera/internal/camera_flash.h" + +#include + +#include "libcamera/internal/v4l2_subdevice.h" + +namespace libcamera { + +LOG_DEFINE_CATEGORY(CameraFlash) + +CameraFlash::CameraFlash(const MediaEntity *entity) + : entity_(entity) +{ +} + +CameraFlash::~CameraFlash() = default; + +int CameraFlash::init() +{ + if (entity_->function() != MEDIA_ENT_F_FLASH) { + LOG(CameraFlash, Error) + << "Invalid flash function " + << utils::hex(entity_->function()); + return -EINVAL; + } + + subdev_ = std::make_unique(entity_); + int ret = subdev_->open(); + if (ret < 0) + return ret; + + controlInfoMap_ = &subdev_->controls(); + + ret = validateDriver(); + if (ret) + return ret; + + model_ = subdev_->model(); + + return 0; +} + +std::optional CameraFlash::getMode() const +{ + Mode mode; + + auto v4l2Mode = getSubdevControl(V4L2_CID_FLASH_LED_MODE); + if (!v4l2Mode) + return std::nullopt; + + switch (*v4l2Mode) { + case V4L2_FLASH_LED_MODE_FLASH: + mode = Mode::Flash; + break; + case V4L2_FLASH_LED_MODE_TORCH: + mode = Mode::Torch; + break; + case V4L2_FLASH_LED_MODE_NONE: + default: + mode = Mode::None; + break; + } + + return mode; +} + +int CameraFlash::setMode(Mode mode) +{ + int32_t v4l2Mode; + + switch (mode) { + case Mode::Flash: + v4l2Mode = V4L2_FLASH_LED_MODE_FLASH; + break; + case Mode::Torch: + v4l2Mode = V4L2_FLASH_LED_MODE_TORCH; + break; + case Mode::None: + v4l2Mode = V4L2_FLASH_LED_MODE_NONE; + break; + default: + return -EINVAL; + } + + return setSubdevControl(V4L2_CID_FLASH_LED_MODE, v4l2Mode); +} + +const ControlInfo &CameraFlash::getFlashIntensityInfo() const +{ + return controlInfoMap_->find(V4L2_CID_FLASH_INTENSITY)->second; +} + +std::optional CameraFlash::getFlashIntensity() const +{ + return getSubdevControl(V4L2_CID_FLASH_INTENSITY); +} + +int CameraFlash::setFlashIntensity(int32_t intensity) +{ + return setSubdevControl(V4L2_CID_FLASH_INTENSITY, intensity); +} + +const ControlInfo &CameraFlash::getFlashTimeoutInfo() const +{ + return controlInfoMap_->find(V4L2_CID_FLASH_TIMEOUT)->second; +} + +std::optional CameraFlash::getFlashTimeout() const +{ + return getSubdevControl(V4L2_CID_FLASH_TIMEOUT); +} + +int CameraFlash::setFlashTimeout(int32_t timeout) +{ + return setSubdevControl(V4L2_CID_FLASH_TIMEOUT, timeout); +} + +std::optional CameraFlash::getStrobeSource() const +{ + StrobeSource source; + + auto v4l2Source = getSubdevControl(V4L2_CID_FLASH_STROBE_SOURCE); + if (!v4l2Source) + return std::nullopt; + + switch (*v4l2Source) { + case V4L2_FLASH_STROBE_SOURCE_EXTERNAL: + source = StrobeSource::External; + break; + case V4L2_FLASH_STROBE_SOURCE_SOFTWARE: + default: + source = StrobeSource::Software; + break; + } + + return source; +} + +int CameraFlash::setStrobeSource(StrobeSource source) +{ + int32_t v4l2Source; + + switch (source) { + case StrobeSource::External: + v4l2Source = V4L2_FLASH_STROBE_SOURCE_EXTERNAL; + break; + case StrobeSource::Software: + v4l2Source = V4L2_FLASH_STROBE_SOURCE_SOFTWARE; + break; + default: + return -EINVAL; + } + + return setSubdevControl(V4L2_CID_FLASH_STROBE_SOURCE, v4l2Source); +} + +int CameraFlash::startStrobe() +{ + return setSubdevControl(V4L2_CID_FLASH_STROBE, 1); +} + +int CameraFlash::stopStrobe() +{ + return setSubdevControl(V4L2_CID_FLASH_STROBE_STOP, 1); +} + +const ControlInfo &CameraFlash::getTorchIntensityInfo() const +{ + return controlInfoMap_->find(V4L2_CID_FLASH_TORCH_INTENSITY)->second; +} + +std::optional CameraFlash::getTorchIntensity() const +{ + return getSubdevControl(V4L2_CID_FLASH_TORCH_INTENSITY); +} + +int CameraFlash::setTorchIntensity(int32_t intensity) +{ + return setSubdevControl(V4L2_CID_FLASH_TORCH_INTENSITY, intensity); +} + +std::string CameraFlash::logPrefix() const +{ + return "'" + entity_->name() + "'"; +} + +std::optional CameraFlash::getSubdevControl(uint32_t id) const +{ + ControlList controlList = subdev_->getControls(std::array{ id }); + + if (controlList.contains(id)) + return std::nullopt; + + return controlList.get(id).get(); +} + +int CameraFlash::setSubdevControl(uint32_t id, int32_t value) +{ + ControlList flashCtrls(*controlInfoMap_); + + flashCtrls.set(id, value); + + if (subdev_->setControls(&flashCtrls)) + return -EINVAL; + + return 0; +} + +int CameraFlash::validateDriver() +{ + int ret = 0; + static constexpr uint32_t mandatoryControls[] = { + V4L2_CID_FLASH_LED_MODE, + V4L2_CID_FLASH_STROBE_SOURCE, + V4L2_CID_FLASH_STROBE, + V4L2_CID_FLASH_TIMEOUT, + V4L2_CID_FLASH_INTENSITY, + V4L2_CID_FLASH_TORCH_INTENSITY, + }; + + for (uint32_t ctrl : mandatoryControls) { + if (!controlInfoMap_->count(ctrl)) { + LOG(CameraFlash, Error) + << "Mandatory V4L2 control " << utils::hex(ctrl) + << " not available"; + ret = -EINVAL; + } + } + + if (ret) { + LOG(CameraFlash, Error) + << "The flash kernel driver needs to be fixed"; + LOG(CameraFlash, Error) + << "See Documentation/flash_driver_requirements.rst in" + << " the libcamera sources for more information"; + return ret; + } + + return ret; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index b3ca27f217da4ba3a896ef7cbfb5502fa82a4907..0f125661a51e2431c1febc353cef30a1219f9ce7 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -20,6 +20,7 @@ libcamera_internal_sources = files([ 'bayer_format.cpp', 'byte_stream_buffer.cpp', 'camera_controls.cpp', + 'camera_flash.cpp', 'camera_lens.cpp', 'clock_recovery.cpp', 'control_serializer.cpp', diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index f9e685a9acc499fc91d51ed1d66780a0ad2d2a8f..632b66ea0aa15fcd654e7f0efb50c24cb9b973bf 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -31,6 +31,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera_flash.h" #include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/camera_sensor_properties.h" @@ -68,6 +69,7 @@ public: V4L2Subdevice *device() override { return subdev_.get(); } CameraLens *focusLens() override { return focusLens_.get(); } + CameraFlash *flash() override { return flash_.get(); } const std::vector &mbusCodes() const override { return mbusCodes_; } std::vector sizes(unsigned int mbusCode) const override; @@ -139,6 +141,7 @@ private: ControlList properties_; std::unique_ptr focusLens_; + std::unique_ptr flash_; }; /** @@ -665,6 +668,16 @@ int CameraSensorLegacy::discoverAncillaryDevices() } break; + case MEDIA_ENT_F_FLASH: + flash_ = std::make_unique(ancillary); + ret = flash_->init(); + if (ret) { + LOG(CameraSensor, Error) + << "Flash initialisation failed, flash disabled"; + flash_.reset(); + } + break; + default: LOG(CameraSensor, Warning) << "Unsupported ancillary entity function " diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 8ea4423698cd8c1eaae43eb5ba8b5d524b94d515..9d533d814b9df453aa4009a87818c1558bcbd665 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -32,6 +32,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera_flash.h" #include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/camera_sensor_properties.h" @@ -69,6 +70,7 @@ public: V4L2Subdevice *device() override { return subdev_.get(); } CameraLens *focusLens() override { return focusLens_.get(); } + CameraFlash *flash() override { return flash_.get(); } const std::vector &mbusCodes() const override { return mbusCodes_; } std::vector sizes(unsigned int mbusCode) const override; @@ -150,6 +152,7 @@ private: ControlList properties_; std::unique_ptr focusLens_; + std::unique_ptr flash_; }; /** @@ -513,6 +516,16 @@ std::optional CameraSensorRaw::init() } break; + case MEDIA_ENT_F_FLASH: + flash_ = std::make_unique(ancillary); + ret = flash_->init(); + if (ret) { + LOG(CameraSensor, Error) + << "Flash initialisation failed, flash disabled"; + flash_.reset(); + } + break; + default: LOG(CameraSensor, Warning) << "Unsupported ancillary entity function " From patchwork Fri Sep 12 07:13:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24344 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 C4057C328C for ; Fri, 12 Sep 2025 07:13:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EC01169371; Fri, 12 Sep 2025 09:13:33 +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="ctk1UdkJ"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 705806936E for ; Fri, 12 Sep 2025 09:13:29 +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=hrmycKM5vz19EHoPbU8uUhqnMarL+q4v19l4pkGwgEs=; b=ctk1UdkJW4rEaA8pI1seDi6/2A 8EP3nd8PUr8InuWKC70Rk9zxSsH6I3ekK4JYKFoJNS+5R/B/OpUJKYZJ95Cv2CglN1roHtzZSxDYn 9Ew/FInP72vs5jj0W6SiKuPcjBPjRAdHCFxk1+OO/XgJ9VjrFlKXFgGLyD04Q/5qJLWc=; 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 1uwxyK-008cBW-J9; Fri, 12 Sep 2025 09:13:28 +0200 From: Matthias Fend Date: Fri, 12 Sep 2025 09:13:22 +0200 Subject: [PATCH v2 3/5] Documentation: Add flash driver requirements MIME-Version: 1.0 Message-Id: <20250912-flash_reco-v2-3-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: Add a class to model camera flash devices. Currently, only v4l2 flash devices are supported. The v4l2 flash devices are implemented similar to the camera lenses. Signed-off-by: Matthias Fend --- include/libcamera/internal/camera_flash.h | 72 ++++++++ include/libcamera/internal/camera_sensor.h | 2 + src/libcamera/camera_flash.cpp | 249 [...] 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" Document the requirements for the v4l2 flash device drivers required by libcamera. Signed-off-by: Matthias Fend Reviewed-by: Isaac Scott --- Documentation/documentation-contents.rst | 1 + Documentation/flash_driver_requirements.rst | 40 +++++++++++++++++++++++++++++ Documentation/index.rst | 1 + Documentation/meson.build | 1 + 4 files changed, 43 insertions(+) diff --git a/Documentation/documentation-contents.rst b/Documentation/documentation-contents.rst index 5c1118493745692f2521bced9dab48098585c39e..be7415cde42f55ae5f9da20bc9211227b8f8658c 100644 --- a/Documentation/documentation-contents.rst +++ b/Documentation/documentation-contents.rst @@ -22,6 +22,7 @@ * :doc:`/internal-api-html/index` * | * **Documentation for System Integrators** + * :doc:`/flash_driver_requirements` * :doc:`/lens_driver_requirements` * :doc:`/sensor_driver_requirements` diff --git a/Documentation/flash_driver_requirements.rst b/Documentation/flash_driver_requirements.rst new file mode 100644 index 0000000000000000000000000000000000000000..b4a1b4866e651c506203af7089b5634808de5ab7 --- /dev/null +++ b/Documentation/flash_driver_requirements.rst @@ -0,0 +1,40 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. include:: documentation-contents.rst + +.. _flash-driver-requirements: + +Flash Driver Requirements +========================= + +libcamera handles V4L2 flash devices in the CameraFlash class and defines +a consistent interface through its API towards other library components. + +The CameraFlash class uses the V4L2 subdev kernel API to interface with the +camera flash through a sub-device exposed to userspace by the V4L2 flash driver. + +In order for libcamera to be fully operational and provide all the required +information to interface with the camera flash to applications and pipeline +handlers, the driver must support a set of mandatory features. + +Mandatory Requirements +---------------------- + +The flash driver is assumed to be fully compliant with the V4L2 specification. + +The flash driver shall support the following V4L2 controls: + +* `V4L2_CID_FLASH_LED_MODE`_ +* `V4L2_CID_FLASH_STROBE_SOURCE`_ +* `V4L2_CID_FLASH_STROBE`_ +* `V4L2_CID_FLASH_TIMEOUT`_ +* `V4L2_CID_FLASH_INTENSITY`_ +* `V4L2_CID_FLASH_TORCH_INTENSITY`_ + +.. _V4L2_CID_FLASH_LED_MODE: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html +.. _V4L2_CID_FLASH_STROBE_SOURCE: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html +.. _V4L2_CID_FLASH_STROBE: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html +.. _V4L2_CID_FLASH_TIMEOUT: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html +.. _V4L2_CID_FLASH_INTENSITY: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html +.. _V4L2_CID_FLASH_TORCH_INTENSITY: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html + diff --git a/Documentation/index.rst b/Documentation/index.rst index 251112fbdf5f075b3e5c064d7230b9ad2c23b587..7ed56c17787fc643ef74cc35ef5b5db7d29eb18d 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -14,6 +14,7 @@ Camera Sensor Model Environment variables Feature Requirements + Flash driver requirements IPA Writer's guide Lens driver requirements libcamera Architecture diff --git a/Documentation/meson.build b/Documentation/meson.build index a8d4afc01dd154546d107b49bc322a993e4d78bd..965b33c60b031610251efbe59abb1682cb714d4a 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -159,6 +159,7 @@ if sphinx.found() 'documentation-contents.rst', 'environment_variables.rst', 'feature_requirements.rst', + 'flash_driver_requirements.rst', 'guides/application-developer.rst', 'guides/ipa.rst', 'guides/pipeline-handler.rst', 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 Reviewed-by: Isaac Scott --- 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', From patchwork Fri Sep 12 07:13:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24346 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 2AF25C332A for ; Fri, 12 Sep 2025 07:13:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78D0169370; Fri, 12 Sep 2025 09:13:37 +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="Gq2NxlTE"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90A666937A 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=dqFRRY77dDi7ond7BaScNXXoUR2h3wlU8GqtWgqWltU=; b=Gq2NxlTELUCFXcnpPtbvFKjnf/ 2FdNM6sKfoPsVSAZes2Rtz0KOfvpBZTvGvMfRnoCWjKF3s0k89NPNDFlSc+Vj5soWSBKOhcOakrLP isH7lAN7pMVqK12pM0eMLJDqSJabi3DxqTLJDcmBK6vcecuTDuB2EuGHceNDBPg3zpro=; 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-OX; Fri, 12 Sep 2025 09:13:30 +0200 From: Matthias Fend Date: Fri, 12 Sep 2025 09:13:24 +0200 Subject: [PATCH v2 5/5] rkisp1: Add support for camera flash devices MIME-Version: 1.0 Message-Id: <20250912-flash_reco-v2-5-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: 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 [...] 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" Use the flash device pipeline helpers to bring flash support to the RKISP1 pipeline. Signed-off-by: Matthias Fend Reviewed-by: Isaac Scott --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index cfcbb3b2590a293106cb4d1a5c5c6adb504a61af..44ffc9b68d17f271fbab5867cc72b4d4f9330381 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -39,6 +39,7 @@ #include "libcamera/internal/converter/converter_v4l2_m2m.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/flash_control.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/media_device.h" @@ -1296,6 +1297,8 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data) activeCrop_ = scalerMaxCrop_; } + FlashControl::updateFlashControls(data->sensor_->flash(), controls); + /* Add the IPA registered controls to list of camera controls. */ for (const auto &ipaControl : data->ipaControls_) controls[ipaControl.first] = ipaControl.second; @@ -1503,6 +1506,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) info->metadataProcessed = true; } + FlashControl::handleFlashControls(data->sensor_->flash(), request->controls(), request->metadata()); + if (!useDewarper_) { completeBuffer(request, buffer); tryCompleteRequest(info);