From patchwork Sat Oct 31 18:40:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 28731 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 6CBB6C3302 for ; Sat, 31 Oct 2026 18:41:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D65DE69159; Sat, 31 Oct 2026 19:41:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="fyYEiG/6"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D850E69136 for ; Sat, 31 Oct 2026 19:41:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793472067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j4pZkBBkzbCBJCp0Jb5XQoQmBbTKaK3mm6zI9E+V8aA=; b=fyYEiG/6lkxnvCOTGeG8tZ+fznIcFSoLNLYXbO8mViZ84hK/HB1GHPKAVG3DBpLd6nDe0I GBdGZWHj3dAYedOX5OUsxCyJfEDh9Ehwe4ElFtAkgibwJy5MHwQs3awlFN9KViwnulNplA Mxd2lXMRIu8bRXxfU543pe07UB1DYN4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-yULyiYtXNT6DtAr-PXbiJw-1; Sat, 31 Oct 2026 14:41:03 -0400 X-MC-Unique: yULyiYtXNT6DtAr-PXbiJw-1 X-Mimecast-MFC-AGG-ID: yULyiYtXNT6DtAr-PXbiJw_1793472062 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 799A81802154; Sat, 31 Oct 2026 18:41:02 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07FE918005BC; Sat, 31 Oct 2026 18:41:00 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= , Kieran Bingham , Robert Mader Subject: [PATCH v2 6/8] ipa: softisp: Add Af algorithm Date: Sat, 31 Oct 2026 19:40:38 +0100 Message-ID: <20261031184040.20139-7-mzamazal@redhat.com> In-Reply-To: <20261031184040.20139-1-mzamazal@redhat.com> References: <20261031184040.20139-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 64d9OegYdok9aQc_tP5f5V86ow2ibFJpIV2SSF5gMDM_1793472062 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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" Let's add Af algorithm, which is mostly a proxy to the libipa Af. The only special feature is setting afEnabled flag to prevent attempting lens movements when the algorithm is not enabled. The algorithm is not enabled yet because there are no autofocus stats computed. Signed-off-by: Milan Zamazal --- src/ipa/softisp/algorithms/af.cpp | 53 ++++++++++++++++++++++++++ src/ipa/softisp/algorithms/af.h | 39 +++++++++++++++++++ src/ipa/softisp/algorithms/meson.build | 1 + src/ipa/softisp/data/uncalibrated.yaml | 1 + src/ipa/softisp/ipa_context.h | 3 ++ 5 files changed, 97 insertions(+) create mode 100644 src/ipa/softisp/algorithms/af.cpp create mode 100644 src/ipa/softisp/algorithms/af.h diff --git a/src/ipa/softisp/algorithms/af.cpp b/src/ipa/softisp/algorithms/af.cpp new file mode 100644 index 000000000..557cca004 --- /dev/null +++ b/src/ipa/softisp/algorithms/af.cpp @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026 Red Hat Inc. + * + * Autofocus + */ + +#include "af.h" + +#include + +#include + +#include "libcamera/internal/software_isp/swisp_stats.h" + +namespace libcamera { + +namespace ipa::softisp::algorithms { + +LOG_DEFINE_CATEGORY(IPASoftIspAf) + +int Af::init(IPAContext &context, [[maybe_unused]] const ValueNode &tuningData) +{ + /* Informs that lens controls can get focus data */ + context.afEnabled = true; + + return 0; +} + +int Af::configure(IPAContext &context, + [[maybe_unused]] const IPAConfigInfo &configInfo) +{ + afAlgo_.configure(context.activeState.af); + + return 0; +} + +void Af::process(IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + const SwIspStats *stats, + [[maybe_unused]] ControlList &metadata) +{ + const double variance = stats->variance; + LOG(IPASoftIspAf, Debug) << "Focus stats: " << variance; + afAlgo_.process(context.activeState.af, variance); +} + +REGISTER_IPA_ALGORITHM(Af, "Af") + +} /* namespace ipa::softisp::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/softisp/algorithms/af.h b/src/ipa/softisp/algorithms/af.h new file mode 100644 index 000000000..881cb4475 --- /dev/null +++ b/src/ipa/softisp/algorithms/af.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026 Red Hat Inc. + * + * Autofocus + */ + +#pragma once + +#include "libipa/af.h" + +#include "algorithm.h" +#include "ipa_context.h" + +namespace libcamera { + +namespace ipa::softisp::algorithms { + +class Af : public Algorithm +{ +public: + Af() = default; + ~Af() = default; + + int init(IPAContext &context, const ValueNode &tuningData) override; + int configure(IPAContext &context, + const IPAConfigInfo &configInfo) override; + void process(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, + const SwIspStats *stats, + ControlList &metadata) override; + +private: + AfAlgorithm afAlgo_; +}; + +} /* namespace ipa::softisp::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/softisp/algorithms/meson.build b/src/ipa/softisp/algorithms/meson.build index d98f4b1f4..7d1077117 100644 --- a/src/ipa/softisp/algorithms/meson.build +++ b/src/ipa/softisp/algorithms/meson.build @@ -2,6 +2,7 @@ softisp_ipa_algorithms = files([ 'adjust.cpp', + 'af.cpp', 'awb.cpp', 'agc.cpp', 'blc.cpp', diff --git a/src/ipa/softisp/data/uncalibrated.yaml b/src/ipa/softisp/data/uncalibrated.yaml index fc90ca526..53d3792a2 100644 --- a/src/ipa/softisp/data/uncalibrated.yaml +++ b/src/ipa/softisp/data/uncalibrated.yaml @@ -4,6 +4,7 @@ version: 1 algorithms: - BlackLevel: + # - Af: - Awb: # Color correction matrices can be defined here. The CCM algorithm # has a significant performance impact, and should only be enabled diff --git a/src/ipa/softisp/ipa_context.h b/src/ipa/softisp/ipa_context.h index 9d8e9f4fb..39823261c 100644 --- a/src/ipa/softisp/ipa_context.h +++ b/src/ipa/softisp/ipa_context.h @@ -20,6 +20,7 @@ #include #include #include +#include "libipa/af.h" #include "libipa/lsc.h" #include "core_ipa_interface.h" @@ -39,6 +40,7 @@ struct IPAActiveState { ipa::awb::ActiveState awb; ipa::ccm::ActiveState ccm; ipa::agc::ActiveState agc; + ipa::af::ActiveState af; struct { uint8_t level; @@ -88,6 +90,7 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; bool ccmEnabled = false; + bool afEnabled = false; bool lscEnabled = false; ipa::lsc::ActiveState lsc; };