Skip to contentSkip to conversation

dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor

PATCH Superseded Tuan Kiet Huynh 2 participants 9 messages Nov 21 – Nov 22

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

PATCH v2 1/2 dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor

From: Andrii Cherniavskyi <[email protected]>

Add Device Tree bindings for the Samsung S5K5E8YX 5MP RAW10 CMOS image sensor, including optional standby-gpios and MIPI CSI-2 endpoint properties.

---
 .../bindings/media/i2c/samsung,s5k5e8yx.yaml  | 102 ++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml new file +102 -0
new file mode 100644
index 000000000..a70becba5
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/samsung,s5k5e8yx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S5K5E8YX Image Sensor
+
+description:
+  Samsung S5K5E8YX image sensor is a 5MP CMOS image sensor.
+  The sensor is controlled over a serial camera control bus protocol,
+  the widest supported output image frame size is 2608x1960 at 30 frames
+  per second, data output format is RAW10 transferred over 2-lane
+  MIPI D-PHY interface.
+
+maintainers:
+  - Andrii Cherniavskyi <[email protected]>
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8yx
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: MCLK supply clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Active low GPIO connected to RESET pad of the sensor.
+    maxItems: 1
+
+  standby-gpios:
+    description: Active low GPIO connected to STANDBY/XSHUTDN pad of the sensor.
+    maxItems: 1
+
+  vdda-supply:
+    description: Analogue voltage supply, 2.8 volts.
+
+  vddd-supply:
+    description: Digital core voltage supply, 1.2 volts.
+
+  vddio-supply:
+    description: Digital I/O voltage supply, 1.8 or 2.8 volts.
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          link-frequencies: true
+          remote-endpoint: true
+
+        required:
+          - link-frequencies
+          - remote-endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+      #include <dt-bindings/gpio/gpio.h>
+
+      i2c {
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          camera@2d {
+              compatible = "samsung,s5k5e8yx";
+              reg = <0x2d>;
+              clocks = <&camera_mclk 0>;
+              assigned-clocks = <&camera_mclk 0>;
+              assigned-clock-rates = <24000000>;
+              reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
+              vdda-supply = <&vreg_2p8>;
+              vddd-supply = <&vreg_1p2>;
+              vddio-supply = <&vreg_1p8>;
+
+              port {
+                  endpoint {
+                      link-frequencies = /bits/ 64 <420000000>;
+                      remote-endpoint = <&mipi_csi2_ep>;
+                  };
+              };
+          };
+      };
+...
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/2 media: i2c: Add Samsung S5K5E8YX camera sensor driver

From: Andrii Cherniavskyi <[email protected]>

Add V4L2 subdev driver for the Samsung S5K5E8YX 5MP CMOS image sensor, supporting 2592x1944 (30 fps) and 1304x980 (60 fps) RAW10 GRBG modes, exposure, analogue gain, VBLANK, H/V flip, test patterns, optional standby GPIO, selection rectangles, and MAINTAINERS entry.

---
 MAINTAINERS                  |   9 +
 drivers/media/i2c/Kconfig    |  10 +
 drivers/media/i2c/Makefile   |   1 +
 drivers/media/i2c/s5k5e8yx.c | 970 +++++++++++++++++++++++++++++++++++
 4 files changed, 990 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8yx.c
MAINTAINERS +9 -0
index 2d8dd1ac5..dbc56c0ae 100644
@@ -23584,6 +23584,15 @@ L:	[email protected]
 S:	Supported
 F:	drivers/media/i2c/s5k5baf.c
 
+SAMSUNG S5K5E8YX CAMERA DRIVER
+M:	Andrii Cherniavskyi <[email protected]>
+M:	Tuan Kiet Huynh <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
+F:	drivers/media/i2c/s5k5e8yx.c
+
 SAMSUNG S5KJN1 CAMERA DRIVER
 M:	Vladimir Zapolskiy <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +10 -0
index 98699f32c..e33da6559 100644
@@ -812,6 +812,16 @@ config VIDEO_S5KJN1
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5kjn1.
 
