Skip to contentSkip to conversation

Add support for the Sony IMX681 camera sensor

PATCH In review Sergey Lebedev 1 participant 5 messages Nov 6 – Nov 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v10 cover Add support for the Sony IMX681 camera sensor

The Sony IMX681 is the user-facing camera on the Microsoft Surface Pro 11 for Business (Intel Lunar Lake, IPU7), ACPI device SONY0681. Without a driver the camera does not appear at all.

  1/3  dt-bindings: media: Add Sony IMX681        (mine)
  2/3  media: i2c: Add Sony IMX681 sensor driver  (Andre's, co-developed)
  3/3  media: ipu-bridge: Add Sony IMX681         (mine)

The driver is Andre's, reverse-engineered from I2C traces taken under Windows.

Changes in v10
==============

- 2/3: hold a runtime PM reference across probe. Setting the autosuspend delay with the usage count at 0 suspended the sensor in the middle of probe, and a later failure then powered it off a second time. Found by Sashiko on v9 2/3 and 3/3.
- All three: the Assisted-by tags are dropped; see the end of this letter.

1/3 and 3/3 are otherwise unchanged. The review and test tags are kept, German's Tested-by on 2/3 too: the change is limited to probe's runtime PM and its error path, both tested below.

While this sensor streams, IPU7's CSI-2 receiver logs "Received packet is too long" once per frame, and the frames are complete. Andre sees the same with his downstream driver, so it does not come from this series.

Tested with v10 on the Surface Pro 11 for Business, on v7.4-rc1 with [1],
[2] and [3] applied, KASAN and lockdep on:
- after probe the sensor stays active and suspends about 1 s later; v9 was already suspended when probe returned;
- probe forced to fail after the runtime PM setup and at registration, with a test-only parameter: no clock or regulator warning, where v9 gives three per failure (clock already disabled and unprepared, unbalanced regulator disable);
- v4l2-compliance 46 of 46, no warnings;
- 3844x2640 at 30.01 fps;
- the four flip states give the four Bayer orders, and EBUSY while streaming;
- runtime suspend after streaming, and capture after unbind and bind and after five module reloads;
- no KASAN or lockdep report;
- W=1 and sparse clean on x86_64, on i386 and without CONFIG_PM; dt_binding_check clean.

Tool use, per Documentation/process/generated-content.rst (Assisted-by tags in commits were dropped in 7.4-rc1):

* My contributions to this series were prepared with Claude Code (claude-opus-5-5); work by others in it is their own.
* This replaces any Assisted-by tags in earlier versions.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
v9: https://lore.kernel.org/all/[email protected]/

Andre Gilerson (1):
media: i2c: Add Sony IMX681 sensor driver

Sergey Lebedev (2):
dt-bindings: media: Add Sony IMX681
media: ipu-bridge: Add Sony IMX681

 .../bindings/media/i2c/sony,imx681.yaml       |  108 ++
 MAINTAINERS                                   |    8 +
 drivers/media/i2c/Kconfig                     |   10 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/imx681.c                    | 1034 +++++++++++++++++
 drivers/media/pci/intel/ipu-bridge.c          |    2 +
 6 files changed, 1163 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx681.yaml
 create mode 100644 drivers/media/i2c/imx681.c

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.54.0
#1 lore raw

PATCH v10 1/3 dt-bindings: media: Add Sony IMX681

The Sony IMX681 is a CMOS image sensor used as the user-facing camera on several Microsoft Surface devices. It operates from analog 2.8 V, digital 1.05 V and interface 1.8 V supplies, is programmable over I2C, and outputs 10-bit Bayer data over a two-lane MIPI CSI-2 D-PHY interface.

---
 .../bindings/media/i2c/sony,imx681.yaml       | 108 ++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx681.yaml
Documentation/devicetree/bindings/media/i2c/sony,imx681.yaml new file +108 -0
new file mode 100644
index 00000000000..24c55760547
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/sony,imx681.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sony IMX681 CMOS Image Sensor
+
+maintainers:
+  - Andre Gilerson <[email protected]>
+  - Sergey Lebedev <[email protected]>
+
+description:
+  The Sony IMX681 is a CMOS active pixel image sensor with a square pixel
+  array, used as the user-facing camera on several Microsoft Surface devices.
+  It operates from analog 2.8 V, digital 1.05 V and interface 1.8 V supplies,
+  is programmable over I2C, and outputs 10-bit Bayer data over a two-lane
+  MIPI CSI-2 D-PHY interface.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: sony,imx681
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Input clock (19.2 MHz)
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8 V)
+
+  dvdd-supply:
+    description: Digital power supply (1.05 V)
+
+  dovdd-supply:
+    description: Interface power supply (1.8 V)
+
+  reset-gpios:
+    description: Sensor reset (XCLR) GPIO, active low
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          data-lanes:
+            items:
+              - const: 1
+              - const: 2
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@10 {
+            compatible = "sony,imx681";
+            reg = <0x10>;
+            clocks = <&clock_cam>;
+            avdd-supply = <&vcc2v8_cam>;
+            dvdd-supply = <&vcc1v05_cam>;
+            dovdd-supply = <&vcc1v8_cam>;
+            reset-gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+            orientation = <0>;
+            rotation = <0>;
+
+            port {
+                imx681_ep: endpoint {
+                    data-lanes = <1 2>;
+                    link-frequencies = /bits/ 64 <969600000>;
+                    remote-endpoint = <&csi_in>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.54.0
#2 lore raw

PATCH v10 2/3 media: i2c: Add Sony IMX681 sensor driver

In reply to Sergey Lebedev

From: Andre Gilerson <[email protected]>

Add a V4L2 sub-device driver for the Sony IMX681, a 10-bit Bayer sensor on a two-lane CSI-2 bus. It offers a single 3844x2640 mode at 30 fps and controls for exposure, analogue and digital gain, vertical blanking, both flips and the sensor's test patterns. The part is enumerated as ACPI device SONY0681 on Intel platforms and by the sony,imx681 compatible elsewhere.

There is no public documentation for this sensor. The initialisation sequence was recovered from I2C traces taken under Windows, so imx681_init_regs[] keeps the writes whose meaning is not known; the registers that are CCS are written by name instead. The pixel rate is measured on the part rather than computed from the CSI-2 link, because the pixel array is clocked from a second PLL - the comment above IMX681_PIXEL_RATE records the measurement.

---
 MAINTAINERS                |    8 +
 drivers/media/i2c/Kconfig  |   10 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/imx681.c | 1034 ++++++++++++++++++++++++++++++++++++
 4 files changed, 1053 insertions(+)
 create mode 100644 drivers/media/i2c/imx681.c
MAINTAINERS +8 -0
index 93abbb31506..12b378fe272 100644
@@ -26194,6 +26194,14 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/sony,imx678.yaml
 F:	drivers/media/i2c/imx678.c
 
+SONY IMX681 SENSOR DRIVER
+M:	Andre Gilerson <[email protected]>
+M:	Sergey Lebedev <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/sony,imx681.yaml
+F:	drivers/media/i2c/imx681.c
+
 SONY MEMORYSTICK SUBSYSTEM
 M:	Maxim Levitsky <[email protected]>
 M:	Alex Dubov <[email protected]>
drivers/media/i2c/Kconfig +10 -0
index 11c30252540..ef18c38215b 100644
@@ -332,6 +332,16 @@ config VIDEO_IMX678
 	  To compile this driver as a module, choose M here: the
 	  module will be called imx678.
 
+config VIDEO_IMX681
+	tristate "Sony IMX681 sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the Sony
+	  IMX681 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called imx681.
+
 config VIDEO_MAX9271_LIB
 	tristate
 
drivers/media/i2c/Makefile +1 -0
index 59e31af457c..4abc1e96296 100644
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_IMX415) += imx415.o
 obj-$(CONFIG_VIDEO_IMX471) += imx471.o
 obj-$(CONFIG_VIDEO_IMX576) += imx576.o
 obj-$(CONFIG_VIDEO_IMX678) += imx678.o
+obj-$(CONFIG_VIDEO_IMX681) += imx681.o
 obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ISL7998X) += isl7998x.o
 obj-$(CONFIG_VIDEO_IT6625) += it6625.o
drivers/media/i2c/imx681.c new file +1034 -0

1,034 lines not on this page · raw message

Signature · 1 line
2.54.0
#3 lore raw

PATCH v10 3/3 media: ipu-bridge: Add Sony IMX681

In reply to Sergey Lebedev

The Microsoft Surface Pro 11 for Business (Intel Lunar Lake, IPU7) carries a Sony IMX681 as its user-facing sensor, enumerated as ACPI device SONY0681. Add it so ipu_bridge_connect_sensors() builds its half of the graph; without the entry the sensor is never connected, whatever driver is present.

One link frequency, 969.6 MHz, on two CSI-2 lanes.

---
 drivers/media/pci/intel/ipu-bridge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +2 -0
index 3739c4a2a8c..2759c776cfc 100644
@@ -124,6 +124,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {
 	IPU_SENSOR_CONFIG("SONY471A", 1, 200000000),
 	/* Sony IMX471 (found on Lenovo X1 Carbon G14) */
 	IPU_SENSOR_CONFIG("TBE20A0", 1, 200000000),
+	/* Sony IMX681 */
+	IPU_SENSOR_CONFIG("SONY0681", 1, 969600000),
 	/* STMicroelectronics VD55G1 (found on Lenovo X1 Carbon G14) */
 	IPU_SENSOR_CONFIG("TBE20A1", 1, 402000000),
 	/* Toshiba T4KA3 */
Signature · 1 line
2.54.0
#4 lore raw
In reply to Sergey Lebedev

Hi Sakari,

A ping on 1/3 and 2/3. You took 3/3 (ad5908546cc5 in media-committers next, thanks); the binding and the driver are still new in patchwork. Is anything needed from me for them?

Not about this series: ov13858 power v4 and gain v2, which I pinged on 6 November, have since got a Tested-by from Emfox Zhou.

Sergey