Skip to content

feat(image): sensor-level flip/mirror via MI_SNR_SetOrien (both backends)#84

Merged
snokvist merged 2 commits into
OpenIPC:masterfrom
snokvist:feature/sensor-flip-mirror
Jun 6, 2026
Merged

feat(image): sensor-level flip/mirror via MI_SNR_SetOrien (both backends)#84
snokvist merged 2 commits into
OpenIPC:masterfrom
snokvist:feature/sensor-flip-mirror

Conversation

@snokvist

@snokvist snokvist commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

image.flip / image.mirror now work correctly on both backends. They
previously rode the VPE digital flip (MI_VPE_SetChannelParam mirror/flip),
which is unreliable on several sensor combos — on IMX335 (Star6E) flip
stalled the encoder outright (a brief flipped frame, then a hang).

Root cause of the stall was a per-frame MI_SNR_SetOrien "storm" (re-applying
orientation every frame for ~5s to fight a phantom "CUS3A clears orientation"
theory); on IMX335 that repeatedly rewrote the sensor's vertical-timing
register table mid-stream and wedged the encoder. It is not a flip-vs-VIF
hardware incompatibility.

Change

Program the sensor's own orientation register via MI_SNR_SetOrien, applied
once at bring-up on both backends:

  • sensor_select: before MI_SNR_Enable, so the driver's init picks up the
    correct flip/mirror state.
  • star6e_pipeline / maruko_pipeline: before the VPE channel starts.
  • VPE digital flip stays disabled (param.mirror/flip = 0).

The sensor driver only rewrites orientation when we set it, so a single apply
holds for the life of the stream. A one-shot re-apply follows the discrete
MI_SNR_SetFps events that can reprogram sensor timing (Star6E live ISP-bin
reload; Maruko cold-boot fps kick).

No per-frame re-apply loop and no MI_SNR_GetOrien (it reads stale values
under AE I2C load on IMX335 — reports m=0/f=0 while the image is plainly held).
MI_VPE_SetChannelParam failure stays fatal.

Tests

  • tests/test_sensor_select.c: test_orientation_applied_as_requested
    unconditional apply for imx335/imx415, and no SetOrien call when neither
    is requested. 1645 tests pass.
  • Build clean on star6e + maruko; make pre-pr gate OK (v0.16.0).

Device verification

  • Star6E / IMX335 and Maruko / IMX415: flip + mirror both visually
    correct and stable — alive, stable PID, frames flowing, no orientation churn,
    no reboot.

🤖 Generated with Claude Code

snokvist and others added 2 commits June 6, 2026 22:52
…h backends)

image.flip / image.mirror previously rode the VPE digital flip
(MI_VPE_SetChannelParam mirror/flip), which is unreliable on several
sensor combos — on IMX335 (Star6E) flip stalled the encoder outright.

Program the sensor's own orientation register via MI_SNR_SetOrien instead,
applied once at bring-up on both backends:
  - sensor_select: before MI_SNR_Enable, so the driver's init picks up the
    correct flip/mirror state.
  - star6e_pipeline / maruko_pipeline: before the VPE channel starts.
The VPE digital flip stays disabled (param.mirror/flip = 0).

The sensor driver only rewrites orientation when we set it, so a single
apply holds for the life of the stream — device-verified on IMX335 (Star6E)
and IMX415 (Maruko), flip + mirror both correct and stable. A one-shot
re-apply follows the discrete MI_SNR_SetFps events that can reprogram sensor
timing (Star6E live ISP-bin reload; Maruko cold-boot fps kick).

No per-frame re-apply loop and no MI_SNR_GetOrien (it reads stale values
under AE I2C load on IMX335). MI_VPE_SetChannelParam failure stays fatal.

Adds test_orientation_applied_as_requested covering unconditional apply for
imx335/imx415 and no SetOrien call when neither is requested.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- VERSION 0.15.0 -> 0.16.0
- HISTORY.md: 0.16.0 entry describing the MI_SNR_SetOrien orientation path.
- README image table: note flip/mirror apply at the sensor at bring-up,
  both backends.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@snokvist snokvist merged commit 3ba6c8a into OpenIPC:master Jun 6, 2026
7 checks passed
@snokvist snokvist deleted the feature/sensor-flip-mirror branch June 6, 2026 20:57
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