From patchwork Thu Nov 19 20:46:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 29057 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 3E175C3355 for ; Thu, 19 Nov 2026 20:46:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DDA616A940; Thu, 19 Nov 2026 21:46:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="iOnVH8Tf"; 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 BF4E26A92B for ; Thu, 19 Nov 2026 21:46:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795121210; 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=h30Jjgz70FRIldYfTb/C16AH/NnAwM+y+anU6L3Fs90=; b=iOnVH8TflrcLVWPCxqijU9fOZZNcbL1w6XZBjZXyZMopnR1gnyeMqNKqEm5RPsZKPInIpM VY5nVxOCtsJKqI3ZOY8szJomJJi7vT449NleUfRSFwvrtgZeKolSWbnWCocfD5034xGaGM xWbntAJ7PNe/E/+6eEQ639mOLUSqB68= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-483-wR9GwxJzPty4fqmKIeHllg-1; Thu, 19 Nov 2026 20:46:25 +0000 X-MC-Unique: wR9GwxJzPty4fqmKIeHllg-1 X-Mimecast-MFC-AGG-ID: wR9GwxJzPty4fqmKIeHllg_1795121180 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 921751955F1B; Thu, 19 Nov 2026 20:46:19 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 73B45195604E; Thu, 19 Nov 2026 20:46:17 +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 , Jayden Milne Subject: [PATCH v3 0/8] Autofocus basics for software ISP Date: Thu, 19 Nov 2026 21:46:03 +0100 Message-ID: <20261119204611.278218-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sVwQqTTe6IUu1J_RKPlauc3vlIYXjH3jExBsWOMWy0s_1795121180 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 v3: - Avoiding autofocus changes based on non-current stats. 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 | 55 +++ 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, 569 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