From patchwork Wed Oct 21 07:59:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 28540 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 1FE99C3302 for ; Wed, 21 Oct 2026 08:00:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 266C168F31; Wed, 21 Oct 2026 10:00:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="h+men0Uz"; 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 11DEA68F2A for ; Wed, 21 Oct 2026 10:00:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792569614; 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=KIbH8Fvhn9CrF77wbFvQtP1tFVq85sNcri6sY3Ch3fs=; b=h+men0UzGX+LaaVeJa/aXNL9OaFO6FeYWJ0dvYb70aPM9rMgcMfOFdvZKWOCg4FkYZJGrh FUUZfvAKJzxf92hbal81Lhh/ACIzH+eo+v0btuJ4NvaI9V8Ipvx66JriWRxRqEIRQSc2Fh reouQcWRyY0UT5m33kp0WVcA5LI6VL8= Received: from mx-prod-mc-03.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-10-pYoT0v3oPRG3Bl-koQ0_fg-1; Wed, 21 Oct 2026 04:00:05 -0400 X-MC-Unique: pYoT0v3oPRG3Bl-koQ0_fg-1 X-Mimecast-MFC-AGG-ID: pYoT0v3oPRG3Bl-koQ0_fg_1792569604 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2BAB51955F7C for ; Wed, 21 Oct 2026 08:00:04 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.43.17.75]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2FF101800444; Wed, 21 Oct 2026 08:00:02 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH 0/7] Autofocus basics for software ISP Date: Wed, 21 Oct 2026 09:59:40 +0200 Message-ID: <20261021080000.16624-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: 1CF9iCKpKfNz0OQX8munc0bFHGLUvO3MLyk0Q4a8Gxs_1792569604 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. It is posted as RFC to gather initial comments on the approach. 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? Milan Zamazal (7): libcamera: software_isp: Let a single point decide about computing stats ipa: ipu3: Move non-specific parts of Af to libipa 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 | 4 + .../internal/software_isp/swstats_cpu.h | 17 +- 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/libipa/af.cpp | 315 ++++++++++++++++++ src/ipa/libipa/af.h | 72 ++++ 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 | 24 +- src/libcamera/software_isp/software_isp.cpp | 4 +- src/libcamera/software_isp/swstats_cpu.cpp | 19 +- 21 files changed, 560 insertions(+), 294 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