From 6e32526819209e63f7f643e803abf52f4bd4a108 Mon Sep 17 00:00:00 2001 From: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:44:38 +0100 Subject: [PATCH 1/2] media: i2c: ov9734: Add reset GPIO, regulator and clock handling The ov9734 driver assumes the sensor is already powered by ACPI domain PM and never drives a reset line or enables its clock. On the Surface Laptop 1 and 2, the sensor (OVTI9734) is powered through a discrete INT3472 device (SKC1) which exposes a clock-enable GPIO, a reset GPIO and a privacy LED. Without toggling these, the sensor never answers on I2C. Request the optional "reset" GPIO and the avdd/dovdd/dvdd supplies, and add power on/off functions that enable the regulators and the clock and release the reset line. Power the sensor on before identifying it and hook the functions up as runtime PM callbacks. Tested on a Surface Laptop 2: the sensor is identified and streams via the IPU3 CIO2 and ImgU with libcamera. Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Patchset: cameras --- drivers/media/i2c/ov9734.c | 93 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c index 0eaf33807fc9..984d10e0cae8 100644 --- a/drivers/media/i2c/ov9734.c +++ b/drivers/media/i2c/ov9734.c @@ -4,9 +4,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -27,6 +29,14 @@ #define OV9734_MODE_STANDBY 0x00 #define OV9734_MODE_STREAMING 0x01 +static const char * const ov9734_supply_names[] = { + "avdd", /* Analog power */ + "dovdd", /* Digital I/O power */ + "dvdd", /* Digital core power */ +}; + +#define OV9734_NUM_SUPPLIES ARRAY_SIZE(ov9734_supply_names) + /* vertical-timings from sensor */ #define OV9734_REG_VTS 0x380e #define OV9734_VTS_30FPS 0x0322 @@ -325,6 +335,8 @@ static const struct ov9734_mode supported_modes[] = { struct ov9734 { struct device *dev; struct clk *clk; + struct gpio_desc *reset; + struct regulator_bulk_data supplies[OV9734_NUM_SUPPLIES]; struct v4l2_subdev sd; struct media_pad pad; @@ -805,6 +817,45 @@ static const struct v4l2_subdev_internal_ops ov9734_internal_ops = { .open = ov9734_open, }; +static int ov9734_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov9734 *ov9734 = to_ov9734(sd); + + gpiod_set_value_cansleep(ov9734->reset, 1); + clk_disable_unprepare(ov9734->clk); + regulator_bulk_disable(OV9734_NUM_SUPPLIES, ov9734->supplies); + + return 0; +} + +static int ov9734_power_on(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov9734 *ov9734 = to_ov9734(sd); + int ret; + + ret = regulator_bulk_enable(OV9734_NUM_SUPPLIES, ov9734->supplies); + if (ret) { + dev_err(dev, "failed to enable regulators: %d", ret); + return ret; + } + + ret = clk_prepare_enable(ov9734->clk); + if (ret) { + dev_err(dev, "failed to enable clock: %d", ret); + regulator_bulk_disable(OV9734_NUM_SUPPLIES, ov9734->supplies); + return ret; + } + + usleep_range(1000, 2000); + gpiod_set_value_cansleep(ov9734->reset, 0); + /* 8192 xvclk cycles before the first SCCB transaction, with margin */ + usleep_range(5000, 6000); + + return 0; +} + static int ov9734_identify_module(struct ov9734 *ov9734) { int ret; @@ -881,6 +932,8 @@ static void ov9734_remove(struct i2c_client *client) media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(ov9734->dev); + if (!pm_runtime_status_suspended(ov9734->dev)) + ov9734_power_off(ov9734->dev); pm_runtime_set_suspended(ov9734->dev); mutex_destroy(&ov9734->mutex); } @@ -915,11 +968,31 @@ static int ov9734_probe(struct i2c_client *client) "external clock %lu is not supported", freq); + ov9734->reset = devm_gpiod_get_optional(ov9734->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(ov9734->reset)) + return dev_err_probe(ov9734->dev, PTR_ERR(ov9734->reset), + "failed to get reset gpio\n"); + + for (unsigned int i = 0; i < OV9734_NUM_SUPPLIES; i++) + ov9734->supplies[i].supply = ov9734_supply_names[i]; + + ret = devm_regulator_bulk_get(ov9734->dev, OV9734_NUM_SUPPLIES, + ov9734->supplies); + if (ret) + return dev_err_probe(ov9734->dev, ret, + "failed to get regulators\n"); + v4l2_i2c_subdev_init(&ov9734->sd, client, &ov9734_subdev_ops); + + ret = ov9734_power_on(ov9734->dev); + if (ret) + return ret; + ret = ov9734_identify_module(ov9734); if (ret) { dev_err(ov9734->dev, "failed to find sensor: %d", ret); - return ret; + goto probe_error_power_off; } mutex_init(&ov9734->mutex); @@ -941,10 +1014,7 @@ static int ov9734_probe(struct i2c_client *client) goto probe_error_v4l2_ctrl_handler_free; } - /* - * Device is already turned on by i2c-core with ACPI domain PM. - * Enable runtime PM and turn off the device. - */ + /* Device is powered on above. Enable runtime PM and turn it off. */ pm_runtime_set_active(ov9734->dev); pm_runtime_enable(ov9734->dev); pm_runtime_idle(ov9734->dev); @@ -960,16 +1030,28 @@ static int ov9734_probe(struct i2c_client *client) probe_error_media_entity_cleanup_pm: pm_runtime_disable(ov9734->dev); + if (!pm_runtime_status_suspended(ov9734->dev)) + ov9734_power_off(ov9734->dev); pm_runtime_set_suspended(ov9734->dev); media_entity_cleanup(&ov9734->sd.entity); + v4l2_ctrl_handler_free(ov9734->sd.ctrl_handler); + mutex_destroy(&ov9734->mutex); + + return ret; probe_error_v4l2_ctrl_handler_free: v4l2_ctrl_handler_free(ov9734->sd.ctrl_handler); mutex_destroy(&ov9734->mutex); +probe_error_power_off: + ov9734_power_off(ov9734->dev); + return ret; } +static DEFINE_RUNTIME_DEV_PM_OPS(ov9734_pm_ops, ov9734_power_off, + ov9734_power_on, NULL); + static const struct acpi_device_id ov9734_acpi_ids[] = { { "OVTI9734", }, {} @@ -981,6 +1063,7 @@ static struct i2c_driver ov9734_i2c_driver = { .driver = { .name = "ov9734", .acpi_match_table = ov9734_acpi_ids, + .pm = pm_ptr(&ov9734_pm_ops), }, .probe = ov9734_probe, .remove = ov9734_remove, From bdd5d113c5fd88e98c38a8d0c7ff6499dcc6512b Mon Sep 17 00:00:00 2001 From: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:44:38 +0100 Subject: [PATCH 2/2] media: ipu-bridge: Add OV9734 for the Surface Laptop 1/2 front camera The front camera of the Surface Laptop 1 and 2 is an OmniVision OV9734 (ACPI HID OVTI9734), connected to CSI-2 port 1 of the IPU3 with one data lane. Without an entry in the supported sensor list, the bridge does not build the fwnode graph for it and the ov9734 driver fails to probe with "failed to check HW configuration: -6". Add the sensor with the 180 MHz link frequency required by the ov9734 driver. Tested on a Surface Laptop 2 together with the ov9734 power handling change: the bridge reports two connected cameras and the front camera streams with libcamera. Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 1aa595cbba32..2cbb3a920785 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -99,6 +99,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = { IPU_SENSOR_CONFIG("OVTI5675", 1, 450000000), /* Omnivision OV8856 */ IPU_SENSOR_CONFIG("OVTI8856", 3, 180000000, 360000000, 720000000), + /* Omnivision OV9734 - Surface Laptop 1/2 front camera */ + IPU_SENSOR_CONFIG("OVTI9734", 1, 180000000), /* Sony IMX471 */ IPU_SENSOR_CONFIG("SONY471A", 1, 200000000), /* Toshiba T4KA3 */