From patchwork Sat Oct 31 18:40:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 28725 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 C528CC3261 for ; Sat, 31 Oct 2026 18:40:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFA3C69138; Sat, 31 Oct 2026 19:40:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Z2PUM79C"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 174996912D for ; Sat, 31 Oct 2026 19:40:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793472051; 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; bh=qClZecnJg0omtVxybosg+9QFgESUo1bGnME5KT7p0b8=; b=Z2PUM79CFR0ioVTLxDgctbgdfifC9H4ZSJvdrkDEY1wGvpQ6+GC7lgTXNcT6t+glFy3Y2T T32l5Vlwwt5XNgk9jguD6vxN7NxeYRYwUr8HTukTbYh6mC2ge7DmXTHFklQ4C8tJqNyute lf5Igqh0t4qzsRW3xszQMoNcamlblV8= Received: from mx-prod-mc-08.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-209-rejVf_JrMBqweykXY62rzw-1; Sat, 31 Oct 2026 14:40:49 -0400 X-MC-Unique: rejVf_JrMBqweykXY62rzw-1 X-Mimecast-MFC-AGG-ID: rejVf_JrMBqweykXY62rzw_1793472048 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4EAF41808872; Sat, 31 Oct 2026 18:40:48 +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 2F81018005B2; Sat, 31 Oct 2026 18:40:45 +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 0/8] Autofocus basics for software ISP Date: Sat, 31 Oct 2026 19:40:32 +0100 Message-ID: <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: JjZKRaLcLwNAnnzqHqoTs3-5sX5od6p4KLA80IjP_j4_1793472048 X-Mimecast-Originator: redhat.com 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" This is another attempt to introduce autofocus to software ISP. It is not a complete implementation; autofocus stats are missing, to be addressed in another patch series, to keep the patch series relatively short. What this series implements: - Software ISP autofocus is based on the IPU3 implementation. Generic parts of the IPU3 autofocus algorithm are moved to libipa for the purpose. - Software ISP autofocus algorithm based on that. - Autofocus (lens) controls added to software ISP. - Rudimentary support for providing the autofocus stats value from stats (without actually implementing it). What should be added in future patch series: - Software ISP autofocus stats. While it may look easy, it’s not, there are several things to address: accuracy, efficiency, frequency, collisions with exposure adjustments, focus area, etc. There is some former work available in Hans’s tree: https://github.com/jwrdegoede/libcamera/tree/software-af-done - Manual focus support. This should be easy, maybe old Pavel’s patches could be reused in some way? Changes in v2: - Regression (wrong condition) in debayer_egl.cpp fixed. - Two more conditions replaced with SwStatsCpu::updating. - The commit message of the autofocus controls commit improved. - New function af::prepareControls. Milan Zamazal (8): libcamera: software_isp: Let a single point decide about computing stats ipa: ipu3: Move non-specific parts of Af to libipa ipa: libipa: Add af::prepareControls() libcamera: software_isp: Add variance to stats ipa: softisp: Remove unused imports from ipa_context.h ipa: softisp: Add Af algorithm libcamera: software_isp: Add autofocus controls ipa: libipa: Use autofocus limits if available .../internal/software_isp/software_isp.h | 4 +- .../internal/software_isp/swisp_stats.h | 8 +- .../internal/software_isp/swstats_cpu.h | 21 +- include/libcamera/ipa/softisp.mojom | 3 +- src/ipa/ipu3/algorithms/af.cpp | 219 +----------- src/ipa/ipu3/algorithms/af.h | 27 +- src/ipa/ipu3/ipa_context.cpp | 17 +- src/ipa/ipu3/ipa_context.h | 8 +- src/ipa/ipu3/ipu3.cpp | 3 +- src/ipa/libipa/af.cpp | 315 ++++++++++++++++++ src/ipa/libipa/af.h | 79 +++++ src/ipa/libipa/meson.build | 2 + src/ipa/softisp/algorithms/af.cpp | 52 +++ 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 | 6 +- src/ipa/softisp/softisp.cpp | 7 +- src/libcamera/pipeline/simple/simple.cpp | 13 +- src/libcamera/software_isp/debayer_egl.cpp | 6 +- src/libcamera/software_isp/software_isp.cpp | 4 +- src/libcamera/software_isp/swstats_cpu.cpp | 19 +- 22 files changed, 566 insertions(+), 288 deletions(-) create mode 100644 src/ipa/libipa/af.cpp create mode 100644 src/ipa/libipa/af.h create mode 100644 src/ipa/softisp/algorithms/af.cpp create mode 100644 src/ipa/softisp/algorithms/af.h