Skip to content

media: i2c: ov5693: Gate the MIPI clock lane for IPU6 Surface front cameras - #180

Open
loisBreant wants to merge 1 commit into
linux-surface:v7.2-surface-develfrom
loisBreant:sp9-ov5693-mipi-clock-lane-gating
Open

loisBreant wants to merge 1 commit into
linux-surface:v7.2-surface-develfrom
loisBreant:sp9-ov5693-mipi-clock-lane-gating

Conversation

@loisBreant

Copy link
Copy Markdown

The front camera of the IPU6 Surface devices (Pro 8, Pro 9, Go 4) still does not stream on the 7.2 kernels. The ov5693 driver starts the sensor, but the IPU6 CSI-2 receiver never gets a frame.

This sets MIPI_CTRL00 (0x4800) bit 5 (clock lane gate) before stream-on when the link is non-continuous. Because this kernel's ipu-bridge does not set clock-noncontinuous yet, it is also enabled for the OVTI5693 HID, which only appears on IPU6 Surfaces. Only that bit is changed, and a clock_ncont module parameter (-1 auto, 0, 1) can force it either way.

Relation to other work

  • It uses the same approach as the upstream series "media: Enable the OV5693 front camera on IPU6 Surface devices" (Fernando Rimoli, in media next), which also gates bit 5 only. Once that series reaches a release, this commit can be dropped in favour of a backport, which moves the decision into ipu-bridge per IPU PCI ID. I can prepare that backport if you prefer it now.
  • cameras: ov5693: make the IPU6 Surface front cameras stream (Pro 8/9, Go 4) linux-surface#2171 fixes the same problem for 6.19 by writing the full vendor value (0x2d). This PR targets 7.2, where nothing fixes it yet.

Testing: Surface Pro 9 (i7-1255U, IPU6 8086:465d), 7.2.11-surface-1, Ubuntu 24.04, libcamera 0.7.2 software ISP:

Without With
Frames received (2592×1944) none 28.6 fps
CSI-2 errors while streaming n/a none
Chrome via v4l2loopback (MediaStreamTrack.stats) n/a 28.6 fps delivered, 0 discarded

On this branch's ov5693.c (identical to 7.2.11-surface-1's), the result builds to exactly the same machine code as the module I have been running (same srcversion, identical disassembly).

The full userspace setup for the Surface Pro 9 (libcamera, v4l2loopback, browser support) is documented in https://github.com/loisBreant/surface-pro-9-camera.

Transparency: I developed this with the help of an AI assistant (Claude). It was built, run and verified on real hardware, and the kernel change was reviewed separately for safety before I used it.

…ameras

On the IPU6 Surface devices (Pro 8, Pro 9, Go 4) the front ov5693 starts
streaming but the IPU6 CSI-2 receiver never gets a frame: the receiver
needs the sensor to gate its clock lane when idle (non-continuous clock),
which the driver never configures.

Set MIPI_CTRL00 (0x4800) bit 5 (clock lane gate) before stream-on when
the endpoint is non-continuous. As this kernel's ipu-bridge does not set
"clock-noncontinuous" yet, also enable it for the OVTI5693 HID, which is
only used on IPU6 Surface devices. Only that bit is touched; the
clock_ncont module parameter can force it on or off.

This follows the approach of the upstream series "media: Enable the
OV5693 front camera on IPU6 Surface devices" (in media next), which
gates bit 5 only. Linux-surface PR #2171 writes the whole register (0x2d)
on 6.19 instead.

Tested on a Surface Pro 9 (i7-1255U, IPU6 8086:465d), 7.2.11-surface-1,
Ubuntu 24.04, libcamera 0.7.2 software ISP: 2592x1944 at 28.6 fps, no
CSI-2 errors while streaming, 28.6 fps delivered in Chrome through
v4l2loopback. Without the change no frame is received.

Developed with the help of an AI assistant (Claude); tested on hardware.

Link: https://patchew.org/linux/20260717132021.18034-1-fernandorimoli11@gmail.com/
Link: linux-surface/linux-surface#2171
Link: https://github.com/loisBreant/surface-pro-9-camera
Patchset: cameras
Signed-off-by: Lois Breant <185382558+loisBreant@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fildunsky

Copy link
Copy Markdown

Surface Pro 8 (IPU6 Tiger Lake, 8086:9a19) supports the bit 5 only approach.

I tested Fernando Rimoli's series at v5 on this machine. It gates only bit 5 of 0x4800 (through clock-noncontinuous from ipu-bridge), and the front camera streamed. That series is now in media next (0e12587945f6), so this PR matches what upstream will ship. Dropping it later in favour of the backport, as you suggest, makes sense.