+config VIDEO_S5K5E8YX
+	tristate "Samsung S5K5E8YX sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a V4L2 sensor driver for Samsung S5K5E8YX 5MP raw
+	  camera sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k5e8yx.
+
 config VIDEO_VD55G1
 	tristate "ST VD55G1 sensor support"
 	select V4L2_CCI_I2C
drivers/media/i2c/Makefile +1 -0
index 1e4b5509c..f24826b31 100644
@@ -132,6 +132,7 @@ obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
+obj-$(CONFIG_VIDEO_S5K5E8YX) += s5k5e8yx.o
 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
 obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
 obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
drivers/media/i2c/s5k5e8yx.c new file +970 -0

970 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

v2 cover media: i2c: Add Samsung S5K5E8YX camera sensor driver

In reply to Tuan Kiet Huynh

Add Device Tree bindings and a V4L2 subdev driver for the Samsung S5K5E8YX 5MP RAW10 CMOS image sensor.

Based on initial work by Andrii Cherniavskyi, updated with standby GPIO handling, crop selection rectangles, MAINTAINERS entry, and tested on Xiaomi Redmi Note 4X (msm8953 / mido) using libcamera SoftISP.

Changes in v2:
- Rebase series onto linux-media/media-committers next branch so Kconfig, Makefile, and MAINTAINERS apply cleanly in Media CI.
- Update .set_fmt and .get_selection signatures for
const struct v4l2_subdev_client_info *ci in media-next.
- Convert PM ops to DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr().
- Fix subdev finalize error message and remaining checkpatch --strict parenthesis line-break style checks.
- Place DT binding MAINTAINERS entry in patch 1/2 so each patch passes checkpatch --strict independently.

Andrii Cherniavskyi (2):
dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor
media: i2c: Add Samsung S5K5E8YX camera sensor driver

 .../bindings/media/i2c/samsung,s5k5e8yx.yaml  | 102 ++
 MAINTAINERS                                   |   9 +
 drivers/media/i2c/Kconfig                     |  10 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/s5k5e8yx.c                  | 972 ++++++++++++++++++
 5 files changed, 1094 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
 create mode 100644 drivers/media/i2c/s5k5e8yx.c
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 1/2 dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor

From: Andrii Cherniavskyi <[email protected]>

Add Device Tree bindings for the Samsung S5K5E8YX 5MP RAW10 CMOS image sensor, including optional standby-gpios and MIPI CSI-2 endpoint properties.

---
 .../bindings/media/i2c/samsung,s5k5e8yx.yaml  | 102 ++++++++++++++++++
 MAINTAINERS                                   |   8 ++
 2 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml new file +102 -0
new file mode 100644
index 000000000..a70becba5
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/samsung,s5k5e8yx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S5K5E8YX Image Sensor
+
+description:
+  Samsung S5K5E8YX image sensor is a 5MP CMOS image sensor.
+  The sensor is controlled over a serial camera control bus protocol,
+  the widest supported output image frame size is 2608x1960 at 30 frames
+  per second, data output format is RAW10 transferred over 2-lane
+  MIPI D-PHY interface.
+
+maintainers:
+  - Andrii Cherniavskyi <[email protected]>
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8yx
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: MCLK supply clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Active low GPIO connected to RESET pad of the sensor.
+    maxItems: 1
+
+  standby-gpios:
+    description: Active low GPIO connected to STANDBY/XSHUTDN pad of the sensor.
+    maxItems: 1
+
+  vdda-supply:
+    description: Analogue voltage supply, 2.8 volts.
+
+  vddd-supply:
+    description: Digital core voltage supply, 1.2 volts.
+
+  vddio-supply:
+    description: Digital I/O voltage supply, 1.8 or 2.8 volts.
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          link-frequencies: true
+          remote-endpoint: true
+
+        required:
+          - link-frequencies
+          - remote-endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+      #include <dt-bindings/gpio/gpio.h>
+
+      i2c {
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          camera@2d {
+              compatible = "samsung,s5k5e8yx";
+              reg = <0x2d>;
+              clocks = <&camera_mclk 0>;
+              assigned-clocks = <&camera_mclk 0>;
+              assigned-clock-rates = <24000000>;
+              reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
+              vdda-supply = <&vreg_2p8>;
+              vddd-supply = <&vreg_1p2>;
+              vddio-supply = <&vreg_1p8>;
+
+              port {
+                  endpoint {
+                      link-frequencies = /bits/ 64 <420000000>;
+                      remote-endpoint = <&mipi_csi2_ep>;
+                  };
+              };
+          };
+      };
+...
MAINTAINERS +8 -0
index f72ce07a4..b98726c35 100644
@@ -25013,6 +25013,14 @@ M:	Andrzej Hajda <[email protected]>
 S:	Supported
 F:	drivers/media/i2c/s5k5baf.c
 
