Skip to contentSkip to conversation

Add bindings and driver for Sony IMX908

PATCH Superseded Lachlan Michael 3 participants 6 messages Oct 16

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add bindings and driver for Sony IMX908

This series adds device tree bindings and a V4L2 sub-device driver for the Sony IMX908 image sensor.

The IMX908 is an 8.39 MP (3856x2176) CMOS image sensor with a MIPI CSI-2 output interface. The driver supports RAW10 and RAW12 output formats, exposure and analogue gain controls, image flipping, blanking controls and test pattern generation.

HDR modes and RAW16 output are not currently supported.

The driver has been tested with libcamera on Raspberry Pi 5 based hardware.

---
Changes in v4:
PATCH 1:
- No changes from v3

PATCH 2:
- Refined sensor initialization for the updated settings, including register-address/value corrections and bit-depth-specific programming
- Removed crop support; the driver now reports the fixed 3856x2176 active-area format and no longer programs crop registers.
- Updated HBLANK and exposure control limits for fixed geometry, including exposure adjustment when VBLANK changes.
- Improved stream start/stop error handling and ensured failures during setup release the runtime-PM reference.
- Consolidated power-on/off into runtime-PM callbacks, corrected probe/ remove power sequencing, and added builds without CONFIG_PM.
- Cleanups and bugfixes from the v3 review comments (thanks to Sakari and Laurent).

Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
PATCH 1:
- Adjust the binding description to match the actual hardware: the I2C target address is selected by the SLAMODE pins, not fixed to 0x1A.
- Add the standard video-interface schema reference so the endpoint and remote-endpoint validation match the media DT conventions.

PATCH 2:
- Correct link-frequency indexing mapping to match the sensor DATARATE_SEL values and the frequency ordering
- Changed the pixel_rate to 16-pixel-per-clocks based on datasheet mode values
- Clean up the constant names, register definitions and comments in response to review feedback.
- Remove various (uneeded) checks in code based on feedback
- Remove cached vmax/hmax and recalculated where necessary
- Drop pixel_rate and test_pattern pointers from struct
- Remove read-only controls set_ctrl switch
- Remove event handlers
- Remove uneeded delays at startup
- Simplify runtime_resume/suspend functions
- Remove the 4k recording-area in favour of larger active area
- Use the same constraints for VMAX for crop and all pixel mode to simplify the driver logic by removing branching
- Rework HMAX based on the fact that the whole line is always read even in crop mode. HMAX varies in all modes now, but not with horizontal crop.
- Minor edits and bugfixes

Link to v2: https://lore.kernel.org/r/[email protected]/

Changes in v2:
PATCH 1:
- Reword subject to drop the redundant "bindings" suffix.
- Reference video-interfaces.yaml for the endpoint and switch to unevaluatedProperties, fixing the remote-endpoint check.
- Drop "link-frequencies: true".
- MAINTAINERS: drop the L: line.
- MAINTAINERS: move the driver F: line to patch 2.

PATCH 2:
- Treat the pixel rate as a fixed sensor property (594 MHz, 8 px/clock), read-only.
- Compute HMAX from both the array and MIPI link floors.
- Express HBLANK in pixels with a step of 8; keep HMAX fixed in crop mode.
- Drop struct imx908_mode; cache hmax/vmax directly.
- Change the link-frequency table to s64.
- Fix the probe error-unwind ordering.
- Be silent on success (chip ID print is now dev_dbg).
- Drop redundant comments.
- Kconfig: fix a "module will be called" typo.

Link to v1: https://lore.kernel.org/r/[email protected]

Lachlan Michael (2):
media: dt-bindings: imx908: Add Sony IMX908 sensor
media: i2c: Add Sony IMX908 image sensor driver

 .../bindings/media/i2c/sony,imx908.yaml       |  108 ++
 MAINTAINERS                                   |    5 +
 drivers/media/i2c/Kconfig                     |   11 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/imx908.c                    | 1168 +++++++++++++++++
 5 files changed, 1293 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml
 create mode 100644 drivers/media/i2c/imx908.c
Signature · 1 line
2.47.3
#1 lore raw

PATCH v4 1/2 media: dt-bindings: imx908: Add Sony IMX908 sensor

The Sony IMX908 is an 8.39 megapixel (3856x2176) CMOS image sensor with a MIPI CSI-2 output interface, supporting RAW10 and RAW12 output over 2 or 4 data lanes.

Add device tree bindings for the sensor.

---
No changes in v4 from v3

