Skip to contentSkip to conversation

GC0308 Camera Sensor

PATCH New Sebastian Reichel 1 participant 4 messages Dec 9, 2023

Subsystems (4)
lore
Share & tools
lore

Sebastian Reichel

author maintainer
#0 lore raw

v5 cover GC0308 Camera Sensor

From: Sebastian Reichel <[email protected]>

Hi,

I did the following tests on an i.MX6ULL based system [0]:

* v4l2-compliance -u /dev/v4l-subdev1
- v4l2-compliance 1.26.0, 32 bits, 32-bit time_t (from Debian testing)
- Total for device /dev/v4l-subdev1: 45, Succeeded: 45
* Using gstreamer + v4l2-ctl
- Tried 640x480, 320x240, 160x120 YUYV8_2X8 formats
- Tested effect of all exposed user controls
* checkpatch does not report any driver issues
* dt_binding_check does not report anything
* rebind driver works

[0] https://embedded-recipes.org/2023/schedule/running-foss-thermal-camera/

Changes since PATCHv4:
* https://lore.kernel.org/all/[email protected]/
* Rebase to latest master branch from Sakari
- v4l2_subdev_get_pad_format -> v4l2_subdev_state_get_format
- v4l2_subdev_get_try_format -> v4l2_subdev_state_get_format
- v4l2_subdev_pad_ops.init_cfg -> v4l2_subdev_internal_ops.init_state
* Fix feedback from Tommaso Merciai
- uint8_t -> u8
- drop extra newline
- introduce gc0308_init_controls
* Drop galaxycore vendor binding (merged)
* Drop async fixes (merged to different tree)

Changes since PATCHv3:
* https://lore.kernel.org/all/[email protected]/
* Rebased to v6.7-rc1
* Replace gc0308_is_valid_format() with gc0308_get_format_idx(), which can be reused in gc0308_set_format().
* Remove the runtime PM get call in remove function
* Move the runtime PM get call before the subdev register call in probe
* Drop message about unsupported format code
* Add Reviewed-by: Jacopo Mondi <[email protected]>
* Merged binding patch with the one from Alain Volmat and add

to him, since his patch arrived first on the ML
* Added two patches to fix an issue with v4l2_async_unregister_subdev() list handling