+SAMSUNG S5K5E8YX CAMERA DRIVER
+M:	Andrii Cherniavskyi <[email protected]>
+M:	Tuan Kiet Huynh <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
+
 SAMSUNG S5KJN1 CAMERA DRIVER
 M:	Vladimir Zapolskiy <[email protected]>
 S:	Maintained
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 2/2 media: i2c: Add Samsung S5K5E8YX camera sensor driver

In reply to Tuan Kiet Huynh

From: Andrii Cherniavskyi <[email protected]>

Add V4L2 subdev driver for the Samsung S5K5E8YX 5MP CMOS image sensor, supporting 2592x1944 (30 fps) and 1304x980 (60 fps) RAW10 GRBG modes, exposure, analogue gain, VBLANK, H/V flip, test patterns, optional standby GPIO, and selection rectangles.

---
 MAINTAINERS                  |   1 +
 drivers/media/i2c/Kconfig    |  10 +
 drivers/media/i2c/Makefile   |   1 +
 drivers/media/i2c/s5k5e8yx.c | 972 +++++++++++++++++++++++++++++++++++
 4 files changed, 984 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8yx.c
MAINTAINERS +1 -0
index b98726c35..5f4fdce90 100644
@@ -25020,6 +25020,7 @@ L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8yx.yaml
+F:	drivers/media/i2c/s5k5e8yx.c
 
 SAMSUNG S5KJN1 CAMERA DRIVER
 M:	Vladimir Zapolskiy <[email protected]>
drivers/media/i2c/Kconfig +10 -0
index 162b8ea02..4ef29f02f 100644
@@ -885,6 +885,16 @@ config VIDEO_S5K5BAF
 	  This is a V4L2 sensor driver for Samsung S5K5BAF 2M
 	  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K5E8YX
+	tristate "Samsung S5K5E8YX sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a V4L2 sensor driver for Samsung S5K5E8YX 5MP raw
+	  camera sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k5e8yx.
+
 config VIDEO_S5K6A3
 	tristate "Samsung S5K6A3 sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index a750942e9..da7dc2277 100644
@@ -137,6 +137,7 @@ obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
+obj-$(CONFIG_VIDEO_S5K5E8YX) += s5k5e8yx.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
 obj-$(CONFIG_VIDEO_S5KJN5) += s5kjn5.o
drivers/media/i2c/s5k5e8yx.c new file +972 -0

972 lines not on this page · raw message

Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH v2 2/2] media: i2c: Add Samsung S5K5E8YX camera sensor driver

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] media: s5k5e8yx: stale mode and unchecked ctrls in s5k5e8yx_set_pad_format() - [Medium] media…

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [Medium] media: s5k5e8yx: stale mode and unchecked ctrls in s5k5e8yx_set_pad_format()
- [Medium] media: s5k5e8yx: missing 0x3307 and 0x3308 writes in 1304x980 mode table
- [Medium] media: s5k5e8yx: pad format code not updated on flip in s5k5e8yx_set_ctrl()
- [Medium] media: s5k5e8yx: missing streaming check in s5k5e8yx_set_pad_format()
- [Low] media: s5k5e8yx: unused macro definition S5K5E8YX_AGAIN_SHIFT --

commit 4982bbedacda1f130bf60b5814bdb3330ccbf970
Author: Andrii Cherniavskyi <[email protected]>