---
 .../bindings/media/i2c/sony,imx908.yaml       | 108 ++++++++++++++++++
 MAINTAINERS                                   |   5 +
 2 files changed, 113 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml
Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml new file +108 -0
new file mode 100644
index 000000000000..828db1175e2f
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2026 Sony Semiconductor Solutions
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/sony,imx908.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sony IMX908 CMOS Image Sensor
+
+maintainers:
+  - Lachlan Michael <[email protected]>
+
+description:
+  Sony IMX908 diagonal 6.42 mm (Type 1/2.8) CMOS active pixel type
+  solid-state image sensor with a square pixel array and 8.39 M
+  (3856x2176) pixels, supporting MIPI CSI-2 output with
+  RAW10 and RAW12 formats, configured as either 2 or 4 data lanes.
+  The I2C target address is selected by the SLAMODE0 and SLAMODE1 pins.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: sony,imx908
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Input clock (24 MHz, 27 MHz, 37.125 MHz, 72 MHz or 74.25 MHz)
+    maxItems: 1
+
+  dvdd-supply:
+    description: Digital supply voltage (1.1V)
+
+  ovdd-supply:
+    description: Interface supply voltage (1.8V)
+
+  avdd-supply:
+    description: Analog supply voltage (3.3V)
+
+  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:
+            oneOf:
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - dvdd-supply
+  - ovdd-supply
+  - avdd-supply
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+         camera@1a {
+            compatible = "sony,imx908";
+            reg = <0x1a>;
+            clocks = <&cdce913_cam0 0>;
+            dvdd-supply = <&cam_dvdd_1r1v>;
+            ovdd-supply = <&cam_ovdd_1r8v>;
+            avdd-supply = <&cam_avdd_3r3v>;
+            reset-gpios = <&tca6416_cam0 5 GPIO_ACTIVE_LOW>;
+
+            port {
+                imx908_out: endpoint {
+                    data-lanes = <1 2 3 4>;
+                    link-frequencies = /bits/ 64 <720000000>;
+                    remote-endpoint = <&csi0_in>;
+                };
+            };
+        };
+    };
+
MAINTAINERS +5 -0
index 5d39ec6feb03..91aaba2cf764 100644
@@ -25578,6 +25578,11 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/sony,imx678.yaml
 F:	drivers/media/i2c/imx678.c
 
+SONY IMX908 SENSOR DRIVER
+M:	Lachlan Michael <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml
+
 SONY MEMORYSTICK SUBSYSTEM
 M:	Maxim Levitsky <[email protected]>
 M:	Alex Dubov <[email protected]>
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH v4 1/2] media: dt-bindings: imx908: Add Sony IMX908 sensor

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] dt-bindings: Top-level additionalProperties: false breaks allOf references --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dt-bindings: Top-level additionalProperties: false breaks allOf references --

commit 4681de18fac98c8519949f316873059d73610eb4
Author: Lachlan Michael <[email protected]>

media: dt-bindings: imx908: Add Sony IMX908 sensor

This commit adds a new device tree binding for the Sony IMX908 CMOS image sensor. It defines properties for a MIPI CSI-2 interface outputting RAW10 and RAW12 formats.

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml new file +0 -0
new file mode 100644
index 0000000000000..828db1175e2f5

[ ... ]

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml new file +4 -0
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:

[ ... ]

Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/sony,imx908.yaml new file +10 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - dvdd-supply
+  - ovdd-supply
+  - avdd-supply
+  - port
+
+additionalProperties: false

[Severity: Medium]
Since this schema includes an allOf reference to video-interface-devices.yaml, should this use unevaluatedProperties: false instead of
additionalProperties: false?

Using additionalProperties only considers the properties explicitly declared in the local properties dictionary and ignores properties introduced via $ref in an allOf block. If a device tree node defines any valid inherited standard property, such as rotation or orientation, schema validation will incorrectly reject it as an invalid additional property. Changing to
unevaluatedProperties: false will correctly allow properties evaluated by the referenced schemas.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH v4 1/2] media: dt-bindings: imx908: Add Sony IMX908 sensor

In reply to Lachlan Michael
Quoted 7 lines · Lachlan Michael

The Sony IMX908 is an 8.39 megapixel (3856x2176) CMOS image sensor with a MIPI CSI-2 output interface, supporting RAW10 and RAW12 output over 2 or 4 data lanes.

Add device tree bindings for the sensor.

Missing Conor's and Laurent's tags. It is your responsibility to add them when sending new versions.

Rob

#4 lore raw

PATCH v4 2/2 media: i2c: Add Sony IMX908 image sensor driver

In reply to Lachlan Michael

The IMX908 is an 8.39 MP (3856x2176) CMOS image sensor with a MIPI CSI-2 output interface. The driver supports RAW10 and RAW12 output formats, exposure and analogue gain controls, image flipping, blanking controls and test pattern generation.

