Skip to contentSkip to conversation

Add Omnivision OV4689 image sensor driver

PATCH Superseded Mikhail Rudenko 3 participants 8 messages Jul 12, 2022 – Aug 15, 2022

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Mikhail Rudenko

author maintainer
#0 lore raw

cover Add Omnivision OV4689 image sensor driver

Hello,

this series implements support for Omnivision OV4689 image sensor. The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel image sensor. Ihis chip supports high frame rate speeds up to 90 fps at 2688x1520 resolution. It is programmable through an I2C interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2 connection.

The driver is based on Rockchip BSP kernel [1]. It implements 4-lane CSI-2 and single 2688x1520 @ 30 fps mode. The driver was tested on Rockchip 3399-based FriendlyElec NanoPi M4 board with MCAM400 camera module.

While porting the driver, I stumbled upon two issues:

(1) In the original driver, horizontal total size (HTS) was set to a value (2584) lower then the frame width (2688), resulting in negative hblank. In this driver, I increased HTS to 2688, but fps dropped from 29.88 to 28.73. What is the preferred way to handle this?

(2) The original driver exposes analog gain range 0x0 - 0x7ff, but the gain is not linear across that range. Instead, it is piecewise linear (and discontinuous). 0x0-0xff register values result in 0x-2x gain, 0x100-0x1ff to 0x-4x, 0x300-0x3ff to 0x-8x, and 0x700-0x7ff to 0x-16x, with more linear segments in between. Rockchip's camera engine code chooses one of the above segments depenging on the desired gain value. The question is, how should we proceed keeping in mind libcamera use case? Should the whole 0x0-0x7ff be exposed as-is and libcamera will do the mapping, or the driver will do the mapping itself and expose some logical gain units not tied to the actual gain register value? Meanwhile, this driver conservatively exposes only 0x0-0xf8 gain register range.

[1] https://github.com/rockchip-linux/kernel/blob/develop-4.19/drivers/media/i2c/ov4689.c

Mikhail Rudenko (2):
media: dt-bindings: media: i2c: document OV4689 DT bindings
media: i2c: add support for ov4689

 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 +++
 MAINTAINERS                                   |   8 +
 drivers/media/i2c/Kconfig                     |  14 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/ov4689.c                    | 899 ++++++++++++++++++
 5 files changed, 1044 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
 create mode 100644 drivers/media/i2c/ov4689.c

--
2.37.0

author maintainer
#1 lore raw

PATCH 1/2 media: dt-bindings: media: i2c: document OV4689 DT bindings

Add device-tree binding documentation for OV4689 image sensor driver, and the relevant MAINTAINERS entries.

---
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +122 -0
new file mode 100644
index 000000000000..6bdebe5862b4
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov4689.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV4689 CMOS Sensor Device Tree Bindings
+
+maintainers:
+  - Mikhail Rudenko <[email protected]>
+
+description: |-
+  The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel
+  image sensor. Ihis chip supports high frame rate speeds up to 90 fps
+  at 2688x1520 resolution. It is programmable through an I2C
+  interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2
+  connection.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov4689
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      External clock for the sensor.
+    items:
+      - const: xclk
+
+  dovdd-supply:
+    description:
+      Definition of the regulator used as Digital I/O voltage supply.
+
+  avdd-supply:
+    description:
+      Definition of the regulator used as Analog voltage supply.
+
+  dvdd-supply:
+    description:
+      Definition of the regulator used as Digital core voltage supply.
+
+  powerdown-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the powerdown pin (active low).
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the reset pin (active low).
+
+  orientation: true
+
+  rotation: true
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+    description:
+      Output port node, single endpoint describing the CSI-2 transmitter.
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dovdd-supply
+  - avdd-supply
+  - dvdd-supply
+  - powerdown-gpios
+  - reset-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ov4689: camera@36 {
+            compatible = "ovti,ov4689";
+            reg = <0x36>;
+
+            clocks = <&ov4689_clk>;
+            clock-names = "xclk";
+
+            avdd-supply = <&ov4689_avdd>;
+            dovdd-supply = <&ov4689_dovdd>;
+            dvdd-supply = <&ov4689_dvdd>;
+
+            powerdown-gpios = <&pio 107 GPIO_ACTIVE_LOW>;
+            reset-gpios = <&pio 109 GPIO_ACTIVE_LOW>;
+
+            orientation = <2>;
+            rotation = <0>;
+
+            port {
+                wcam_out: endpoint {
+                    remote-endpoint = <&mipi_in_wcam>;
+                };
+            };
+        };
+    };
+
+...
MAINTAINERS +7 -0
index f468864fd268..63c4844f26e6 100644
@@ -14523,6 +14523,13 @@ S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/i2c/ov2740.c
 
