Skip to content

media: backport the IPU6 ov5693 clock-lane gate and ov13858 flip controls from v7.4-rc1 - #193

Open
CmdrShepardsPie wants to merge 7 commits into
linux-surface:v7.3-surface-develfrom
CmdrShepardsPie:camera-backports-7.3
Open

CmdrShepardsPie wants to merge 7 commits into
linux-surface:v7.3-surface-develfrom
CmdrShepardsPie:camera-backports-7.3

Conversation

@CmdrShepardsPie

Copy link
Copy Markdown

Seven cherry-picks from mainline v7.4-rc1 that fix the two camera problems the Surface Pro 9 still has on the 7.3 kernels:

  • Front (ov5693): on IPU6 the CSI-2 receiver doesn't lock onto the sensor's free-running MIPI clock, so no frames arrive. Fernando Rimoli's series makes ipu-bridge request a non-continuous clock for ov5693 on the IPU6 variants where it was confirmed (Tiger Lake, Alder Lake-P, Alder Lake-N), and ov5693 then gates the clock lane (bit 5 of 0x4800). This covers INT33BE (Pro 7+, Pro 8, Go 4) and OVTI5693 (Pro 9). IPU3 machines are unaffected.
  • Rear (ov13858): with the quirk from Surface Pro 9: fix rear camera rotation #170 the sensor reports Rotation 180, but ov13858 has no flip controls, so libcamera can't turn the image the right way up, and clients that don't rotate it themselves show it upside down. Sergey Lebedev's commit adds V4L2_CID_HFLIP/VFLIP (0x3820 bits 3 and 4). The Bayer order doesn't change, and the crop window is left alone.
# Mainline Subject Author
1 torvalds/linux@eda381fd8c0c media: ipu-bridge: Add ipu_bridge_get_ipu6() (prerequisite: the IPU6 PCI ID table) Sakari Ailus
2 torvalds/linux@0e12587945f6 media: i2c: ov5693: Gate the MIPI clock lane for non-continuous clock Fernando Rimoli
3 torvalds/linux@3436405beac8 media: ipu-bridge: Assign endpoint property indices dynamically Fernando Rimoli
4 torvalds/linux@b883954d842f media: ipu-bridge: Match sensor configs per IPU and add config flags Fernando Rimoli
5 torvalds/linux@8e3def7bf410 media: ipu-bridge: Request non-continuous clock for ov5693 on IPU6 Fernando Rimoli
6 torvalds/linux@a20c843c9bc4 media: ipu-bridge: Keep the clock-noncontinuous property name out of rodata (fix for 5) Fernando Rimoli
7 torvalds/linux@deb515fcc369 media: i2c: ov13858: add horizontal and vertical flip controls Sergey Lebedev

Six are clean cherry-picks with the same patch-id as mainline. In 5, the new OVTI5693 entry goes directly before the existing one from "Add camera support for Surface Pro 9", which sits after INT33F0 rather than in sorted order, because ipu-bridge needs the entries for one HID to be adjacent. The commit message notes this. None of the seven is tagged for stable, so they won't arrive through 7.3.y, and they can be dropped at the move to 7.4.

Related work:

Testing, Surface Pro 9 (IPU6 Alder Lake-P, 8086:465d), Fedora 45:

  • linux-surface 7.3.3-1 as released: the front camera shows no picture (privacy LED on). The rear sensor reports Rotation 0, has no flip controls, and its image is upside down.
  • Same kernel, stock modules, cam 30-frame captures, 3 runs: front got frames in 1 of 3 starts (none in the other two); rear 30/30 each, Rotation 0, no flip controls.
  • Same kernel with ipu-bridge, ov5693 and ov13858 built from v7.3-surface (so including Surface Pro 9: fix rear camera rotation #170) plus these commits, loaded in a boot where the stock camera modules never ran (the rear sensor rebound once after the bridge built its graph, since it had probed first): front 30/30 frames with data in 3 of 3 starts; rear 30/30 in 3 of 3, Rotation 180, Location back, HFLIP/VFLIP present. In GNOME Snapshot both cameras show a picture and both are upright.
  • Earlier, a 7.3.1 build carrying the same seven commits (with mainline's Surface Pro 9 rotation quirks instead of Surface Pro 9: fix rear camera rotation #170): front cam captures at 2592x1944 got 30/30 frames with data in 12 of 12 starts, in each of 3 runs. Rear: 90/90 frames at 29.95 fps, 3 runs.
  • Applies with git am and no fuzz to v7.3-surface-devel and v7.3-surface. ipu-bridge, ov5693 and ov13858 build with W=1 and no warnings.

Sakari Ailus and others added 7 commits November 12, 2026 18:23
Add ipu_bridge_get_ipu6() for obtaining the IPU 6 (or soon later) PCI
device. This isn't technically a job of the IPU bridge, but the
functionality is required in conjunction with the firmware definitions
that necessitate the use of the IPU bridge on many systems.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Antti Laakso <antti.laakso@linux.intel.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
(cherry picked from commit eda381f)
[ backport: taken as a prerequisite of 8e3def7, which uses the IPU6 PCI IDs
  from <media/ipu6-pci-table.h> that this commit includes ]
Patchset: cameras
The ov5693 never programs MIPI_CTRL00 (0x4800), leaving it at its 0x00
power-on default, which lets the MIPI clock run freely. The IPU3 CSI-2
receiver tolerates this, but the IPU6 receiver (e.g. on Microsoft
Surface Pro 7+, Pro 8, Pro 9 and Surface Go 4) fails to lock onto the
link, so the sensor streams but capture times out with "stream stop
time out". On most affected machines no frames arrive at all; on some
the failure is intermittent.

Gate the clock lane while idle at stream on when the endpoint requests a
non-continuous clock.

Only the gate bit is touched, so platforms that do not request it are
unaffected. No counterpart is needed at stream off, as the link is down
by then and the register returns to its default when the sensor is
powered off.

The property is supplied by the ipu-bridge in a subsequent patch.

Link: linux-surface/linux-surface#2171
Co-developed-by: Arsalan Naeem <naeemarsalan@gmail.com>
Signed-off-by: Arsalan Naeem <naeemarsalan@gmail.com>
Signed-off-by: Fernando Rimoli <fernandorimoli11@gmail.com>
Tested-by: Jakob Berg Jespersen <dev@berg.pm> # Surface Pro 7+, IPU6 Tiger Lake
Tested-by: Fil Dunsky <filipp.dunsky@gmail.com> # Surface Pro 8, IPU6 Tiger Lake (8086:9a19)
Tested-by: Lucas Lis <lucaseze.lis@gmail.com> # Surface Pro 7+, IPU6 Tiger Lake (0x9a19)
Tested-by: Kengo Oki <dev.kengo.fugu0141@gmail.com> # Surface Go 4, IPU6 Alder Lake-N 8086:462e
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit 0e12587)
Patchset: cameras
Index the ep_properties array dynamically instead of plain numerical
values as is done in mipi-disco-img.c.

Signed-off-by: Fernando Rimoli <fernandorimoli11@gmail.com>
Tested-by: Jakob Berg Jespersen <dev@berg.pm> # Surface Pro 7+, IPU6 Tiger Lake
Tested-by: Fil Dunsky <filipp.dunsky@gmail.com> # Surface Pro 8, IPU6 Tiger Lake (8086:9a19)
Tested-by: Lucas Lis <lucaseze.lis@gmail.com> # Surface Pro 7+, IPU6 Tiger Lake (0x9a19)
Tested-by: Kengo Oki <dev.kengo.fugu0141@gmail.com> # Surface Go 4, IPU6 Alder Lake-N 8086:462e
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit 3436405)
Patchset: cameras
Some sensors need different treatment depending on which IPU they are
connected to, so the ACPI HID alone is not enough.

Match on an optional list of IPU PCI product IDs. Entries for one HID
must be adjacent, IPU-specific ones first, so the generic entry is
skipped once a specific one has matched.

Signed-off-by: Fernando Rimoli <fernandorimoli11@gmail.com>
Tested-by: Jakob Berg Jespersen <dev@berg.pm> # Surface Pro 7+, IPU6 Tiger Lake
Tested-by: Fil Dunsky <filipp.dunsky@gmail.com> # Surface Pro 8, IPU6 Tiger Lake (8086:9a19)
Tested-by: Lucas Lis <lucaseze.lis@gmail.com> # Surface Pro 7+, IPU6 Tiger Lake (0x9a19)
Tested-by: Kengo Oki <dev.kengo.fugu0141@gmail.com> # Surface Go 4, IPU6 Alder Lake-N 8086:462e
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit b883954)
Patchset: cameras
The ov5693 (INT33BE / OVTI5693) needs its MIPI clock lane gated while
idle for the IPU6 CSI-2 receiver to lock onto the link, which the sensor
driver does when the endpoint requests a non-continuous clock.

The same sensor works with a free-running clock on the IPU3, so request
it only for the IPU6 variants where it has been confirmed on hardware:
Tiger Lake, Alder Lake-P and Alder Lake-N.

Signed-off-by: Fernando Rimoli <fernandorimoli11@gmail.com>
Tested-by: Jakob Berg Jespersen <dev@berg.pm> # Surface Pro 7+, IPU6 Tiger Lake
Tested-by: Fil Dunsky <filipp.dunsky@gmail.com> # Surface Pro 8, IPU6 Tiger Lake (8086:9a19)
Tested-by: Lucas Lis <lucaseze.lis@gmail.com> # Surface Pro 7+, IPU6 Tiger Lake (0x9a19)
Tested-by: Kengo Oki <dev.kengo.fugu0141@gmail.com> # Surface Go 4, IPU6 Alder Lake-N 8086:462e
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit 8e3def7)
[ backport: linux-surface's "Add camera support for Surface Pro 9" lists OVTI5693
  after INT33F0 rather than in sorted order, so the new OVTI5693 entry goes just
  before that one instead of at the sorted position; no other change ]
Assisted-by: LLM
Patchset: cameras
…rodata

The software nodes ipu-bridge registers on a successful init are never
unregistered. There is no module_exit and no remove hook, and every
software_node_unregister_node_group() call sits on an error unwind label
inside ipu_bridge_init(), so on success the nodes stay registered and
readable after the module is unloaded, which a later rebind relies on.

Nothing reachable from a registered node may therefore point into the
module image. PROPERTY_ENTRY_BOOL() stores a pointer to its name, so the
"clock-noncontinuous" string literal leaves the surviving node carrying a
dangling property name once ipu-bridge is gone.

Add the name to struct ipu_property_names, which is copied by value into
each struct ipu_sensor, and use that copy, as every other endpoint
property name already does.

Fixes: 8e3def7 ("media: ipu-bridge: Request non-continuous clock for ov5693 on IPU6")
Reported-by: D. Manresa <dmanresa@gmail.com>
Closes: https://lore.kernel.org/linux-media/20260905211307.542810-1-dmanresa@gmail.com/
Signed-off-by: Fernando Rimoli <fernandorimoli11@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit a20c843)
Patchset: cameras
The Microsoft Surface Pro 11 for Business (Intel) mounts this sensor
upside down, as commit b238116 ("media: ipu-bridge: Add upside-down
quirk for Surface Pro 11") records, and the driver has no flip controls
to compensate.

Add V4L2_CID_HFLIP and V4L2_CID_VFLIP on bits 3 and 4 of register 0x3820.
The mirror bit is active low, as in Intel's out-of-tree ov13858 driver.
The Bayer order does not change with either flip, so the controls do not
set V4L2_CTRL_FLAG_MODIFY_LAYOUT. They are clustered, and grabbed while
streaming.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>
Tested-by: German Pablo Lindo <germanpapulindez@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
(cherry picked from commit deb515f)
Patchset: cameras
@T-Caster

Copy link
Copy Markdown

Tested on a Surface Pro 7+ (IPU6 Tiger Lake 8086:9a19, front sensor INT33BE, SKU Surface_Pro_7+_1960), Debian 13, linux-surface 7.3.4-1.

I cherry-picked the six ipu-bridge/ov5693 commits (not the ov13858 one, there is no such sensor here) onto v7.3-surface and loaded them as replacement modules. They applied without conflicts. intel-ipu6 and intel-ipu6-isys were rebuilt from unchanged sources alongside, because ipu_bridge_parse_ssdb() gets a new symbol CRC.

  • Before (stock 6.19.8-surface-3, which is what I had running): libcamera lists the front camera but a capture gets 0 frames. The stock 7.3.4 ov5693.ko and ipu-bridge.ko do not contain the gate either.
  • With these commits: the front camera streams at 2592x1944. Raw capture from the ISYS node (BG10, v4l2-ctl --stream-mmap), 6 start/stop cycles of 20 frames, repeated over three boots: every frame arrived and had image content, none constant or repeated. libcamera reports 28.6 fps.
  • The sensor's colour-bar test pattern comes through clean.

Two things I noticed that are not caused by this PR:

  • Roughly every second stream start logs a short burst of csi2-4 error: Transfer FIFO overflow / Inter-frame short/long packet discarded. The frames of those runs are fine.
  • With either flip control set, the 1296x972 binned mode delivers no frames (Frame sync error), and libcamera sets both flips on this machine because the sensor reports rotation 180. Applications asking for 720p or less therefore get a black picture until the binned-mode patch is in as well. D. Manresa's ov5693-binned-no-mipictrl.patch (the variant without the 0x4800 write) on top of these commits fixes that here; more detail in my comment on media: Surface Pro 5 (IPU3) camera fixes: OV8865, OV5693, OV7251 IR illuminator #181.

So for the Pro 7+ front camera: works for me with this backport.

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.

3 participants