Skip to contentSkip to conversation

Add support for OV5693 Sensor

PATCH Superseded Daniel Scally 1 participant 4 messages Oct 8, 2021

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add support for OV5693 Sensor

Hello all

This series adds support for the OV5693 sensor found as the front camera in many Microsoft Surface devices, along with a number of similar style laptops. It is a heavily adapted derivative of the atomisp-ov5693 driver in staging, which retains most of the global register settings and some of the other functions from that driver, but otherwise uses the "normal" v4l2 infrastructure.

As we're targeting libcamera, all mandatory, recommended and optional controls for that library (at least, at time of writing) are supported.

Series changes: a new patch adding the link frequency for this driver to the cio2-bridge supported-sensors table so it'll be added as a property against the sensor's firmware.

Daniel Scally (3):
media: ipu3-cio2: Toggle sensor streaming in pm runtime ops
media: ipu3-cio2: Add link freq for INT33BE entry
media: i2c: Add support for ov5693 sensor

 MAINTAINERS                                   |    7 +
 drivers/media/i2c/Kconfig                     |   11 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/ov5693.c                    | 1532 +++++++++++++++++
 drivers/media/pci/intel/ipu3/cio2-bridge.c    |    2 +-
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c |   15 +-
 6 files changed, 1566 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/i2c/ov5693.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/3 media: ipu3-cio2: Toggle sensor streaming in pm runtime ops

The .suspend() and .resume() runtime_pm operations for the ipu3-cio2 driver currently do not handle the sensor's stream. Setting .s_stream() on or off for the sensor subdev means that sensors will pause and resume the stream at the appropriate time even if their drivers don't implement those operations.

---
Changes since v3:

- None

 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +14 -1
index 47db0ee0fcbf..7bb86e246ebe 100644
@@ -1973,12 +1973,19 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 	struct pci_dev *pci_dev = to_pci_dev(dev);
 	struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
 	struct cio2_queue *q = cio2->cur_queue;
+	int r;
 
 	dev_dbg(dev, "cio2 suspend\n");
 	if (!cio2->streaming)
 		return 0;
 
 	/* Stop stream */
+	r = v4l2_subdev_call(q->sensor, video, s_stream, 0);
+	if (r) {
+		dev_err(dev, "failed to stop sensor streaming\n");
+		return r;
+	}
+
 	cio2_hw_exit(cio2, q);
 	synchronize_irq(pci_dev->irq);
 
@@ -2013,8 +2020,14 @@ static int __maybe_unused cio2_resume(struct device *dev)
 	}
 
 	r = cio2_hw_init(cio2, q);
-	if (r)
+	if (r) {
 		dev_err(dev, "fail to init cio2 hw\n");
+		return r;
+	}
+
+	r = v4l2_subdev_call(q->sensor, video, s_stream, 1);
+	if (r)
+		dev_err(dev, "fail to start sensor streaming\n");
 
 	return r;
 }
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/3 media: ipu3-cio2: Add link freq for INT33BE entry

In reply to Daniel Scally

Add a link frequency to the cio2-bridge table of supported sensors. This means that the driver can parse supported link frequencies from firmware in the usual way and validate that it can accommodate them.

---
Changes since v3:

- Patch introduced

 drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
index 30d29b96a339..1039d0b473ce 100644
@@ -21,7 +21,7 @@
  */
 static const struct cio2_sensor_config cio2_supported_sensors[] = {
 	/* Omnivision OV5693 */
-	CIO2_SENSOR_CONFIG("INT33BE", 0),
+	CIO2_SENSOR_CONFIG("INT33BE", 1, 419200000),
 	/* Omnivision OV2680 */
 	CIO2_SENSOR_CONFIG("OVTI2680", 0),
 };
Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 3/3 media: i2c: Add support for ov5693 sensor

In reply to Daniel Scally

The OV5693 is a 5 Mpx CMOS image sensor, connected via MIPI CSI-2. The chip is capable of a single lane configuration, but currently only two lanes are supported.

Most of the sensor's features are supported, with the main exception being the lens correction algorithm.

The driver provides all mandatory, optional and recommended V4L2 controls for maximum compatibility with libcamera.

---
Changes since v3 (sakari):

- Moved to a single read/write operation for consecutive registers.
- Wrapped a bunch of lines over 80 chars wide.
- Stopped writing to the VTS registers twice on resume.
- Provided ov5693_check_hwcfg() to get and put the endpoint properly, as well as validate that the number of data lanes and link frequency from firmware are supported by the driver.
- Switched to warning when clk_get_rate() reports an unsupported value instead of failing.

 MAINTAINERS                |    7 +
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/ov5693.c | 1532 ++++++++++++++++++++++++++++++++++++
 4 files changed, 1551 insertions(+)
 create mode 100644 drivers/media/i2c/ov5693.c
MAINTAINERS +7 -0
index 1c3fd45edd94..c97ca95802e9 100644
@@ -13861,6 +13861,13 @@ S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/i2c/ov5675.c
 
+OMNIVISION OV5693 SENSOR DRIVER
+M:	Daniel Scally <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	drivers/media/i2c/ov5693.c
+
 OMNIVISION OV5695 SENSOR DRIVER
 M:	Shunqian Zheng <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +11 -0
index 08feb3e8c1bf..82d5c9b7f540 100644
@@ -1042,6 +1042,17 @@ config VIDEO_OV5675
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov5675.
 
+config VIDEO_OV5693
+	tristate "OmniVision OV5693 sensor support"
+	depends on I2C && VIDEO_V4L2
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor driver for the OmniVision
+	  OV5693 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ov5693.
+
 config VIDEO_OV5695
 	tristate "OmniVision OV5695 sensor support"
 	depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
index 83268f20aa3a..6b910ba2dde2 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5648) += ov5648.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
 obj-$(CONFIG_VIDEO_OV5675) += ov5675.o
+obj-$(CONFIG_VIDEO_OV5693) += ov5693.o
 obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7251) += ov7251.o
drivers/media/i2c/ov5693.c new file +1532 -0

1,532 lines not on this page · raw message

Signature · 1 line
2.25.1