+OMNIVISION OV4689 SENSOR DRIVER
+M:	Mikhail Rudenko <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
+
 OMNIVISION OV5640 SENSOR DRIVER
 M:	Steve Longerbeam <[email protected]>
 L:	[email protected]
Signature · 1 line
2.37.0
#2 lore raw

Re: [PATCH 1/2] media: dt-bindings: media: i2c: document OV4689 DT bindings

Quoted 16 lines · Mikhail Rudenko

Add device-tree binding documentation for OV4689 image sensor driver, and the relevant MAINTAINERS entries.

---
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +0 -0
new file mode 100644
index 000000000000..6bdebe5862b4

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +7 -0
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov4689.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV4689 CMOS Sensor Device Tree Bindings

s/Device Tree Bindings//

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 12

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+maintainers:
+  - Mikhail Rudenko <[email protected]>
+
+description: |-

No need for -

Quoted 12 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +12 -0
+  The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel
+  image sensor. Ihis chip supports high frame rate speeds up to 90 fps
+  at 2688x1520 resolution. It is programmable through an I2C
+  interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2
+  connection.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov4689

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      External clock for the sensor.

This goes to clocks instead.

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 36

Quoted 2 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +2 -0
+    items:
+      - const: xclk

No need for clock-names for such case.

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 40

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  dovdd-supply:
+    description:
+      Definition of the regulator used as Digital I/O voltage supply.

s/Definition of the regulator used as //

It's redundant...

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 44

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  avdd-supply:
+    description:
+      Definition of the regulator used as Analog voltage supply.

Ditto

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  dvdd-supply:
+    description:
+      Definition of the regulator used as Digital core voltage supply.

Ditto

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+  powerdown-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the powerdown pin (active low).

s/Reference to the//

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 58

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the reset pin (active low).

The same.

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +6 -0
+
+  orientation: true
+
+  rotation: true
+
+  port:

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 74

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +10 -0
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+    description:
+      Output port node, single endpoint describing the CSI-2 transmitter.
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+

Best regards,
Krzysztof

author maintainer
#3 lore raw

Re: [PATCH 1/2] media: dt-bindings: media: i2c: document OV4689 DT bindings

Hi Krzysztof,

Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Mikhail Rudenko

Add device-tree binding documentation for OV4689 image sensor driver, and the relevant MAINTAINERS entries.

---
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
Quoted 15 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 7

Quoted 13 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +7 -0
new file mode 100644
index 000000000000..6bdebe5862b4
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov4689.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV4689 CMOS Sensor Device Tree Bindings

s/Device Tree Bindings//

Ack, will fix in v2.

Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 12

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+maintainers:
+  - Mikhail Rudenko <[email protected]>
+
+description: |-

No need for -

Ack

Quoted 16 lines
Quoted 16 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +16 -0
+  The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel
+  image sensor. Ihis chip supports high frame rate speeds up to 90 fps
+  at 2688x1520 resolution. It is programmable through an I2C
+  interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2
+  connection.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov4689
+
+  reg:
+    maxItems: 1
+
Quoted 9 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 34

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +6 -0
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      External clock for the sensor.

This goes to clocks instead.

Ack

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 36

Quoted 2 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +2 -0
+    items:
+      - const: xclk

No need for clock-names for such case.

Ack