media: i2c: Add Samsung S5K5E8YX camera sensor driver

This commit adds a V4L2 subdev driver for the Samsung S5K5E8YX 5MP CMOS image sensor supporting 2592x1944 (30 fps) and 1304x980 (60 fps) RAW10 GRBG modes.

Quoted 6 lines
drivers/media/i2c/s5k5e8yx.c new file +0 -0
new file mode 100644
index 0000000000000..5ad42e2fc7e14
@@ -0,0 +1,972 @@

[ ... ]

drivers/media/i2c/s5k5e8yx.c line 42

Quoted 6 lines
drivers/media/i2c/s5k5e8yx.c new file +6 -0
+#define S5K5E8YX_REG_AGAIN		CCI_REG16(0x0204)
+#define S5K5E8YX_AGAIN_MIN		0x020
+#define S5K5E8YX_AGAIN_MAX		0x200
+#define S5K5E8YX_AGAIN_STEP		1
+#define S5K5E8YX_AGAIN_DEFAULT		0x020
+#define S5K5E8YX_AGAIN_SHIFT		5

[Severity: Low]
S5K5E8YX_AGAIN_SHIFT is unused since S5K5E8YX_AGAIN_MIN and S5K5E8YX_AGAIN_MAX are already pre-shifted and written directly to S5K5E8YX_REG_AGAIN.

[ ... ]

Quoted 1 line

+static const struct cci_reg_sequence s5k5e8yx_2592x1944_30fps_mode[] = {

[ ... ]

Quoted 15 lines
drivers/media/i2c/s5k5e8yx.c new file +15 -0
+	{ CCI_REG8(0x3306), 0x00 },
+	{ CCI_REG8(0x3307), 0x08 },
+	{ CCI_REG8(0x3308), 0x0a },
+	{ CCI_REG8(0x3309), 0x27 },
+	{ CCI_REG8(0x330a), 0x01 },
+	{ CCI_REG8(0x330b), 0x01 },
+	{ CCI_REG8(0x330e), 0x00 },
+	{ CCI_REG8(0x330f), 0x08 },
+	{ CCI_REG8(0x3310), 0x07 },
+	{ CCI_REG8(0x3311), 0x9f },
+	{ CCI_REG8(0x3312), 0x01 },
+	{ CCI_REG8(0x3313), 0x01 },
+};
+
+static const struct cci_reg_sequence s5k5e8yx_1304x980_60fps_mode[] = {

[ ... ]

drivers/media/i2c/s5k5e8yx.c line 266

Quoted 11 lines
drivers/media/i2c/s5k5e8yx.c new file +11 -0
+	{ CCI_REG8(0x3306), 0x00 },
+	{ CCI_REG8(0x3309), 0x2f },
+	{ CCI_REG8(0x330a), 0x01 },
+	{ CCI_REG8(0x330b), 0x01 },
+	{ CCI_REG8(0x330e), 0x00 },
+	{ CCI_REG8(0x330f), 0x00 },
+	{ CCI_REG8(0x3310), 0x07 },
+	{ CCI_REG8(0x3311), 0xa7 },
+	{ CCI_REG8(0x3312), 0x03 },
+	{ CCI_REG8(0x3313), 0x01 },
+};

[Severity: Medium]
Should s5k5e8yx_1304x980_60fps_mode[] also program registers 0x3307 (0x00) and 0x3308 (0x0a)?

s5k5e8yx_2592x1944_30fps_mode[] writes 0x08 to 0x3307 and init_array_setting does not touch 0x3307 or 0x3308. If streaming is restarted in 1304x980 mode before runtime-PM autosuspend powers down the sensor (or when optional reset/standby GPIOs are absent), 0x3307 retains 0x08 from the 2592x1944 mode instead of 0x00.

[ ... ]

