media: i2c: ov7251: fixes and infrared strobe for Surface Book 2
Subsystems (3)
cover media: i2c: ov7251: fixes and infrared strobe for Surface Book 2
The Microsoft Surface Book 2 has an OV7251 infrared camera (used by Windows Hello) next to its front camera, both on the Intel IPU3 camera interface. Its 850 nm emitter is wired to the sensor's STROBE output
pin: the ACPI tables describe no LED, GPIO line or regulator for it. With the mainline driver the camera streams, but always unlit.
Patches 1 to 3 fix bugs found while testing on this machine, patch 4 adds the placement controls:
- 1: the link frequency index is taken from the firmware list instead of the driver's table, so the sensor runs at 240 MHz while ipu-bridge asks for 319.2 MHz (Fixes, Cc stable).
- 2: the 60 and 90 fps frame intervals are accepted but the sensor keeps streaming at 30 fps, the vertical blanking control not being updated (Fixes, Cc stable).
- 3: control events, the one v4l2-compliance failure on the sensor.
- 4: orientation and rotation controls from firmware.
Patches 5 and 6 add the emitter. 5 moves the strobe registers, which the three mode tables write identically, out of the tables without functional change. 6 adds a V4L2_CID_FLASH_STROBE_OE control that enables the STROBE pin, pulses it on alternate frames and makes the pulse follow the exposure, from 52 lines up to 45% of the frame and never more than 776 lines. This matches the Windows driver installed on this machine (Intel ov7251.sys 30.18305.6.5127, read with a decompiler): all four of its streaming modes enable the STROBE pin and clamp the pulse to the exposure within 52 to 776 lines; the two modes Windows Hello uses light alternate frames (0xaa), the other two every frame (0xff). A register dump taken on a Surface Book 2 during a Windows Hello sign-in [1] matches the 30 fps alternate mode. V4L2 has no per-frame illumination flag, so user space tells lit frames from dark ones by brightness; the dark frames give it the ambient-light reference a face liveness check uses. With every frame lit and filmed by a phone at locked exposure, each pulse is 1.1x (default exposure) to 1.2x (776-line pulse) as bright as during a Windows Hello sign-in on the same unit; with alternate frames the average emission is within the same ratio of Windows'.
A linux-surface pull request for the Surface Pro 7+ [2] instead turns the emitter on unconditionally while the sensor streams, with a module parameter to disable it. This series leaves the choice to user space:
the control is off by default, and the emitter is off whenever the sensor is not streaming.
Patch 7 makes ipu-bridge report a rotation of 90 degrees for the infrared sensor, whose frames show an upright scene turned 90 degrees clockwise while the firmware says 0. It adds a DMI quirk table next to the existing one for upside-down sensors. A user-space project for the Surface Book 3 rotates that model's infrared frames by 90 degrees as well [3]; the quirk covers only the Book 2, the one checked.
[1] https://github.com/linux-surface/linux-surface/issues/739
[2] https://github.com/linux-surface/linux-surface/pull/2252
[3] https://github.com/linux-surface/linux-surface/pull/2289
Tested on a Surface Book 2 (i7-8650U) with the series built out of tree against linux-surface 7.2.12 (test suite, logs and a v4l2loopback bridge for applications: https://github.com/antoine79/surface-ir-camera):
- link frequency 319200000, pixel rate 63840000, 30.01 fps unchanged
- v4l2-compliance -u on the sensor: 0 failures (was 1)
- --set-subdev-fps 60 / 90: 60.16 / 90.45 fps measured (was 30.01)
- orientation front, rotation 90 (0 before patch 7); the colour sensors still report 180
- dark frames and the sensor test pattern unchanged after patch 5
- strobe span read back while streaming: 504 lines at exposure 504, 776 at exposure 1704 (30 fps), 258 at exposure 552 (90 fps)
- mean pixel value of an indoor infrared frame at analogue gain 128:
19 unlit; with the strobe enabled the lit frames read 496 at exposure 504 and 587 at 1704, the dark frames in between 18 to 20
- strobe off and sensor suspended within 2 s of the stream stopping
- 10 unbind/unload/load cycles: no warning in the kernel log
- Howdy face login enrols and recognises through a v4l2loopback bridge that passes the lit frames
The remaining v4l2-compliance failures are in the ipu3-cio2 capture driver (buffer creation and mapping checks) and unchanged by this series.
I developed this series with an AI coding assistant (Claude): the design choices (alternate frames, the pulse limits, the exact SKU match), the reading of the Windows driver and the measurements above are mine, and I reviewed and tested every patch on the hardware before signing it off.
Antoine Pichot (7):
media: i2c: ov7251: Fix link frequency index
media: i2c: ov7251: Reset vblank when the frame interval changes
media: i2c: ov7251: Add control event support
media: i2c: ov7251: Add orientation and rotation controls
media: i2c: ov7251: Move the strobe registers out of the mode tables
media: i2c: ov7251: Add strobe output enable control
media: ipu-bridge: Add a 90 degree rotation quirk for Surface Book 2
drivers/media/i2c/ov7251.c | 203 ++++++++++++++++++++++++----------- drivers/media/pci/intel/ipu-bridge.c | 22 ++++ 2 files changed, 161 insertions(+), 64 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/7 media: i2c: ov7251: Fix link frequency index
ov7251_check_hwcfg() stores i, the index into the firmware's link_frequencies array, in link_freq_idx, which the driver then uses to index its own link_freq[], pixel_rates[] and pll1[] tables. The matching driver entry is j. Store j.
Observed on a Surface Book 2, where ipu-bridge lists one link frequency, 319.2 MHz, which is link_freq[1]: V4L2_CID_LINK_FREQ reads 240000000, and the pixel rate and PLL registers are off the same way.
--- drivers/media/i2c/ov7251.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov7251.c +1 -1
@@ -1523,7 +1523,7 @@ static int ov7251_check_hwcfg(struct ov7251 *ov7251) goto out_free_bus_cfg; } - ov7251->link_freq_idx = i; + ov7251->link_freq_idx = j; out_free_bus_cfg:v4l2_fwnode_endpoint_free (&bus_cfg);
Signature · 1 line
2.53.0
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
Quoted 3 lines · Antoine Pichot
Observed on a Surface Book 2, where ipu-bridge lists one link frequency, 319.2 MHz, which is link_freq[1]:
V4L2_CID_LINK_FREQreads 240000000, and the pixel rate and PLL registers are off the same way.
The diagnosis holds on a Surface Pro 7+ (IPU6 Tiger Lake, 8086:9a19). ipu-bridge gives this machine the same single frequency as yours:
IPU_SENSOR_CONFIG("INT347E", 1, 319200000)
and unpatched, the sensor reports
link_frequency ... value=0 (240000000)
pixel_rate ... value=48000000
exactly the mismatch you describe.
Applying the patch makes this machine worse, though, and since it carries
Cc: stable I think that is worth resolving before it goes in.
The fix does not only correct a reported value: it reprograms the PLL and moves the link from 480 to 638.4 Mbps.
unpatched v6.19 + this patch link_frequency 0 (240000000) 1 (319200000) pixel_rate 48000000 63840000 PLL1 0x30b1/b3/b4 0x01 / 0x4b / 0x03 0x04 / 0x85 / 0x01
The IPU6 receiver here does not hold that link. 150-frame captures of the 640x480 30 fps mode, counting dropped buffers from v4l2-ctl and csi2-5 error lines from dmesg (including the "callbacks suppressed" lines):
unpatched run 1 dropped 23 csi2 errors ~7216 unpatched run 2 dropped 23 csi2 errors 13277 unpatched run 3 dropped 13 csi2 errors 4722 patched run 1 dropped 106 csi2 errors 120788 patched run 3 stalled: 50 frames, then none for 60 s
The errors are DPHY fatal error, SOT sync error, inter-frame short/long packet discarded and frame sync error. The frames that do arrive look normal, so this is the link and not the image.
Two things to be honest about. This unit is not a clean baseline: even unpatched, mainline already logs thousands of CSI-2 errors per run at 30 fps, and the out-of-tree Surface driver sidesteps the whole area with a vts_boost parameter -- at its production VTS of 3448, 15 fps, I measure zero CSI-2 errors. And the sample is small: three runs each, one unit. What makes me report it anyway is that the one-line difference was consistent in every run, that it introduced hard stalls I never saw unpatched, and that going back to a build with only that line reverted gave 568 consecutive frames with zero CSI-2 errors.
One hypothesis tried and failed, so you do not repeat it: the out-of-tree Surface driver notes that the vendor runs the 319.2 MHz PLL with the MIPI divider at 0x01 rather than 0x05. Building this patch with mipi_div changed to 0x01 in the 19_2_mhz_319_2_mhz entry was worse, not better -- 3 frames in about four minutes. So the divider alone is not the missing piece. The vendor path also uses VTS 522, which I did not try.
So either ipu-bridge's advertised link frequency is wrong for this SKU, or mainline's 319.2 MHz PLL entry needs more than the index fix to be usable. I have the machine for a few more days and can run whatever would help decide which.
The rest of the series tests well here; I have replied to the cover letter with that.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
Hi,
Quoted 2 lines · D. Manresa
Applying the patch makes this machine worse, though, and since it carries
Cc: stable I think that is worth resolving before it goes in.
Agreed, and thank you for the measurements.
The patch selects the 319.2 MHz PLL table, which the index bug has kept unused on IPU machines since it was added in 2022. That table runs the PLL oscillator (the VCO of figure 2-12 in the OV7251 datasheet, rev 2.12) out of range: it multiplies before it divides, so the oscillator sits at 19.2 x 133 = 2553.6 MHz before the divide by 4 brings it down to 638.4 MHz, and table 2-11 allows 300 to 800 MHz. The 240 MHz table divides by 3 first and stays at 480 MHz. The datasheet is public at
https://dlscorp.com/wp-content/uploads/2019/02/ov7750_ov7251_csp3_rev1f_ds_2.12.pdf
The Windows driver on the Surface Book 2 uses both orders. Its Windows Hello mode divides by 4 first, which keeps the oscillator at 638.4 MHz for the same 638.4 Mbps, and writes 0x1f to 0x4837, the MIPI pixel clock period register. Its two 640x480 modes keep the mainline order, with the MIPI divider at 0x01 and 0x4837 at 0x19.
On my Surface Book 2 (IPU3, kernel 7.2) I ran three 150-frame captures at 30 fps with each of these, the last four with the series applied:
the 240 MHz table (unpatched)
the mainline 319.2 MHz table
the Windows Hello divider order
the Windows Hello divider order + 0x4837 = 0x1f the mainline table + mipi_div = 0x01 (what you tried)
All gave 0 dropped buffers and 0 CSI-2 error lines, so the divider swap is only a hypothesis for your machine.
Quoted 6 lines
One hypothesis tried and failed, so you do not repeat it: the out-of-tree Surface driver notes that the vendor runs the 319.2 MHz PLL with the MIPI divider at
0x01rather than0x05. Building this patch withmipi_divchanged to0x01in the 19_2_mhz_319_2_mhz entry was worse, not better -- 3 frames in about four minutes. So the divider alone is not the missing piece. The vendor path also uses VTS 522, which I did not try.
The datasheet decodes both as "divide by 1" (0x30b5[2:0]: 2 is /2, 4 is /4, anything else /1). A frame length (VTS) of 522 belongs to the Windows driver's 640x480 modes at about 99 fps, so it is no alternative at 30 fps.
Quoted 4 lines
So either ipu-bridge's advertised link frequency is wrong for this SKU, or mainline's 319.2 MHz PLL entry needs more than the index fix to be usable. I have the machine for a few more days and can run whatever would help decide which.
Could you please try the two patches below, the first alone and then both, with your 150-frame measurement? They are on
https://github.com/antoine79/surface-ir-camera/tree/test/pll1-vco under kernel/patches-test/, for git am on top of 1/7.
The first swaps the two dividers of the 319.2 MHz table:
- .pre_div = 0x01,
+ .pre_div = 0x04,
.mult = 0x85,
- .div = 0x04,
+ .div = 0x01,
The second also writes 0x1f instead of 0x19 to 0x4837 in the three mode tables.
If the swap helps, v2 puts the PLL table fix before the index fix, both
Cc: stable. If it does not, the question moves to the Pro 7+ receiver:
ipu-bridge asks for 319.2 MHz on both machines, and the Windows driver programs 638.4 Mbps on the Book 2. Your unpatched numbers point the same
way: at 480 Mbps, three runs logged thousands of error lines and your 568-frame run logged none, with the same timing per line. Could you please also run 2/7 without 1/7 at 60 and 90 fps? That shows whether the error count follows the number of frame starts.
After 1/7, pixel_rate reads 63840000, but the pixel array runs at 48 MHz whatever the link frequency; v2 fixes that in a separate patch. My 319.2 MHz captures above ran at 30.0 fps, which is 48e6 / (928 pixels per line x 1724 lines); 63.84 MHz would give 39.9 fps. 63.84 MHz is the CSI-2 bus rate, not what V4L2_CID_PIXEL_RATE reports (Documentation/driver-api/media/tx-rx.rst).
Thanks,
Antoine
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
Hi,
Quoted 2 lines · Antoine Pichot
Could you please try the two patches below, the first alone and then both, with your 150-frame measurement?
Done. The swap fixes the link completely on this receiver. Details below, but first a correction to my own numbers, because they are wrong in the archive.
Correction to the dropped-buffer figures in my previous mail
------------------------------------------------------------
I read v4l2-ctl's output wrong. It prints a line roughly once a second, and "dropped buffers: N" is the drops in that interval, not a running total; the suffix is omitted entirely when there were none. The column I posted was the last line of each run, so it was the drops in the final second, not the drops in the run. Summed over the run the figures are some fifty times larger. The CSI-2 error counts came from dmesg and are unaffected.
With that fixed, 1/7 alone at 30 fps, three 150-frame runs:
dropped (sum over run) 1181 388 926 CSI-2 error lines >=4996 >=1931 >=3785 elapsed for 150 frames 47.0 s 18.8 s 38.4 s
A clean run of the same capture takes 5.2 s. Error totals remain lower
bounds: the printk is rate-limited and I add the "callbacks suppressed" counts, but the suppressions of the last partial interval are never printed.
The divider swap
----------------
Your 0001 removes the problem here. Every run: 150 of 150 frames in 5.20 to 5.24 s at 30.00 fps, zero dropped buffers, zero CSI-2 error lines. Thirteen runs. Readback over i2c mid-stream, with 0x0100 = 0x01 confirming the sensor was streaming:
build 30b0 30b1 30b3 30b4 30b5 4837 link_freq pixel_rate unpatched 0x0a 0x01 0x4b 0x03 0x05 0x19 240000000 48000000 1/7 0x0a 0x04 0x85 0x01 0x05 0x19 319200000 63840000 1/7+0001 0x0a 0x01 0x85 0x04 0x05 0x19 319200000 63840000 1/7+0001+0002 0x0a 0x01 0x85 0x04 0x05 0x1f 319200000 63840000
The only difference from 1/7 alone is the two dividers, with the link frequency and pixel rate unchanged, so this is the VCO as you say and not the link speed.
0002 adds nothing measurable: ten runs, the same perfect result as 0001 alone. 0x4837 = 0x1f is confirmed in the hardware, so that is a real null and not an unapplied patch. It does no harm either.
Why I ran more than three of each
---------------------------------
Because on this machine each stream start is a lottery and three runs cannot see it. A run is either perfectly clean or uniformly broken for its whole duration, with nothing in between, and the unpatched driver began failing later in the session too, so results taken in blocks are confounded by drift.
So I interleaved: unpatched, 1/7, 1/7+0001, 1/7+0001+0002, one 150-frame run of each per cycle, swapping the module every time, seven cycles.
build runs with any CSI-2 error stalls
unpatched 1 of 7 1 1/7 4 of 7 3 1/7+0001 0 of 7 0 1/7+0001+0002 0 of 7 0
Pooled with the block runs: unpatched 3 bad of 13, 1/7 7 bad of 10, 1/7+0001 0 of 13, 1/7+0001+0002 0 of 10. The +0001 build was also re-checked immediately after the worst runs of the session and was still clean, so this is not simply a good patch of time.
One caveat for the record: this receiver intermittently fails to lock even with a completely unpatched driver, 3 of 13 runs at 30 fps including two 60-second stalls. The Pro 7+ has a baseline instability of its own. 1/7 makes it far more likely; 0001 removed it entirely in this sample.
So v2 with the PLL table fix before the index fix, both Cc: stable, matches what I measure here. Send it and I will run it on this machine while it is still with me.
2/7 at 60 and 90 fps, without 1/7
---------------------------------
The error count follows frame starts, not the link. The link is 240 MHz / 480 Mbps at all three rates (0x30b3 = 0x4b, 0x30b4 = 0x03 confirmed by readback), and vblank follows the mode as 2/7 intends: 1244, 380, 92.
One module load, then 30, 60 and 90 fps interleaved, five cycles. That block fell entirely in the bad regime, which is what makes the rates comparable:
rate errors per frame start errors per second mean dropped/run
30 fps 3.62 104 867 60 fps 3.70 204 517 90 fps 2.72 222 262
Per second the count doubles from 30 to 60 fps over an identical link. Per frame start the three collapse onto each other, and 90 fps is about 25% lower per frame while carrying three times the payload of 30 fps. The bad 1/7 runs at 319.2 MHz sit in the same range, 3.5 to 4.6 errors per frame, so the per-frame cost of a bad lock is the same at both link frequencies.
That reads as a failure to lock at stream start which then persists for the whole stream, rather than anything accumulating with transported bits. It is also why errors per run vary by two orders of magnitude while errors per frame do not.
On the cover letter
-------------------
6/7: I would rather re-run it than have the tag carried across a rewrite I did not test. Send me the v2 version and I will repeat the clamp sweep and the photometry while the machine is still here. If v2 goes out before that, carry it, since you say the result is unchanged, but I would rather earn it.
Thank you for the pixel_rate explanation. I had taken 63840000 at face value.
7/7: I will answer on the orientation in a separate mail.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
In reply to D. ManresaHello
On 27/10/2026 10:26, D. Manresa wrote:
<snip>
Quoted 4 lines
So either ipu-bridge's advertised link frequency is wrong for this SKU, or mainline's 319.2 MHz PLL entry needs more than the index fix to be usable. I have the machine for a few more days and can run whatever would help decide which.
It would be worth validating the settings for the 319.2MHz link frequency to make sure that the PLL is being configured correctly. The link frequency itself advertised by the ipu-bridge strictly just needs to be one that the sensor driver is capable of configuring, but ideally we would make sure that the sensor can configure one that these platforms tend to use, as the platform designers will generally choose it carefully to be appropriate for their device. When I made these changes I checked and the driver for my Surface Go 2 was setting 319.2 MHz, so I would be more suspicious of the driver's PLL settings than that value.
Dan
Quoted 7 lines
The rest of the series tests well here; I have replied to the cover letter with that.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
In reply to D. ManresaHi Antoine and D. Manresa
Quoted 5 lines · D. Manresa
Quoted 3 lines · Antoine Pichot
Observed on a Surface Book 2, where ipu-bridge lists one link frequency, 319.2 MHz, which is link_freq[1]:
V4L2_CID_LINK_FREQreads 240000000, and the pixel rate and PLL registers are off the same way.
I'll agree that the link frequency isn't abided by, and your patch does fix that. However testing on a DT based system (Raspberry Pi) with a 24MHz extclk I'm also seeing issues.
I'm working with the datasheet from
https://static6.arrow.com/aropdfconversion/dedba0a4f2b52e9b6587341a0e31cd115a2c3a46/ov7750_ov7251_csp3_rev1f_ds_2.12.pdf
As I read it, the pixelrate is configured via PLL2. Those settings are identical between the 2 link frequencies, so the pixel rate should be 48000000 in both cases. Without that I was getting 75fps from libcamera when I asked for 100fps. 100 * 480 / 638.4 = 75.1fps. The settings for PLL2 with a 24MHz extclk exactly follow the sample PLL configuration in table 2.10 of the datasheet. For 24MHz the multiplier is 0x28 / 40dec vs 0x32 / 50dec for 19.2MHz, resulting in the same rate.
The settings for PLL1 seem to be all over the shop if the datasheet is correct.
With a 24MHz extclk and measuring with an oscilloscope, the "240MHz link freq" actually runs at 400MHz. The "319.2MHz link frequency" runs at 454MHz.
If I follow the datasheet, then the 240MHz mode does fall out at 400MHz For the 319.2MHz mode I reckon that the VCO is well out of spec - 2.128GHz when the limit is 800MHz.
The numbers for the 19.2MHz modes look sane in their ratios, but I can't test them.
The 240MHz link freq does a prediv of 3, multiply by 75, and divider of 1, which keeps things in range, and 19.2 / 3 * 75 / 1 = 480MPix/s, or 240MHz.
The 319.2MHz link frequency uses a prediv of 1 and multiply by 0x85 / 133 gives a VCO frequency of 2.55GHz, when again the limit is 800MHz. That then gets divided by 4 afterwards for a supposed result of 638.4MPix/s or 319.2MHz.
@D. Manresa it'd be worth trying using a prediv instead of (post)div:
static const struct ov7251_pll1_cfg ov7251_pll1_cfg_19_2_mhz_319_2_mhz = {
.pre_div = 0x04,
.mult = 0x85,
.div = 0x01,
.pix_div = 0x0a,
.mipi_div = 0x05,
};So I'll agree the patch is correct, but it'll show up other failures that were currently masked. I'm not fussed about the 24MHz mode, but it sounds like there are devices using the 19.2MHz / 319.2MHz mode.
(I've also noted that the driver allows V4L2_CID_VBLANK to go down to 1, when 40 or below seem to give corrupt images for me. Implementing set_frame_interval for a raw sensor is also wrong, particularly when V4L2_CID_VBLANK is also implemented. I'll see if I can find some time to patch it up).
Hope that helps.
Dave
Quoted 66 lines
The diagnosis holds on a Surface Pro 7+ (IPU6 Tiger Lake, 8086:9a19). ipu-bridge gives this machine the same single frequency as yours:
IPU_SENSOR_CONFIG("INT347E", 1, 319200000)and unpatched, the sensor reports
link_frequency... value=0 (240000000)
pixel_rate... value=48000000exactly the mismatch you describe.
Applying the patch makes this machine worse, though, and since it carries
Cc: stable I think that is worth resolving before it goes in.The fix does not only correct a reported value: it reprograms the PLL and moves the link from 480 to 638.4 Mbps.
unpatched v6.19 + this patch link_frequency 0 (240000000) 1 (319200000) pixel_rate 48000000 63840000 PLL1 0x30b1/b3/b4 0x01 / 0x4b / 0x03 0x04 / 0x85 / 0x01The IPU6 receiver here does not hold that link. 150-frame captures of the 640x480 30 fps mode, counting dropped buffers from v4l2-ctl and csi2-5 error lines from dmesg (including the "callbacks suppressed" lines):
unpatched run 1 dropped 23 csi2 errors ~7216 unpatched run 2 dropped 23 csi2 errors 13277 unpatched run 3 dropped 13 csi2 errors 4722 patched run 1 dropped 106 csi2 errors 120788 patched run 3 stalled: 50 frames, then none for 60 sThe errors are DPHY fatal error, SOT sync error, inter-frame short/long packet discarded and frame sync error. The frames that do arrive look normal, so this is the link and not the image.
Two things to be honest about. This unit is not a clean baseline: even unpatched, mainline already logs thousands of CSI-2 errors per run at 30 fps, and the out-of-tree Surface driver sidesteps the whole area with a
vts_boostparameter -- at its production VTS of 3448, 15 fps, I measure zero CSI-2 errors. And the sample is small: three runs each, one unit. What makes me report it anyway is that the one-line difference was consistent in every run, that it introduced hard stalls I never saw unpatched, and that going back to a build with only that line reverted gave 568 consecutive frames with zero CSI-2 errors.One hypothesis tried and failed, so you do not repeat it: the out-of-tree Surface driver notes that the vendor runs the 319.2 MHz PLL with the MIPI divider at
0x01rather than0x05. Building this patch withmipi_divchanged to0x01in the 19_2_mhz_319_2_mhz entry was worse, not better -- 3 frames in about four minutes. So the divider alone is not the missing piece. The vendor path also uses VTS 522, which I did not try.So either ipu-bridge's advertised link frequency is wrong for this SKU, or mainline's 319.2 MHz PLL entry needs more than the index fix to be usable. I have the machine for a few more days and can run whatever would help decide which.
The rest of the series tests well here; I have replied to the cover letter with that.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
Hi Dave,
Quoted 4 lines · Dave Stevenson
@D. Manresa it'd be worth trying using a prediv instead of (post)div:
.pre_div = 0x04, .mult = 0x85, .div = 0x01,
Our mails crossed, and that is exactly the change I had just finished measuring, from a test patch Antoine sent me. It fixes the link on this
receiver: thirteen 150-frame runs at 30 fps, every one 150 of 150 in 5.2 s with zero dropped buffers and zero CSI-2 error lines, against seven bad runs out of ten with the index fix alone, three of them hard stalls. i2c readback mid-stream confirms 0x30b4 = 0x04 and 0x30b1 = 0x01 with link_frequency still 319200000, so the link rate is unchanged and only the VCO moved. Full numbers are in my other mail on this thread, which went out a few minutes after yours arrived and does not mention you only because I had not yet seen it.
So the 19.2 MHz / 319.2 MHz mode you could not test behaves exactly as your 24 MHz oscilloscope measurements predict.
Dan's instinct in the parallel branch was right too: it was the driver's PLL settings and not the value ipu-bridge advertises.
One data point on VBLANK, since you raised it. With 2/7 of this series the 90 fps mode runs at vblank 92, and in its clean runs it logged no CSI-2 errors and no corruption I could see here. I did not go below 40, so I can neither confirm nor contradict that part.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Re: [PATCH 1/7] media: i2c: ov7251: Fix link frequency index
In reply to Antoine PichotHi Antoine
Quoted 5 lines · Antoine Pichot
ov7251_check_hwcfg()stores i, the index into the firmware'slink_frequenciesarray, inlink_freq_idx, which the driver then uses to index its own link_freq[], pixel_rates[] and pll1[] tables. The matching driver entry is j. Store j.
Quoted 8 lines
Observed on a Surface Book 2, where ipu-bridge lists one link frequency, 319.2 MHz, which is link_freq[1]:
V4L2_CID_LINK_FREQreads 240000000, and the pixel rate and PLL registers are off the same way.Fixes cc125aaa5a78 ("media: i2c: Provide ov7251_check_hwcfg()")Signed-off-by Antoine Pichot <[email protected]>---
Thanks for the patch, this is right:
Quoted 16 lines
drivers/media/i2c/ov7251.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/i2c/ov7251.c +1
-1@@ -1523,7 +1523,7 @@ static int ov7251_check_hwcfg(struct ov7251 *ov7251) goto out_free_bus_cfg; } - ov7251->link_freq_idx = i; + ov7251->link_freq_idx = j; out_free_bus_cfg:v4l2_fwnode_endpoint_free (&bus_cfg);
PATCH 2/7 media: i2c: ov7251: Reset vblank when the frame interval changes
In reply to Antoine PichotSetting a 60 or 90 fps frame interval is accepted and read back, but the sensor keeps streaming at 30 fps.
The three modes differ only in their frame length (VTS: 1724, 860 and 572 lines), which each mode's register table writes to 0x380e/0x380f. Since the V4L2_CID_VBLANK control was added, s_stream() applies the controls with __v4l2_ctrl_handler_setup() after the mode table, so the VBLANK control rewrites VTS. ov7251_set_frame_interval() switches current_mode but never updates the VBLANK control, which keeps the 30 fps value (1244, VTS 1724) and overrides the 60 or 90 fps VTS at every stream start.
ov7251_set_format() has the same issue in the other direction: it updates the VBLANK range and default for the new mode, but __v4l2_ctrl_modify_range() keeps the current value when it is still in range, so after a 60 fps frame interval a format change would go back to the 30 fps mode with a 60 fps VTS.
Update the VBLANK range and default in ov7251_set_frame_interval() too, and set VBLANK to the mode's default in both places, as is already done for exposure and gain. The VBLANK handler then also restores the exposure range for the new frame length.
Tested on a Microsoft Surface Book 2 (IPU3 CIO2): after v4l2-ctl --set-subdev-fps pad=0,fps=60 (90), v4l2-ctl measures 60.15 (90.45) fps instead of 30.01, with vblank 380 (92).
--- drivers/media/i2c/ov7251.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/media/i2c/ov7251.c +18 -0
@@ -1261,6 +1261,10 @@ static int ov7251_set_format(struct v4l2_subdev *sd,if (ret <0 ) goto exit; + ret =__v4l2_ctrl_s_ctrl (ov7251->vblank, vblank_def); +if (ret <0 ) + goto exit; + ov7251->current_mode = new_mode; }
@@ -1414,6 +1418,7 @@ static int ov7251_set_frame_interval(struct v4l2_subdev *subdev, {struct ov7251 *ov7251 =to_ov7251 (subdev);const struct ov7251_mode_info *new_mode; +int vblank_def;int ret =0 ;/*
@@ -1442,6 +1447,19 @@ static int ov7251_set_frame_interval(struct v4l2_subdev *subdev,if (ret <0 ) goto exit; + vblank_def = new_mode->vts - new_mode->height; + ret =__v4l2_ctrl_modify_range (ov7251->vblank, +OV7251_TIMING_MIN_VTS , +OV7251_TIMING_MAX_VTS - + new_mode->height, +1 , vblank_def); +if (ret <0 ) + goto exit; + + ret =__v4l2_ctrl_s_ctrl (ov7251->vblank, vblank_def); +if (ret <0 ) + goto exit; + ov7251->current_mode = new_mode; }
Signature · 1 line
2.53.0
PATCH 3/7 media: i2c: ov7251: Add control event support
In reply to Antoine PichotThe driver exposes writable controls on its subdev node but does not support control events, so VIDIOC_SUBSCRIBE_EVENT fails and v4l2-compliance reports:
fail: v4l2-test-controls.cpp(1128): subscribe event for control 'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
Set V4L2_SUBDEV_FL_HAS_EVENTS and use the standard control event helpers, as other sensor drivers do.
--- drivers/media/i2c/ov7251.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/i2c/ov7251.c +9 -1
@@ -19,6 +19,7 @@#include <linux/slab.h> #include <linux/types.h> #include <media/v4l2-ctrls.h> +#include <media/v4l2-event.h> #include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h>
@@ -1471,6 +1472,11 @@ static int ov7251_set_frame_interval(struct v4l2_subdev *subdev,return ret; } +static const struct v4l2_subdev_core_ops ov7251_core_ops = { + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, +}; +static const struct v4l2_subdev_video_ops ov7251_video_ops = { .s_stream = ov7251_s_stream, };
@@ -1487,6 +1493,7 @@ static const struct v4l2_subdev_pad_ops ov7251_subdev_pad_ops = { };static const struct v4l2_subdev_ops ov7251_subdev_ops = { + .core = &ov7251_core_ops, .video = &ov7251_video_ops, .pad = &ov7251_subdev_pad_ops, };
@@ -1717,7 +1724,8 @@ static int ov7251_probe(struct i2c_client *client)v4l2_i2c_subdev_init (&ov7251->sd, client, &ov7251_subdev_ops); ov7251->sd.internal_ops = &ov7251_internal_ops; - ov7251->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; + ov7251->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE | +V4L2_SUBDEV_FL_HAS_EVENTS ; ov7251->pad.flags =MEDIA_PAD_FL_SOURCE ; ov7251->sd.dev = &client->dev; ov7251->sd.entity.function =MEDIA_ENT_F_CAM_SENSOR ;
Signature · 1 line
2.53.0
Sakari Ailus
maintainerRe: [PATCH 3/7] media: i2c: ov7251: Add control event support
Hi Antoine,
Quoted 4 lines · Antoine Pichot
The driver exposes writable controls on its subdev node but does not support control events, so
VIDIOC_SUBSCRIBE_EVENTfails and v4l2-compliance reports:
Quoted 8 lines
fail: v4l2-test-controls.cpp(1128): subscribe event for control 'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAILSet
V4L2_SUBDEV_FL_HAS_EVENTSand use the standard control event helpers, as other sensor drivers do.Signed-off-by Antoine Pichot <[email protected]>
Instead of adding explicit support for events, could you instead make the driver to use sub-device state? See commit e8a5b1df000e1a23c04dadbe99621441e0889f88 for an example.
Signature · 3 lines
Kind regards, Sakari Ailus
Re: [PATCH 3/7] media: i2c: ov7251: Add control event support
Hi Sakari,
Quoted 3 lines · Sakari Ailus
Instead of adding explicit support for events, could you instead make the driver to use sub-device state? See commit
e8a5b1df000e1a23c04dadbe99621441e0889f88for an example.
Sure. In v2, patch 3 converts the driver to the sub-device active state, following ov5645 and the imx219 commit you pointed to. I'll wait a few days for other comments before sending v2.
Thanks,
Antoine
PATCH 4/7 media: i2c: ov7251: Add orientation and rotation controls
In reply to Antoine PichotParse the firmware device properties and register the V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION controls, as documented in Documentation/driver-api/media/camera-sensor.rst. libcamera uses them to place the camera and to correct the image orientation.
While at it, bump the control handler size hint to the number of controls the driver now creates.
On the Microsoft Surface Book 2 the ACPI _PLD (via ipu-bridge) reports the IR sensor as front facing with no rotation.
--- drivers/media/i2c/ov7251.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/media/i2c/ov7251.c +10 -1
@@ -1591,11 +1591,17 @@ static int ov7251_detect_chip(struct ov7251 *ov7251)static int ov7251_init_ctrls (struct ov7251 *ov7251) { +struct v4l2_fwnode_device_properties props;int vblank_max, vblank_def;s64 pixel_rate;int hblank; +int ret; -v4l2_ctrl_handler_init (&ov7251->ctrls,7 ); + ret =v4l2_fwnode_device_parse (ov7251->dev, &props); +if (ret) +return ret; + +v4l2_ctrl_handler_init (&ov7251->ctrls,11 ); ov7251->ctrls.lock = &ov7251->lock; v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
@@ -1642,6 +1648,9 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)OV7251_TIMING_MIN_VTS , vblank_max,1 , vblank_def); +v4l2_ctrl_new_fwnode_properties (&ov7251->ctrls, &ov7251_ctrl_ops, + &props); + ov7251->sd.ctrl_handler = &ov7251->ctrls;if (ov7251->ctrls.error) {
Signature · 1 line
2.53.0
PATCH 5/7 media: i2c: ov7251: Move the strobe registers out of the mode tables
In reply to Antoine PichotThe three mode tables write the same values to the STROBE pad output enable bit (0x3005) and to the strobe control block (0x3b80-0x3b96). Move these writes to a separate register array written right after the mode table at stream start, and name the registers a following patch
needs: SC_REG5 (0x3005, whose bit 3 enables the STROBE pad output), the strobe frame pattern (0x3b81) and the 32-bit strobe frame span (0x3b8c).
The values written are unchanged, only the order of the writes within the stream start sequence changes. No functional change intended.
--- drivers/media/i2c/ov7251.c | 93 ++++++++++++++------------------------ 1 file changed, 33 insertions(+), 60 deletions(-)
drivers/media/i2c/ov7251.c +33 -60
@@ -53,6 +53,9 @@#define OV7251_PLL2_DIVIDER_REG 0x309d#define OV7251_PLL2_SYS_DIV_REG 0x309a#define OV7251_PLL2_ADC_DIV_REG 0x309b +#define OV7251_SC_REG5 0x3005 +#define OV7251_STROBE_FRAME_PATTERN 0x3b81 +#define OV7251_STROBE_FRAME_SPAN 0x3b8c#define OV7251_NATIVE_WIDTH 656#define OV7251_NATIVE_HEIGHT 496
@@ -240,8 +243,31 @@ static const struct reg_value ov7251_global_init_setting[] = { { 0x303b, 0x02 }, }; +/* Strobe output settings, the same for all modes */ +static const struct reg_value ov7251_strobe_regs[] = { + {OV7251_SC_REG5 ,0x00 }, + {0x3b80 ,0x00 }, + {OV7251_STROBE_FRAME_PATTERN ,0xa5 }, + {0x3b82 ,0x10 }, + {0x3b83 ,0x00 }, + {0x3b84 ,0x08 }, + {0x3b85 ,0x00 }, + {0x3b86 ,0x01 }, + {0x3b87 ,0x00 }, + {0x3b88 ,0x00 }, + {0x3b89 ,0x00 }, + {0x3b8a ,0x00 }, + {0x3b8b ,0x05 }, + {OV7251_STROBE_FRAME_SPAN ,0x00 }, + {0x3b8d ,0x00 }, + {0x3b8e ,0x00 }, + {0x3b8f ,0x1a }, + {0x3b94 ,0x05 }, + {0x3b95 ,0xf2 }, + {0x3b96 ,0x40 }, +}; +static const struct reg_value ov7251_setting_vga_30fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, { 0x3014, 0x04 },
@@ -314,25 +340,6 @@ static const struct reg_value ov7251_setting_vga_30fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },
@@ -369,7 +376,6 @@ static const struct reg_value ov7251_setting_vga_30fps[] = { };static const struct reg_value ov7251_setting_vga_60fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, {0x3014 ,0x04 },
@@ -442,25 +448,6 @@ static const struct reg_value ov7251_setting_vga_60fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },
@@ -497,7 +484,6 @@ static const struct reg_value ov7251_setting_vga_60fps[] = { };static const struct reg_value ov7251_setting_vga_90fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, {0x3014 ,0x04 },
@@ -570,25 +556,6 @@ static const struct reg_value ov7251_setting_vga_90fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },
@@ -1369,6 +1336,12 @@ static int ov7251_s_stream(struct v4l2_subdev *subdev, int enable) ov7251->current_mode->height); goto err_power_down; } + ret =ov7251_set_register_array (ov7251, ov7251_strobe_regs, +ARRAY_SIZE (ov7251_strobe_regs)); +if (ret <0 ) { +dev_err (ov7251->dev,"could not set strobe defaults\n" ); + goto err_power_down; + } ret =__v4l2_ctrl_handler_setup (&ov7251->ctrls);if (ret <0 ) {dev_err (ov7251->dev,"could not sync v4l2 controls\n" );
Signature · 1 line
2.53.0
Re: [PATCH 5/7] media: i2c: ov7251: Move the strobe registers out of the mode tables
Hi Antoine
Quoted 31 lines · Antoine Pichot
The three mode tables write the same values to the STROBE pad output enable bit (
0x3005) and to the strobe control block (0x3b80-0x3b96). Move these writes to a separate register array written right after the mode table at stream start, and name the registers a following patch
needs:SC_REG5(0x3005, whose bit 3 enables the STROBE pad output), the strobe frame pattern (0x3b81) and the 32-bit strobe frame span (0x3b8c).The values written are unchanged, only the order of the writes within the stream start sequence changes. No functional change intended.
Signed-off-by Antoine Pichot <[email protected]>--- drivers/media/i2c/ov7251.c | 93 ++++++++++++++------------------------ 1 file changed, 33 insertions(+), 60 deletions(-)drivers/media/i2c/ov7251.c +3
-0@@ -53,6 +53,9 @@#define OV7251_PLL2_DIVIDER_REG 0x309d#define OV7251_PLL2_SYS_DIV_REG 0x309a#define OV7251_PLL2_ADC_DIV_REG 0x309b +#define OV7251_SC_REG5 0x3005 +#define OV7251_STROBE_FRAME_PATTERN 0x3b81 +#define OV7251_STROBE_FRAME_SPAN 0x3b8c#define OV7251_NATIVE_WIDTH 656#define OV7251_NATIVE_HEIGHT 496
drivers/media/i2c/ov7251.c static const struct reg_value ov7251_global_init_setting[] = { · line 247
Quoted 5 lines
drivers/media/i2c/ov7251.c +2
-0@@ -240,8 +243,31 @@ static const struct reg_value ov7251_global_init_setting[] = { { 0x303b, 0x02 }, }; +/* Strobe output settings, the same for all modes */ +static const struct reg_value ov7251_strobe_regs[] = {
Is there a real need to add a new array of registers for these, or can they be added to ov7251_global_init_setting? As long as it's after the {0x0103, 0x01} reset, then order shouldn't matter.
Seeing as there obviously are others using this sensor, I'm looking at upstreaming a few of the obvious clean ups, and I have a couple of patches in the downstream Pi kernel.
One of the first steps is to pull all the common registers out of the ov7251_setting_vga_* arrays into ov7251_global_init_setting, and this change is partly going in the opposite direction.
Thanks
Dave
Quoted 138 lines
drivers/media/i2c/ov7251.c +28
-61+ { OV7251_SC_REG5, 0x00 }, + { 0x3b80, 0x00 }, + { OV7251_STROBE_FRAME_PATTERN, 0xa5 }, + { 0x3b82, 0x10 }, + { 0x3b83, 0x00 }, + { 0x3b84, 0x08 }, + { 0x3b85, 0x00 }, + { 0x3b86, 0x01 }, + { 0x3b87, 0x00 }, + { 0x3b88, 0x00 }, + { 0x3b89, 0x00 }, + { 0x3b8a, 0x00 }, + { 0x3b8b, 0x05 }, + { OV7251_STROBE_FRAME_SPAN, 0x00 }, + { 0x3b8d, 0x00 }, + { 0x3b8e, 0x00 }, + { 0x3b8f, 0x1a }, + { 0x3b94, 0x05 }, + { 0x3b95, 0xf2 }, + { 0x3b96, 0x40 }, +}; +static const struct reg_value ov7251_setting_vga_30fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, { 0x3014, 0x04 },@@ -314,25 +340,6 @@ static const struct reg_value ov7251_setting_vga_30fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },@@ -369,7 +376,6 @@ static const struct reg_value ov7251_setting_vga_30fps[] = { };static const struct reg_value ov7251_setting_vga_60fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, {0x3014 ,0x04 },@@ -442,25 +448,6 @@ static const struct reg_value ov7251_setting_vga_60fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },@@ -497,7 +484,6 @@ static const struct reg_value ov7251_setting_vga_60fps[] = { };static const struct reg_value ov7251_setting_vga_90fps[] = { - {0x3005 ,0x00 }, {0x3012 ,0xc0 }, {0x3013 ,0xd2 }, {0x3014 ,0x04 },@@ -570,25 +556,6 @@ static const struct reg_value ov7251_setting_vga_90fps[] = { { 0x3834, 0x00 }, { 0x3835, 0x0c }, { 0x3837, 0x00 }, - { 0x3b80, 0x00 }, - { 0x3b81, 0xa5 }, - { 0x3b82, 0x10 }, - { 0x3b83, 0x00 }, - { 0x3b84, 0x08 }, - { 0x3b85, 0x00 }, - { 0x3b86, 0x01 }, - { 0x3b87, 0x00 }, - { 0x3b88, 0x00 }, - { 0x3b89, 0x00 }, - { 0x3b8a, 0x00 }, - { 0x3b8b, 0x05 }, - { 0x3b8c, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, - { 0x3b94, 0x05 }, - { 0x3b95, 0xf2 }, - { 0x3b96, 0x40 }, { 0x3c00, 0x89 }, { 0x3c01, 0x63 }, { 0x3c02, 0x01 },@@ -1369,6 +1336,12 @@ static int ov7251_s_stream(struct v4l2_subdev *subdev, int enable) ov7251->current_mode->height); goto err_power_down; } + ret =ov7251_set_register_array (ov7251, ov7251_strobe_regs, +ARRAY_SIZE (ov7251_strobe_regs)); +if (ret <0 ) { +dev_err (ov7251->dev,"could not set strobe defaults\n" ); + goto err_power_down; + } ret =__v4l2_ctrl_handler_setup (&ov7251->ctrls);if (ret <0 ) {dev_err (ov7251->dev,"could not sync v4l2 controls\n" ); --2.53.0
Re: [PATCH 5/7] media: i2c: ov7251: Move the strobe registers out of the mode tables
Hi Dave,
Quoted 3 lines · Dave Stevenson
Is there a real need to add a new array of registers for these, or can they be added to
ov7251_global_init_setting? As long as it's after the {0x0103,0x01} reset, then order shouldn't matter.
No need. v3 drops this patch and takes your "Move the common registers into the global init table" in its place, under your authorship, so the strobe registers go into ov7251_global_init_setting with the rest, and the strobe control patch only names the three it writes. Details on the v2 1/9 thread, where you posted the branch.
Thanks,
Antoine
PATCH 6/7 media: i2c: ov7251: Add strobe output enable control
In reply to Antoine PichotThe OV7251 has a STROBE output that pulses during the exposure of selected frames, meant to drive an illuminator. On the Microsoft Surface Book 2 the front OV7251 is an infrared camera (Windows Hello) and its 850 nm emitter is wired to that pin: ACPI describes no separate LED, GPIO line or regulator for it. The mode tables leave the pad disabled, so the camera only sees an unlit scene.
Add a V4L2_CID_FLASH_STROBE_OE control, off by default. When enabled it sets the STROBE pad output enable (SC_REG5 bit 3), strobes alternate frames (frame pattern 0xaa instead of the default 0xa5, which lights four frames in eight) and sets the
pulse length (strobe frame span, in lines) to the exposure time, clamped between 52 lines and 45% of the frame length, never more than 776 lines. When disabled it
restores the defaults the mode tables used to write. The span follows exposure and vertical blanking changes while the strobe is enabled.
The limits come from the Windows driver, which clamps the span to 52 to 776 lines: 776 lines is 45% of the 1724-line frame of the 30 fps mode. Expressing the upper limit as a duty cycle keeps the emitter within that envelope (eye safety) at 60 and 90 fps too, where a fixed 776 lines would let the pulse cover up to 96% of the frame (552 of 572 lines). Keeping the 776-line limit as well bounds the pulse when vertical blanking stretches the frame, up to 65535 lines.
Alternate frames is what the Windows driver uses for face recognition on this hardware: its 30 and 60 fps modes write 0xaa, and a register dump taken during a Windows Hello sign-in on a Surface Book 2 shows the same. Lighting every frame (0xff, which two of its other modes use) would double the average emitter power. User space tells lit frames from dark ones by their brightness; V4L2 has no per-frame illumination flag yet.
The control is written only while the sensor is powered, and from __v4l2_ctrl_handler_setup() at stream start, after the mode and strobe register tables. Setting it while the sensor is idle does not power it up, and the emitter goes off with the sensor when streaming stops.
On a Surface Book 2 at analogue gain 128 the mean pixel value of the infrared image of a room is 19 unlit; with the strobe enabled the lit frames read 496 at exposure 504 (span 504) and 587 at exposure 1704 (span 776), the dark frames in between 18 to 20.
The span read back while streaming is 258 at 90 fps, 45% of the 572-line frame.
--- drivers/media/i2c/ov7251.c | 85 ++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 9 deletions(-)
drivers/media/i2c/ov7251.c +76 -9
@@ -18,6 +18,7 @@#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/unaligned.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-event.h> #include <media/v4l2-fwnode.h>
@@ -54,8 +55,15 @@#define OV7251_PLL2_SYS_DIV_REG 0x309a#define OV7251_PLL2_ADC_DIV_REG 0x309b#define OV7251_SC_REG5 0x3005 +#define OV7251_SC_REG5_STROBE_OE BIT(3)#define OV7251_STROBE_FRAME_PATTERN 0x3b81 +#define OV7251_STROBE_FRAME_PATTERN_ALT 0xaa/* alternate frames */ +#define OV7251_STROBE_FRAME_PATTERN_DEF 0xa5#define OV7251_STROBE_FRAME_SPAN 0x3b8c +#define OV7251_STROBE_FRAME_SPAN_DEF 0x1a +#define OV7251_STROBE_SPAN_MIN 52 +#define OV7251_STROBE_SPAN_MAX 776 +#define OV7251_STROBE_MAX_DUTY_PERCENT 45#define OV7251_NATIVE_WIDTH 656#define OV7251_NATIVE_HEIGHT 496
@@ -151,6 +159,7 @@ struct ov7251 {struct v4l2_ctrl *gain;struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank; +struct v4l2_ctrl *strobe;/* Cached register values */ u8 aec_pk_manual;
@@ -243,11 +252,12 @@ static const struct reg_value ov7251_global_init_setting[] = { { 0x303b, 0x02 }, }; -/* Strobe output settings, the same for all modes */ +/* +* Strobe output settings, the same for all modes. The STROBE_OE control +* writes SC_REG5, the frame pattern and the frame span. +*/ static const struct reg_value ov7251_strobe_regs[] = { - {OV7251_SC_REG5 ,0x00 }, {0x3b80 ,0x00 }, - {OV7251_STROBE_FRAME_PATTERN ,0xa5 }, {0x3b82 ,0x10 }, {0x3b83 ,0x00 }, { 0x3b84, 0x08 },
@@ -258,10 +268,6 @@ static const struct reg_value ov7251_strobe_regs[] = { { 0x3b89, 0x00 }, { 0x3b8a, 0x00 }, { 0x3b8b, 0x05 }, - { OV7251_STROBE_FRAME_SPAN, 0x00 }, - { 0x3b8d, 0x00 }, - { 0x3b8e, 0x00 }, - { 0x3b8f, 0x1a }, { 0x3b94, 0x05 }, { 0x3b95, 0xf2 }, { 0x3b96, 0x40 },
@@ -724,7 +730,7 @@ static int ov7251_write_reg(struct ov7251 *ov7251, u16 reg, u8 val)static int ov7251_write_seq_regs (struct ov7251 *ov7251,u16 reg,u8 *val,u8 num) { -u8 regbuf[5 ]; +u8 regbuf[6 ];u8 nregbuf =sizeof (reg) + num *sizeof (*val);int ret =0 ;
@@ -976,6 +982,56 @@ static int ov7251_set_test_pattern(struct ov7251 *ov7251, s32 value)return ret; } +static int ov7251_set_strobe_span (struct ov7251 *ov7251) +{ +u32 span =OV7251_STROBE_FRAME_SPAN_DEF ; +u32 vts, max_span; +u8 val[4 ]; + +/* +* The pulse starts with the integration: make it cover the exposure, +* from 52 lines up to 45% of the frame and never more than 776 lines. +* The vendor driver caps it at 776 lines, 45% of the 1724 lines 30 fps +* frame; the duty cycle limit keeps the emitter within that envelope +* at higher frame rates, the absolute one with long vertical blanking. +*/ +if (ov7251->strobe->val) { + vts = ov7251->current_mode->height + ov7251->vblank->val; + max_span =DIV_ROUND_UP (vts *OV7251_STROBE_MAX_DUTY_PERCENT , +100 ); + max_span =min (max_span,OV7251_STROBE_SPAN_MAX ); + span =clamp_t (u32, ov7251->exposure->val, +OV7251_STROBE_SPAN_MIN , max_span); + } + +put_unaligned_be32 (span, val); + +return ov7251_write_seq_regs (ov7251,OV7251_STROBE_FRAME_SPAN , val, +sizeof (val)); +} + +static int ov7251_set_strobe (struct ov7251 *ov7251,s32 value) +{ +int ret; + +/* +* The other SC_REG5 bits enable other pads, which the mode tables +* have always left disabled (0x00). +*/ + ret =ov7251_write_reg (ov7251,OV7251_SC_REG5 , + value ?OV7251_SC_REG5_STROBE_OE :0 ); +if (ret) +return ret; + + ret =ov7251_write_reg (ov7251,OV7251_STROBE_FRAME_PATTERN , + value ?OV7251_STROBE_FRAME_PATTERN_ALT : +OV7251_STROBE_FRAME_PATTERN_DEF ); +if (ret) +return ret; + +return ov7251_set_strobe_span (ov7251); +} +static const char *const ov7251_test_pattern_menu[] = {"Disabled" ,"Vertical Pattern Bars" ,
@@ -1019,6 +1075,8 @@ static int ov7251_s_ctrl(struct v4l2_ctrl *ctrl)switch (ctrl->id) {case V4L2_CID_EXPOSURE : ret =ov7251_set_exposure (ov7251, ctrl->val); +if (!ret && ov7251->strobe->val) + ret =ov7251_set_strobe_span (ov7251);break ;case V4L2_CID_GAIN : ret =ov7251_set_gain (ov7251, ctrl->val);
@@ -1034,6 +1092,11 @@ static int ov7251_s_ctrl(struct v4l2_ctrl *ctrl)break ;case V4L2_CID_VBLANK : ret =ov7251_vts_configure (ov7251, ctrl->val); +if (!ret && ov7251->strobe->val) + ret =ov7251_set_strobe_span (ov7251); +break ; +case V4L2_CID_FLASH_STROBE_OE : + ret =ov7251_set_strobe (ov7251, ctrl->val);break ;default : ret = -EINVAL ;
@@ -1574,7 +1637,7 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)if (ret)return ret; -v4l2_ctrl_handler_init (&ov7251->ctrls,11 ); +v4l2_ctrl_handler_init (&ov7251->ctrls,12 ); ov7251->ctrls.lock = &ov7251->lock; v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
@@ -1621,6 +1684,10 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)OV7251_TIMING_MIN_VTS , vblank_max,1 , vblank_def); + ov7251->strobe =v4l2_ctrl_new_std (&ov7251->ctrls, &ov7251_ctrl_ops, +V4L2_CID_FLASH_STROBE_OE , +0 ,1 ,1 ,0 ); +v4l2_ctrl_new_fwnode_properties (&ov7251->ctrls, &ov7251_ctrl_ops, &props);
Signature · 1 line
2.53.0
Re: [PATCH 6/7] media: i2c: ov7251: Add strobe output enable control
Quoted 44 lines · Antoine Pichot
The OV7251 has a STROBE output that pulses during the exposure of selected frames, meant to drive an illuminator. On the Microsoft Surface Book 2 the front OV7251 is an infrared camera (Windows Hello) and its 850 nm emitter is wired to that pin: ACPI describes no separate LED, GPIO line or regulator for it. The mode tables leave the pad disabled, so the camera only sees an unlit scene.
Add a
V4L2_CID_FLASH_STROBE_OEcontrol, off by default. When enabled it sets the STROBE pad output enable (SC_REG5bit 3), strobes alternate frames (frame pattern0xaainstead of the default0xa5, which lights four frames in eight) and sets the
pulse length (strobe frame span, in lines) to the exposure time, clamped between 52 lines and 45% of the frame length, never more than 776 lines. When disabled it
restores the defaults the mode tables used to write. The span follows exposure and vertical blanking changes while the strobe is enabled.The limits come from the Windows driver, which clamps the span to 52 to 776 lines: 776 lines is 45% of the 1724-line frame of the 30 fps mode. Expressing the upper limit as a duty cycle keeps the emitter within that envelope (eye safety) at 60 and 90 fps too, where a fixed 776 lines would let the pulse cover up to 96% of the frame (552 of 572 lines). Keeping the 776-line limit as well bounds the pulse when vertical blanking stretches the frame, up to 65535 lines.
Alternate frames is what the Windows driver uses for face recognition on this hardware: its 30 and 60 fps modes write
0xaa, and a register dump taken during a Windows Hello sign-in on a Surface Book 2 shows the same. Lighting every frame (0xff, which two of its other modes use) would double the average emitter power. User space tells lit frames from dark ones by their brightness; V4L2 has no per-frame illumination flag yet.The control is written only while the sensor is powered, and from
__v4l2_ctrl_handler_setup()at stream start, after the mode and strobe register tables. Setting it while the sensor is idle does not power it up, and the emitter goes off with the sensor when streaming stops.On a Surface Book 2 at analogue gain 128 the mean pixel value of the infrared image of a room is 19 unlit; with the strobe enabled the lit frames read 496 at exposure 504 (span 504) and 587 at exposure 1704 (span 776), the dark frames in between 18 to 20.
The span read back while streaming is 258 at 90 fps, 45% of the 572-line frame.
...
Quoted 7 lines
drivers/media/i2c/ov7251.c +6
-0+static int ov7251_set_strobe_span (struct ov7251 *ov7251) +{ +u32 span =OV7251_STROBE_FRAME_SPAN_DEF ; +u32 vts, max_span; +u8 val[4 ]; +/*
drivers/media/i2c/ov7251.c static int ov7251_set_test_pattern(struct ov7251 *ov7251, s32 value) · line 1001
Quoted 10 lines
drivers/media/i2c/ov7251.c +10
-0+* The pulse starts with the integration: make it cover the exposure, +* from 52 lines up to 45% of the frame and never more than 776 lines. +* The vendor driver caps it at 776 lines, 45% of the 1724 lines 30 fps +* frame; the duty cycle limit keeps the emitter within that envelope +* at higher frame rates, the absolute one with long vertical blanking. +*/ +if (ov7251->strobe->val) { + vts = ov7251->current_mode->height + ov7251->vblank->val; + max_span =DIV_ROUND_UP (vts *OV7251_STROBE_MAX_DUTY_PERCENT , +100 );
units.h provides PERCENT constant.
max_span = DIV_ROUND_UP(vts * OV7251_STROBE_MAX_DUTY_PERCENT, PERCENT);
drivers/media/i2c/ov7251.c static int ov7251_set_test_pattern(struct ov7251 *ov7251, s32 value) · line 1004
Quoted 3 lines
drivers/media/i2c/ov7251.c +3
-0+ max_span =min (max_span,OV7251_STROBE_SPAN_MAX ); + span =clamp_t (u32, ov7251->exposure->val, +OV7251_STROBE_SPAN_MIN , max_span);
Can we avoid using _t version of clamp()?
And naturally I would first clamp over the _MAX/_MIN range (this addresses the previous Q) and then run min() on top.
drivers/media/i2c/ov7251.c static int ov7251_set_test_pattern(struct ov7251 *ov7251, s32 value) · line 1010
Quoted 6 lines
drivers/media/i2c/ov7251.c +6
-0+ } + +put_unaligned_be32 (span, val); + +return ov7251_write_seq_regs (ov7251,OV7251_STROBE_FRAME_SPAN , val, +sizeof (val));
Can we move at some point to CCI accessors (v4l2-cci.h)?
Quoted 1 line
+}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 6/7] media: i2c: ov7251: Add strobe output enable control
Hi Andy,
Thanks Andy for your comments. The first two are fixed in v2; I'll take care of the CCI accessors in a follow-up once this is in. I'll send v2 in a few days to give everyone time to comment.
Cheers,
Antoine
PATCH 7/7 media: ipu-bridge: Add a 90 degree rotation quirk for Surface Book 2
In reply to Antoine PichotThe infrared camera of the Microsoft Surface Book 2, an OmniVision OV7251 with ACPI ID INT347E, is mounted rotated by 90 degrees. An upright scene appears rotated 90 degrees clockwise in its frames, with the top of the scene at the right edge of the image, while a frame taken at the same moment by the colour camera next to it shows the scene upright. The degree field of the sensor's SSDB buffer in the ACPI tables is 0, and so is the rotation field of its _PLD, so ipu_bridge_parse_rotation() sets the rotation property to 0 and userspace has no way to know that the image needs correcting.
The firmware is wrong here, and ipu-bridge is where the firmware data is turned into the rotation property: it already carries DMI (Desktop Management Interface) quirks for sensors mounted upside down without the firmware saying so. Add a second table for sensors rotated by 90 degrees, checked the same way, with one entry for the Surface Book 2 infrared sensor. Following V4L2_CID_CAMERA_SENSOR_ROTATION, 90 is the counter-clockwise rotation to apply to correct the image. The entry matches on the SKU of the 13 inch model, the one checked; the 15 inch model has its own SKU and has not been checked. The colour sensors of this machine (INT33BE and INT347A) already report 180 degrees and are unchanged.
Tested on a 13 inch Surface Book 2 (SKU Surface_Book_1832) with a 7.2.12 kernel: V4L2_CID_CAMERA_SENSOR_ROTATION on the OV7251 reads 90 instead of 0, the colour sensors still read 180 and the orientation controls are unchanged.
--- drivers/media/pci/intel/ipu-bridge.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +22 -0
@@ -281,6 +281,23 @@ static const struct dmi_system_id upside_down_sensor_dmi_ids[] = { {}/* Terminating entry */ }; +/* +* DMI matches for laptops which have their sensor mounted rotated by 90 degrees +* without reporting it in the SSDB. +*/ +static const struct dmi_system_id rotated_90_sensor_dmi_ids[] = { + { +/* Microsoft Surface Book 2 13 inch, infrared sensor */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR , +"Microsoft Corporation" ), +DMI_EXACT_MATCH (DMI_PRODUCT_SKU ,"Surface_Book_1832" ), + }, + .driver_data ="INT347E" , + }, + {}/* Terminating entry */ +}; +static const struct ipu_property_names prop_names = { .clock_frequency ="clock-frequency" , .rotation ="rotation" ,
@@ -474,6 +491,11 @@ static u32 ipu_bridge_parse_rotation(struct acpi_device *adev,if (acpi_dev_hid_match (adev, dmi_id->driver_data))return 180 ; +for (dmi_id =dmi_first_match (rotated_90_sensor_dmi_ids); dmi_id; + dmi_id =dmi_first_match (dmi_id +1 )) +if (acpi_dev_hid_match (adev, dmi_id->driver_data)) +return 90 ; +switch (ssdb->degree) {case IPU_SENSOR_ROTATION_NORMAL :return 0 ;
Signature · 1 line
2.56.0
Hi Antoine,
I ran the series on a Surface Pro 7+ (IPU6 Tiger Lake, 8086:9a19), the front-facing OV7251 at i2c 3-0060, on a 6.19-based kernel. Patches 2 to 6 all do what they say here, so:
I have deliberately scoped that tag. 1/7 is a regression on this machine and I have replied separately on that patch; please do not read the tag as covering it. 7/7 is keyed on DMI_PRODUCT_SKU "Surface_Book_1832" and this machine reports "Surface_Pro_7+_1960", so I did not build or test it.
What each one did here:
2/7: reproduced the bug and the fix. Unpatched, --set-subdev-fps is accepted and reads back, but the VTS register stays at 1724 and the sensor keeps delivering 30 fps. With the patch:
requested vblank VTS reg measured
90 fps 92 572 90.45 fps
60 fps 380 860 60.16 fps
30 fps 1244 1724 30.01 fps3/7: v4l2-compliance on the subdev goes from
fail: subscribe event for control 'User Controls' failed
Total: 44, Succeeded: 43, Failed: 1
to 44 of 44 with no failures.
4/7: camera_orientation reads Front and camera_sensor_rotation 0, both read-only, consistent with the _PLD here.
5/7: no functional change observed. With the new control off, the registers read exactly what the mode tables used to write: 0x3005 = 0x00, 0x3b81 = 0xa5, span 26.
6/7: works, and the register behaviour matches your description exactly. The control appears as strobe_output_enable and defaults to 0. Read back over i2c mid-stream:
off: 0x3005 = 0x00 0x3b81 = 0xa5 span 26
on: 0x3005 = 0x08 0x3b81 = 0xaa span clamp(exposure, 52,
min(45% of VTS, 776))Both clamp limits are exact over a 12-point exposure sweep from 1 to 1704 at VTS 1724, and the duty rule holds as VTS varies: 1724 -> 776, 1280 -> 576, 880 -> 396, 680 -> 306, 572 -> 258. That last one reproduces the 258 at 90 fps from your cover letter.
For the illuminator itself I did not trust anything but the sensor: one 568-frame capture, strobe toggled 0/1/0/1/0 inside the single stream, exposure 776, VTS 1724, gain 16, same scene, zero CSI-2 errors, per-frame mean of the Y10 data:
strobe 0: n=252 mean 517.58 std 0.25 |even-odd| 0.00-0.01
strobe 1: n=169 mean 546.27 std 28.81 |even-odd| 57.61
lit frames 575.4 unlit frames 517.6With the strobe off there is no per-frame structure at all; with it on the frames split into two populations 57.6 counts apart, alternating, and the unlit frames inside an ON segment match the strobe-off level to within 0.3 counts. That is the illuminator firing on alternate frames and nothing else. The effect is only +5.5% overall because the scene had a lot of ambient daylight IR; every number above is a within-capture comparison, as absolute levels drifted between separate captures.
Two notes that might save someone else time.
6/7 does not build on a tree without V4L2_CID_FLASH_STROBE_OE:
ov7251.c:1688:44: error: 'V4L2_CID_FLASH_STROBE_OE' undeclared
That CID is not added by this series -- it comes from 5be4154f6255 ("media: v4l: ctrls: add a control for enabling strobe output"), which landed after v6.19. Since 6/7 uses v4l2_ctrl_new_std() it needs the v4l2-ctrls-defs.c entries too, not just the uapi define, or the control is never created. Worth a word in the cover letter for anyone testing on a stable tree.
And on this hardware the series supersedes the out-of-tree Surface driver's ir_led module parameter, which drives the same two registers. Measured on the shipped module while streaming, that parameter lights every frame with the mode table's 26-line pulse, about 0.7% duty at its production VTS of 3448, and never updates the span. 6/7 is strictly better behaved. They cannot coexist, since 5/7 removes those writes from the mode tables, so ir_led would have to go when this lands. That is our problem, not yours.
What I did not test: 7/7, the 60 and 90 fps modes photometrically, v4l2-compliance streaming, and whether the pulse follows the exposure in time -- I verified the programmed span, not the pulse position. The photometric capture was taken with 1/7 reverted, since with it the link here is too unstable to capture reliably; the register-level strobe behaviour was re-verified identically with 1 to 6 exactly as posted.
I also had to rebase onto v6.19 to build at all, because mainline's ov7251.c uses pad-op signatures this kernel does not have; the unpatched file fails the same way, so that is unrelated to your series. Patches 1 to 6 applied to v6.19 with line offsets of at most one and no fuzz.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)
Hi,
Quoted 1 line · D. Manresa
Thank you for the thorough test. v2 carries the tag on 2, 4 and 5. Patch 6 changed after Andy's review (the span computation rewritten, same result), so I will carry it there too unless you object. Patch 3 is replaced by a conversion to the sub-device active state, as Sakari asked.
Quoted 6 lines
That CID is not added by this series -- it comes from
5be4154f6255("media: v4l: ctrls: add a control for enabling strobe output"), which landed after v6.19. Since 6/7 usesv4l2_ctrl_new_std()it needs thev4l2-ctrls-defs.centries too, not just the uapi define, or the control is never created. Worth a word in the cover letter for anyone testing on a stable tree.
The v2 cover letter will say so: 6/7 needs the strobe control from kernel 7.0 and is not for stable.
Quoted 2 lines
4/7:
camera_orientationreads Front andcamera_sensor_rotation0, both read-only, consistent with the_PLDhere.
On the Book 2 the firmware reports 0 but the picture comes out turned by 90 degrees, which 7/7 corrects for that model. Could you please check whether the frames are upright on the Pro 7+ and, if not, tell me which way they turn? 7/7 can then carry the Pro 7+ as well.
The link question continues on the 1/7 thread.
Thanks,
Antoine
Hi,
Quoted 4 lines · Antoine Pichot
On the Book 2 the firmware reports 0 but the picture comes out turned by 90 degrees, which 7/7 corrects for that model. Could you please check whether the frames are upright on the Pro 7+ and, if not, tell me which way they turn?
They are not upright here either, and they turn the same amount: the Pro 7+ delivers the scene rotated 90 degrees clockwise. To display it upright you rotate the frame 90 degrees counter-clockwise, that is 270 degrees clockwise.
Two independent cues, because I did not want to rely on how I held a test object:
- the ceiling lamp of the room. In a frame from the colour front camera, which is upright, it is at the top centre. In the IR frame taken at the same moment it is at the right edge, vertically centred. A ceiling lamp is up by definition, so "up" leaves at the right-hand edge;
- an open hand held in front of the camera with the fingers pointing at the ceiling. The fingers come out pointing at the right-hand edge of the IR frame and the thumb towards the bottom.
Both say the same: up maps to right, which is a 90 degree clockwise rotation of the scene.
Conditions, so you can tell whether it is comparable with the Book 2:
- measured on the capture node fed straight from the IPU6 ISYS, Y10 640x480, with the userspace bridge only shifting the 10-bit samples down to 8 bits. It does not transpose, flip or rotate anything, and I checked that before trusting the frames;
- HORIZONTAL_FLIP and VERTICAL_FLIP both read 0 on the sensor;
- this particular capture ran on the out-of-tree Surface driver, which is what is installed here, not on your series. When I had your 4/7 applied, camera_orientation read Front and camera_sensor_rotation read 0, so this machine has the same disagreement between firmware and reality that you describe: _PLD says 0, the picture says 90.
If the Book 2 also comes out "up at the right edge", then the Pro 7+ can carry 7/7 as well and I will test it here. If it turns the other way, the two SKUs need different values and mine is the clockwise one. Either way the DMI match for this machine is
sys_vendor Microsoft Corporation
product_name Surface Pro 7+
with the DMI product SKU reading Surface_Pro_7+_1960, against the Surface_Book_1832 in your 7/7.
D. Manresa
(Written with AI assistance, directed and reviewed by me.)