[RFC,0/7] Autofocus basics for software ISP
mbox series

Message ID 20261021080000.16624-1-mzamazal@redhat.com
Headers show
Series
  • Autofocus basics for software ISP
Related show

Message

Milan Zamazal Oct. 21, 2026, 7:59 a.m. UTC
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