Quoted 10 lines
drivers/media/i2c/s5k5e8yx.c new file +10 -0
+static int s5k5e8yx_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct s5k5e8yx *s5k5e8yx =
+		container_of(ctrl->handler, struct s5k5e8yx, ctrl_handler);
+	const struct s5k5e8yx_mode *mode = s5k5e8yx->mode;
+	s64 exposure_max;
+	int ret;
+
+	/* Propagate change of current control to all related controls */
+	switch (ctrl->id) {

drivers/media/i2c/s5k5e8yx.c line 324

Quoted 10 lines
drivers/media/i2c/s5k5e8yx.c new file +10 -0
+	case V4L2_CID_VBLANK:
+		/* Update max exposure while meeting expected vblanking */
+		exposure_max =
+			mode->height + ctrl->val - S5K5E8YX_EXPOSURE_MARGIN;
+		__v4l2_ctrl_modify_range(s5k5e8yx->exposure,
+					 s5k5e8yx->exposure->minimum,
+					 exposure_max, s5k5e8yx->exposure->step,
+					 s5k5e8yx->exposure->default_value);
+		break;
+	}

[Severity: Medium]
Does changing V4L2_CID_HFLIP or V4L2_CID_VFLIP leave the active subdev state pad format code out of sync with the hardware Bayer order?

Flipping immediately changes the Bayer media bus code returned by s5k5e8yx_get_format_code(), which s5k5e8yx_enum_mbus_code() and s5k5e8yx_enum_frame_size() use, and both controls carry V4L2_CTRL_FLAG_MODIFY_LAYOUT. However, s5k5e8yx_set_ctrl() never updates v4l2_subdev_state_get_format(state, 0)->code, so v4l2_subdev_get_fmt() and v4l2_subdev_link_validate() continue to report the old Bayer format code unless VIDIOC_SUBDEV_S_FMT is called again.

[ ... ]

Quoted 9 lines
drivers/media/i2c/s5k5e8yx.c new file +9 -0
+static int s5k5e8yx_set_pad_format(struct v4l2_subdev *sd,
+				   const struct v4l2_subdev_client_info *ci,
+				   struct v4l2_subdev_state *state,
+				   struct v4l2_subdev_format *fmt)
+{
+	struct s5k5e8yx *s5k5e8yx = to_s5k5e8yx(sd);
+	s64 hblank, vblank, exposure_max;
+	const struct s5k5e8yx_mode *mode;
+

drivers/media/i2c/s5k5e8yx.c line 552

Quoted 10 lines
drivers/media/i2c/s5k5e8yx.c new file +10 -0
+	mode = v4l2_find_nearest_size(s5k5e8yx_supported_modes,
+				      ARRAY_SIZE(s5k5e8yx_supported_modes),
+				      width, height, fmt->format.width,
+				      fmt->format.height);
+
+	s5k5e8yx_update_pad_format(s5k5e8yx, mode, &fmt->format);
+
+	/* Format code could be updated with respect to flip controls */
+	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY || s5k5e8yx->mode == mode)
+		goto set_format;

[Severity: Medium]
Should s5k5e8yx_set_pad_format() reject V4L2_SUBDEV_FORMAT_ACTIVE changes with -EBUSY when v4l2_subdev_is_streaming(sd) is true?

The V4L2 subdev core does not block VIDIOC_SUBDEV_S_FMT while streaming. Without that check, changing the active format mid-stream updates s5k5e8yx->mode, control ranges, and the active pad format, and writes the new mode's VTS and exposure registers to the running sensor while its PLL, binning, HTS, and output size registers remain configured for the old mode.

Quoted 9 lines
drivers/media/i2c/s5k5e8yx.c new file +9 -0
+
+	hblank = mode->hts - mode->width;
+	__v4l2_ctrl_modify_range(s5k5e8yx->hblank, hblank, hblank, 1, hblank);
+
+	vblank = mode->vts - mode->height;
+	__v4l2_ctrl_modify_range(s5k5e8yx->vblank, vblank,
+				 S5K5E8YX_VTS_MAX - mode->height, 1, vblank);
+	__v4l2_ctrl_s_ctrl(s5k5e8yx->vblank, vblank);
+

drivers/media/i2c/s5k5e8yx.c line 571