One thing to watch when testing on the Pro 8: here, the first capture after a cold boot often succeeds even without any 0x4800 write. Only the captures after that fail. So capture at least twice before concluding the fix is present or absent.

@technosf

technosf commented Nov 2, 2026

Copy link
Copy Markdown

Tested on a Surface Pro 8 (Tiger Lake IPU6, front camera = ov5693, ACPI HID INT33BE, 2 lanes), linux-surface kernel 7.2.14-1-surface, this PR's patch applied to the in-tree ov5693.c (all hunks apply cleanly, builds without warnings). Raw V4L2 (media-ctl + v4l2-ctl --stream-mmap), libcamera not involved.

Result: it fixes the Pro 8 front camera, but only with clock_ncont=1.

  • clock_ncont=1: 3 of 3 captures at 2592x1944 (5 frames each, 3 s apart so the sensor autosuspends between them), each exactly 5 frames. dmesg: ov5693 i2c-INT33BE:00: MIPI clock lane gating enabled.
  • Auto (the default): gating is not enabled on the Pro 8. The Pro 8 front camera has ACPI HID INT33BE, not OVTI5693 (the driver's own ACPI table lists INT33BE; the rear camera is OVTID858), and ipu-bridge doesn't set clock-noncontinuous here, so neither condition in ov5693_check_hwcfg() matches. Without the bit the stock driver delivers no frames. The OVTI5693 match presumably covers the Pro 9 you tested.

Suggestion: also match INT33BE (or set the non-continuous flag for these devices in ipu-bridge), so the Pro 8 works without a module option.

Notes:

  • Only bit 5 is written (cci_update_bits), which is enough here. I had earlier used a plain 0x2d write; this is the narrower fix.
  • Binned 1296x972 is not part of this PR and was not tested with it. On the Pro 8 it needs the tables from #2252 and a mode rewrite on every stream-on.
  • The receiver still logs Transfer FIFO overflow / discarded packets (csi2-4 error) at the start of the streams; frames arrive complete anyway.

@JoseBCN84

JoseBCN84 commented Nov 6, 2026 •

Copy link
Copy Markdown

Tested on a Surface Go 4 (Intel N200, IPU6 8086:462e, front OV5693 as INT33BE), Fedora 44, stock 7.2.15-200.fc44 kernel, libcamera 0.7.2.

Without a fix, the front camera stalls with "stream stop time out". Setting only bit 5 of MIPI_CTRL00 before stream-on (out-of-tree ov5693 module, applied unconditionally) fixes it: 60/60 frames at 28.6 fps at 2592x1968. The binned 1296x972 mode also streams, at about 55 fps through libcamera. Over three days of repeated starts, dmesg shows no time-outs and one burst of csi2 "Transfer FIFO overflow" and "packet discarded" messages.

I tested the same one-bit change rather than this exact PR. The Go 4 uses INT33BE like the Pro 8 tested above, so I'd expect it to need the same handling. I did this with help from Claude.

Update: more testing with the same one-bit change. After a reboot, 10 start/stop cycles, a 2-minute stream in the binned mode and suspend/resume all worked, with no csi2 errors or time-outs in dmesg. Other Go 4 findings are in linux-surface/linux-surface#2154.

@nimoscar

Copy link
Copy Markdown

Surface Pro 7+ data point (Tiger Lake IPU6 8086:9a19, front ov5693 at \_SB_.PC00.I2C2.CAMF, ACPI HID INT33BE), kernel 7.3.4-2-surface with the stock ov5693 (no clock_ncont yet), libcamera software ISP.

Bit 5 alone is enough on the Pro 7+. With a stalled stream (0 frames for ~66 s, 0x4800 = 0x00 read over I2C), writing 0x20 to 0x4800 made frames start immediately: 959 frames at a steady 28.65 fps, no CSI-2 errors while streaming, clean stop with no stream stop/close time out. Earlier I had the same result with 0x24 (see my comments on linux-surface/linux-surface#2171).

Note on the auto-detection: the Pro 7+ front sensor enumerates as INT33BE, not OVTI5693. As written, the acpi_dev_hid_match(..., "OVTI5693") fallback would leave gating disabled on this device, unless ipu-bridge sets the non-continuous clock flag (it doesn't in this kernel). INT33BE is also used on IPU3 Surfaces (Pro 4-7, Book 2), where the 0x00 default works, so matching on the HID alone may not be right. Matching on the IPU generation (or the ipu-bridge flag on IPU6) would cover the Pro 7+ too. Until then, options ov5693 clock_ncont=1 is the workaround for Pro 7+ users.

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.

5 participants