Changes since PATCHv2:
* https://lore.kernel.org/all/[email protected]/
* Simplify Kconfig dependencies
* Do not store code/resolution; which is available from subdev state
* Store register values for mode settings to avoid second lookup in s_stream
* Reduce power_on sleep times
* remove debug dev_err() print, that I accidently added in v2
* add missing format check in gc0308_enum_frame_size()
* do not PM resume in gc0308_s_ctrl()
* enable and use runtime PM autosuspend
* add .init_cfg() PAD op
* use CCI helper instead of raw regmap
* cluster both flip controls
(that's not just a performance optimization, but fixes an issue, that register update is slow, so fast sequential setting of VFLIP/HFLIP override each other without this)
* simplify gc0308_set_power_line_freq
* free control handler on probe error
* use first format by default
* expose V4L2_CID_HBLANK, V4L2_CID_VBLANK, V4L2_CID_PIXEL_RATE
* remove incorrect support for framerate and instead add a comment

Changes since PATCHv1:
* https://lore.kernel.org/all/[email protected]/
* Update binding: i2c0 -> i2c
* Update binding: make GC0309 use GC0308 as fallback compatible
* Add regulator handling in power_on/power_off
* Fix alignment of regmap_multi_reg_write arguments
* Fix useless extra return
* Do not check for pad in gc0308_enum_frame_size()
* Drop get_mbus_config implementation
* Use V4L2_CID_AUTO_EXPOSURE_BIAS instead of V4L2_CID_EXPOSURE
* Drop gc0308_get_format in favour of v4l2_subdev_get_fmt
* Replace open-coded v4l2_find_nearest_size() logic
* check clock rate instead of setting it
* use fwnode_graph_get_endpoint_by_id()
* power off device when probe errors out after power on
* replace mutex with sub-device state
* add Galaxycore to generic camera sensors section in MAINTAINERS
* add GC0308 entry in MAINTAINERS

Greetings,

-- Sebastian

Sebastian Reichel (3):
media: dt-bindings: gc0308: add binding
media: MAINTAINERS: Add GalaxyCore in camera sensor section
media: i2c: gc0308: new driver

 .../bindings/media/i2c/galaxycore,gc0308.yaml |  108 ++
 MAINTAINERS                                   |    8 +
 drivers/media/i2c/Kconfig                     |   10 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/gc0308.c                    | 1451 +++++++++++++++++
 5 files changed, 1578 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/galaxycore,gc0308.yaml
 create mode 100644 drivers/media/i2c/gc0308.c
Signature · 1 line
2.42.0
author maintainer
#1 lore raw

PATCH v5 1/3 media: dt-bindings: gc0308: add binding

Add DT binding for GalaxyCore GC0308 camera sensor.

---
 .../bindings/media/i2c/galaxycore,gc0308.yaml | 108 ++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/galaxycore,gc0308.yaml
Documentation/devicetree/bindings/media/i2c/galaxycore,gc0308.yaml new file +108 -0
new file mode 100644
index 000000000000..f81e7daed67b
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/galaxycore,gc0308.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Galaxycore GC0308 and GC0309 Image Sensors
+
+maintainers:
+  - Sebastian Reichel <[email protected]>
+
+description: |
+  The GalaxyCore GC0308 (1/6.5") and GC0309 (1/9") are 640x480 VGA sensors
+  programmable through an I2C interface and connected via parallel bus.
+  They include an ISP capable of auto exposure and auto white balance.
+
+allOf:
+  - $ref: ../video-interface-devices.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: galaxycore,gc0308
+      - items:
+          - const: galaxycore,gc0309
+          - const: galaxycore,gc0308
+
+  reg:
+    const: 0x21
+
+  clocks:
+    description: Reference to the xclk clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: GPIO descriptor for the reset pin.
+    maxItems: 1
+
+  powerdown-gpios:
+    description: GPIO descriptor for the powerdown pin.
+    maxItems: 1
+
+  vdd28-supply:
+    description: 2.8V supply
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    description: |
+      Video output port.
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          bus-width: true
+          data-shift: true
+          hsync-active: true
+          vsync-active: true
+          data-active: true
+          pclk-sample: true
+
+        required:
+          - bus-width
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - powerdown-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@21 {
+            compatible = "galaxycore,gc0308";
+            reg = <0x21>;
+            clocks = <&camera_clk>;
+            powerdown-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
+            reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+            vdd28-supply = <&vdd28>;
+
+            port {
+                gc0308_ep: endpoint {
+                    remote-endpoint = <&parallel_from_gc0308>;
+                    bus-width = <8>;
+                    data-shift = <2>; /* lines 9:2 are used */
+                    hsync-active = <1>; /* active high */
+                    vsync-active = <1>; /* active high */
+                    data-active = <1>; /* active high */
+                    pclk-sample = <1>; /* sample on rising edge */
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.42.0
author maintainer
#2 lore raw

PATCH v5 2/3 media: MAINTAINERS: Add GalaxyCore in camera sensor section

In reply to Sebastian Reichel

"gc" prefixed i2c media drivers are most likely GalaxyCore camera sensor drivers, so add it to the list.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index b6c4c8e037bf..142225181316 100644
@@ -22833,6 +22833,7 @@ S:	Maintained
 F:	Documentation/driver-api/media/camera-sensor.rst
 F:	Documentation/driver-api/media/tx-rx.rst
 F:	drivers/media/i2c/ar*
+F:	drivers/media/i2c/gc*
 F:	drivers/media/i2c/hi*
 F:	drivers/media/i2c/imx*
 F:	drivers/media/i2c/mt*
Signature · 1 line
2.42.0
author maintainer
#3 lore raw

PATCH v5 3/3 media: i2c: gc0308: new driver

In reply to Sebastian Reichel

Introduce new driver for GalaxyCore GC0308, which is a cheap 640x480 with an on-chip ISP sensor sold since 2010. Data is provided via parallel bus.

---
 MAINTAINERS                |    7 +
 drivers/media/i2c/Kconfig  |   10 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/gc0308.c | 1451 ++++++++++++++++++++++++++++++++++++
 4 files changed, 1469 insertions(+)
 create mode 100644 drivers/media/i2c/gc0308.c
MAINTAINERS +7 -0
index 142225181316..d9b108ee068f 100644
@@ -8778,6 +8778,13 @@ F:	drivers/mfd/gateworks-gsc.c
 F:	include/linux/mfd/gsc.h
 F:	include/linux/platform_data/gsc_hwmon.h
 
+GC0308 GALAXYCORE CAMERA SENSOR DRIVER
+M:	Sebastian Reichel <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/galaxycore,gc0308.yaml
+F:	drivers/media/i2c/gc0308.c
+
 GCC PLUGINS
 M:	Kees Cook <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +10 -0
index aae05142e191..4af216ec7124 100644
@@ -50,6 +50,16 @@ config VIDEO_AR0521
 	  To compile this driver as a module, choose M here: the
 	  module will be called ar0521.
 
+config VIDEO_GC0308
+	tristate "GalaxyCore GC0308 sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the GalaxyCore
+	  GC0308 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called gc0308.
+
 config VIDEO_GC2145
 	select V4L2_CCI_I2C
 	tristate "GalaxyCore GC2145 sensor support"
drivers/media/i2c/Makefile +1 -0
index a7ee96174397..ad4c4ee3f13f 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_VIDEO_DW9719) += dw9719.o
 obj-$(CONFIG_VIDEO_DW9768) += dw9768.o
 obj-$(CONFIG_VIDEO_DW9807_VCM) += dw9807-vcm.o
 obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8/
+obj-$(CONFIG_VIDEO_GC0308) += gc0308.o
 obj-$(CONFIG_VIDEO_GC2145) += gc2145.o
 obj-$(CONFIG_VIDEO_HI556) += hi556.o
 obj-$(CONFIG_VIDEO_HI846) += hi846.o
drivers/media/i2c/gc0308.c new file +1451 -0

1,451 lines not on this page · raw message

Signature · 1 line
2.42.0