Quoted 10 lines
drivers/media/i2c/s5k5e8yx.c new file +10 -0
+	exposure_max = mode->vts - S5K5E8YX_EXPOSURE_MARGIN;
+	__v4l2_ctrl_modify_range(s5k5e8yx->exposure, S5K5E8YX_EXPOSURE_MIN,
+				 exposure_max, S5K5E8YX_EXPOSURE_STEP,
+				 mode->exposure);
+	__v4l2_ctrl_s_ctrl(s5k5e8yx->exposure, mode->exposure);
+
+	if (s5k5e8yx->sd.ctrl_handler->error)
+		return s5k5e8yx->sd.ctrl_handler->error;
+
+	s5k5e8yx->mode = mode;

[Severity: Medium]
Should s5k5e8yx->mode be updated before updating the vblank and exposure controls?

__v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() on s5k5e8yx->vblank synchronously invoke s5k5e8yx_set_ctrl(), which reads s5k5e8yx->mode->height. Because s5k5e8yx->mode still points to the previous mode here, s5k5e8yx_set_ctrl() computes exposure_max with the old mode height and, if the device is runtime-PM active (such as during the 1000 ms autosuspend window after probe or stream stop), writes ctrl->val + old_mode->height to S5K5E8YX_REG_VTS.

In addition, __v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() return their error code directly and do not set ctrl_handler->error, so checking s5k5e8yx->sd.ctrl_handler->error never catches control or I2C failures here.

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

v3 cover media: i2c: Add Samsung S5K5E8 camera sensor driver

In reply to Tuan Kiet Huynh

Add Device Tree bindings and a V4L2 subdev driver for the Samsung S5K5E8 5MP RAW10 CMOS image sensor.

Initial patches were authored by Andrii Cherniavskyi (shown in the git shortlog below); v2 and v3 updates, active-state refinements, and hardware testing on Xiaomi Redmi Note 4X (msm8953 / mido) were carried out by Tuan Kiet Huynh.

