Skip to content

media: i2c: ov13858: apply 180-degree sensor flip on Surface Pro 9 - #177

Open
dragged9698 wants to merge 1 commit into
linux-surface:v6.19-surface-develfrom
dragged9698:cameras/sp9-ov13858-hw-rotate
Open

media: i2c: ov13858: apply 180-degree sensor flip on Surface Pro 9#177
dragged9698 wants to merge 1 commit into
linux-surface:v6.19-surface-develfrom
dragged9698:cameras/sp9-ov13858-hw-rotate

Conversation

@dragged9698

Copy link
Copy Markdown

PipeWire and the camera portal leave the Surface Pro 9 rear camera upside-down even when Rotation=180 is advertised. This applies the 180-degree correction in the OV13858 itself so those clients get an upright image.

Why not metadata-only

#170 is the right ipu-bridge fix for clients that honor V4L2 Rotation (GNOME Snapshot / libcamera). PipeWire ignores that property, so OBS and similar stay inverted. This PR is the pixel-path complement: after the mode table is written, it ORs FORMAT2 horizontal bits (same ones ov5693 uses on this tablet) and ov13b10 FORMAT1 vertical bits 4+5. ov5693's FORMAT1 bits are a no-op on this die.

V4L2 HFLIP/VFLIP are not advertised — libcamera remaps Bayer from those controls and the image washed out when we tried that.

When the hardware flip is on, rotation is reported as 0 so a later merge of #170 does not double-rotate.

Not in this PR

Test plan

  • Surface Pro 9, CachyOS 6.19.8-1-cachyos-surface, out-of-tree ov13858.ko with this overlay
  • Rear capture via PipeWire / libcamera is upright
  • Front ov5693 still streams (unchanged by this commit)
  • No V4L2 HFLIP/VFLIP; colour not washed out (that was the Bayer-remap failure mode)

Patchset: cameras

The Surface Pro 9 rear OV13858 (OVTID858) is mounted upside-down.
SSDB reports degree=0, and PipeWire does not rotate buffers from V4L2
Rotation metadata, so the image stays inverted even after ipu-bridge
reports Rotation=180.

Do not advertise V4L2 HFLIP/VFLIP: libcamera remaps Bayer order from
those controls and the image washes out. After the mode table is
programmed, set the FORMAT2 horizontal bits the ov5693 uses on this
tablet plus the ov13b10 FORMAT1 vertical bits (4 and 5). The ov5693
FORMAT1 bits are a no-op on this die.

Report rotation=0 when the hardware flip is applied so clients that
do honor metadata do not double-rotate.

Tested on Surface Pro 9 (CachyOS 6.19.8-1-cachyos-surface) with
PipeWire and libcamera. Front ov5693 is unchanged.

Link: linux-surface/linux-surface#1892
Link: linux-surface#170
Patchset: cameras
Signed-off-by: Jeff <125375211+dragged9698@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@zR-JB

zR-JB commented Aug 31, 2026

Copy link
Copy Markdown

I do not think we want to flip bytes in the driver

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.

2 participants