Skip to content

sensor monitor: add IMX291 + document the feature#159

Merged
widgetii merged 1 commit intomasterfrom
feat/imx291-monitor
May 5, 2026
Merged

sensor monitor: add IMX291 + document the feature#159
widgetii merged 1 commit intomasterfrom
feat/imx291-monitor

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented May 5, 2026

Summary

  • Add IMX291 register table to ipctool sensor monitor, focused on AE/WDR debugging surfaces (HCG_FRSEL, GAIN, VMAX, HMAX, SHS1, OPORTSEL).
  • Add sensor monitor to --help (was implemented in Detect runtime mode switches in segmenter, emit per-mode functions #149 for SC2315E / IMX385 but never advertised).
  • Update docs/sensor-driver-extraction.md with the supported-sensor table, a real IMX291 sample output, and the HCG/FRSEL clobber pattern that this register set was designed to surface.

Why IMX291 specifically

Came up while debugging WDR on hi3516cv300 + IMX291. The sensor's 0x3009 packs HCG into bit 4 and FRSEL into bits 3:0, so AE flipping HCG can clobber FRSEL and drop the sensor out of WDR for one frame. sensor monitor watching HCG_FRSEL makes that visible — 0x12 is healthy WDR with HCG on, 0x11 or anything with low nibble != 2 means the bug. The driver-side fix is widgetii/sony_imx291@b51850c.

The docs note that IMX291 has only Multiple Exposure WDR (single SHS1 knob), not DOL — SHS2 / RHS1 are present in the silicon address map but non-functional, so they're not in the monitor table.

Test plan

  • Builds clean against arm-openipc-linux-musleabi.cmake toolchain.
  • clang-format happy (pre-commit hook passes).
  • Live-validation on hi3516cv300 + IMX291 camera deferred — camera was unreachable at PR time. Table format mirrors existing IMX385 / SC2315E entries (same Reg[] layout, same .be = 0 little-endian convention) so behaviour is determined entirely by the existing dispatch code. Will follow up with a real-output sample once the camera's back.

🤖 Generated with Claude Code

The `sensor monitor` subcommand was implemented (#149) for SC2315E and
IMX385 but missing from `print_usage`, and the supported-sensors set
didn't cover IMX291. Add IMX291 register table tuned for DOL/WDR
debugging and document the feature with an example.

The IMX291 set focuses on what matters when chasing WDR exposure bugs:

  HCG_FRSEL  0x3009 (1)    HCG bit 4 + FRSEL bits 3:0 packed
  GAIN       0x3014 (1)    analog gain
  VMAX       0x3018 (3)    vertical period
  HMAX       0x301C (2)    horizontal period
  SHS1       0x3020 (3)    integration time (only functional shutter on IMX291)
  OPORTSEL   0x3046 (1)    output mode

SHS2 / RHS1 are deliberately omitted -- they read as 0 on IMX291
(present in the silicon address map but non-functional, see Sony
IMX291 datasheet vs IMX290 datasheet -- only IMX290/307/327 expose
DOL through that triplet).

Watching `HCG_FRSEL` is particularly useful: AE writes this register
when it wants to flip High Conversion Gain, and a buggy gu8HCGReg in
the sensor driver can drop FRSEL bits there, kicking the sensor out
of WDR for one frame. The fix in widgetii/sony_imx291@b51850c was
diagnosed via this register; the docs include the symptom pattern
to look for.

`print_usage` now lists `sensor monitor` alongside `trace`, `gpio`,
`reginfo` etc. with the supported-sensor list inline.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii
Copy link
Copy Markdown
Member Author

widgetii commented May 5, 2026

Live validation

Cameras came back online, deployed build-hisiv500/ipctool (rebuilt against arm-hisiv500-linux toolchain so the binary actually runs on armv5te Hi3516CV300 — the default arm-openipc-linux-musleabi produces v7-A code that gets Illegal instruction on this SoC, separate problem tracked elsewhere).

sensor monitor works on both the OpenIPC port and the XM Sofia reference camera in WDR mode, with essentially identical readings:

reg hi3516cv300 + OpenIPC hi3516cv300 + Sofia
HCG_FRSEL 0x02 0x02
GAIN 0x02 0x03
VMAX 0x550 (1360) 0x547 (1351)
HMAX 0x1130 (4400) 0x1130 (4400)
SHS1 0x54a (1354) 0x53e (1342)
OPORTSEL 0xe1 (MIPI 12-bit) 0xe1

Decoded: both cameras at ~30fps WDR, FRSEL=2 (DOL), HCG=0 (low gain, bright daylight), integration ≈ 6-9 lines per sub-frame. AE has converged to almost-identical values across both sensor drivers.

--help lists sensor monitor correctly:

  sensor monitor            poll AE/exposure registers from the
                            running sensor every 2s. Supported:
                            SC2315E, IMX291, IMX385.
  trace [--skip=usleep] [--output=PATH] ...

This validates the IMX291 sensor driver port in widgetii/sony_imx291 — same AE behaviour as Sofia's reference, observable through the same sensor monitor interface.

@widgetii widgetii merged commit 89149c1 into master May 5, 2026
3 checks passed
@widgetii widgetii deleted the feat/imx291-monitor branch May 5, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant