Repository navigation
Conversation
|
I tested this PR's head (76d2ae0) as-is on a Surface Pro 9 (IPU6, Alder Lake-P Works on IPU6:
Regression: full-resolution colours (1ee078c). On this unit the sensor runs with
So in full mode the horizontal-flip column offset is one column off on this sensor. The row handling is right, and binned mode is right with both flips. Stock 7.2.11 and 7.3 give correct full-resolution colours on this unit. I'm happy to test a revision, and I'll add a Tested-by once full mode is fixed. |
76d2ae0 to
5b3b61e
Compare
|
Thanks for testing, and for the table — it pinned it down. In the full readout each flip moves the Bayer phase by one column, so the two cancel out when both are set; my patch only compensated the vertical one, which was enough on the SP5 (hflip stays 0 there) but not with the 180° rotation on the Pro 9. Fixed in 1ee078c → dee4ccd (force-pushed): the output window is shifted when hflip XOR vflip, and reprogrammed when either flip changes. Binned mode is untouched. On the Surface Pro 5, raw full-resolution frames from the CIO2 now come out BGGR for all four hflip/vflip combinations (before: GBRG whenever hflip was set), and libcamera still gives 0 errors and natural colours at every size. A re-test on the Pro 9 would be welcome. |
|
@rylos, a data point for the OV5693 binned mode from a different receiver: a Surface Pro 7 (Ice Lake, IPU4P). Disclosure: this work was done with help from an AI coding assistant. I ran it on my own Surface Pro 7. Setup: Ubuntu 24.04, linux-surface 7.3.0-rc7 with Sakari's IPU7 v4 series, ruslanbay's IPU4P-on-IPU6 RFC series and my SP7 patches. The front OV5693 is on CSI-2 port 2 (firmware source 7, two lanes), with his fixed receiver timing for that port. What I tested: only the Method: raw ISYS node, no libcamera. Each start sets the sensor pad and the CSI-2 pads to 1296x972 SBGGR10 with
The binned-mode patch from linux-surface#2252 on its own gave the same 10/10 here: linux-surface/linux-surface#2252 (comment) Not measured: the ov7251, ov8865 and ipu-bridge changes, full resolution with this PR (so not the hflip/vflip Bayer fix), the frame rate, colours, mode switches (every start set the format after a suspend), and the other Note on the "without" row: my ov5693 carries a local hflip fix, and at its default both horizontal flip bits are set, while the patched module is stock-based and clears them. So the 0/10 isn't a clean stock baseline. It's the binned mode as I had it. |
|
@loafecho thanks, that's a useful third receiver: binned 1296x972 clean on IPU3 (SP5), IPU6 (Pro 9, @CmdrShepardsPie's test) and now IPU4P. If you have time for one more run, full resolution would cover the part nobody has checked off this receiver yet: 2592x1944 SBGGR10 on the raw ISYS node with the four A quick way to tell without libcamera: split a raw frame into its four 2x2 sub-planes. The green pair is the diagonal whose two planes are most alike, so (0,1)/(1,0) means BGGR/RGGB and (0,0)/(1,1) means GBRG/GRBG. That's how I checked it on the SP5. |
|
Re-tested at 5b3b61e on the Surface Pro 9 (Intel, Alder Lake-P; IPU6, front ov5693) on two kernels: linux-surface's Fedora 7.2.12-1 package plus this PR's 10 commits, and v7.3-surface (1ea399d) plus the same commits. "Before" is the 7.2.12-1 package as-is. Raw frames come from the ISYS node; long runs and mode switches use libcamera 0.5.2
The flips read back as set in every case. No frame-sync errors; the occasional FIFO overflow or inter-frame packet discard (up to 3 per switch pair) also shows up without the PR.
This covers the ov5693 changes and the rear camera still working; the OV8865/OV7251 and Pro 5 parts don't apply to this hardware. Tested-by: Chris Simpson chris@nilk.net # Surface Pro 9 (IPU6), 7.2.12 and 7.3 Do you plan to send the ov5693 changes, including the stream-start mode programming (ac26433), to linux-media? If so, I'll test what you post on the Pro 9 and reply with a Tested-by on the list, and the Pro 9 mode-switch numbers are yours to cite. |
|
@rylos, here's the full-resolution run, on the same Surface Pro 7 (Ice Lake, IPU4P). Disclosure: as before, this work was done with help from an AI coding assistant. I ran it on my own Surface Pro 7. Setup: same as before: Ubuntu 24.04, linux-surface 7.3.0-rc7 with Sakari's IPU7 v4 series, ruslanbay's IPU4P-on-IPU6 RFC series and my SP7 patches. The front OV5693 is on CSI-2 port 2 (firmware source 7, two lanes). What I tested: the Method: raw ISYS node, no libcamera.
So it stays on the BGGR/RGGB diagonal in all four, as you expected. That matches CmdrShepardsPie's Pro 9 (IPU6) re-test just above, which got BGGR at all four full-resolution flip settings on IPU6; this table shows the same diagonal on an IPU4P receiver. None of the four captures logged a Did the flips really happen? A second run, about two minutes after the one above, on the same scene (30 frames per setting, its own module load; I didn't check the scene for movement). I compared the green-plane column and row profiles of each setting against hflip=0/vflip=0:
So the second run shows the controls reach the sensor, and in the first run the order held at all four settings. Reference, my installed ov5693: GBRG/GRBG at vflip=0 (with hflip off or on) and BGGR/RGGB at vflip=1, while reporting SBGGR10 every time. A separate run right after the #181 one, same scene: green pair (0,0)/(1,1) at r 0.9921 with diff 0.0641 for hflip=0/vflip=0. So the test does separate the two diagonals on this sensor. My hflip fix inverts the control (at hflip=0 both horizontal flip bits are set), so its hflip rows aren't the same register state as this PR's, and it's a different driver from your Not measured: the binned mode with flips, frame rate, colours through libcamera, and the ov7251, ov8865 and ipu-bridge changes. Only one frame per setting went through the sub-plane test. |
Same issue as ov8865: the mode registers are only written on runtime PM resume, so a format change on a sensor that stays powered never reaches the chip. Program the mode before the controls on every stream start. Tested-by: Chris Simpson <chris@nilk.net> # Surface Pro 9 (IPU6) Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
The SSDB of the Surface Pro 5 (SKU 1796, and 1807 for the LTE model) reports a 180 degree rotation for both the front OV5693 and the rear OV8865. Measured on the device, both sensors need a vertical flip only, without mirroring, which is not a rotation: applying the reported 180 degrees leaves both images mirrored. - ipu-bridge: add a DMI list of sensors that are not rotated despite what the SSDB says, and report 0 degrees for them. - ov8865: on these machines invert the VFLIP control, so the default value gives an upright image and userspace (libcamera resets the flip controls) keeps working. The front sensor gets the same treatment in a separate patch. Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
On the Surface Pro 5 the IR flood LED is driven by the OV7251 STROBE pad, not by a GPIO or the TPS68470 LED outputs, and ACPI does not describe it. The mode tables leave the pad disabled (0x3005 = 0x00, 0x3016..0x301c = 0xf0), so the LED never lights and the IR camera, which sits behind an IR-pass filter, only sees black. Enable the STROBE output on stream start on the Surface Pro 5 (SKU 1796 and 1807), with an alternate-frame pattern (0x3b81 = 0xaa) so userspace gets lit and unlit frames. The module parameter surface_ir_strobe overrides the DMI match (-1 auto, 0 off, 1 on). Verified on a Surface Pro 5 (1796): with the strobe enabled the mean level of consecutive 640x480 frames alternates between 16 and 42, with it disabled it stays at 16. Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
The driver's 1296x972 binned mode has never streamed on IPU6 machines
(Surface Pro 7+/8/9, Go 4): the receiver reports "Transfer FIFO
overflow" or "Frame sync error" and no frame ever completes. Because of
that, every IPU6 setup has had to read the sensor at full 2592x1944 and
downscale, throwing away two stops of light and pinning the AGC at its
maximum analogue gain (127 vs ~15) - the familiar "working but unusably
noisy" IPU6 front camera. Fix the mode by porting what the vendor
(Windows) driver ov5693.sys programs differently, extracted from its
mode tables:
- Per-mode MIPI PLL (0x30b3: 0x70 binned / 0x83 full) and six per-mode
analogue readout registers. Mainline writes only the full-resolution
values, once, globally; the binned readout then overflows the
receiver's FIFO.
- Readout geometry with spare pixels: cropping exactly the output size
starves the sensor's internal ISP and every frame fails CSI-2 framing
("Frame sync error"). The vendor reads the whole pixel array, bins it
to 1312x978, and places the 1296x972 output via the ISP window
offsets. The parity of the Y offset selects the vertical Bayer phase
(even = the advertised BGGR, odd = GRBG); it is exposed as a module
parameter (binned_y_offset, default 2) because libcamera's software
ISP wants the advertised phase while pipelines built around the
Windows tuning (Intel's IPU6 HAL/PSYS) expect the vendor's odd
offset.
- Mode-dependent vertical-flip bits: with binning, setting both FORMAT1
flip bits corrupts the CSI-2 framing and the ISP bit alone does not
flip; only the sensor-side bit both streams and flips. Re-apply the
vflip control when the mode is configured, since the correct bits
depend on the selected mode.
- Cap the frame rate at 30 fps: the auto-picked 60 fps VTS for the
binned mode exceeds what the slower binned MIPI PLL can carry (the
vendor runs this mode at VTS 1984 / 30 fps).
- Program MIPI_CTRL00 (0x4800) = 0x2d before stream-on. The 0x00
power-on default is fine on IPU3 but leaves the IPU6 D-PHY unable to
lock: the sensor streams yet no CSI-2 data arrives.
Also document the black-level pedestal next to the BLC init values: the
sensor keeps ~16 LSB (10-bit) at every analogue gain, while OEM .aiqb
calibrations state 64.9 because Windows' ISYS delivers RAW10 aligned to
12 bits.
Verified on a Surface Pro 7+ (IPU6, Tiger Lake): 1296x972 at 30 fps,
analogue gain in normal indoor light drops from 127 (maximum) to ~15,
both through libcamera's software ISP and through Intel's IPU6 HAL on
top of the hardware ISP. Reference setup and measurements:
https://github.com/dmanresa-saes/surface-ipu6-cameras
Signed-off-by: D. Manresa <d.manresa@electronica-submarina.com>
Tested-by: Chris Simpson <chris@nilk.net> # Surface Pro 9 (IPU6)
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
Patchset: cameras
The front OV5693 of the Surface Pro 5 is mounted vertically mirrored: the upright, unmirrored image needs the sensor vertical flip and no horizontal flip. The firmware reports a 180 degree rotation, which makes userspace enable both flips and leaves the image mirrored. ipu-bridge now reports 0 degrees for this sensor; invert the VFLIP control on the Surface Pro 5 (SKU 1796/1807) so that its default value gives the upright image. In the full 2592x1944 readout each flip also moves the Bayer phase by one column: with exactly one of them enabled the receiver gets GBRG instead of BGGR, which gives a magenta image through libcamera; with both enabled the two shifts cancel out. The crop start only moves in steps of two columns, so shift the output window by one column and widen the crop accordingly when hflip XOR vflip, and reprogram the window when either flip changes. The binned readout keeps its phase with either flip. Verified on a Surface Pro 5 (1796): raw full-resolution frames are BGGR for all four hflip/vflip combinations; upright and unmirrored in the full and in the binned 1296x972 mode, natural colours through libcamera. Tested-by: Chris Simpson <chris@nilk.net> # Surface Pro 9 (IPU6) Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
…rface Pro 5 set_fmt() updates the VBLANK range and default for the new mode but keeps the current value when it is still in range. A value left over from the previous mode then keeps that mode's timing: after the full-size mode (VBLANK 22) the 800x600 mode runs faster than its nominal 90 fps, with the exposure capped accordingly. Set VBLANK to the mode default on every active format change, and derive the exposure range from it. On the Surface Pro 5 the rear camera is used through libcamera's IPU3 pipeline, which does not change the frame length. With the 800x600 mode, which libcamera picks for 640x480 and smaller requests, the exposure is limited to ~11 ms and indoor images are black even at maximum analogue gain. On this machine (SKU 1796/1807) default that mode to 30 fps by tripling its frame length; higher frame rates remain available through VBLANK. Verified on a Surface Pro 5 (1796): 800x600 at 30.6 fps with the full exposure range usable. Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
With the readout and MIPI PLL values of the 60 fps binned mode, the IPU3
CIO2 of the Surface Pro 5 loses several frames per stream ("frame sync
error", payloads of 778 or 831 lines instead of 972). The 30 fps binned
values (MIPI PLL multiplier 0x7d, analogue 0x3620-0x3622, 0x3708,
0x3709, 0x371f) stream cleanly: 90 of 90 frames, no errors, through
libcamera at 640x480.
Use them by default; the module parameter binned_regs selects the old
set (0) or the 30 fps values with the full-mode PLL (2). Also set 0x4307
to 0x30 and add a blc_target parameter for the black level target
(0x4009) for further tuning.
Tested-by: Chris Simpson <chris@nilk.net> # Surface Pro 9 (IPU6)
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
Patchset: cameras
Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
5b3b61e to
2bc8353
Compare
|
@CmdrShepardsPie @loafecho thanks, both. So the full-resolution Bayer order is now BGGR at all four flip settings on IPU3 (SP5), IPU6 (Pro 9) and IPU4P (SP7), and binned streams cleanly on all three. I've added Yes, I'll send the ov5693 changes to linux-media, starting with the stream-start mode programming, and I'll Cc you both. Your in-window mode-switch numbers on the Pro 9 (0 of 50 without the fix, 14 of 14 with it) are exactly what the commit message needs, so I'll cite them with a Reported-by/Tested-by as you suggested. |
|
@CmdrShepardsPie asked for in-window mode switches from the Pro 7+ before it goes. Here they are, with Short answer: on Tiger Lake it is 0/16 without the commit and 16/16 with it, and the register readback says why. But I could not use the method as given, and that part matters more than the number — please read it before quoting anything. Why
|
|
@loafecho @CmdrShepardsPie the linux-media series is ready: two ov5693 patches on top of the media tree's Once it's out, I'll post the lore.kernel.org link here. Since I don't have an address for you, @loafecho, you can reply on the list from there (lore has a "reply" link with the right headers) with your Tested-by for the SP7, and Chris for the Pro 9. |
|
@dmanresa-saes thank you, that's the clean measurement this needed: the register readback settles it. I've put your 0/16 against 16/16 in the commit message of the stream-start patch, instead of the Pro 9 figures I mentioned above: given what you found about You're right about the stop path too, and it's going in the series as patch 3, with a Reported-by for you. One nuance on the mechanism, from the runtime PM core: So the series is now three patches, not two. Here is the exact series I'm about to send to linux-media, against the media tree's
Note that patch 2 touches the readout window in Series (git am)From 18eec3f7f3c9ad9a7507c8a02dc29abaf71a7b4b Mon Sep 17 00:00:00 2001
From: Marco Ziliani <rylos78@gmail.com>
Date: Thu, 15 Oct 2026 22:04:29 +0200
Subject: [PATCH 1/3] media: i2c: ov5693: Program the mode registers on stream
start
The mode registers (readout window, binning and subsampling) are only
written from the runtime PM resume handler, and ov5693_set_fmt() merely
stores the requested mode. If the sensor stays powered between two
streams, the new mode never reaches the chip: the sensor keeps
streaming the previous mode while the CSI-2 receiver expects the newly
negotiated format.
This happens whenever the format is changed while the sensor is still
powered. On a Surface Pro 7+ (IPU6), with the sensor held powered
between two streams, OUTPUT_SIZE_X read back over I2C showed the sensor
stuck in the mode it was powered up in, and 0 of 16 streams that asked
for a different mode produced a frame. With this change, 32 of 32
streams completed and the register followed the requested mode.
Program the mode on every stream start, before the controls, so that
the mode registers don't clobber them. This matches what commit
4e1446ac169a ("media: i2c: ov8865: Program the sensor on stream start")
does for the ov8865.
Fixes: 89aef879cb53 ("media: i2c: Add support for ov5693 sensor")
Link: https://github.com/linux-surface/kernel/pull/181
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
drivers/media/i2c/ov5693.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 56599f9ca..579aa55b7 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -1000,6 +1000,19 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
return ret;
mutex_lock(&ov5693->lock);
+
+ /*
+ * The mode registers are otherwise only written on runtime PM
+ * resume, so a format change on a sensor that stays powered
+ * would never reach the chip. Program the mode first, then the
+ * controls, so the mode registers don't clobber them.
+ */
+ ret = ov5693_mode_configure(ov5693);
+ if (ret) {
+ mutex_unlock(&ov5693->lock);
+ goto err_power_down;
+ }
+
ret = __v4l2_ctrl_handler_setup(&ov5693->ctrls.handler);
if (ret) {
mutex_unlock(&ov5693->lock);
From 6d3cf2ee5517c853819e7f200080199b738c1cd4 Mon Sep 17 00:00:00 2001
From: Marco Ziliani <rylos78@gmail.com>
Date: Tue, 27 Oct 2026 08:12:37 +0100
Subject: [PATCH 2/3] media: i2c: ov5693: Keep the Bayer order when flipping at
full resolution
In the full (unbinned) readout each of the horizontal and vertical
flips moves the Bayer phase by one column. With exactly one flip
enabled the CSI-2 receiver gets GBRG instead of the SBGGR10 the driver
reports, which gives a magenta and green image; with both enabled the
two shifts cancel out.
The crop start is only honoured in steps of two pixels, so compensate
by shifting the output window by one column when hflip XOR vflip, and
widen the crop by two columns, within the pixel array, so that the
window still fits. Reprogram the window when either flip changes. The
binned readout is left unchanged.
With this change, raw 2592x1944 frames come out BGGR at all four
hflip/vflip settings on the Surface Pro 5 (IPU3); the same change in
the linux-surface tree gave BGGR at all four settings on a Surface
Pro 7 (IPU4P) and a Surface Pro 9 (IPU6). Without it, the order is only
right with both flips off or both on.
Fixes: 89aef879cb53 ("media: i2c: Add support for ov5693 sensor")
Link: https://github.com/linux-surface/kernel/pull/181
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
drivers/media/i2c/ov5693.c | 56 ++++++++++++++++++++++++++++++++------
1 file changed, 48 insertions(+), 8 deletions(-)
diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 579aa55b7..ca0968498 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -361,6 +361,49 @@ static const u8 ov5693_test_pattern_bits[] = {
/* V4L2 Controls Functions */
+/*
+ * In the full (unbinned) readout each flip moves the Bayer phase by one
+ * column, so with exactly one of them enabled the CSI-2 receiver gets GBRG
+ * instead of the SBGGR10 the driver reports; with both enabled the two shifts
+ * cancel out. The crop start is only honoured in steps of two pixels, so
+ * compensate by shifting the output window by one column instead, and widen
+ * the crop so that the window still fits.
+ */
+static bool ov5693_bayer_shift(struct ov5693_device *ov5693)
+{
+ const struct ov5693_mode *mode = &ov5693->mode;
+ bool hflip, vflip;
+
+ if (mode->binning_x || mode->binning_y)
+ return false;
+
+ hflip = ov5693->ctrls.hflip && ov5693->ctrls.hflip->val;
+ vflip = ov5693->ctrls.vflip && ov5693->ctrls.vflip->val;
+
+ return hflip ^ vflip;
+}
+
+static int ov5693_window_x_configure(struct ov5693_device *ov5693)
+{
+ const struct ov5693_mode *mode = &ov5693->mode;
+ bool shift = ov5693_bayer_shift(ov5693);
+ u32 crop_end = mode->crop.left + mode->crop.width;
+ int ret = 0;
+
+ /* Widen the crop for the shifted window, within the pixel array */
+ if (shift)
+ crop_end = min(crop_end + 2,
+ max_t(u32, crop_end, OV5693_NATIVE_WIDTH - 1));
+
+ /* Offset X */
+ cci_write(ov5693->regmap, OV5693_OFFSET_START_X_REG, shift, &ret);
+
+ /* Crop End X */
+ cci_write(ov5693->regmap, OV5693_CROP_END_X_REG, crop_end, &ret);
+
+ return ret;
+}
+
static int ov5693_flip_vert_configure(struct ov5693_device *ov5693,
bool enable)
{
@@ -373,7 +416,7 @@ static int ov5693_flip_vert_configure(struct ov5693_device *ov5693,
if (ret)
return ret;
- return 0;
+ return ov5693_window_x_configure(ov5693);
}
static int ov5693_flip_horz_configure(struct ov5693_device *ov5693,
@@ -388,7 +431,7 @@ static int ov5693_flip_horz_configure(struct ov5693_device *ov5693,
if (ret)
return ret;
- return 0;
+ return ov5693_window_x_configure(ov5693);
}
static int ov5693_get_exposure(struct ov5693_device *ov5693, s32 *value)
@@ -566,16 +609,13 @@ static int ov5693_mode_configure(struct ov5693_device *ov5693)
cci_write(ov5693->regmap, OV5693_CROP_START_X_REG, mode->crop.left,
&ret);
- /* Offset X */
- cci_write(ov5693->regmap, OV5693_OFFSET_START_X_REG, 0, &ret);
-
/* Output Size X */
cci_write(ov5693->regmap, OV5693_OUTPUT_SIZE_X_REG, mode->format.width,
&ret);
- /* Crop End X */
- cci_write(ov5693->regmap, OV5693_CROP_END_X_REG,
- mode->crop.left + mode->crop.width, &ret);
+ /* Offset X and Crop End X follow the flips, see ov5693_bayer_shift() */
+ if (!ret)
+ ret = ov5693_window_x_configure(ov5693);
/* Horizontal Total Size */
cci_write(ov5693->regmap, OV5693_TIMING_HTS_REG, OV5693_FIXED_PPL,
From 0ad6a26f3533836f7b10b928fde0836d3d6a094c Mon Sep 17 00:00:00 2001
From: Marco Ziliani <rylos78@gmail.com>
Date: Tue, 27 Oct 2026 08:29:18 +0100
Subject: [PATCH 3/3] media: i2c: ov5693: Use autosuspend when stopping the
stream
The driver enables runtime PM autosuspend with a 1 second delay at
probe, but drops the usage count at stream stop with pm_runtime_put(),
which doesn't update the device's last busy time. The autosuspend
delay is then counted from the runtime resume at stream start rather
than from stream stop, so after any stream longer than the delay the
sensor is powered off right away.
Use pm_runtime_put_autosuspend(), which marks the device busy, so that
the delay counts from stream stop as intended, and a following stream
started within it doesn't power the sensor up from scratch again. With
the mode now programmed on every stream start, keeping the sensor
powered between streams no longer leaves it in a stale mode.
Fixes: 89aef879cb53 ("media: i2c: Add support for ov5693 sensor")
Reported-by: Dario Manresa <d.manresa@electronica-submarina.com>
Closes: https://github.com/linux-surface/kernel/pull/181#issuecomment-6436016335
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
drivers/media/i2c/ov5693.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index ca0968498..ef5e7285c 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -1070,7 +1070,7 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
goto err_power_down;
if (!enable)
- pm_runtime_put(ov5693->dev);
+ pm_runtime_put_autosuspend(ov5693->dev);
return 0;
err_power_down: |
|
@dmanresa-saes the Pro 9 runs the I didn't read @rylos that's fine with me. I'll test the series you send on the Pro 9 and reply on the list with the result. |
|
@rylos before you send: Simon Kruse sent an ov5693 patch to linux-media this "media: i2c: ov5693: Use sub-device active state", 2026-10-27 07:49 UTC, same Where it collides, from its own diff:
It also fixes the same v4l2-compliance control-events failure, through That does not make your work redundant. The Bayer order with flips and the I have no stake in who sends first -- I just happen to be talking to both. He On the PM point, you are right and I was wrong, and I would rather say so
So the mechanism is right about the code and still does not explain my I still have the machine. I will measure the actual stop-to-suspend latency The Tested-by offer stands for whatever you send, and I will test it against |
|
One small thing on patch 3, while it is still unsent: could you put the Reported-by: D. Manresa dmanresa@gmail.com That is the address on my Signed-off-by and on every Tested-by I have given, |
|
@rylos, here's your 3-patch series on the same Surface Pro 7 (Ice Lake, IPU4P). All three patches pass here, and I'll send a Tested-by on the list once the series is up. Disclosure: as before, this work was done with help from an AI coding assistant. I ran it on my own Surface Pro 7. Setup: same as before: Ubuntu 24.04, linux-surface 7.3.0-rc7 with Sakari's IPU7 v4 series, ruslanbay's IPU4P-on-IPU6 RFC series and my SP7 patches. Front OV5693 on CSI-2 port 2. What I tested: the three patches from your comment above, applied with
No Two things I noticed along the way:
On the stop-path mechanism (dmanresa-saes's last comment): my streams were 60 frames at 2592x1944, about 2 s, so longer than the 1 s delay. With stock I tested the three patches exactly as posted above, on the 7.3 base. If what goes to the list changes, for example rebased onto Simon Kruse's active-state patch, I'll re-run it before sending a Tested-by. Not measured: frame rate, colours through libcamera, binned with flips, the ov7251/ov8865 changes. One scene only. |
|
@rylos I've tested your three patches on the Surface Pro 9 (Intel i7-1255U, IPU6 Method: direct V4L2 on the ISYS node (
FIFO overflow messages and inter-frame packet discards appeared in both builds at similar counts. On patch 3: the unpatched times fit your Not tested: libcamera/ These results are for the series as posted; as I said above, I'll test what reaches the list and reply there. |
|
The series is on the list: The code is byte for byte what you tested from my comment above; only the commit messages changed. They now carry the Pro 7+ and Pro 9 numbers from this thread plus an A/B run on the SP5 (IPU3), against media
No CSI-2 errors in either run. @dmanresa-saes the Reported-by on patch 3 uses @CmdrShepardsPie @loafecho since it's the code you already ran, a Tested-by as a reply on the list is all it needs. @loafecho, lore's "reply" link at the bottom of each message gives the Thanks all three of you: the series is a lot stronger for your measurements. |
|
Hi all, Simon Kruse here (the active-state patch on linux-media). @dmanresa-saes, thanks for pointing out the overlap. Plan, also posted on the list as a reply to the cover letter:
I'll post here when v2 is on the list. It adds the conversion on top of whatever version of Marco's series is current then. Disclosure: like the others here, I work on this with an AI coding assistant (the patch carries an |
|
Tested on a Surface Pro 4 SP4 (DMI SKU Build: Test: fresh boot, front camera only, raw capture of 5 frames per step through the CIO2 video node with Without the patches (stock 7.2.15): all four steps returned buffers of the expected size, but the kernel logged ten times With this PR: no Caveats: the images are close to saturation (mean about 1000 of 1023) because the capture used default exposure with no AEC, so I make no claim about image quality or colour. One run each. Orientation (front camera): the firmware reports The test scripts and this summary were prepared with an AI coding assistant (Claude); I ran the tests on my Surface Pro 4. |
|
Tested on a Surface Pro 8 SP8 (IPU6; front OV5693 = ACPI Raw capture of 5 frames per step, no gap between steps: 1296x972, 2592x1944, 1296x972, 2592x1944, after a reboot, twice, and once more with a 3 s gap between steps so that the sensor suspended in between. All three runs delivered 5 frames of the requested size on all four steps, with pixel data (images near saturation, default exposure). So with this PR, which writes Things I saw: the receiver logs This overlaps with #180, which sets only bit 5 of the same register when The test scripts and this summary were prepared with an AI coding assistant (Claude); I ran the tests on my Surface Pro 8. |
|
@technosf Thanks a lot for both runs, the Pro 4 one in particular: it is the first IPU3 data point besides my Pro 5, and the Pro 4 orientation. "Upside down and mirrored" in the raw frames is what a real 180° rotation looks like, and the SSDB says 180°, so the firmware may well be right on the Pro 4. On the Pro 5 the raw frames were upside down without the mirroring, which is why it needs the DMI quirk. Could you check it end to end? With this PR as it is (no
|
|
I ran the end-to-end check on the Pro 4 for both cameras (stock modules, so "the PR as it is": its DMI entries don't match Front (OV5693):
Rear (OV8865, 3264x2448):
So, as on the Pro 5, the reported 180° leaves the final image mirrored on both cameras, and the Pro 4 needs the same treatment: |
The Surface Pro 4 (IPU3, DMI SKU "Surface_Pro_4") has the same cameras as the Pro 5 and the same mounting: the SSDB reports a 180 degree rotation for the front OV5693 and the rear OV8865, but both sensors only need a vertical flip. Applying the reported rotation leaves both images mirrored. Add the Pro 4 to the ipu-bridge list of sensors that are not rotated and to the VFLIP inversion lists of ov5693 and ov8865, as for the Pro 5. Checked on a Surface Pro 4 with a letter held in front of each camera: the raw frames of both sensors show a vertical flip only, and after the reported 180 degree rotation the letter is mirrored. Reported-by: technosf <technosf@hit-on.com> Link: linux-surface#181 (comment) Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
|
@technosf Thanks, that settles it: same mounting as the Pro 5 on both cameras. Pushed as a separate commit, bb48b22 ("media: Surface Pro 4: same camera orientation quirks as the Pro 5"): If you get the chance, a run with this PR on the Pro 4 through libcamera ( |
|
Patch tested with libcamera-ipa, Before (same machine, without bb48b22): the F was upright but mirrored (back-to-front) on both the front and the rear camera, as expected from the raw frames. After (with bb48b22): the F is upright and not mirrored on both the front (OV5693) and the rear (OV8865) camera. I.e. It is correct Thank you @rylos |
The Surface Pro 4 (IPU3, DMI SKU "Surface_Pro_4") has the same cameras as the Pro 5 and the same mounting: the SSDB reports a 180 degree rotation for the front OV5693 and the rear OV8865, but both sensors only need a vertical flip. Applying the reported rotation leaves both images mirrored. Add the Pro 4 to the ipu-bridge list of sensors that are not rotated and to the VFLIP inversion lists of ov5693 and ov8865, as for the Pro 5. Checked on a Surface Pro 4 with a letter held in front of each camera: the raw frames of both sensors show a vertical flip only, and after the reported 180 degree rotation the letter is mirrored. Reported-by: technosf <technosf@hit-on.com> Link: linux-surface#181 (comment) Tested-by: technosf <technosf@hit-on.com> # Surface Pro 4 Signed-off-by: Marco Ziliani <rylos78@gmail.com> Patchset: cameras
bb48b22 to
8e38339
Compare
On the Surface Pro 5/6 the IR lights hang off the OV7251's STROBE pin, which the driver leaves off (linux-surface/kernel#181, not merged). "lit" writes the same sensor registers over I2C while the camera streams; the sensor forgets them when the stream stops. The lights flash every other frame, so the photo shows lit, unlit, and lit minus unlit. All photos are now turned a quarter anticlockwise, the way the sensor is mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XWRVQj81Vw5DNLETcaUeEh
|
Some results from a Surface Pro 7+ (IPU6 Tiger Lake ov5693: Program the mode registers on stream start (e753f13): cherry-picked cleanly. With it I can switch between 2592x1944 and 1296x972 back to back with no pause between the captures (raw capture from the ISYS node, four switches in a row) and every capture delivers frames with image content. ov5693 binned mode: I did not use the commit in this PR but D. Manresa's later variant of the same patch,
The sensor's colour bars come out clean and in the right colours with flips 0/0 and 1/1, so the Bayer phase stays BGGR. Through libcamera and PipeWire the 640x480 and 1280x720 streams, which use this mode with both flips set, went from black to a normal picture. That may be useful when the ov8865: Allow fine analogue gain steps (7dc915f): cherry-picked cleanly. With the step of 128, libcamera's software ISP got stuck at a low gain in a dark room (exposure at maximum, gain 256 of 2048). With a step of 1 the gain ramps up to the maximum as expected. ov8865: Fix the VTS high byte mask (7b2ab04): cherry-picked cleanly and the rear camera streams normally with it, but I did not exercise frame lengths above 4095 lines, so I cannot confirm the fix itself. I have not tested the ov7251 commits from this PR. For the IR camera I used Antoine Pichot's v3 series from linux-media instead, which works on this machine. |
Fixes for the three cameras of the Surface Pro 5 (1796, Kaby Lake / IPU3), tested on v7.2.12 with the current 7.2 patch set. Previously posted in linux-surface/linux-surface#2233. Most of them are generic or apply to the other IPU3 Surfaces with the same sensors (Book 2, Pro 6, Go).
OV8865 (rear)
OV8865_VTS_H()keeps bits 11:8 only, so any frame length above 4095 lines wraps around and long exposures give black frames. Generic.The "program the mode on stream start" fix I had for the OV8865 is dropped: Jurison Murati's patches already on this branch cover it.
OV5693 (front)
MIPI_CTRL00(0x4800) for IPU6; with #2252 writing it unconditionally (0x2d), the two need reconciling if both land. On IPU30x2dis harmless.OV7251 (IR)
ov7251.surface_ir_strobe/surface_ir_pattern.Orientation (SP5)
Verification: 11 libcamera configurations (320x240 → full resolution, front and rear), 0 CSI-2 errors, correct frame rates, neutral colours; IR frames alternate between mean level 16 and 42; face login with howdy working.