Skip to content

WIP: media: i2c: imx471: add settle delay before entering streaming mode - #460

Draft
deep0294 wants to merge 4 commits into
intel:masterfrom
deep0294:fix/imx471-privacy-reopen-settle-delay
Draft

deep0294 wants to merge 4 commits into
intel:masterfrom
deep0294:fix/imx471-privacy-reopen-settle-delay

Conversation

@deep0294

Copy link
Copy Markdown

Status: WIP — for early feedback only, not ready for review.

Problem

On platforms with a discrete MIPI retimer between the imx471 sensor and the IPU CSI2 receiver (e.g. Lenovo privacy-shutter designs that gate the retimer via EC), reopening the camera stream (privacy shutter un-shutter / switchToNormal) can produce CSI2 short-packet errors (error status 0x00000020 / 0x00000048) on the very first frame of the new session, which can cascade into sync-frame-drop and V4L2 poll timeouts downstream.

Root cause

imx471_start_streaming() writes MODE_SELECT = STREAMING with no settle margin after finishing register configuration. This triggers the sensor's first MIPI HS burst immediately, racing against the external retimer's PLL/CDR lock time (which is not tracked or signaled back to the driver).

Change

Adds a usleep_range(30000, 50000) settle window immediately before the MODE_SELECT = STREAMING write in imx471_start_streaming(), giving the retimer time to complete HS lock before the sensor begins transmitting.

Notes

  • This is a first-pass mitigation via a fixed delay; there is no retimer-ready handshake available to poll instead.
  • Posting as draft/WIP for early visibility while further validation is in progress.

Insert a usleep_range(30000, 50000) settle window between the final
mode-configuration register write and the MODE_SELECT=STREAMING write
in imx471_start_streaming().

On platforms with a discrete MIPI retimer between the sensor and the
IPU CSI2 receiver, the retimer's PLL/CDR needs time to complete HS
lock after the sensor is powered back on (e.g. after a privacy-shutter
reopen). Without this margin, the very first HS burst can arrive
before the retimer has locked, causing the CSI2 receiver to flag
short-packet errors on frame 0 of the new streaming session, which can
cascade into sync-frame-drop / poll-timeout symptoms downstream.

WIP: posting for early feedback, not ready for review yet.
Signed-off-by: Amarnath Kumar, Deepak <deepak.amarnath.kumar@intel.com>
Replace the fixed usleep_range(30000, 50000) settle delay with a
per-platform configurable value (imx471->settle_delay_us, default
40ms +/-10ms), overridable via the optional firmware property
"intel,retimer-settle-delay-us".

This mirrors the pattern used by the Windows sensor driver, which
defines a per-module default delay that can be overridden via a
registry key (OS_ReadRegistry_V2(..., "IsSupportCameraMask"/delay
overrides, ...)). Linux lacks the same per-DSDT-module-name string
identification Windows uses, so this exposes the equivalent knob as
a standard fwnode/ACPI property instead, so specific boards (e.g.
platforms with a discrete MIPI retimer) can tune the value without
a code change.

Signed-off-by: Amarnath Kumar, Deepak <deepak.amarnath.kumar@intel.com>
- imx471_power_off(): assert hardware reset (XCLR low) and wait 1-2ms
  while the imaging clock is still active, before disabling the clock
  and regulator. Previously the clock was cut before reset was
  asserted, risking undefined internal sensor state on next power-up.

- imx471_power_on(): assert reset immediately, then enable
  regulator/clock, hold reset low for >= 20ms while supplies and MCLK
  stabilize, then release reset and wait 30ms for the sensor's
  internal PLL and I2C core to stabilize before any register access.
  Previously reset was never actively asserted during power-up and had
  no hold time, matching reference driver patterns (ov01a10.c,
  ov02c10.c, ov5675.c) that all assert reset for >= 2-20ms during
  power-up and enforce a post-reset settle delay.

This is a separate, complementary fix to the retimer settle delay in
imx471_start_streaming(): this one ensures the sensor's own internal
state (frame counters, PLL, I2C core) is reliably reset on every
power-on, independent of any external MIPI retimer.

Signed-off-by: Amarnath Kumar, Deepak <deepak.amarnath.kumar@intel.com>
Issue IMX471_REG_SW_RESET (0x0103=1) and place the sensor in standby
(MODE_SELECT=STANDBY) at the start of imx471_start_streaming(),
before identify_module()/register configuration, to reset frame
counters and digital logic on every stream start.

Uses a 10-15ms settle window after the software reset write (matching
ov2740.c and imx258.c's ~12ms), NOT the shorter 1-2ms initially
proposed: a too-short settle here was previously observed to cause
MIPI runt packets on frame 0 and FLL/VMAX timing-register corruption
(66 FPS overrun) when register writes landed while the digital core
was still mid-reset.

Signed-off-by: Amarnath Kumar, Deepak <deepak.amarnath.kumar@intel.com>
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