From 7201b28f3b9d338478603767f7a5068c1a539de0 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Mon, 7 Sep 2026 17:30:21 +0300 Subject: [PATCH 1/7] media: ipu-bridge: Add ipu_bridge_get_ipu6() Add ipu_bridge_get_ipu6() for obtaining the IPU 6 (or soon later) PCI device. This isn't technically a job of the IPU bridge, but the functionality is required in conjunction with the firmware definitions that necessitate the use of the IPU bridge on many systems. Signed-off-by: Sakari Ailus Reviewed-by: Antti Laakso Reviewed-by: Daniel Scally (cherry picked from commit eda381fd8c0c6f77cc0b3b8d777129eb884a08e0) [ backport: taken as a prerequisite of 8e3def7bf410, which uses the IPU6 PCI IDs from that this commit includes ] Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 13 +++++++++++++ include/media/ipu-bridge.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 271b987660c5c..69fbfbcf0f017 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -15,6 +15,7 @@ #include #include +#include #include #define ADEV_DEV(adev) ACPI_PTR(&((adev)->dev)) @@ -967,6 +968,18 @@ static int ipu_bridge_check_fwnode_graph(struct fwnode_handle *fwnode) return ipu_bridge_check_fwnode_graph(fwnode->secondary); } +struct pci_dev *ipu_bridge_get_ipu6(void) +{ + struct pci_dev *ipu = NULL; + + for (unsigned int i = 0; !ipu && ipu6_pci_tbl[i].vendor; i++) + ipu = pci_get_device(ipu6_pci_tbl[i].vendor, + ipu6_pci_tbl[i].device, NULL); + + return ipu; +} +EXPORT_SYMBOL_NS_GPL(ipu_bridge_get_ipu6, "INTEL_IPU_BRIDGE"); + static DEFINE_MUTEX(ipu_bridge_mutex); int ipu_bridge_init(struct device *dev, diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index 16fac765456e8..b46b6693f856b 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -169,11 +169,13 @@ struct ipu_bridge { }; #if IS_ENABLED(CONFIG_IPU_BRIDGE) +struct pci_dev *ipu_bridge_get_ipu6(void); int ipu_bridge_init(struct device *dev, ipu_parse_sensor_fwnode_t parse_sensor_fwnode); int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor); int ipu_bridge_instantiate_vcm(struct device *sensor); #else +static inline struct pci_dev *ipu_bridge_get_ipu6(void) { return NULL; } /* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */ #define ipu_bridge_init(dev, parse_sensor_fwnode) (0) static inline int ipu_bridge_instantiate_vcm(struct device *s) { return 0; } From eaed2310aa532793aca0960603ff85acb323e0cd Mon Sep 17 00:00:00 2001 From: Fernando Rimoli Date: Wed, 2 Sep 2026 16:23:18 +0200 Subject: [PATCH 2/7] media: i2c: ov5693: Gate the MIPI clock lane for non-continuous clock The ov5693 never programs MIPI_CTRL00 (0x4800), leaving it at its 0x00 power-on default, which lets the MIPI clock run freely. The IPU3 CSI-2 receiver tolerates this, but the IPU6 receiver (e.g. on Microsoft Surface Pro 7+, Pro 8, Pro 9 and Surface Go 4) fails to lock onto the link, so the sensor streams but capture times out with "stream stop time out". On most affected machines no frames arrive at all; on some the failure is intermittent. Gate the clock lane while idle at stream on when the endpoint requests a non-continuous clock. Only the gate bit is touched, so platforms that do not request it are unaffected. No counterpart is needed at stream off, as the link is down by then and the register returns to its default when the sensor is powered off. The property is supplied by the ipu-bridge in a subsequent patch. Link: https://github.com/linux-surface/linux-surface/pull/2171 Co-developed-by: Arsalan Naeem Signed-off-by: Arsalan Naeem Signed-off-by: Fernando Rimoli Tested-by: Jakob Berg Jespersen # Surface Pro 7+, IPU6 Tiger Lake Tested-by: Fil Dunsky # Surface Pro 8, IPU6 Tiger Lake (8086:9a19) Tested-by: Lucas Lis # Surface Pro 7+, IPU6 Tiger Lake (0x9a19) Tested-by: Kengo Oki # Surface Go 4, IPU6 Alder Lake-N 8086:462e Signed-off-by: Sakari Ailus (cherry picked from commit 0e12587945f66d5b8c72be145b95fc5f109b3a32) Patchset: cameras --- drivers/media/i2c/ov5693.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index d90f135bc55f4..37f24f4d6e91d 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -35,6 +35,11 @@ #define OV5693_STOP_STREAMING 0x00 #define OV5693_SW_RESET 0x01 +/* MIPI transmitter control */ +#define OV5693_MIPI_CTRL00_REG CCI_REG8(0x4800) +/* Gate the clock lane when there is no packet to transmit */ +#define OV5693_MIPI_CTRL00_CLOCK_LANE_GATE BIT(5) + #define OV5693_REG_CHIP_ID CCI_REG16(0x300a) /* Yes, this is right. The datasheet for the OV5693 gives its ID as 0x5690 */ #define OV5693_CHIP_ID 0x5690 @@ -144,6 +149,9 @@ struct ov5693_device { struct regulator_bulk_data supplies[OV5693_NUM_SUPPLIES]; struct clk *xvclk; + /* Gate the MIPI clock lane when idle (CSI-2 non-continuous clock) */ + bool clock_ncont; + struct ov5693_mode { struct v4l2_rect crop; struct v4l2_mbus_framefmt format; @@ -611,6 +619,19 @@ static int ov5693_enable_streaming(struct ov5693_device *ov5693, bool enable) { int ret = 0; + /* + * Gate the MIPI clock lane while idle if the CSI-2 link is configured + * for a non-continuous clock. Only that bit is touched, and only in + * that case, so the register keeps whatever the platform left in it + * and the clock stays free-running as before everywhere else. It + * needs no counterpart at stream off: the link is down by then, and + * the register returns to its default when the sensor is powered off. + */ + if (enable && ov5693->clock_ncont) + cci_update_bits(ov5693->regmap, OV5693_MIPI_CTRL00_REG, + OV5693_MIPI_CTRL00_CLOCK_LANE_GATE, + OV5693_MIPI_CTRL00_CLOCK_LANE_GATE, &ret); + cci_write(ov5693->regmap, OV5693_SW_STREAM_REG, enable ? OV5693_START_STREAMING : OV5693_STOP_STREAMING, &ret); @@ -1259,6 +1280,9 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) goto out_free_bus_cfg; } + ov5693->clock_ncont = bus_cfg.bus.mipi_csi2.flags & + V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK; + out_free_bus_cfg: v4l2_fwnode_endpoint_free(&bus_cfg); From 016e585d5c750cd432a1aec05bd73f9ba7955a78 Mon Sep 17 00:00:00 2001 From: Fernando Rimoli Date: Wed, 2 Sep 2026 16:23:19 +0200 Subject: [PATCH 3/7] media: ipu-bridge: Assign endpoint property indices dynamically Index the ep_properties array dynamically instead of plain numerical values as is done in mipi-disco-img.c. Signed-off-by: Fernando Rimoli Tested-by: Jakob Berg Jespersen # Surface Pro 7+, IPU6 Tiger Lake Tested-by: Fil Dunsky # Surface Pro 8, IPU6 Tiger Lake (8086:9a19) Tested-by: Lucas Lis # Surface Pro 7+, IPU6 Tiger Lake (0x9a19) Tested-by: Kengo Oki # Surface Go 4, IPU6 Alder Lake-N 8086:462e Signed-off-by: Sakari Ailus (cherry picked from commit 3436405beac895b589e2ad4a7be3b57e17605057) Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 27 ++++++++++++++------------- include/media/ipu-bridge.h | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 69fbfbcf0f017..8eb52dd99ee1d 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -499,6 +499,7 @@ 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; sensor->prop_names = prop_names; @@ -556,21 +557,21 @@ static void ipu_bridge_create_fwnode_properties( PROPERTY_ENTRY_REF_ARRAY("lens-focus", sensor->vcm_ref); } - sensor->ep_properties[0] = PROPERTY_ENTRY_U32( - sensor->prop_names.bus_type, - V4L2_FWNODE_BUS_TYPE_CSI2_DPHY); - sensor->ep_properties[1] = PROPERTY_ENTRY_U32_ARRAY_LEN( - sensor->prop_names.data_lanes, - bridge->data_lanes, sensor->lanes); - sensor->ep_properties[2] = PROPERTY_ENTRY_REF_ARRAY( - sensor->prop_names.remote_endpoint, - sensor->local_ref); + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_BUS_TYPE)] = + PROPERTY_ENTRY_U32(names->bus_type, + V4L2_FWNODE_BUS_TYPE_CSI2_DPHY); + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_DATA_LANES)] = + PROPERTY_ENTRY_U32_ARRAY_LEN(names->data_lanes, + bridge->data_lanes, sensor->lanes); + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_REMOTE_EP)] = + PROPERTY_ENTRY_REF_ARRAY(names->remote_endpoint, + sensor->local_ref); if (cfg->nr_link_freqs > 0) - sensor->ep_properties[3] = PROPERTY_ENTRY_U64_ARRAY_LEN( - sensor->prop_names.link_frequencies, - cfg->link_freqs, - cfg->nr_link_freqs); + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_LINK_FREQUENCIES)] = + PROPERTY_ENTRY_U64_ARRAY_LEN(names->link_frequencies, + cfg->link_freqs, + cfg->nr_link_freqs); sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes, diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index b46b6693f856b..e8aeb23dc5a21 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -64,6 +64,23 @@ enum ipu_sensor_swnodes { SWNODE_COUNT }; +enum ipu_bridge_ep_props { + IPU_BRIDGE_EP_BUS_TYPE, + IPU_BRIDGE_EP_DATA_LANES, + IPU_BRIDGE_EP_REMOTE_EP, + IPU_BRIDGE_EP_LINK_FREQUENCIES, + IPU_BRIDGE_EP_NUM_OF, + IPU_BRIDGE_EP_NUM_ENTRIES +}; + +/* + * Get the index of the next property in a property array, with a given maximum + * value. + */ +#define IPU_BRIDGE_NEXT_PROPERTY(index, max) \ + (WARN_ON((index) > IPU_BRIDGE_##max) ? \ + IPU_BRIDGE_##max : (index)++) + /* Data representation as it is in ACPI SSDB buffer */ struct ipu_sensor_ssdb { u8 version; @@ -141,7 +158,7 @@ struct ipu_sensor { const char *vcm_type; struct ipu_property_names prop_names; - struct property_entry ep_properties[5]; + struct property_entry ep_properties[IPU_BRIDGE_EP_NUM_ENTRIES]; struct property_entry dev_properties[5]; struct property_entry ipu_properties[3]; struct property_entry ivsc_properties[1]; From 0116c6190145ff81b9c8eb141c5ce896f90191fd Mon Sep 17 00:00:00 2001 From: Fernando Rimoli Date: Wed, 2 Sep 2026 16:23:20 +0200 Subject: [PATCH 4/7] media: ipu-bridge: Match sensor configs per IPU and add config flags Some sensors need different treatment depending on which IPU they are connected to, so the ACPI HID alone is not enough. Match on an optional list of IPU PCI product IDs. Entries for one HID must be adjacent, IPU-specific ones first, so the generic entry is skipped once a specific one has matched. Signed-off-by: Fernando Rimoli Tested-by: Jakob Berg Jespersen # Surface Pro 7+, IPU6 Tiger Lake Tested-by: Fil Dunsky # Surface Pro 8, IPU6 Tiger Lake (8086:9a19) Tested-by: Lucas Lis # Surface Pro 7+, IPU6 Tiger Lake (0x9a19) Tested-by: Kengo Oki # Surface Go 4, IPU6 Alder Lake-N 8086:462e Signed-off-by: Sakari Ailus (cherry picked from commit b883954d842f57f6f349bbbdf3d4347db3a416dc) Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 35 ++++++++++++++++++++++++++++ include/media/ipu-bridge.h | 26 +++++++++++++++++---- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 8eb52dd99ee1d..a31d3f34f6360 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -901,8 +902,28 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, return ret; } +/* + * Whether a sensor config applies to the IPU this bridge sits on. A config + * listing PCI product IDs only applies to those IPUs. + */ +static bool ipu_bridge_config_matches(const struct ipu_sensor_config *cfg, + struct ipu_bridge *bridge) +{ + const u16 *id; + + if (!cfg->pci_ids) + return true; + + for (id = cfg->pci_ids; *id; id++) + if (*id == bridge->pci_id) + return true; + + return false; +} + static int ipu_bridge_connect_sensors(struct ipu_bridge *bridge) { + const char *done_hid = NULL; unsigned int i; int ret; @@ -910,9 +931,22 @@ static int ipu_bridge_connect_sensors(struct ipu_bridge *bridge) const struct ipu_sensor_config *cfg = &ipu_supported_sensors[i]; + /* + * Entries for one HID are adjacent, IPU-specific ones first, + * so the generic entry is skipped once a specific one has + * matched and the sensor is not connected twice. + */ + if (done_hid && !strcmp(cfg->hid, done_hid)) + continue; + + if (!ipu_bridge_config_matches(cfg, bridge)) + continue; + ret = ipu_bridge_connect_sensor(cfg, bridge); if (ret) goto err_unregister_sensors; + + done_hid = cfg->hid; } return 0; @@ -1008,6 +1042,7 @@ int ipu_bridge_init(struct device *dev, sizeof(bridge->ipu_node_name)); bridge->ipu_hid_node.name = bridge->ipu_node_name; bridge->dev = dev; + bridge->pci_id = dev_is_pci(dev) ? to_pci_dev(dev)->device : 0; bridge->parse_sensor_fwnode = parse_sensor_fwnode; ret = software_node_register(&bridge->ipu_hid_node); diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index e8aeb23dc5a21..c562db794ca8b 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -17,13 +17,24 @@ #define IPU_SENSOR_ROTATION_NORMAL 0 #define IPU_SENSOR_ROTATION_INVERTED 1 -#define IPU_SENSOR_CONFIG(_HID, _NR, ...) \ - (const struct ipu_sensor_config) { \ - .hid = _HID, \ - .nr_link_freqs = _NR, \ - .link_freqs = { __VA_ARGS__ } \ +/* + * Sensor config specific to one or more IPUs, identified by their PCI product + * IDs, with flags describing what the sensor needs there. Entries for one HID + * must be adjacent in ipu_supported_sensors[], with the IPU-specific ones + * before the generic one. + */ +#define IPU_SENSOR_CONFIG_MATCH_FL(_HID, _IDS, _FLAGS, _NR, ...) \ + (const struct ipu_sensor_config) { \ + .hid = _HID, \ + .pci_ids = _IDS, \ + .flags = _FLAGS, \ + .nr_link_freqs = _NR, \ + .link_freqs = { __VA_ARGS__ } \ } +#define IPU_SENSOR_CONFIG(_HID, _NR, ...) \ + IPU_SENSOR_CONFIG_MATCH_FL(_HID, NULL, 0, _NR, __VA_ARGS__) + #define NODE_SENSOR(_HID, _PROPS) \ (const struct software_node) { \ .name = _HID, \ @@ -132,6 +143,9 @@ struct ipu_node_names { struct ipu_sensor_config { const char *hid; + /* Zero-terminated list of IPU PCI product IDs, NULL for any IPU */ + const u16 *pci_ids; + const u32 flags; const u8 nr_link_freqs; const u64 link_freqs[MAX_NUM_LINK_FREQS]; }; @@ -177,6 +191,8 @@ typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev, struct ipu_bridge { struct device *dev; + /* PCI product ID of the IPU, 0 if it is not a PCI device */ + u16 pci_id; ipu_parse_sensor_fwnode_t parse_sensor_fwnode; char ipu_node_name[ACPI_ID_LEN]; struct software_node ipu_hid_node; From 391c3aae130ece6bc9026b1035d9d47e474e5183 Mon Sep 17 00:00:00 2001 From: Fernando Rimoli Date: Wed, 2 Sep 2026 16:23:21 +0200 Subject: [PATCH 5/7] media: ipu-bridge: Request non-continuous clock for ov5693 on IPU6 The ov5693 (INT33BE / OVTI5693) needs its MIPI clock lane gated while idle for the IPU6 CSI-2 receiver to lock onto the link, which the sensor driver does when the endpoint requests a non-continuous clock. The same sensor works with a free-running clock on the IPU3, so request it only for the IPU6 variants where it has been confirmed on hardware: Tiger Lake, Alder Lake-P and Alder Lake-N. Signed-off-by: Fernando Rimoli Tested-by: Jakob Berg Jespersen # Surface Pro 7+, IPU6 Tiger Lake Tested-by: Fil Dunsky # Surface Pro 8, IPU6 Tiger Lake (8086:9a19) Tested-by: Lucas Lis # Surface Pro 7+, IPU6 Tiger Lake (0x9a19) Tested-by: Kengo Oki # Surface Go 4, IPU6 Alder Lake-N 8086:462e Signed-off-by: Sakari Ailus (cherry picked from commit 8e3def7bf4102c5b32b597b2f6ea1419174fc480) [ backport: linux-surface's "Add camera support for Surface Pro 9" lists OVTI5693 after INT33F0 rather than in sorted order, so the new OVTI5693 entry goes just before that one instead of at the sorted position; no other change ] Assisted-by: LLM Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 18 ++++++++++++++++++ include/media/ipu-bridge.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index a31d3f34f6360..271afcc22ac67 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -50,6 +50,14 @@ * * Please keep the list sorted by ACPI HID. */ +/* IPU6 variants whose CSI-2 receiver needs the ov5693 clock lane gated */ +static const u16 ipu6_ov5693_ncont_clk[] = { + PCI_DEVICE_ID_INTEL_IPU6, /* Tiger Lake */ + PCI_DEVICE_ID_INTEL_IPU6EP_ADLP, /* Alder Lake-P */ + PCI_DEVICE_ID_INTEL_IPU6EP_ADLN, /* Alder Lake-N */ + 0 +}; + static const struct ipu_sensor_config ipu_supported_sensors[] = { /* Himax HM1092 */ IPU_SENSOR_CONFIG("HIMX1092", 2, 180000000, 180480000), @@ -62,10 +70,16 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = { /* GalaxyCore GC0310 */ IPU_SENSOR_CONFIG("INT0310", 1, 55692000), /* Omnivision OV5693 */ + IPU_SENSOR_CONFIG_MATCH_FL("INT33BE", ipu6_ov5693_ncont_clk, + IPU_BR_FL_CSI2_CLK_NONCONTINUOUS, + 1, 419200000), IPU_SENSOR_CONFIG("INT33BE", 1, 419200000), /* Onsemi MT9M114 */ IPU_SENSOR_CONFIG("INT33F0", 1, 384000000), /* Omnivision OV5693 - Surface Pro 9 */ + IPU_SENSOR_CONFIG_MATCH_FL("OVTI5693", ipu6_ov5693_ncont_clk, + IPU_BR_FL_CSI2_CLK_NONCONTINUOUS, + 1, 419200000), IPU_SENSOR_CONFIG("OVTI5693", 1, 419200000), /* Omnivision OV13858 - Surface Pro 9 */ IPU_SENSOR_CONFIG("OVTID858", 4, 540000000), @@ -574,6 +588,10 @@ static void ipu_bridge_create_fwnode_properties( cfg->link_freqs, cfg->nr_link_freqs); + if (cfg->flags & IPU_BR_FL_CSI2_CLK_NONCONTINUOUS) + sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_CLOCK_NONCONTINUOUS)] = + PROPERTY_ENTRY_BOOL("clock-noncontinuous"); + sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes, bridge->data_lanes, sensor->lanes); diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index c562db794ca8b..760f0767ce58f 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -17,6 +17,10 @@ #define IPU_SENSOR_ROTATION_NORMAL 0 #define IPU_SENSOR_ROTATION_INVERTED 1 +/* Flags for struct ipu_sensor_config */ +/* The sensor's CSI-2 transmitter needs a non-continuous clock */ +#define IPU_BR_FL_CSI2_CLK_NONCONTINUOUS BIT(0) + /* * Sensor config specific to one or more IPUs, identified by their PCI product * IDs, with flags describing what the sensor needs there. Entries for one HID @@ -80,6 +84,7 @@ enum ipu_bridge_ep_props { IPU_BRIDGE_EP_DATA_LANES, IPU_BRIDGE_EP_REMOTE_EP, IPU_BRIDGE_EP_LINK_FREQUENCIES, + IPU_BRIDGE_EP_CLOCK_NONCONTINUOUS, IPU_BRIDGE_EP_NUM_OF, IPU_BRIDGE_EP_NUM_ENTRIES }; From 60b5460ae0c525e1e84533e63a7730b8ae661cc3 Mon Sep 17 00:00:00 2001 From: Fernando Rimoli Date: Sun, 13 Sep 2026 20:38:40 +0100 Subject: [PATCH 6/7] media: ipu-bridge: Keep the clock-noncontinuous property name out of rodata The software nodes ipu-bridge registers on a successful init are never unregistered. There is no module_exit and no remove hook, and every software_node_unregister_node_group() call sits on an error unwind label inside ipu_bridge_init(), so on success the nodes stay registered and readable after the module is unloaded, which a later rebind relies on. Nothing reachable from a registered node may therefore point into the module image. PROPERTY_ENTRY_BOOL() stores a pointer to its name, so the "clock-noncontinuous" string literal leaves the surviving node carrying a dangling property name once ipu-bridge is gone. Add the name to struct ipu_property_names, which is copied by value into each struct ipu_sensor, and use that copy, as every other endpoint property name already does. Fixes: 8e3def7bf410 ("media: ipu-bridge: Request non-continuous clock for ov5693 on IPU6") Reported-by: D. Manresa Closes: https://lore.kernel.org/linux-media/20260905211307.542810-1-dmanresa@gmail.com/ Signed-off-by: Fernando Rimoli Signed-off-by: Sakari Ailus (cherry picked from commit a20c843c9bc40ab8703a2b17fcbc69532baca692) Patchset: cameras --- drivers/media/pci/intel/ipu-bridge.c | 3 ++- include/media/ipu-bridge.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 271afcc22ac67..b55578be327f6 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -244,6 +244,7 @@ static const struct ipu_property_names prop_names = { .data_lanes = "data-lanes", .remote_endpoint = "remote-endpoint", .link_frequencies = "link-frequencies", + .clock_noncontinuous = "clock-noncontinuous", }; static const char * const ipu_vcm_types[] = { @@ -590,7 +591,7 @@ static void ipu_bridge_create_fwnode_properties( if (cfg->flags & IPU_BR_FL_CSI2_CLK_NONCONTINUOUS) sensor->ep_properties[IPU_BRIDGE_NEXT_PROPERTY(i, EP_CLOCK_NONCONTINUOUS)] = - PROPERTY_ENTRY_BOOL("clock-noncontinuous"); + PROPERTY_ENTRY_BOOL(names->clock_noncontinuous); sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes, diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index 760f0767ce58f..3ef94c2b76789 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -135,6 +135,7 @@ struct ipu_property_names { char data_lanes[11]; char remote_endpoint[16]; char link_frequencies[17]; + char clock_noncontinuous[20]; }; struct ipu_node_names { From ac46d69bdea313751bc4527850d870fbbeee1658 Mon Sep 17 00:00:00 2001 From: Sergey Lebedev Date: Wed, 30 Sep 2026 07:33:12 +0000 Subject: [PATCH 7/7] media: i2c: ov13858: add horizontal and vertical flip controls The Microsoft Surface Pro 11 for Business (Intel) mounts this sensor upside down, as commit b238116ccd4b ("media: ipu-bridge: Add upside-down quirk for Surface Pro 11") records, and the driver has no flip controls to compensate. Add V4L2_CID_HFLIP and V4L2_CID_VFLIP on bits 3 and 4 of register 0x3820. The mirror bit is active low, as in Intel's out-of-tree ov13858 driver. The Bayer order does not change with either flip, so the controls do not set V4L2_CTRL_FLAG_MODIFY_LAYOUT. They are clustered, and grabbed while streaming. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Sergey Lebedev Tested-by: German Pablo Lindo Signed-off-by: Sakari Ailus (cherry picked from commit deb515fcc369f16ffe099a8b3b940785180dfc48) Patchset: cameras --- drivers/media/i2c/ov13858.c | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c index 015493a164309..8e2065b089609 100644 --- a/drivers/media/i2c/ov13858.c +++ b/drivers/media/i2c/ov13858.c @@ -77,6 +77,12 @@ #define OV13858_DGTL_GAIN_DEFAULT 1024 /* Default gain = 1 X */ #define OV13858_DGTL_GAIN_STEP 1 /* Each step = 1/1024 */ +/* Readout direction */ +#define OV13858_REG_FORMAT1 0x3820 +#define OV13858_FORMAT1_VFLIP BIT(4) +/* Horizontal flip, active low: every mode table sets this bit */ +#define OV13858_FORMAT1_HFLIP_N BIT(3) + /* Test Pattern Control */ #define OV13858_REG_TEST_PATTERN 0x4503 #define OV13858_TEST_PATTERN_ENABLE BIT(7) @@ -1051,6 +1057,8 @@ struct ov13858 { struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; + struct v4l2_ctrl *hflip; + struct v4l2_ctrl *vflip; /* Current mode */ const struct ov13858_mode *cur_mode; @@ -1331,6 +1339,31 @@ static int ov13858_enable_test_pattern(struct ov13858 *ov13858, u32 pattern) OV13858_REG_VALUE_08BIT, val); } +static int ov13858_update_flips(struct ov13858 *ov13858) +{ + u32 val; + int ret; + + ret = ov13858_read_reg(ov13858, OV13858_REG_FORMAT1, + OV13858_REG_VALUE_08BIT, &val); + if (ret) + return ret; + + if (ov13858->vflip->val) + val |= OV13858_FORMAT1_VFLIP; + else + val &= ~OV13858_FORMAT1_VFLIP; + + /* The mirror bit is active low, as it is on ov13b10. */ + if (ov13858->hflip->val) + val &= ~OV13858_FORMAT1_HFLIP_N; + else + val |= OV13858_FORMAT1_HFLIP_N; + + return ov13858_write_reg(ov13858, OV13858_REG_FORMAT1, + OV13858_REG_VALUE_08BIT, val); +} + static int ov13858_set_ctrl(struct v4l2_ctrl *ctrl) { struct ov13858 *ov13858 = container_of(ctrl->handler, @@ -1377,6 +1410,10 @@ static int ov13858_set_ctrl(struct v4l2_ctrl *ctrl) ov13858->cur_mode->height + ctrl->val); break; + case V4L2_CID_HFLIP: + case V4L2_CID_VFLIP: + ret = ov13858_update_flips(ov13858); + break; case V4L2_CID_TEST_PATTERN: ret = ov13858_enable_test_pattern(ov13858, ctrl->val); break; @@ -1603,6 +1640,13 @@ static int ov13858_set_stream(struct v4l2_subdev *sd, int enable) pm_runtime_put(ov13858->dev); } + /* + * Do not let the flips change while streaming. ov13858->mutex is the + * control handler's own lock and is held here, hence the __ form. + */ + __v4l2_ctrl_grab(ov13858->hflip, enable); + __v4l2_ctrl_grab(ov13858->vflip, enable); + mutex_unlock(&ov13858->mutex); return ret; @@ -1745,6 +1789,12 @@ static int ov13858_init_controls(struct ov13858 *ov13858) OV13858_DGTL_GAIN_MIN, OV13858_DGTL_GAIN_MAX, OV13858_DGTL_GAIN_STEP, OV13858_DGTL_GAIN_DEFAULT); + ov13858->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, + V4L2_CID_HFLIP, 0, 1, 1, 0); + ov13858->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, + V4L2_CID_VFLIP, 0, 1, 1, 0); + v4l2_ctrl_cluster(2, &ov13858->hflip); + v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_TEST_PATTERN, ARRAY_SIZE(ov13858_test_pattern_menu) - 1,