Quoted 9 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 40

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  dovdd-supply:
+    description:
+      Definition of the regulator used as Digital I/O voltage supply.

s/Definition of the regulator used as //

It's redundant...

Ack

Quoted 7 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 44

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  avdd-supply:
+    description:
+      Definition of the regulator used as Analog voltage supply.

Ditto

Ack

Quoted 7 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +4 -0
+
+  dvdd-supply:
+    description:
+      Definition of the regulator used as Digital core voltage supply.

Ditto

Ack

Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+  powerdown-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the powerdown pin (active low).

s/Reference to the//

Ack

Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 58

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the reset pin (active low).

The same.

Ack

Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +11 -0
+
+  orientation: true
+
+  rotation: true
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+    description:
+      Output port node, single endpoint describing the CSI-2 transmitter.
+
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 74

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+

Best regards,
Krzysztof

Thanks for review! By the way, I used an existing schema for a similar sensor ("ovti,ov02a10.yaml", specifically) as an example, and your notes apply to it too. Looks like it should also be fixed...

--
Best regards,
Mikhail Rudenko

#4 lore raw

Re: [PATCH 1/2] media: dt-bindings: media: i2c: document OV4689 DT bindings

In reply to Mikhail Rudenko

Hi Mikhail,

Thanks for the patch.

Quoted 79 lines · Mikhail Rudenko

Add device-tree binding documentation for OV4689 image sensor driver, and the relevant MAINTAINERS entries.

---
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +63 -0
new file mode 100644
index 000000000000..6bdebe5862b4
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov4689.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV4689 CMOS Sensor Device Tree Bindings
+
+maintainers:
+  - Mikhail Rudenko <[email protected]>
+
+description: |-
+  The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel
+  image sensor. Ihis chip supports high frame rate speeds up to 90 fps
+  at 2688x1520 resolution. It is programmable through an I2C
+  interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2
+  connection.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov4689
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      External clock for the sensor.
+    items:
+      - const: xclk
+
+  dovdd-supply:
+    description:
+      Definition of the regulator used as Digital I/O voltage supply.
+
+  avdd-supply:
+    description:
+      Definition of the regulator used as Analog voltage supply.
+
+  dvdd-supply:
+    description:
+      Definition of the regulator used as Digital core voltage supply.
+
+  powerdown-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the powerdown pin (active low).
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the reset pin (active low).
+
+  orientation: true
+
+  rotation: true
+

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 73

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +10 -0
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+    description:
+      Output port node, single endpoint describing the CSI-2 transmitter.
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false

The number of lanes is needed, please require data-lanes property here (as well as add it to the example).

Quoted 67 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +49 -0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dovdd-supply
+  - avdd-supply
+  - dvdd-supply
+  - powerdown-gpios
+  - reset-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ov4689: camera@36 {
+            compatible = "ovti,ov4689";
+            reg = <0x36>;
+
+            clocks = <&ov4689_clk>;
+            clock-names = "xclk";
+
+            avdd-supply = <&ov4689_avdd>;
+            dovdd-supply = <&ov4689_dovdd>;
+            dvdd-supply = <&ov4689_dvdd>;
+
+            powerdown-gpios = <&pio 107 GPIO_ACTIVE_LOW>;
+            reset-gpios = <&pio 109 GPIO_ACTIVE_LOW>;
+
+            orientation = <2>;
+            rotation = <0>;
+
+            port {
+                wcam_out: endpoint {
+                    remote-endpoint = <&mipi_in_wcam>;
+                };
+            };
+        };
+    };
+
+...
MAINTAINERS +7 -0
index f468864fd268..63c4844f26e6 100644
@@ -14523,6 +14523,13 @@ S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/i2c/ov2740.c
 
+OMNIVISION OV4689 SENSOR DRIVER
+M:	Mikhail Rudenko <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
+
 OMNIVISION OV5640 SENSOR DRIVER
 M:	Steve Longerbeam <[email protected]>
 L:	[email protected]
Signature · 3 lines
Regards,

Sakari Ailus
author maintainer
#5 lore raw