HDR modes and RAW16 output are not currently supported.

---
Changes in v4:
- Refined sensor initialization for the updated settings, including register-address/value corrections and bit-depth-specific programming
- Removed crop support; the driver now reports the fixed 3856x2176 active-area format and no longer programs crop registers.
- Updated HBLANK and exposure control limits for fixed geometry, including exposure adjustment when VBLANK changes.
- Improved stream start/stop error handling and ensured failures during setup release the runtime-PM reference.
- Consolidated power-on/off into runtime-PM callbacks, corrected probe/ remove power sequencing, and added builds without CONFIG_PM.
- Cleanups and bugfixes from the v3 review comments (thanks to Sakari and Laurent).

---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/imx908.c | 1168 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1180 insertions(+)
 create mode 100644 drivers/media/i2c/imx908.c
drivers/media/i2c/Kconfig +11 -0
index 5c52007f9cbe..c8bee297cf9b 100644
@@ -310,6 +310,17 @@ config VIDEO_IMX678
 	  To compile this driver as a module, choose M here: the
 	  module will be called imx678.
 
+config VIDEO_IMX908
+	tristate "Sony IMX908 sensor support"
+	depends on GPIOLIB
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the Sony
+	  IMX908 CMOS image sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called imx908.
+
 config VIDEO_MAX9271_LIB
 	tristate
 
drivers/media/i2c/Makefile +1 -0
index d04bd5724552..d91ed1bc6427 100644
@@ -63,6 +63,7 @@ obj-$(CONFIG_VIDEO_IMX412) += imx412.o
 obj-$(CONFIG_VIDEO_IMX415) += imx415.o
 obj-$(CONFIG_VIDEO_IMX678) += imx678.o
 obj-$(CONFIG_VIDEO_IMX471) += imx471.o
+obj-$(CONFIG_VIDEO_IMX908) += imx908.o
 obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ISL7998X) += isl7998x.o
 obj-$(CONFIG_VIDEO_KS0127) += ks0127.o
drivers/media/i2c/imx908.c new file +1168 -0

1,168 lines not on this page · raw message

Signature · 1 line
2.47.3
#5 lore raw

Re: [PATCH v4 2/2] media: i2c: Add Sony IMX908 image sensor driver

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] pm: runtime PM usage counter underflow due to unhandled -EINVAL --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pm: runtime PM usage counter underflow due to unhandled -EINVAL
--

commit 8e82ea0902df5655064466676b372c25f29a3de5
Author: Lachlan Michael <[email protected]>

media: i2c: Add Sony IMX908 image sensor driver

The IMX908 is an 8.39 MP (3856x2176) CMOS image sensor with a MIPI CSI-2 output interface. The driver supports RAW10 and RAW12 output formats, exposure and analogue gain controls, image flipping, blanking controls and test pattern generation.

Quoted 5 lines
drivers/media/i2c/imx908.c new file +0 -0
new file mode 100644
index 0000000000000..4c7e78cfdcc4f

[ ... ]

Quoted 2 lines
drivers/media/i2c/imx908.c new file +2 -0
+static int imx908_set_ctrl(struct v4l2_ctrl *ctrl)
+{

[ ... ]

drivers/media/i2c/imx908.c line 522

Quoted 3 lines
drivers/media/i2c/imx908.c new file +3 -0
+	/* Hardware writes only when powered; cached ctrls applied on resume */
+	if (IS_ENABLED(CONFIG_PM) && !pm_runtime_get_if_active(imx->dev))
+		return 0;

[Severity: High]
Does this logic correctly handle errors from pm_runtime_get_if_active()?

The pm_runtime_get_if_active() function returns 1 when the device is active, 0 when suspended, and a negative error code (like -EINVAL) when Runtime PM is disabled.

If it returns -EINVAL, the logical NOT operator evaluates to false. This causes the safety check to be bypassed, allowing the driver to proceed to execute hardware writes on a potentially unpowered device.

[ ... ]

drivers/media/i2c/imx908.c line 576

Quoted 2 lines
drivers/media/i2c/imx908.c new file +2 -0
+	if (IS_ENABLED(CONFIG_PM))
+		pm_runtime_put(imx->dev);

[Severity: High]
If the initial pm_runtime_get_if_active() call failed and returned -EINVAL, does this unmatched pm_runtime_put() cause a usage counter underflow?

Since the initial get call did not increment the usage counter on failure, executing this put drops the usage counter below its baseline, corrupting the device's Runtime PM state.

Quoted 3 lines
drivers/media/i2c/imx908.c new file +3 -0
+
+	return ret;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2