[v2,0/8] Autofocus basics for software ISP
mbox series

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

Message

Milan Zamazal Oct. 31, 2026, 6:40 p.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.

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