Re: [PATCH 1/2] media: dt-bindings: media: i2c: document OV4689 DT bindings

Quoted 89 lines · Sakari Ailus

Hi Mikhail,

Thanks for the patch.

Quoted 84 lines · Mikhail Rudenko

Add device-tree binding documentation for OV4689 image sensor driver, and the relevant MAINTAINERS entries.

---
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +68 -0
new file mode 100644
index 000000000000..6bdebe5862b4
@@ -0,0 +1,122 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov4689.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Omnivision OV4689 CMOS Sensor Device Tree Bindings
+
+maintainers:
+  - Mikhail Rudenko <[email protected]>
+
+description: |-
+  The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel
+  image sensor. Ihis chip supports high frame rate speeds up to 90 fps
+  at 2688x1520 resolution. It is programmable through an I2C
+  interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2
+  connection.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov4689
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    description:
+      External clock for the sensor.
+    items:
+      - const: xclk
+
+  dovdd-supply:
+    description:
+      Definition of the regulator used as Digital I/O voltage supply.
+
+  avdd-supply:
+    description:
+      Definition of the regulator used as Analog voltage supply.
+
+  dvdd-supply:
+    description:
+      Definition of the regulator used as Digital core voltage supply.
+
+  powerdown-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the powerdown pin (active low).
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      Reference to the GPIO connected to the reset pin (active low).
+
+  orientation: true
+
+  rotation: true
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+    description:
+      Output port node, single endpoint describing the CSI-2 transmitter.
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml line 73

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +5 -0
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false

The number of lanes is needed, please require data-lanes property here (as well as add it to the example).

Thanks for review, will fix in v2

Quoted 57 lines
Quoted 57 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml new file +49 -0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - dovdd-supply
+  - avdd-supply
+  - dvdd-supply
+  - powerdown-gpios
+  - reset-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ov4689: camera@36 {
+            compatible = "ovti,ov4689";
+            reg = <0x36>;
+
+            clocks = <&ov4689_clk>;
+            clock-names = "xclk";
+
+            avdd-supply = <&ov4689_avdd>;
+            dovdd-supply = <&ov4689_dovdd>;
+            dvdd-supply = <&ov4689_dvdd>;
+
+            powerdown-gpios = <&pio 107 GPIO_ACTIVE_LOW>;
+            reset-gpios = <&pio 109 GPIO_ACTIVE_LOW>;
+
+            orientation = <2>;
+            rotation = <0>;
+
+            port {
+                wcam_out: endpoint {
+                    remote-endpoint = <&mipi_in_wcam>;
+                };
+            };
+        };
+    };
+
+...
MAINTAINERS +0 -0
index f468864fd268..63c4844f26e6 100644
@@ -14523,6 +14523,13 @@ S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/i2c/ov2740.c
 
Quoted 10 lines

MAINTAINERS S: Maintained · line 14535

Quoted 10 lines
MAINTAINERS +7 -0
+OMNIVISION OV4689 SENSOR DRIVER
+M:	Mikhail Rudenko <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
+
 OMNIVISION OV5640 SENSOR DRIVER
 M:	Steve Longerbeam <[email protected]>
 L:	[email protected]

--
Best regards,
Mikhail Rudenko

author maintainer
#6 lore raw

PATCH 2/2 media: i2c: add support for ov4689

In reply to Mikhail Rudenko

Add a V4L2 sub-device driver for OmniVision OV4689 image sensor. This is a 4 Mpx image sensor using the I2C bus for control and the CSI-2 bus for data.

This driver supports following features:
- manual exposure and analog gain control support
- test pattern support
- media controller support
- runtime PM support
- support following resolutions:
+ 2688x1520 at 30 fps

The driver provides all mandatory V4L2 controls for compatibility with libcamera. The sensor supports 1/2/4-lane CSI-2 modes, but the driver implements 4 lane mode only at this moment.

---
 MAINTAINERS                |   1 +
 drivers/media/i2c/Kconfig  |  14 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov4689.c | 899 +++++++++++++++++++++++++++++++++++++
 4 files changed, 915 insertions(+)
 create mode 100644 drivers/media/i2c/ov4689.c