Changes in v3:
- Rename driver, DT binding, Kconfig symbol (VIDEO_S5K5E8), compatible string ("samsung,s5k5e8"), and MAINTAINERS entry from s5k5e8yx to s5k5e8.
- Rename standby-gpios to powerdown-gpios in both the DT binding and driver, and switch to sequential regulator_enable() (vddio -> vdda -> vddd) with powerdown-then-reset deassertion (matching the Samsung S5K5E8 OEM PWR_ON sequence).
- Use RUNTIME_PM_OPS() with pm_ptr() instead of DEFINE_RUNTIME_DEV_PM_OPS() per Documentation/driver-api/media/camera-sensor.rst (runtime PM only, leaving stream suspend/resume coordination to the bridge driver).
- Adopt full V4L2 subdev active state: drop duplicated s5k5e8->mode and err_restore_mode, derive mode from state in enable_streams() and s5k5e8_set_ctrl() (guarded by WARN_ON_ONCE(!state) -> -EINVAL), and store/return active and try crop rectangles in v4l2_subdev_state (CROP_DEFAULT returns mode 0's crop).
- Align 2592x1944 X_ADDR_START (0x0008) with 0x3306/07 and reported crop ((8, 8)/2592x1944); program 0x3307 (0x00) and 0x3308 (0x0a) in 1304x980_60fps_mode[]; align 1304x980 MIPI link PLL registers (0x0306, 0x0308, 0x0820/21 = 0x0344) with Samsung OEM binned preview so both modes share the 168 Mpix/s VT clock and ~418 MHz actual (420 MHz nominal) CSI link.
- Update active pad Bayer format code synchronously on V4L2_CID_HFLIP / V4L2_CID_VFLIP changes, cluster hflip/vflip controls, and reject active format changes with -EBUSY while streaming.
- Pass NULL ops for read-only V4L2_CID_LINK_FREQ, V4L2_CID_PIXEL_RATE, and V4L2_CID_HBLANK controls, set V4L2_CID_PIXEL_RATE minimum to pixel_rate, check ctrl_hdlr->error in s5k5e8_init_controls(), and clamp default exposure in s5k5e8_set_ctrl().
- Set V4L2_SUBDEV_FL_HAS_EVENTS, use pm_runtime_get_if_in_use() == 0, call pm_runtime_dont_use_autosuspend() in s5k5e8_remove(), remove redundant 0x0100=0 writes in mode tables, document init_array_setting[] as the vendor flow, remove unused S5K5E8_AGAIN_SHIFT, add copyright headers, and unify probe error reporting with ret = dev_err_probe() and an explicit chip ID mismatch message.
- Update DT binding to require vdda-supply, vddd-supply, vddio-supply, and endpoint data-lanes (and enforce data-lanes presence in s5k5e8_check_hwcfg()), drop driver-mode claims from description, add data-lanes and powerdown-gpios to example, and add Tuan Kiet Huynh as binding maintainer.

Changes in v2:
- Rebase onto linux-media next branch and update .set_fmt/.get_selection for const struct v4l2_subdev_client_info *ci.
- Convert PM ops to pm_ptr().
- Place DT binding MAINTAINERS entry in patch 1/2.

Verification:
- Build/schema checks run against media-next:
- yamllint + make ARCH=arm64 DT_SCHEMA_FILES=Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml dt_binding_check: 0 warnings, 0 errors (samsung,s5k5e8.example.dtb built cleanly).
- ./scripts/checkpatch.pl --strict (with spdxcheck.py): 0 errors, 0 warnings, 0 checks on both patches (123 and 1071 lines checked).
- Compiled drivers/media/i2c/s5k5e8.o with GCC W=1 and Clang LLVM=1 W=1: 0 warnings, 0 errors.
- Applied cleanly via git am onto media-next (origin/next).
- Live hardware tests run on Xiaomi Redmi Note 4X (msm8953 / mido) using
downstream Linux 7.0.9-msm8953 with this driver backported (without
media-next's const struct v4l2_subdev_client_info *ci parameter in
set_fmt/get_selection):
- v4l2-compliance -u /dev/v4l-subdev17: Total: 46, Succeeded: 46, Failed: 0, Warnings: 0.
- media-ctl -d /dev/media0 -p (front sensor entity):
- entity 428: s5k5e8 4-002d (1 pad, 1 link, 0 routes)
pad0: SOURCE [stream:0 fmt:SGRBG10_1X10/2592x1944 field:none colorspace:raw xfer:none quantization:full-range
crop.bounds:(0,0)/2608x1960 crop:(8,8)/2592x1944]
- libcamera cam -c 2: verified streaming in both 1304x980 (59.81 fps)

    and 2592x1944 (29.89 fps) with SoftISP and unbind/bind cycle.

Andrii Cherniavskyi (2):
dt-bindings: media: i2c: Add Samsung S5K5E8 image sensor
media: i2c: Add Samsung S5K5E8 camera sensor driver

 .../bindings/media/i2c/samsung,s5k5e8.yaml    |  109 ++
 MAINTAINERS                                   |    9 +
 drivers/media/i2c/Kconfig                     |   10 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/s5k5e8.c                    | 1041 +++++++++++++++++
 5 files changed, 1170 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
 create mode 100644 drivers/media/i2c/s5k5e8.c
Signature · 1 line
2.43.0
#7 lore raw

PATCH v3 1/2 dt-bindings: media: i2c: Add Samsung S5K5E8 image sensor

From: Andrii Cherniavskyi <[email protected]>

Add Device Tree bindings for the Samsung S5K5E8 5MP RAW10 CMOS image sensor, including required regulators, optional reset/powerdown GPIOs, and 2-lane MIPI CSI-2 endpoint properties.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 109 ++++++++++++++++++
 MAINTAINERS                                   |   8 ++
 2 files changed, 117 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +109 -0
new file mode 100644
index 000000000..3aa50bd58
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/samsung,s5k5e8.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S5K5E8 Image Sensor
+
+description:
+  Samsung S5K5E8 is a 5MP CMOS image sensor controlled over an I2C-compatible
+  serial interface, outputting RAW10 image data over a 2-lane MIPI D-PHY
+  interface.
+
+maintainers:
+  - Andrii Cherniavskyi <[email protected]>
+  - Tuan Kiet Huynh <[email protected]>
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: MCLK supply clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Active low GPIO connected to RESET pad of the sensor.
+    maxItems: 1
+
+  powerdown-gpios:
+    description:
+      Active low GPIO connected to the XSHUTDN (powerdown) pad of the sensor.
+    maxItems: 1
+
+  vdda-supply:
+    description: Analogue voltage supply, 2.8 volts.
+
+  vddd-supply:
+    description: Digital core voltage supply, 1.2 volts.
+
+  vddio-supply:
+    description: Digital I/O voltage supply, 1.8 or 2.8 volts.
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: 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:
+  - compatible
+  - reg
+  - clocks
+  - vdda-supply
+  - vddd-supply
+  - vddio-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+      #include <dt-bindings/gpio/gpio.h>
+
+      i2c {
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          camera@2d {
+              compatible = "samsung,s5k5e8";
+              reg = <0x2d>;
+              clocks = <&camera_mclk 0>;
+              assigned-clocks = <&camera_mclk 0>;
+              assigned-clock-rates = <24000000>;
+              reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
+              powerdown-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
+              vdda-supply = <&vreg_2p8>;
+              vddd-supply = <&vreg_1p2>;
+              vddio-supply = <&vreg_1p8>;
+
+              port {
+                  endpoint {
+                      data-lanes = <1 2>;
+                      link-frequencies = /bits/ 64 <420000000>;
+                      remote-endpoint = <&mipi_csi2_ep>;
+                  };
+              };
+          };
+      };
+...
MAINTAINERS +8 -0
index f72ce07a4..10b7bf57a 100644
@@ -25013,6 +25013,14 @@ M:	Andrzej Hajda <[email protected]>
 S:	Supported
 F:	drivers/media/i2c/s5k5baf.c
 
+SAMSUNG S5K5E8 CAMERA DRIVER
+M:	Andrii Cherniavskyi <[email protected]>
+M:	Tuan Kiet Huynh <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
+
 SAMSUNG S5KJN1 CAMERA DRIVER
 M:	Vladimir Zapolskiy <[email protected]>
 S:	Maintained
Signature · 1 line
2.43.0
#8 lore raw

PATCH v3 2/2 media: i2c: Add Samsung S5K5E8 camera sensor driver

In reply to Tuan Kiet Huynh

From: Andrii Cherniavskyi <[email protected]>

Add V4L2 subdev driver for the Samsung S5K5E8 5MP CMOS image sensor, supporting 2592x1944 (30 fps) and 1304x980 (60 fps) RAW10 GRBG modes, exposure, analogue gain, VBLANK, H/V flip, test patterns, optional reset/powerdown GPIOs, and selection rectangles.

---
 MAINTAINERS                |    1 +
 drivers/media/i2c/Kconfig  |   10 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/s5k5e8.c | 1041 ++++++++++++++++++++++++++++++++++++
 4 files changed, 1053 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8.c
MAINTAINERS +1 -0
index 10b7bf57a..d55b9b1bc 100644
@@ -25020,6 +25020,7 @@ L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
+F:	drivers/media/i2c/s5k5e8.c
 
 SAMSUNG S5KJN1 CAMERA DRIVER
 M:	Vladimir Zapolskiy <[email protected]>
drivers/media/i2c/Kconfig +10 -0
index 162b8ea02..e36e50d8d 100644
@@ -885,6 +885,16 @@ config VIDEO_S5K5BAF
 	  This is a V4L2 sensor driver for Samsung S5K5BAF 2M
 	  camera sensor with an embedded SoC image signal processor.
 
+config VIDEO_S5K5E8
+	tristate "Samsung S5K5E8 sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a V4L2 sensor driver for Samsung S5K5E8 5MP raw
+	  camera sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k5e8.
+
 config VIDEO_S5K6A3
 	tristate "Samsung S5K6A3 sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index a750942e9..decc5035f 100644
@@ -137,6 +137,7 @@ obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
+obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
 obj-$(CONFIG_VIDEO_S5KJN5) += s5kjn5.o
drivers/media/i2c/s5k5e8.c new file +1041 -0

1,041 lines not on this page · raw message

Signature · 1 line
2.43.0