media: Add the ST VD55G0 global shutter sensor
Subsystems (3)
v2 cover media: Add the ST VD55G0 global shutter sensor
The ST VD55G0 is a 644x604 monochrome global shutter sensor. It is the infrared camera of the Microsoft Surface Pro 11 for Business with Intel (Lunar Lake, IPU7) and of the Surface Pro 9 (Alder Lake, IPU6), ACPI device SMO55F0. Without a driver the camera does not appear at all.
1/4 dt-bindings: media: i2c: st,vd55g1: Add ST VD55G0 2/4 media: i2c: Add ST VD55G0 global shutter sensor driver 3/4 media: ipu-bridge: Add ST VD55G0 4/4 media: ipu-bridge: Add the Surface Pro 9 and 11 infrared illuminator
The driver is a port of ST's own downstream driver, firmware patch included, as vd55g1 carries its own:
https://github.com/STMicroelectronics/vd55g0-linux-driver
Benjamin reviewed it off-list before v1; 2/4 carries his Co-developed-by, and its clock tree is based on his.
Changes since v1:
- 1/4: the VD55G0 joins st,vd55g1.yaml instead of a file of its own, with its 375 MHz link-frequency minimum in an if/then, as Krzysztof pointed to. Benjamin's Co-developed-by went with the separate file.
- 2/4: no code change; MAINTAINERS no longer lists a binding for it.
- 4/4: the st,leds name and GPIO numbers now live in the bridge's own structs, as the software nodes outlive the module (Fernando). With v1, unloading ipu-bridge and rebinding the sensor froze the machine. Adds the Surface Pro 9, which strobes from the same GPIO (Fernando).
- Rebased on v7.4-rc1.
On both machines the sensor needs Hao Yao's int3472 fix: the SSDB asks for 24 MHz, but INT3472 enables the clock at 19.2 MHz, so without it the sensor runs at four fifths of every rate this series computes:
https://lore.kernel.org/all/[email protected]/
Its v2 fixes the Surface Pro 11. On the Alder Lake Surface Pro 9 the _DSM takes 0 for 24 MHz rather than 3, as Fernando measured, so its v3 has to choose the value per platform.
On IPU6, frames come out corrupted unless a CPU latency bound is held while streaming; that is the ISYS, not this sensor (Fernando, on v1).
v1: https://lore.kernel.org/all/[email protected]/
Tested on the Surface Pro 11 for Business, on v7.4-rc1 with Hao Yao's int3472 v2, D. Manresa's ipu-bridge 1/2 for the unload test, KASAN with KASAN_VMALLOC, and lockdep, IPU7 run by the ipu6 driver:
- probe defers until ipu-bridge has made the endpoint, then binds;
- every mode runs at 59.14 fps, as the controls give, in Y8 and Y10 at all four sizes and in Y10 packed at full size;
- under auto exposure, exposure and the gains read back what the sensor applies, and carry over to manual mode;
- the illuminator through led_mode;
- v4l2-compliance 46 of 46, and 54 of 54 through the media device, with two warnings for the read-only crop;
- unloading the IPU stack and ipu-bridge, then unbinding and binding the sensor, is clean; with v1 it froze the machine;
- no KASAN, lockdep or Oops report; the only WARNING is the ipu6 driver's lockdep_assert_held() at each stream start, as with v1;
- W=1 and sparse clean; dt_binding_check clean, and it refuses a VD55G0 example at 125 MHz.
The Surface Pro 9 entry is not tested here.
Sergey Lebedev (4):
dt-bindings: media: i2c: st,vd55g1: Add ST VD55G0
media: i2c: Add ST VD55G0 global shutter sensor driver
media: ipu-bridge: Add ST VD55G0
media: ipu-bridge: Add the Surface Pro 9 and 11 infrared illuminator
.../bindings/media/i2c/st,vd55g1.yaml | 27 +- MAINTAINERS | 9 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/vd55g0.c | 2434 +++++++++++++++++ drivers/media/pci/intel/ipu-bridge.c | 70 +- include/media/ipu-bridge.h | 6 +- 7 files changed, 2551 insertions(+), 7 deletions(-) create mode 100644 drivers/media/i2c/vd55g0.c
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.54.0
PATCH v2 1/4 dt-bindings: media: i2c: st,vd55g1: Add ST VD55G0
The VD55G0 is a monochrome global shutter sensor with a 644x604 active array, sending over a single MIPI CSI-2 lane, with the same supplies, reset and strobe GPIOs as the VD55G1. Its MIPI rate runs from 750 to 1200 Mbps (UM2829, 13.1), so its link frequency starts at 375 MHz, and its I2C address is set in its NVM rather than fixed.
allOf moves below required to carry the if/then for that minimum.
---
v2: the VD55G0 joins this file instead of a st,vd55g0.yaml of its own, with allOf below required for the if/then, as Krzysztof pointed to. It is Peter Marshall's 01/11 and 02/11 of his vd55g1 v2 squashed, as Krzysztof asked there, with the VD55G0's description added:
https://lore.kernel.org/all/[email protected]/
.../bindings/media/i2c/st,vd55g1.yaml | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/media/i2c/st,vd55g1.yaml +23 -4
@@ -16,21 +16,23 @@ description: |- array size of 804H x 704V. It is programmable through I2C interface. The I2C address is fixed to 0x10. + The VD55G0 is a monochrome global shutter image sensor with an active array + size of 644H x 604V, programmable through I2C at an address set in its NVM. + Image data is sent through MIPI CSI-2, which is configured as only 1 data lane. The sensor provides 4 GPIOS that can be used for external LED signal (synchronized with sensor integration periods). -allOf: - - $ref: /schemas/media/video-interface-devices.yaml# - properties: compatible: enum: + - st,vd55g0 - st,vd55g1 - st,vd55g4 - st,vd65g4 description: - VD55G1 and VD55G4 are monochrome variants, while VD65G4 is a color one. + VD55G0, VD55G1 and VD55G4 are monochrome variants, while VD65G4 is a + color one. reg: maxItems: 1
@@ -101,6 +103,23 @@ required: - reset-gpios - port +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + - if: + properties: + compatible: + contains: + const: st,vd55g0 + then: + properties: + port: + properties: + endpoint: + properties: + link-frequencies: + items: + minimum: 375000000 + unevaluatedProperties: false examples:
Signature · 1 line
2.54.0
PATCH v2 2/4 media: i2c: Add ST VD55G0 global shutter sensor driver
In reply to Sergey LebedevThe VD55G0 is a 644x604 monochrome global shutter sensor from STMicroelectronics. It streams Y8 or Y10 over one CSI-2 lane, runs its own auto exposure, can strobe an illuminator from its GPIOs, and needs a firmware patch at every power-on, carried in the driver as vd55g1 does.
The driver is ported from ST's own, GPL-2.0, to current interfaces: CCI register access, .enable_streams with the subdev state, fwnode properties, devm_v4l2_sensor_clk_get(), and an ACPI match for x86 machines where the sensor sits behind ipu-bridge:
https://github.com/STMicroelectronics/vd55g0-linux-driver
ST's st,out-sync and st,in-sync and its two private controls are left out, as vd55g1 has none of them. With the ACPI ID the supplies take the names INT3472 registers, avdd and dovdd; a PRP0001 device keeps the DT names.
The clock tree is computed from the input clock and the one link frequency the endpoint gives, as in vd55g1. The MIPI rate must be an integer multiple of the input clock, or the sensor would run at another one, so any other link frequency fails probe.
Exposure and the two gains form an auto cluster with auto exposure, as in
vd55g1: while auto exposure runs, they read back what the sensor applies.
---
On ACPI the supplies take the names INT3472 registers, avdd and dovdd, through acpi_match_device(); vd55g1 is served by an entry in int3472's map instead. I did not add one, as it would have to say which rail each pin feeds, and that is not known here: INT3472 calls pin type 0x10 DOVDD, while Windows' camera driver calls it Avdd. If a map entry is preferred, I can move the names there.
v2: no code change; MAINTAINERS no longer lists a binding for it.
MAINTAINERS | 9 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/vd55g0.c | 2434 ++++++++++++++++++++++++++++++++++++ 4 files changed, 2455 insertions(+) create mode 100644 drivers/media/i2c/vd55g0.c
MAINTAINERS +9 -0
@@ -26592,6 +26592,14 @@ F: Documentation/devicetree/bindings/hwmon/st,tsc1641.yaml F: Documentation/hwmon/tsc1641.rst F: drivers/hwmon/tsc1641.c +ST VD55G0 DRIVER +M: Benjamin Mugnier <[email protected]> +M: Sergey Lebedev <[email protected]> +M: Sylvain Petinot <[email protected]> +L: [email protected] +S: Maintained +F: drivers/media/i2c/vd55g0.c + ST VD55G1 DRIVER M: Benjamin Mugnier <[email protected]> M: Sylvain Petinot <[email protected]>
@@ -29317,6 +29325,7 @@ F: drivers/media/i2c/mt* F: drivers/media/i2c/og* F: drivers/media/i2c/ov* F: drivers/media/i2c/s5* +F: drivers/media/i2c/vd55g0.c F: drivers/media/i2c/vd55g1.c F: drivers/media/i2c/vd56g3.c F: drivers/media/i2c/vgxy61.c
drivers/media/i2c/Kconfig +11 -0
@@ -891,6 +891,17 @@ config VIDEO_T4KA3 To compile this driver as a module, choose M here: the module will be called t4ka3. +config VIDEO_VD55G0 + tristate "ST VD55G0 sensor support" + select V4L2_CCI_I2C + depends on GPIOLIB + help + This is a Video4Linux2 sensor driver for the ST VD55G0 + camera sensor. + + To compile this driver as a module, choose M here: the + module will be called vd55g0. + config VIDEO_VD55G1 tristate "ST VD55G1 sensor support" select V4L2_CCI_I2C
drivers/media/i2c/Makefile +1 -0
@@ -171,6 +171,7 @@ obj-$(CONFIG_VIDEO_TW9910) += tw9910.o obj-$(CONFIG_VIDEO_UDA1342) += uda1342.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o +obj-$(CONFIG_VIDEO_VD55G0) += vd55g0.o obj-$(CONFIG_VIDEO_VD55G1) += vd55g1.o obj-$(CONFIG_VIDEO_VD56G3) += vd56g3.o obj-$(CONFIG_VIDEO_VGXY61) += vgxy61.o
drivers/media/i2c/vd55g0.c new file +2434 -0
2,434 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 2/4] media: i2c: Add ST VD55G0 global shutter sensor driver
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] media: i2c: vd55g0: volatile auto-exposure values lost on runtime suspend - [Medium] media: i2c…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] media: i2c: vd55g0: volatile auto-exposure values lost on runtime suspend
- [Medium] media: i2c: vd55g0: missing pm_runtime_get_noresume() in vd55g0_probe()
- [Low] media: i2c: vd55g0: wrap dev_pm_ops with pm_ptr() and RUNTIME_PM_OPS() --
commit 4ee425e92cc09cc24222143b83ab50039d6092fe
Author: Sergey Lebedev <[email protected]>
media: i2c: Add ST VD55G0 global shutter sensor driver
This commit adds a V4L2 subdevice driver for the STMicroelectronics VD55G0 644x604 monochrome global shutter camera sensor over MIPI CSI-2, supporting Y8 and Y10 formats, firmware patching, auto-exposure clustering, and DT/ACPI enumeration.
Quoted 6 lines
drivers/media/i2c/vd55g0.c new file +0
-0@@ -0,0 +1,2434 @@
[ ... ]
Quoted 12 lines
drivers/media/i2c/vd55g0.c new file +12
-0+static void vd55g0_save_exposure (struct vd55g0_dev *sensor) +{ +u64 val; + +/* On a read error, keep what the previous stream left */ +if (!vd55g0_read (sensor,VD55G0_REG_APPLIED_COARSE_EXPOSURE , &val,NULL )) + sensor->cold_start.expo = val; +if (!vd55g0_read (sensor,VD55G0_REG_APPLIED_DIGITAL_GAIN , &val,NULL )) + sensor->cold_start.digital_gain = val; +if (!vd55g0_read (sensor,VD55G0_REG_APPLIED_ANALOG_GAIN , &val,NULL )) + sensor->cold_start.analog_gain = val; +}
[ ... ]
Quoted 18 lines
drivers/media/i2c/vd55g0.c new file +18
-0+/* Under auto exposure, the manual controls read what the sensor applies */ +static int vd55g0_g_volatile_ctrl (struct v4l2_ctrl *ctrl) +{ +struct vd55g0_dev *sensor =to_vd55g0_dev (ctrl_to_sd (ctrl)); +struct device *dev = &sensor->i2c_client->dev; +u64 expo, again, dgain; +int ret =0 ; + +if (ctrl->id !=V4L2_CID_EXPOSURE_AUTO ) +return -EINVAL ; + +/* Only a powered sensor has applied values; keep the last ones */ +if (!pm_runtime_get_if_in_use (dev)) +return 0 ; + +vd55g0_read (sensor,VD55G0_REG_APPLIED_COARSE_EXPOSURE , &expo, &ret); +vd55g0_read (sensor,VD55G0_REG_APPLIED_ANALOG_GAIN , &again, &ret); +vd55g0_read (sensor,VD55G0_REG_APPLIED_DIGITAL_GAIN , &dgain, &ret);
drivers/media/i2c/vd55g0.c line 1908
Quoted 10 lines
drivers/media/i2c/vd55g0.c new file +10
-0+if (!ret) { + sensor->expo_ctrl->val = expo; + sensor->again_ctrl->val = again; + sensor->dgain_ctrl->val = dgain; + } + +pm_runtime_put_autosuspend (dev); + +return ret; +}
[Severity: Medium]
When the sensor is runtime-suspended after streaming under V4L2_EXPOSURE_AUTO, will returning 0 from vd55g0_g_volatile_ctrl() actually preserve the last applied values on sensor->expo_ctrl, sensor->again_ctrl, and sensor->dgain_ctrl?
Before invoking .g_volatile_ctrl(), the V4L2 control framework callers (get_ctrl(), v4l2_g_ext_ctrls_common(), and update_from_auto_cluster()) call cur_to_new() on each control in the cluster, which overwrites ctrl->val with ctrl->cur.val.
When vd55g0_g_volatile_ctrl() runs while powered on, it only updates ctrl->val, and vd55g0_save_exposure() in vd55g0_stream_disable() only saves the hardware values into sensor->cold_start without updating cur.val on sensor->expo_ctrl, sensor->again_ctrl, and sensor->dgain_ctrl (unlike vd55g1_read_expo_cluster() and vd56g3_read_expo_cluster()).
Once the device suspends, won't reading those controls or switching V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL revert to the stale manual defaults in ctrl->cur.val instead of keeping the last applied exposure and gain values?
[ ... ]
Quoted 2 lines
drivers/media/i2c/vd55g0.c new file +2
-0+static int vd55g0_probe (struct i2c_client *client) +{
[ ... ]
Quoted 27 lines
drivers/media/i2c/vd55g0.c new file +27
-0+pm_runtime_set_active (dev); +pm_runtime_enable (dev); + + ret =v4l2_async_register_subdev (&sensor->sd); +if (ret) { +dev_err (&client->dev,"async subdev register failed %d\n" , ret); + goto error_pm_runtime; + } + +/* Runtime PM may power the sensor down only from here on */ +pm_runtime_set_autosuspend_delay (&client->dev,1000 ); +pm_runtime_use_autosuspend (&client->dev); +pm_runtime_idle (dev); + +dev_dbg (&client->dev,"vd55g0 probe successfully\n" ); + +return 0 ; + +error_put_handle: +fwnode_handle_put (handle); + +return ret; + +error_pm_runtime: +pm_runtime_disable (&client->dev); +pm_runtime_set_suspended (&client->dev); +v4l2_subdev_cleanup (&sensor->sd);
drivers/media/i2c/vd55g0.c line 2386
Quoted 10 lines
drivers/media/i2c/vd55g0.c new file +10
-0+error_media_entity: +media_entity_cleanup (&sensor->sd.entity); +error_handler_free: +v4l2_ctrl_handler_free (sensor->sd.ctrl_handler); +error_power_off: +mutex_destroy (&sensor->lock); +vd55g0_power_off (dev); + +return ret; +}
[Severity: Medium]
In vd55g0_probe(), pm_runtime_enable(dev) is called while the runtime PM usage count is 0, prior to v4l2_async_register_subdev() and prior to configuring autosuspend.
First, on the normal probe path, calling pm_runtime_set_autosuspend_delay() while runtime PM is enabled, usage_count is 0, and use_autosuspend is still false causes update_autosuspend() -> rpm_idle() -> rpm_suspend() to synchronously suspend the sensor inside pm_runtime_set_autosuspend_delay() before pm_runtime_use_autosuspend() is called.
Second, because usage_count is 0 during v4l2_async_register_subdev(), runtime PM can already suspend the device (for example via sysfs or a notifier) before v4l2_async_register_subdev() returns. If registration then fails and jumps to error_pm_runtime, error_power_off unconditionally calls vd55g0_power_off(dev) a second time, leading to unbalanced clk_disable_unprepare() and regulator_bulk_disable() calls.
Should vd55g0_probe() take a runtime reference with pm_runtime_get_noresume(dev) before pm_runtime_enable(dev) and release it with pm_runtime_put_autosuspend(dev) after pm_runtime_use_autosuspend() (and with pm_runtime_put_noidle(dev) on error_pm_runtime)?
[ ... ]
drivers/media/i2c/vd55g0.c line 2422
Quoted 11 lines
drivers/media/i2c/vd55g0.c new file +11
-0+static const struct dev_pm_ops vd55g0_pm_ops = { +SET_RUNTIME_PM_OPS (vd55g0_power_off, vd55g0_power_on,NULL ) +}; + +static struct i2c_driver vd55g0_i2c_driver = { + .driver = { + .name ="vd55g0" , + .of_match_table = vd55g0_dt_ids, + .acpi_match_table = vd55g0_acpi_ids, + .pm = &vd55g0_pm_ops, + },
[Severity: Low]
This isn't a bug, but could vd55g0_pm_ops use RUNTIME_PM_OPS() (or DEFINE_RUNTIME_DEV_PM_OPS()) and wrap the .pm assignment in vd55g0_i2c_driver with pm_ptr(&vd55g0_pm_ops) so the PM ops and callbacks can be eliminated by the compiler when CONFIG_PM is disabled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/4] media: i2c: Add ST VD55G0 global shutter sensor driver
In reply to Sergey LebedevSashiko's review of this patch [1] went to devicetree, not linux-media. All three points are right; v3 will fix them. Tested on the Surface Pro 11 with v2 and with the fix:
1. Auto exposure. Once a stream stops, the exposure and gains read back, and carry into manual mode, the values set before switching to auto, not the last applied ones. No runtime suspend is needed for this:
pm_runtime_get_if_in_use() fails as soon as the stream's reference is dropped. Here the stream applied 1796/24/2048; after the stop the controls read 123/7/333, the manual values set before, and a manual stream then applied 123/7/333. v3 returns what the last stream applied, which the driver already keeps for the next cold start; the controls then read 1796/24/2048 and the manual stream applies that. So the v2 cover letter's "carry over to manual mode" held only while streaming.
2. Probe. The sensor was runtime suspended 22 ms after bind returned, not after the 1 s autosuspend delay. v3 takes a reference before pm_runtime_enable() and sets up autosuspend before registering, as vd55g1 does, and drops the reference once registered; the sensor then suspends 1.2 s after bind. The error path was not exercised.
3. RUNTIME_PM_OPS() and pm_ptr(): in v3. With CONFIG_PM=n, vd55g0_pm_ops is then no longer in the object.
With the fix, v4l2-compliance passes 46 of 46, with no KASAN or lockdep report.
[1] https://lore.kernel.org/all/[email protected]/
Sergey
PATCH 1/1 media: i2c: vd55g0: register through the sensor helper
In reply to Sergey LebedevThe plain async subdevice registration function does not acquire the privacy LED described by firmware. Consequently, a board can provide leds and led-names = "privacy" without the V4L2 streaming helpers ever being able to switch that indicator on.
Use v4l2_async_register_subdev_sensor() to acquire the privacy LED and register the sensor's firmware associations. The helper releases its resources on registration failure, and v4l2_async_unregister_subdev() already releases them on removal.
---
Hi Sergey,
While preparing to test your driver on the Surface Laptop 7, I noticed that the registration path skips privacy LED acquisition. My board describes a white camera indicator through leds/led-names. This increment is against v2 2/4 and is separate from the three v3 updates you described in your November 3 follow-up.
The driver builds with W=1 on ARM64 after adapting the two unused client-info parameters and their internal call to my older local V4L2 pad API. That compatibility change is not part of this patch. I have not run this standalone driver on the hardware yet.
drivers/media/i2c/vd55g0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/vd55g0.c +1 -1
@@ -2350,7 +2350,7 @@ static int vd55g0_probe(struct i2c_client *client)pm_runtime_set_active (dev);pm_runtime_enable (dev); - ret =v4l2_async_register_subdev (&sensor->sd); + ret =v4l2_async_register_subdev_sensor (&sensor->sd);if (ret) {dev_err (&client->dev,"async subdev register failed %d\n" , ret); goto error_pm_runtime;
Signature · 1 line
2.53.0
Re: [PATCH] media: i2c: vd55g0: register through the sensor helper
Hi Jizhou,
Thanks, you are right, and the Surface Pro 11 needs it too: its INT3472 describes a privacy LED for the IR sensor, and with v2 an IR stream left it off. With your change on top of the fixes for Sashiko's review, on 7.4-rc1 with KASAN and lockdep on:
- the sensor holds the LED once bound; it is on while streaming and off after;
- unbinding releases it, and binding takes it again;
- v4l2-compliance passes 46 of 46.
I will fold it into v3 2/4, with credit in the changelog.
Sergey
PATCH v2 3/4 media: ipu-bridge: Add ST VD55G0
In reply to Sergey LebedevThe infrared camera of the Surface Pro 11 with Intel is an ST VD55G0, enumerated by ACPI as SMO55F0 and wired to the IPU7 over one CSI-2 data lane.
The vd55g0 driver takes only a link frequency whose MIPI rate, twice it, is an integer multiple of the input clock. 396 MHz gives 792 Mbps, 33 times the 24 MHz the sensor's SSDB lists on the Surface Pro 8, 9, 10 and 11, and within the sensor's 750 to 1200 Mbps. Peter Marshall's earlier patch for the Surface Pro 9 used 380 MHz, 760 Mbps, which is not a multiple of 24 MHz, so the driver would refuse it:
https://lore.kernel.org/all/[email protected]/
--- drivers/media/pci/intel/ipu-bridge.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +2 -0
@@ -120,6 +120,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {IPU_SENSOR_CONFIG ("OVTI5693" ,1 ,419200000 ),/* Omnivision OV8856 */ IPU_SENSOR_CONFIG ("OVTI8856" ,3 ,180000000 ,360000000 ,720000000 ), +/* STMicroelectronics VD55G0 */ +IPU_SENSOR_CONFIG ("SMO55F0" ,1 ,396000000 ),/* Sony IMX471 */ IPU_SENSOR_CONFIG("SONY471A", 1, 200000000),/* Sony IMX471 (found on Lenovo X1 Carbon G14) */
Signature · 1 line
2.54.0
PATCH v2 4/4 media: ipu-bridge: Add the Surface Pro 9 and 11 infrared illuminator
In reply to Sergey LebedevOn the Surface Pro 9 and on the Surface Pro 11 with Intel, the infrared illuminator is driven by the VD55G0's GPIO 1, which strobes it during the exposure. The ACPI tables do not describe it, so the sensor driver finds no st,leds and offers no V4L2_CID_FLASH_LED_MODE.
Give the sensor's software node st,leds from a DMI match, as the upside-down quirk gives a rotation. dev_properties gains an entry for it, as a sensor can also have a lens-focus reference. The software nodes outlive the module, so the property name goes into struct ipu_property_names and the GPIO numbers into struct ipu_sensor, where nothing points into the module image.
---
v2: the st,leds name and GPIO numbers live in the bridge's own structs, as the software nodes outlive the module (Fernando); the Surface Pro 9 is added (Fernando).
D. Manresa's ipu-bridge series changes the same lens-focus line; whichever of the two lands second needs a trivial rebase:
https://lore.kernel.org/all/[email protected]/
drivers/media/pci/intel/ipu-bridge.c | 68 +++++++++++++++++++++++++++- include/media/ipu-bridge.h | 6 ++- 2 files changed, 71 insertions(+), 3 deletions(-)
drivers/media/pci/intel/ipu-bridge.c +66 -2
@@ -283,6 +283,42 @@ static const struct dmi_system_id upside_down_sensor_dmi_ids[] = { {}/* Terminating entry */ }; +/* +* Sensor GPIOs that drive an illuminator, for machines whose ACPI tables do +* not say which. They reach the sensor driver as its own leds property. +*/ +struct ipu_sensor_leds { +const char *hid; +u32 gpios[IPU_MAX_LED_GPIOS ]; +unsigned int nr_gpios; +}; + +/* The infrared illuminator, strobed by the VD55G0's GPIO 1 */ +static const struct ipu_sensor_leds surface_pro_ir_leds = { + .hid ="SMO55F0" , + .gpios = {1 }, + .nr_gpios =1 , +}; + +static const struct dmi_system_id sensor_leds_dmi_ids[] = { + { + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"Microsoft Corporation" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Surface Pro 9" ), + }, + .driver_data = (void *)&surface_pro_ir_leds, + }, + { + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"Microsoft Corporation" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME , +"Surface Pro for Business 11th Edition with Intel" ), + }, + .driver_data = (void *)&surface_pro_ir_leds, + }, + {}/* Terminating entry */ +}; +static const struct ipu_property_names prop_names = { .clock_frequency ="clock-frequency" , .rotation ="rotation" ,
@@ -292,6 +328,7 @@ static const struct ipu_property_names prop_names = { .remote_endpoint = "remote-endpoint", .link_frequencies = "link-frequencies", .clock_noncontinuous = "clock-noncontinuous", + .st_leds = "st,leds", };static const char *const ipu_vcm_types[] = {
@@ -563,6 +600,22 @@ int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor) }EXPORT_SYMBOL_NS_GPL (ipu_bridge_parse_ssdb,"INTEL_IPU_BRIDGE" ); +static const struct ipu_sensor_leds * +ipu_bridge_get_leds (const struct ipu_sensor_config *cfg) +{ +const struct dmi_system_id *dmi_id; +const struct ipu_sensor_leds *leds; + +for (dmi_id =dmi_first_match (sensor_leds_dmi_ids); dmi_id; + dmi_id =dmi_first_match (dmi_id +1 )) { + leds = dmi_id->driver_data; +if (!strcmp (cfg->hid, leds->hid)) +return leds; + } + +return NULL ; +} + static void ipu_bridge_create_fwnode_properties( struct ipu_sensor *sensor, struct ipu_bridge *bridge,
@@ -570,7 +623,8 @@ static void ipu_bridge_create_fwnode_properties( {struct ipu_property_names *names = &sensor->prop_names;struct software_node *nodes = sensor->swnodes; -unsigned int i =0 ; +const struct ipu_sensor_leds *leds; +unsigned int i =0 , d =3 ; sensor->prop_names = prop_names;
@@ -624,10 +678,20 @@ static void ipu_bridge_create_fwnode_properties(if (sensor->vcm_type) { sensor->vcm_ref[0 ] =SOFTWARE_NODE_REFERENCE (&sensor->swnodes[SWNODE_VCM ]); - sensor->dev_properties[3 ] = + sensor->dev_properties[d++] =PROPERTY_ENTRY_REF_ARRAY ("lens-focus" , sensor->vcm_ref); } + leds =ipu_bridge_get_leds (cfg); +if (leds) { +memcpy (sensor->led_gpios, leds->gpios, +sizeof (sensor->led_gpios)); + sensor->dev_properties[d++] = +PROPERTY_ENTRY_U32_ARRAY_LEN (names->st_leds, + sensor->led_gpios, + leds->nr_gpios); + } + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY (i,EP_BUS_TYPE )] =PROPERTY_ENTRY_U32 (names->bus_type,V4L2_FWNODE_BUS_TYPE_CSI2_DPHY );
include/media/ipu-bridge.h +5 -1
@@ -12,6 +12,7 @@#define IPU_MAX_LANES 4#define IPU_MAX_PORTS 4#define MAX_NUM_LINK_FREQS 3 +#define IPU_MAX_LED_GPIOS 4/* Values are educated guesses as we don't have a spec */ #define IPU_SENSOR_ROTATION_NORMAL 0
@@ -136,6 +137,7 @@ struct ipu_property_names {char remote_endpoint[16 ];char link_frequencies[17 ];char clock_noncontinuous[20 ]; +char st_leds[8 ]; };struct ipu_node_names {
@@ -178,8 +180,10 @@ struct ipu_sensor {const char *vcm_type;struct ipu_property_names prop_names; +/* The software nodes outlive the module, so these values live here */ +u32 led_gpios[IPU_MAX_LED_GPIOS ];struct property_entry ep_properties[IPU_BRIDGE_EP_NUM_ENTRIES ]; -struct property_entry dev_properties[5 ]; +struct property_entry dev_properties[6 ];struct property_entry ipu_properties[3 ];struct property_entry ivsc_properties[1 ];struct property_entry ivsc_sensor_ep_properties[4 ];
Signature · 1 line
2.54.0
Hi Sergey,
On the Surface Pro 9 (Alder Lake, IPU6 8086:465d), on a 6.19-based kernel, with 3/4 and 4/4 in the bridge and 2/4 adapted only for 6.19 (no v4l2_subdev_client_info argument, and the "dvdd" supply name this tree's int3472 uses), plus an int3472 that passes 0 to the clock _DSM as on Hao's thread:
- 4/4 gives the sensor st,leds: led_mode appears without the GPIO 1 fallback I used for v1, and at manual exposure 600 and analogue gain 8 the frame mean goes from 15.9 with it off to 32.7 with flash;
- with the clock now at a real 24 MHz and the link at 396 MHz, R8, R10 and R10_CSI2P at all four sizes run at 59.14 fps, as the controls give, except R8 at 320x240, which now delivers no frames rather than the third it gave with v1: the IPU6 limit on narrow packed lines from my v1 report;
- v4l2-compliance 1.26.1 on the subdev passes 44 of 44 in both exposure modes.
This covers 2/4 to 4/4. I did not test unloading ipu-bridge, since a warm reload of the IPU6 needs a cold boot to recover on this machine. If v3 changes 2/4 only as in your reply to Sashiko's review, feel free to keep the tag.
Fernando