MAINTAINERS +1 -0
index 63c4844f26e6..1857f3864e1b 100644
@@ -14529,6 +14529,7 @@ L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
+F:	drivers/media/i2c/ov5647.c
 
 OMNIVISION OV5640 SENSOR DRIVER
 M:	Steve Longerbeam <[email protected]>
drivers/media/i2c/Kconfig +14 -0
index fae2baabb773..4993e1ae2ea8 100644
@@ -429,6 +429,20 @@ config VIDEO_OV2740
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov2740.
 
+config VIDEO_OV4689
+	tristate "OmniVision OV4689 sensor support"
+	depends on OF
+	depends on GPIOLIB && VIDEO_DEV && I2C
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor-level driver for the OmniVision
+	  OV4689 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ov4689.
+
 config VIDEO_OV5640
 	tristate "OmniVision OV5640 sensor support"
 	depends on OF
drivers/media/i2c/Makefile +1 -0
index 3e1696963e7f..7446c0a1eed0 100644
@@ -78,6 +78,7 @@ obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
 obj-$(CONFIG_VIDEO_OV2680) += ov2680.o
 obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV2740) += ov2740.o
+obj-$(CONFIG_VIDEO_OV4689) += ov4689.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
drivers/media/i2c/ov4689.c new file +899 -0

899 lines not on this page · raw message

Signature · 1 line
2.37.0
author maintainer
#7 lore raw
In reply to Mikhail Rudenko

Gentle ping. Still waiting for any [2/2] review. Should I resend?

Quoted 39 lines · Mikhail Rudenko

Hello,

this series implements support for Omnivision OV4689 image sensor. The Omnivision OV4689 is a high performance, 1/3-inch, 4 megapixel image sensor. Ihis chip supports high frame rate speeds up to 90 fps at 2688x1520 resolution. It is programmable through an I2C interface, and sensor output is sent via 1/2/4 lane MIPI CSI-2 connection.

The driver is based on Rockchip BSP kernel [1]. It implements 4-lane CSI-2 and single 2688x1520 @ 30 fps mode. The driver was tested on Rockchip 3399-based FriendlyElec NanoPi M4 board with MCAM400 camera module.

While porting the driver, I stumbled upon two issues:

(1) In the original driver, horizontal total size (HTS) was set to a value (2584) lower then the frame width (2688), resulting in negative hblank. In this driver, I increased HTS to 2688, but fps dropped from 29.88 to 28.73. What is the preferred way to handle this?

(2) The original driver exposes analog gain range 0x0 - 0x7ff, but the gain is not linear across that range. Instead, it is piecewise linear (and discontinuous). 0x0-0xff register values result in 0x-2x gain, 0x100-0x1ff to 0x-4x, 0x300-0x3ff to 0x-8x, and 0x700-0x7ff to 0x-16x, with more linear segments in between. Rockchip's camera engine code chooses one of the above segments depenging on the desired gain value. The question is, how should we proceed keeping in mind libcamera use case? Should the whole 0x0-0x7ff be exposed as-is and libcamera will do the mapping, or the driver will do the mapping itself and expose some logical gain units not tied to the actual gain register value? Meanwhile, this driver conservatively exposes only 0x0-0xf8 gain register range.

[1] https://github.com/rockchip-linux/kernel/blob/develop-4.19/drivers/media/i2c/ov4689.c

Mikhail Rudenko (2):
media: dt-bindings: media: i2c: document OV4689 DT bindings
media: i2c: add support for ov4689

Quoted 8 lines
 .../bindings/media/i2c/ovti,ov4689.yaml       | 122 +++
 MAINTAINERS                                   |   8 +
 drivers/media/i2c/Kconfig                     |  14 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/ov4689.c                    | 899 ++++++++++++++++++
 5 files changed, 1044 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov4689.yaml
 create mode 100644 drivers/media/i2c/ov4689.c

--
Best regards,
Mikhail Rudenko