Skip to contentSkip to conversation

arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

PATCH Superseded Hikmah Gumelar 6 participants 40 messages Nov 23

Subsystems (7)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

This series enables both the front (Samsung S5K5E8) and rear (OmniVision OV12A10) MIPI CSI-2 cameras on the Xiaomi Mi A1 (msm8953-xiaomi-tissot):

- Fix the 100 MHz parent entry in ftbl_csi_phytimer_clk_src so gcc_camss_csi0phytimer_clk enables properly on MSM8953.
- Add Devicetree binding schemas and V4L2 subdev drivers for the Samsung S5K5E8 and OmniVision OV12A10 CMOS image sensors.
- Wire up CAMSS, CCI, CSIPHY0/CSIPHY2, and both camera sensors in msm8953-xiaomi-tissot.dts.

Tested on Xiaomi Mi A1 (tissot) using libcamera SimpleISP and GNOME Snapshot.

Hikmah Gumelar (6):
clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent
media: dt-bindings: media: i2c: add Samsung S5K5E8
media: i2c: add s5k5e8 image sensor driver
media: dt-bindings: media: i2c: add OmniVision OV12A10
media: i2c: add ov12a10 image sensor driver
arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

 .../bindings/media/i2c/ovti,ov12a10.yaml      | 115 +++
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 +++
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 114 +++
 drivers/clk/qcom/gcc-msm8953.c                |   2 +-
 drivers/media/i2c/Kconfig                     |  26 +
 drivers/media/i2c/Makefile                    |   2 +
 drivers/media/i2c/ov12a10.c                   | 720 ++++++++++++++++++
 drivers/media/i2c/s5k5e8.c                    | 500 ++++++++++++
 8 files changed, 1581 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
 create mode 100644 drivers/media/i2c/ov12a10.c
 create mode 100644 drivers/media/i2c/s5k5e8.c
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/6 clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot).

Switch the 100 MHz parent to P_GPLL0 with a divider of 8 (800 MHz / 8 = 100 MHz), matching the 200 MHz and 266.67 MHz entries.

---
 drivers/clk/qcom/gcc-msm8953.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-msm8953.c +1 -1
index c4ec9950ab68..3987cab327b4 100644
@@ -964,7 +964,7 @@ static struct clk_rcg2 csi2p_clk_src = {
 };
 
 static const struct freq_tbl ftbl_csi_phytimer_clk_src[] = {
-	F(100000000, P_GPLL0_DIV2, 4, 0, 0),
+	F(100000000, P_GPLL0, 8, 0, 0),
 	F(200000000, P_GPLL0, 4, 0, 0),
 	F(266670000, P_GPLL0, 3, 0, 0),
 	{ }
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/6 media: dt-bindings: media: i2c: add Samsung S5K5E8

In reply to Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +103 -0
new file mode 100644
index 000000000000..0e440209c3fd
@@ -0,0 +1,103 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org
+
+title: Samsung S5K5E8 1/5-inch 5Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  Samsung S5K5E8 is a 1/5-inch 5-megapixel CMOS active-pixel digital image
+  sensor with a 2-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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: 0
+              - const: 1
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@2d {
+            compatible = "samsung,s5k5e8";
+            reg = <0x2d>;
+            clocks = <&camss_mclk1>;
+            reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+            avdd-supply = <&pm8953_l22>;
+            dvdd-supply = <&pm8953_l23>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <0 1>;
+                    remote-endpoint = <&csiphy2_ep>;
+                    link-frequencies = /bits/ 64 <418000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#3 lore raw

Re: [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8

Quoted 9 lines · Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml: error checking schema file: cannot load meta-schema http://devicetree.org

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#4 lore raw

PATCH 3/6 media: i2c: add s5k5e8 image sensor driver

In reply to Hikmah Gumelar

Add V4L2 subdev driver for the Samsung S5K5E8 5MP MIPI CSI-2 image sensor supporting 2592x1944 raw10 capture.

---
 drivers/media/i2c/Kconfig  |  13 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/s5k5e8.c | 500 +++++++++++++++++++++++++++++++++++++
 3 files changed, 514 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8.c
drivers/media/i2c/Kconfig +13 -0
index e9e405ac94e4..3a0a041a4c2b 100644
@@ -805,6 +805,19 @@ config VIDEO_S5K3M5
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5k3m5.
 
+config VIDEO_S5K5E8
+	tristate "Samsung S5K5E8 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor driver for the Samsung
+	  S5K5E8 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k5e8.
+
 config VIDEO_S5K5BAF
 	tristate "Samsung S5K5BAF sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index 393927f55e05..f93d7205817d 100644
@@ -130,6 +130,7 @@ obj-$(CONFIG_VIDEO_SIMPLE_LENS) += simple-lens.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K2XX) += s5k2xx.o
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
+obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
drivers/media/i2c/s5k5e8.c new file +500 -0

500 lines not on this page · raw message

Signature · 1 line
2.47.3
#5 lore raw

PATCH 4/6 media: dt-bindings: media: i2c: add OmniVision OV12A10

In reply to Hikmah Gumelar

Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/ovti,ov12a10.yaml      | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +115 -0
new file mode 100644
index 000000000000..6919277c2b3f
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org
+
+title: OmniVision OV12A10 1/2.8-inch 12Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  OmniVision OV12A10 is a 1/2.8-inch 12-megapixel CMOS active-pixel digital
+  image sensor with a 4-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov12a10
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  pwdn-gpios:
+    description: Active-low power-down GPIO.
+    maxItems: 1
+
+  vana-gpios:
+    description: Active-high analog power enable GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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: 0
+              - const: 1
+              - const: 2
+              - const: 3
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@10 {
+            compatible = "ovti,ov12a10";
+            reg = <0x10>;
+            clocks = <&camss_mclk0>;
+            reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+            pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+            vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+            avdd-supply = <&pm8953_l22>;
+            dvdd-supply = <&pm8953_l2>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <0 1 2 3>;
+                    remote-endpoint = <&csiphy0_ep>;
+                    link-frequencies = /bits/ 64 <216000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#6 lore raw

PATCH 5/6 media: i2c: add ov12a10 image sensor driver

In reply to Hikmah Gumelar

Add V4L2 subdev driver for the OmniVision OV12A10 12MP MIPI CSI-2 image sensor supporting 1280x720 binned raw10 capture.

---
 drivers/media/i2c/Kconfig   |  13 +
 drivers/media/i2c/Makefile  |   1 +
 drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++++++++++++++++++++
 3 files changed, 734 insertions(+)
 create mode 100644 drivers/media/i2c/ov12a10.c
drivers/media/i2c/Kconfig +13 -0
index 3a0a041a4c2b..fd2928de223d 100644
@@ -454,6 +454,19 @@ config VIDEO_OV08X40
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov08x40.
 
+config VIDEO_OV12A10
+	tristate "OmniVision OV12A10 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor driver for the OmniVision
+	  OV12A10 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ov12a10.
+
 config VIDEO_OV13858
 	tristate "OmniVision OV13858 sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index f93d7205817d..27830499333f 100644
@@ -91,6 +91,7 @@ obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
 obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
 obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o
 obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o
+obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o
 obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
 obj-$(CONFIG_VIDEO_OV13B10) += ov13b10.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
drivers/media/i2c/ov12a10.c new file +720 -0

720 lines not on this page · raw message

Signature · 1 line
2.47.3
#7 lore raw

PATCH 6/6 arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

In reply to Hikmah Gumelar

Enable the CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear camera and Samsung S5K5E8 front camera on Xiaomi Mi A1 (tissot).

---
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 114 ++++++++++++++++++
 1 file changed, 114 insertions(+)
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +114 -0
index 8ba7982fcd81..40a14301ee3f 100644
@@ -271,6 +271,20 @@ headphones_amp_default: headphones-switch-default-state {
 		bias-disable;
 		output-low;
 	};
+
+	cam_sensor_rear_default: cam-sensor-rear-default-state {
+		pins = "gpio33", "gpio39", "gpio62";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
+
+	cam_sensor_front_default: cam-sensor-front-default-state {
+		pins = "gpio129";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
 };
 
 &uart_0 {
@@ -288,3 +302,103 @@ &wcd_codec {
 	qcom,mbhc-vthreshold-high = <91 259 488 488 488>;
 	qcom,mbhc-vthreshold-low = <91 259 488 488 488>;
 };
+
+&camss {
+	status = "okay";
+	vdda-supply = <&pm8953_s3>;
+
+	ports {
+		port@0 {
+			reg = <0>;
+			csiphy0_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&rear_cam_ep>;
+			};
+		};
+
+		port@2 {
+			reg = <2>;
+			csiphy2_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1>;
+				remote-endpoint = <&front_cam_ep>;
+			};
+		};
+	};
+};
+
+&cci {
+	pinctrl-names = "default";
+	pinctrl-0 = <&cci0_default>,
+		    <&cci1_default>,
+		    <&camss_mclk0_default>,
+		    <&camss_mclk1_default>,
+		    <&camss_mclk2_default>;
+
+	status = "okay";
+};
+
+&cci_i2c0 {
+	camera-sensor@10 {
+		compatible = "ovti,ov12a10";
+		reg = <0x10>;
+		clocks = <&gcc GCC_CAMSS_MCLK0_CLK>;
+		pinctrl-0 = <&cam_sensor_rear_default>;
+		pinctrl-names = "default";
+		reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+		pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+		vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l2>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <270>;
+		orientation = <1>;
+		status = "okay";
+		port {
+			rear_cam_ep: endpoint {
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&csiphy0_ep>;
+				link-frequencies = /bits/ 64 <216000000>;
+			};
+		};
+	};
+};
+
+&cci_i2c1 {
+	camera-sensor@2d {
+		compatible = "samsung,s5k5e8";
+		reg = <0x2d>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK1_CLK>;
+		pinctrl-0 = <&cam_sensor_front_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l23>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <90>;
+		orientation = <0>;
+
+		status = "okay";
+
+		port {
+			front_cam_ep: endpoint {
+				data-lanes = <0 1>;
+				remote-endpoint = <&csiphy2_ep>;
+				link-frequencies = /bits/ 64 <418000000>;
+			};
+		};
+	};
+};
+
+&pm8953_l23 {
+	regulator-min-microvolt = <1200000>;
+};
+
+&pm8953_l2 {
+	regulator-min-microvolt = <1200000>;
+	regulator-max-microvolt = <1225000>;
+};
Signature · 1 line
2.47.3
#8 lore raw

v2 cover arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

In reply to Hikmah Gumelar

Enable both the front (Samsung S5K5E8) and rear (OmniVision OV12A10) MIPI CSI-2 cameras on Xiaomi Mi A1 (msm8953-xiaomi-tissot).

Changes in v2:
- Rebased onto linux-media/media-committers.git next branch.
- Updated set_fmt and get_selection pad ops signatures for v7.4-rc.
- Added the missing MSM8953 SoC CAMSS node and MCLK pinctrl states to msm8953.dtsi so the board DTB builds cleanly on upstream.

Hikmah Gumelar (7):
clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent
media: dt-bindings: media: i2c: add Samsung S5K5E8
media: i2c: add s5k5e8 image sensor driver
media: dt-bindings: media: i2c: add OmniVision OV12A10
media: i2c: add ov12a10 image sensor driver
arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states
arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

 .../bindings/media/i2c/ovti,ov12a10.yaml      | 115 +++
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 +++
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 114 +++
 arch/arm64/boot/dts/qcom/msm8953.dtsi         | 155 ++++
 drivers/clk/qcom/gcc-msm8953.c                |   2 +-
 drivers/media/i2c/Kconfig                     |  18 +
 drivers/media/i2c/Makefile                    |   2 +
 drivers/media/i2c/ov12a10.c                   | 720 ++++++++++++++++++
 drivers/media/i2c/s5k5e8.c                    | 500 ++++++++++++
 9 files changed, 1728 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
 create mode 100644 drivers/media/i2c/ov12a10.c
 create mode 100644 drivers/media/i2c/s5k5e8.c
Signature · 1 line
2.47.3
#9 lore raw

PATCH v2 1/7 clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot).

Switch the 100 MHz parent to P_GPLL0 with a divider of 8 (800 MHz / 8 = 100 MHz), matching the 200 MHz and 266.67 MHz entries.

---
 drivers/clk/qcom/gcc-msm8953.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-msm8953.c +1 -1
index 8fe1d3e42144..8aec5600e837 100644
@@ -964,7 +964,7 @@ static struct clk_rcg2 csi2p_clk_src = {
 };
 
 static const struct freq_tbl ftbl_csi_phytimer_clk_src[] = {
-	F(100000000, P_GPLL0_DIV2, 4, 0, 0),
+	F(100000000, P_GPLL0, 8, 0, 0),
 	F(200000000, P_GPLL0, 4, 0, 0),
 	F(266670000, P_GPLL0, 3, 0, 0),
 	{ }
Signature · 1 line
2.47.3
#10 lore raw

Re: [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] clk: qcom: gcc-msm8953: missing Fixes trailer in commit message --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] clk: qcom: gcc-msm8953: missing Fixes trailer in commit message --

commit 59570529f8fc55fdf8adbdb3388beb1cf4e96df4
Author: Hikmah Gumelar <[email protected]>

Quoted 10 lines

clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot).

Switch the 100 MHz parent to P_GPLL0 with a divider of 8 (800 MHz / 8 = 100 MHz), matching the 200 MHz and 266.67 MHz entries.

[Severity: Low]
This fixes the 100 MHz entry in ftbl_csi_phytimer_clk_src introduced with the driver. Should the commit message include:

Fixes 9bb6cfc3c77e ("clk: qcom: Add Global Clock Controller driver for MSM8953")
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#11 lore raw

PATCH v2 2/7 media: dt-bindings: media: i2c: add Samsung S5K5E8

In reply to Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +103 -0
new file mode 100644
index 000000000000..0e440209c3fd
@@ -0,0 +1,103 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org
+
+title: Samsung S5K5E8 1/5-inch 5Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  Samsung S5K5E8 is a 1/5-inch 5-megapixel CMOS active-pixel digital image
+  sensor with a 2-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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: 0
+              - const: 1
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@2d {
+            compatible = "samsung,s5k5e8";
+            reg = <0x2d>;
+            clocks = <&camss_mclk1>;
+            reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+            avdd-supply = <&pm8953_l22>;
+            dvdd-supply = <&pm8953_l23>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <0 1>;
+                    remote-endpoint = <&csiphy2_ep>;
+                    link-frequencies = /bits/ 64 <418000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#12 lore raw

Re: [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] dt-bindings: media: i2c: invalid $id and $schema URIs in samsung,s5k5e8.yaml - [Medium]…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] dt-bindings: media: i2c: invalid $id and $schema URIs in samsung,s5k5e8.yaml
- [Medium] dt-bindings: media: i2c: 0-based CSI-2 data-lanes in samsung,s5k5e8.yaml
--

commit b55315d405d591f8eee7ad684f3b49e1f2a7e7c2
Author: Hikmah Gumelar <[email protected]>

media: dt-bindings: media: i2c: add Samsung S5K5E8

This commit adds a Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml line 5

Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +5 -0
new file mode 100644
index 0000000000000..0e440209c3fd2
@@ -0,0 +1,103 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org

[Severity: Medium]
Are $id and $schema truncated here? Running dt_binding_check fails unless $id is http://devicetree.org/schemas/media/i2c/samsung,s5k5e8.yaml# and $schema is http://devicetree.org/meta-schemas/core.yaml#.

[ ... ]

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +4 -0
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+

Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml line 55

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +10 -0
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          data-lanes:
+            items:
+              - const: 0
+              - const: 1

[Severity: Medium]
Should data-lanes use 1-based physical lane indices (1 and 2) here and in the example below?

Per video-interfaces.yaml and v4l2_fwnode_endpoint_parse_csi2_bus(), physical lane 0 on a MIPI CSI-2 D-PHY bus is the clock lane by default and data lanes are 1-indexed, so data-lanes = <0 1> assigns physical lane 0 to both the clock lane and data lane 0 while rejecting valid <1 2> endpoints.

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

Re: [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8

In reply to Hikmah Gumelar
Quoted 9 lines · Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml: error checking schema file: cannot load meta-schema http://devicetree.org

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#14 lore raw

PATCH v2 3/7 media: i2c: add s5k5e8 image sensor driver

In reply to Hikmah Gumelar
---
 drivers/media/i2c/Kconfig  |   9 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/s5k5e8.c | 500 +++++++++++++++++++++++++++++++++++++
 3 files changed, 510 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8.c
drivers/media/i2c/Kconfig +9 -0
index 162b8ea02601..095a911c5043 100644
@@ -879,6 +879,15 @@ config VIDEO_S5K3M5
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5k3m5.
 
+config VIDEO_S5K5E8
+	tristate "Samsung S5K5E8 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  V4L2 sensor driver for Samsung S5K5E8.
+
 config VIDEO_S5K5BAF
 	tristate "Samsung S5K5BAF sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index a750942e9c62..bdcb8f34aca3 100644
@@ -136,6 +136,7 @@ obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o
 obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
+obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
drivers/media/i2c/s5k5e8.c new file +500 -0

500 lines not on this page · raw message

Signature · 1 line
2.47.3
#15 lore raw

Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider: - [High] media: i2c: s5k5e8: broken runtime PM in s5k5e8_probe() and s5k5e8_set_ctrl() - [Medium] media: i2c…

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider:
- [High] media: i2c: s5k5e8: broken runtime PM in s5k5e8_probe() and s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: missing v4l2_subdev_cleanup() in probe() and remove()
- [Medium] media: i2c: s5k5e8: uninitialized and unupdated active state in set_format()
- [Medium] media: i2c: s5k5e8: missing exposure update on VBLANK in s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: missing clock rate and fwnode check in s5k5e8_probe()
- [Low] media: i2c: s5k5e8: custom CCI helpers, legacy s_stream, and missing pm_ptr()
- [Low] media: i2c: s5k5e8: missing pm_ptr() wrapper on s5k5e8_i2c_driver.driver.pm
- [Low] media: i2c: s5k5e8: empty commit message body for new sensor driver
--

commit e12574756509927d5cb3038e7e50ce4245c96a90
Author: Hikmah Gumelar <[email protected]>

Quoted 3 lines

media: i2c: add s5k5e8 image sensor driver

[Severity: Low]
This commit adds a new 500-line image sensor driver with an empty commit message body. Could a description of the sensor and its supported features be added to the changelog?

Quoted 5 lines
drivers/media/i2c/s5k5e8.c new file +0 -0
new file mode 100644
index 0000000000000..80931e5a1c6b2

[ ... ]

Quoted 37 lines
drivers/media/i2c/s5k5e8.c new file +37 -0
+static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
+	struct i2c_msg msgs[2];
+	u8 addr_buf[2], data_buf[4] = { 0 };
+	int ret;
+
+	put_unaligned_be16(reg, addr_buf);
+	msgs[0].addr = client->addr;
+	msgs[0].flags = 0;
+	msgs[0].len = 2;
+	msgs[0].buf = addr_buf;
+	msgs[1].addr = client->addr;
+	msgs[1].flags = I2C_M_RD;
+	msgs[1].len = len;
+	msgs[1].buf = &data_buf[4 - len];
+	ret = i2c_transfer(client->adapter, msgs, 2);
+	if (ret != 2)
+		return ret < 0 ? ret : -EIO;
+	*val = get_unaligned_be32(data_buf);
+	return 0;
+}
+
+static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
+	u8 buf[6];
+	int ret;
+
+	put_unaligned_be16(reg, buf);
+	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
+	ret = i2c_master_send(client, buf, len + 2);
+	return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO);
+}
+
+static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len)
+{

drivers/media/i2c/s5k5e8.c line 147

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	u32 i;
+	int ret;
+
+	for (i = 0; i < len; i++) {
+		ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}

[Severity: Low]
This isn't a bug, but s5k5e8_read_reg(), s5k5e8_write_reg(), and s5k5e8_write_regs() duplicate the standard V4L2 CCI regmap helpers. Could this driver select V4L2_CCI_I2C and use devm_cci_regmap_init_i2c(), cci_read(), cci_write(), and cci_multi_reg_write() instead? Likewise, new sensor drivers should implement v4l2_subdev_pad_ops.enable_streams and .disable_streams with v4l2_subdev_s_stream_helper rather than manual s5k5e8->streaming tracking in .s_stream, and wrap s5k5e8_pm_ops with pm_ptr().

[ ... ]

Quoted 15 lines
drivers/media/i2c/s5k5e8.c new file +15 -0
+static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler);
+	int ret = 0;
+
+	if (!pm_runtime_get_if_in_use(s5k5e8->dev))
+		return 0;
+	switch (ctrl->id) {
+	case V4L2_CID_ANALOGUE_GAIN:
+		ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_ANALOG_GAIN, 2, ctrl->val);
+	break;
+	case V4L2_CID_EXPOSURE:
+		ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_EXPOSURE, 2, ctrl->val);
+	break;
+	case V4L2_CID_VBLANK:

drivers/media/i2c/s5k5e8.c line 205

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+		ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_VTS, 2,
+				s5k5e8->cur_mode->height + ctrl->val);
+	break;
+	case V4L2_CID_TEST_PATTERN:
+		ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_TEST_PATTERN, 2, ctrl->val);
+	break;
+	}
+	pm_runtime_put(s5k5e8->dev);
+	return ret;
+}

[Severity: High]
Can s5k5e8_set_ctrl() underflow dev->power.usage_count and write to the sensor while runtime PM is disabled?

pm_runtime_get_if_in_use() returns -EINVAL without incrementing usage_count when runtime PM is disabled (or when CONFIG_PM is unset). Because !-EINVAL is false, s5k5e8_set_ctrl() proceeds with I2C writes and then calls an unbalanced pm_runtime_put(). In addition, s5k5e8_probe() calls v4l2_async_register_subdev_sensor() before pm_runtime_set_active() and pm_runtime_enable(), so if the bridge notifier is already registered, the subdevice can be bound and accessed while runtime PM is still disabled, causing pm_runtime_resume_and_get() in s5k5e8_set_stream() to fail with -EACCES.

Checking pm_runtime_get_if_in_use(s5k5e8->dev) <= 0 and enabling runtime PM before v4l2_async_register_subdev_sensor() (with proper unwind on error) would avoid both issues.

[Severity: Medium]
Should V4L2_CID_VBLANK in s5k5e8_set_ctrl() also update the maximum range of s5k5e8->exposure?

s5k5e8_init_controls() initializes V4L2_CID_EXPOSURE with a maximum of 1964 lines (vts_def - 4), but changing V4L2_CID_VBLANK never calls __v4l2_ctrl_modify_range() on s5k5e8->exposure before the pm_runtime_get_if_in_use() check. As a result, userspace cannot increase exposure beyond 1964 lines after increasing vertical blanking.

[ ... ]

Quoted 13 lines
drivers/media/i2c/s5k5e8.c new file +13 -0
+static int s5k5e8_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state,
+		struct v4l2_subdev_format *fmt)
+{
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+
+	s5k5e8_update_pad_format(&supported_modes[0], &fmt->format);
+	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+		*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+	else
+		s5k5e8->cur_mode = &supported_modes[0];
+
+	return 0;
+}

[ ... ]

drivers/media/i2c/s5k5e8.c line 372

Quoted 9 lines
drivers/media/i2c/s5k5e8.c new file +9 -0
+static int s5k5e8_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
+{
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+
+	mutex_lock(&s5k5e8->mutex);
+	s5k5e8_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, 0));
+	mutex_unlock(&s5k5e8->mutex);
+	return 0;
+}

[Severity: Medium]
Does this leave sd->active_state->pads[0].format permanently zeroed?

s5k5e8_probe() calls v4l2_subdev_init_finalize(), which initializes sd->active_state via internal_ops->init_state, but s5k5e8_internal_ops only provides .open (which initializes per-filehandle fh->state on devnode open). Furthermore, s5k5e8_set_format() only writes to *v4l2_subdev_state_get_format(sd_state, fmt->pad) when fmt->which is V4L2_SUBDEV_FORMAT_TRY. Any bridge driver or V4L2 helper querying the active format from sd->active_state will see width, height, and media bus code as 0.

Implementing .init_state in s5k5e8_internal_ops and unconditionally updating *v4l2_subdev_state_get_format(sd_state, fmt->pad) in s5k5e8_set_format() would also allow replacing s5k5e8_get_format() with v4l2_subdev_get_fmt.

[ ... ]

Quoted 7 lines
drivers/media/i2c/s5k5e8.c new file +7 -0
+static int s5k5e8_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct s5k5e8 *s5k5e8;
+	u32 val = 0;
+	unsigned int i;
+	int ret;

drivers/media/i2c/s5k5e8.c line 425

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+
+	s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL);
+	if (!s5k5e8)
+		return -ENOMEM;
+	s5k5e8->dev = dev;
+	v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops);
+	s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+	if (IS_ERR(s5k5e8->xvclk))
+		return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n");
+	clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);

[Severity: Medium]
Should s5k5e8_probe() validate the xvclk frequency and the fwnode endpoint configuration?

clk_set_rate() is called without checking its return value or verifying via clk_get_rate() that the clock rate matches S5K5E8_XVCLK_FREQ (24 MHz), which can leave the sensor PLL and MIPI link frequency misconfigured if a different rate is supplied. In addition, s5k5e8_probe() never parses the fwnode endpoint via v4l2_fwnode_endpoint_alloc_parse() to verify that the configured data-lanes and link-frequencies match the 2-lane, 418 MHz register settings hardcoded in the driver.

[ ... ]

Quoted 22 lines
drivers/media/i2c/s5k5e8.c new file +22 -0
+	s5k5e8->sd.state_lock = &s5k5e8->mutex;
+	ret = v4l2_subdev_init_finalize(&s5k5e8->sd);
+	if (ret)
+		goto err_media;
+	ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd);
+	if (ret)
+		goto err_media;
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+	return 0;
+err_media: media_entity_cleanup(&s5k5e8->sd.entity);
+err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler);
+err_mutex: mutex_destroy(&s5k5e8->mutex);
+err_power: s5k5e8_power_off(dev);
+	return ret;
+}
+
+static void s5k5e8_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);

drivers/media/i2c/s5k5e8.c line 488

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+
+	v4l2_async_unregister_subdev(sd);
+	media_entity_cleanup(&sd->entity);
+	v4l2_ctrl_handler_free(sd->ctrl_handler);
+	mutex_destroy(&s5k5e8->mutex);
+	pm_runtime_disable(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev))
+		s5k5e8_power_off(&client->dev);
+	pm_runtime_set_suspended(&client->dev);
+}

[Severity: Medium]
Does this leak sd->active_state when v4l2_async_register_subdev_sensor() fails or when s5k5e8_remove() runs?

v4l2_subdev_init_finalize() allocates sd->active_state, and v4l2_async_register_subdev_sensor() populates sd->async_subdev_endpoint_list, but neither the error path after v4l2_subdev_init_finalize() nor s5k5e8_remove() calls v4l2_subdev_cleanup(sd).

drivers/media/i2c/s5k5e8.c line 495

Quoted 7 lines
drivers/media/i2c/s5k5e8.c new file +7 -0
+
+static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off,
+		s5k5e8_power_on, NULL) };
+static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } };
+MODULE_DEVICE_TABLE(of, s5k5e8_of_match);
+static struct i2c_driver s5k5e8_i2c_driver = {
+	.driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match },

[Severity: Low]
Should s5k5e8_pm_ops use DEFINE_RUNTIME_DEV_PM_OPS() and be assigned via pm_ptr(&s5k5e8_pm_ops) so the PM structure and callbacks can be dropped by the compiler when CONFIG_PM is disabled?

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

Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver

In reply to Hikmah Gumelar

Hello,

drivers/media/i2c/s5k5e8.c line 6

Quoted 12 lines · Hikmah Gumelar
drivers/media/i2c/s5k5e8.c new file +6 -0
new file mode 100644
index 000000000000..80931e5a1c6b
@@ -0,0 +1,500 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>

<linux/i2c.h> already provides of_device_id, so please drop <linux/mod_devicetable.h> (which adds a lot of unneeded dependencies).

Quoted 52 lines
drivers/media/i2c/s5k5e8.c new file +52 -0
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/unaligned.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-fwnode.h>
+
+#define S5K5E8_CHIP_ID_REG		0x0000
+#define S5K5E8_CHIP_ID			0x5e80
+#define S5K5E8_REG_MODE_SELECT		0x0100
+#define S5K5E8_MODE_STANDBY		0x00
+#define S5K5E8_MODE_STREAMING		0x01
+#define S5K5E8_REG_VTS			0x0340
+#define S5K5E8_REG_EXPOSURE		0x0202
+#define S5K5E8_REG_ANALOG_GAIN		0x0204
+#define S5K5E8_REG_TEST_PATTERN		0x0600
+#define S5K5E8_XVCLK_FREQ		24000000
+#define S5K5E8_LINK_FREQ_418MHZ		418000000ULL
+#define S5K5E8_PIXEL_RATE		167200000ULL
+
+struct s5k5e8_reg { u16 address;
+u8 val;
+};
+struct s5k5e8_mode {
+	u32 width, height, hts_def, vts_def, vts_min, num_regs;
+	const struct s5k5e8_reg *regs;
+};
+
+static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" };
+#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names)
+
+static const struct s5k5e8_reg s5k5e8_common_regs[] = {
+	{ 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 },
+	{ 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e },
+	{ 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 },
+	{ 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 },
+	{ 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 },
+	{ 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 },
+	{ 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 },
+	{ 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 },
+	{ 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac },
+};
+
+static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = {
+	{ 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 },
+	{ 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 },
+	{ 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 },
+	{ 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 },
+	{ 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 },
+	{ 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 },
+	{ 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 },

drivers/media/i2c/s5k5e8.c line 68

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	{ 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 },
+	{ 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 },
+	{ 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 },
+	{ 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde },
+	{ 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 },
+	{ 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a },
+	{ 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 },
+	{ 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 },
+	{ 0x3313, 0x01 },
+};

Is this a reverse engineered table of initial register values? A comment would be awesome.

Quoted 6 lines
drivers/media/i2c/s5k5e8.c new file +6 -0
+static const struct s5k5e8_mode supported_modes[] = {
+	{
+		.width = 2592, .height = 1944, .hts_def = 2856,
+		.vts_def = 1968, .vts_min = 1968,
+		.num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs),
+		.regs = s5k5e8_2592x1944_regs,

drivers/media/i2c/s5k5e8.c

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +9 -0
+	},
+};
+
[...]
+static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state,
+		struct v4l2_subdev_frame_size_enum *fse)
+{
+	if (fse->index >= ARRAY_SIZE(supported_modes) ||
+	    fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
+		return -EINVAL;

ARRAY_SIZE(supported_modes) is one. Does supported_modes really need to be an array?

Quoted 27 lines
drivers/media/i2c/s5k5e8.c new file +26 -0
+	fse->min_width = fse->max_width = supported_modes[fse->index].width;
+	fse->min_height = fse->max_height = supported_modes[fse->index].height;
+	return 0;
+}
+
[...]
+static int s5k5e8_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct s5k5e8 *s5k5e8;
+	u32 val = 0;
+	unsigned int i;
+	int ret;
+
+	s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL);
+	if (!s5k5e8)
+		return -ENOMEM;
+	s5k5e8->dev = dev;
+	v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops);
+	s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+	if (IS_ERR(s5k5e8->xvclk))
+		return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n");
+	clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
+	s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(s5k5e8->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n");
+	for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++)

drivers/media/i2c/s5k5e8.c line 439

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+		s5k5e8->supplies[i].supply = s5k5e8_supply_names[i];
+	ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
+	if (ret)
+		return dev_err_probe(dev, ret, "regulators\n");
+	ret = s5k5e8_power_on(dev);
+	if (ret)
+		return ret;
+	ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val);
+	if (ret || val != S5K5E8_CHIP_ID) {
+		dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val);

Use dev_err_probe() for error messages in the probe function.

drivers/media/i2c/s5k5e8.c line 443

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+		ret = ret ? ret : -ENXIO;
+		goto err_power;
+	}
+	dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val);

Degrade to dev_dbg() or drop. Once the driver is considered ok, messages of this kind only clutter the kernel log with very little value and add to the boot time.

drivers/media/i2c/s5k5e8.c line 456

Quoted 13 lines
drivers/media/i2c/s5k5e8.c new file +13 -0
+	mutex_init(&s5k5e8->mutex);
+	s5k5e8->cur_mode = &supported_modes[0];
+	ret = s5k5e8_init_controls(s5k5e8);
+	if (ret)
+		goto err_mutex;
+	s5k5e8->sd.internal_ops = &s5k5e8_internal_ops;
+	s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+	s5k5e8->sd.entity.ops = &s5k5e8_entity_ops;
+	s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+	s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE;
+	ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad);
+	if (ret)
+		goto err_ctrl;

Use newlines to separate function call + its error handling from the other code.

Quoted 5 lines
drivers/media/i2c/s5k5e8.c new file +5 -0
+	s5k5e8->sd.state_lock = &s5k5e8->mutex;
+	ret = v4l2_subdev_init_finalize(&s5k5e8->sd);
+	if (ret)
+		goto err_media;
+	ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd);

drivers/media/i2c/s5k5e8.c line 471

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	if (ret)
+		goto err_media;
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+	return 0;
+err_media: media_entity_cleanup(&s5k5e8->sd.entity);
+err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler);
+err_mutex: mutex_destroy(&s5k5e8->mutex);
+err_power: s5k5e8_power_off(dev);

A label should be on its own line.

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	return ret;
+}
+
+static void s5k5e8_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+
+	v4l2_async_unregister_subdev(sd);
+	media_entity_cleanup(&sd->entity);

drivers/media/i2c/s5k5e8.c line 491

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	v4l2_ctrl_handler_free(sd->ctrl_handler);
+	mutex_destroy(&s5k5e8->mutex);
+	pm_runtime_disable(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev))
+		s5k5e8_power_off(&client->dev);
+	pm_runtime_set_suspended(&client->dev);
+}
+
+static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off,
+		s5k5e8_power_on, NULL) };

This looks strange. I'd add a \n before SET_RUNTIME_PM_OPS. In general align continuation lines to the previous opening brace or parenthesis.

Quoted 1 line

+static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } };

Please fix the layout of this struct. It should look like:

static const struct of_device_id s5k5e8_of_match[] = {
	{ .compatible = "samsung,s5k5e8" },
	{ }
};

drivers/media/i2c/s5k5e8.c line 496

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+MODULE_DEVICE_TABLE(of, s5k5e8_of_match);
+static struct i2c_driver s5k5e8_i2c_driver = {
+	.driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match },
+	.probe = s5k5e8_probe, .remove = s5k5e8_remove,

This also lacks newlines.

drivers/media/i2c/s5k5e8.c line 500

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+};
+module_i2c_driver(s5k5e8_i2c_driver);
+MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver");
+MODULE_LICENSE("GPL");

The same critics apply to (at least) patch #5, too.

Best regards
Uwe

#17 lore raw

Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver

Hi Uwe,
Thanks for the review! I had just sent out v3 right before seeing your feedback; I will drop <linux/mod_devicetable.h> from both s5k5e8.c and ov12a10.c in v4 along with any further review comments on v3. Best regards,
Hikmah

Pada Sen, 23 Nov 2026 pukul 20.56 Uwe Kleine-König <[email protected]> menulis:

Quoted 240 lines

Hello,

drivers/media/i2c/s5k5e8.c line 6

Quoted 12 lines · Hikmah Gumelar
drivers/media/i2c/s5k5e8.c new file +6 -0
new file mode 100644
index 000000000000..80931e5a1c6b
@@ -0,0 +1,500 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>

<linux/i2c.h> already provides of_device_id, so please drop <linux/mod_devicetable.h> (which adds a lot of unneeded dependencies).

Quoted 52 lines
drivers/media/i2c/s5k5e8.c new file +52 -0
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/unaligned.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-fwnode.h>
+
+#define S5K5E8_CHIP_ID_REG           0x0000
+#define S5K5E8_CHIP_ID                       0x5e80
+#define S5K5E8_REG_MODE_SELECT               0x0100
+#define S5K5E8_MODE_STANDBY          0x00
+#define S5K5E8_MODE_STREAMING                0x01
+#define S5K5E8_REG_VTS                       0x0340
+#define S5K5E8_REG_EXPOSURE          0x0202
+#define S5K5E8_REG_ANALOG_GAIN               0x0204
+#define S5K5E8_REG_TEST_PATTERN              0x0600
+#define S5K5E8_XVCLK_FREQ            24000000
+#define S5K5E8_LINK_FREQ_418MHZ              418000000ULL
+#define S5K5E8_PIXEL_RATE            167200000ULL
+
+struct s5k5e8_reg { u16 address;
+u8 val;
+};
+struct s5k5e8_mode {
+     u32 width, height, hts_def, vts_def, vts_min, num_regs;
+     const struct s5k5e8_reg *regs;
+};
+
+static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" };
+#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names)
+
+static const struct s5k5e8_reg s5k5e8_common_regs[] = {
+     { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 },
+     { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e },
+     { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 },
+     { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 },
+     { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 },
+     { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 },
+     { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 },
+     { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 },
+     { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac },
+};
+
+static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = {
+     { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 },
+     { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 },
+     { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 },
+     { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 },
+     { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 },
+     { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 },
+     { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 },

drivers/media/i2c/s5k5e8.c line 68

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+     { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 },
+     { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 },
+     { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 },
+     { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde },
+     { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 },
+     { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a },
+     { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 },
+     { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 },
+     { 0x3313, 0x01 },
+};

Is this a reverse engineered table of initial register values? A comment would be awesome.

Quoted 6 lines
drivers/media/i2c/s5k5e8.c new file +6 -0
+static const struct s5k5e8_mode supported_modes[] = {
+     {
+             .width = 2592, .height = 1944, .hts_def = 2856,
+             .vts_def = 1968, .vts_min = 1968,
+             .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs),
+             .regs = s5k5e8_2592x1944_regs,

drivers/media/i2c/s5k5e8.c

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +9 -0
+     },
+};
+
[...]
+static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state,
+             struct v4l2_subdev_frame_size_enum *fse)
+{
+     if (fse->index >= ARRAY_SIZE(supported_modes) ||
+         fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
+             return -EINVAL;

ARRAY_SIZE(supported_modes) is one. Does supported_modes really need to be an array?

Quoted 27 lines
drivers/media/i2c/s5k5e8.c new file +26 -0
+     fse->min_width = fse->max_width = supported_modes[fse->index].width;
+     fse->min_height = fse->max_height = supported_modes[fse->index].height;
+     return 0;
+}
+
[...]
+static int s5k5e8_probe(struct i2c_client *client)
+{
+     struct device *dev = &client->dev;
+     struct s5k5e8 *s5k5e8;
+     u32 val = 0;
+     unsigned int i;
+     int ret;
+
+     s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL);
+     if (!s5k5e8)
+             return -ENOMEM;
+     s5k5e8->dev = dev;
+     v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops);
+     s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+     if (IS_ERR(s5k5e8->xvclk))
+             return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n");
+     clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
+     s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+     if (IS_ERR(s5k5e8->reset_gpio))
+             return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n");
+     for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++)

drivers/media/i2c/s5k5e8.c line 439

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+             s5k5e8->supplies[i].supply = s5k5e8_supply_names[i];
+     ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
+     if (ret)
+             return dev_err_probe(dev, ret, "regulators\n");
+     ret = s5k5e8_power_on(dev);
+     if (ret)
+             return ret;
+     ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val);
+     if (ret || val != S5K5E8_CHIP_ID) {
+             dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val);

Use dev_err_probe() for error messages in the probe function.

drivers/media/i2c/s5k5e8.c line 443

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+             ret = ret ? ret : -ENXIO;
+             goto err_power;
+     }
+     dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val);

Degrade to dev_dbg() or drop. Once the driver is considered ok, messages of this kind only clutter the kernel log with very little value and add to the boot time.

drivers/media/i2c/s5k5e8.c line 456

Quoted 13 lines
drivers/media/i2c/s5k5e8.c new file +13 -0
+     mutex_init(&s5k5e8->mutex);
+     s5k5e8->cur_mode = &supported_modes[0];
+     ret = s5k5e8_init_controls(s5k5e8);
+     if (ret)
+             goto err_mutex;
+     s5k5e8->sd.internal_ops = &s5k5e8_internal_ops;
+     s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+     s5k5e8->sd.entity.ops = &s5k5e8_entity_ops;
+     s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+     s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE;
+     ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad);
+     if (ret)
+             goto err_ctrl;

Use newlines to separate function call + its error handling from the other code.

Quoted 5 lines
drivers/media/i2c/s5k5e8.c new file +5 -0
+     s5k5e8->sd.state_lock = &s5k5e8->mutex;
+     ret = v4l2_subdev_init_finalize(&s5k5e8->sd);
+     if (ret)
+             goto err_media;
+     ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd);

drivers/media/i2c/s5k5e8.c line 471

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+     if (ret)
+             goto err_media;
+     pm_runtime_set_active(dev);
+     pm_runtime_enable(dev);
+     pm_runtime_idle(dev);
+     return 0;
+err_media: media_entity_cleanup(&s5k5e8->sd.entity);
+err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler);
+err_mutex: mutex_destroy(&s5k5e8->mutex);
+err_power: s5k5e8_power_off(dev);

A label should be on its own line.

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+     return ret;
+}
+
+static void s5k5e8_remove(struct i2c_client *client)
+{
+     struct v4l2_subdev *sd = i2c_get_clientdata(client);
+     struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+
+     v4l2_async_unregister_subdev(sd);
+     media_entity_cleanup(&sd->entity);

drivers/media/i2c/s5k5e8.c line 491

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+     v4l2_ctrl_handler_free(sd->ctrl_handler);
+     mutex_destroy(&s5k5e8->mutex);
+     pm_runtime_disable(&client->dev);
+     if (!pm_runtime_status_suspended(&client->dev))
+             s5k5e8_power_off(&client->dev);
+     pm_runtime_set_suspended(&client->dev);
+}
+
+static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off,
+             s5k5e8_power_on, NULL) };

This looks strange. I'd add a \n before SET_RUNTIME_PM_OPS. In general align continuation lines to the previous opening brace or parenthesis.

Quoted 1 line

+static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } };

Please fix the layout of this struct. It should look like:

static const struct of_device_id s5k5e8_of_match[] = {
        { .compatible = "samsung,s5k5e8" },
        { }
};

drivers/media/i2c/s5k5e8.c line 496

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+MODULE_DEVICE_TABLE(of, s5k5e8_of_match);
+static struct i2c_driver s5k5e8_i2c_driver = {
+     .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match },
+     .probe = s5k5e8_probe, .remove = s5k5e8_remove,

This also lacks newlines.

drivers/media/i2c/s5k5e8.c line 500

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+};
+module_i2c_driver(s5k5e8_i2c_driver);
+MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver");
+MODULE_LICENSE("GPL");

The same critics apply to (at least) patch #5, too.

Best regards
Uwe

Signature · 2 lines
Best regards,
Hikmah Gumelar
#18 lore raw

PATCH v2 4/7 media: dt-bindings: media: i2c: add OmniVision OV12A10

In reply to Hikmah Gumelar

Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/ovti,ov12a10.yaml      | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +115 -0
new file mode 100644
index 000000000000..6919277c2b3f
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org
+
+title: OmniVision OV12A10 1/2.8-inch 12Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  OmniVision OV12A10 is a 1/2.8-inch 12-megapixel CMOS active-pixel digital
+  image sensor with a 4-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov12a10
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  pwdn-gpios:
+    description: Active-low power-down GPIO.
+    maxItems: 1
+
+  vana-gpios:
+    description: Active-high analog power enable GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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: 0
+              - const: 1
+              - const: 2
+              - const: 3
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@10 {
+            compatible = "ovti,ov12a10";
+            reg = <0x10>;
+            clocks = <&camss_mclk0>;
+            reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+            pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+            vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+            avdd-supply = <&pm8953_l22>;
+            dvdd-supply = <&pm8953_l2>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <0 1 2 3>;
+                    remote-endpoint = <&csiphy0_ep>;
+                    link-frequencies = /bits/ 64 <216000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#19 lore raw

Re: [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] media: dt-bindings: ovti,ov12a10: invalid $id and $schema URIs break validation - [Medium] media…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] media: dt-bindings: ovti,ov12a10: invalid $id and $schema URIs break validation
- [Medium] media: dt-bindings: ovti,ov12a10: 0-based MIPI CSI-2 D-PHY data-lanes indices
- [Low] media: dt-bindings: ovti,ov12a10: deprecated pwdn-gpios and custom vana-gpios
--

commit 2adecf2c1e39908b70d5c8d587dc348d341ebb34
Author: Hikmah Gumelar <[email protected]>

media: dt-bindings: media: i2c: add OmniVision OV12A10

This commit adds a Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor.

Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml line 5

Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +5 -0
new file mode 100644
index 0000000000000..6919277c2b3f2
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org
+$schema: http://devicetree.org

[Severity: Medium]
Should $id be http://devicetree.org/schemas/media/i2c/ovti,ov12a10.yaml#
and $schema be http://devicetree.org/meta-schemas/core.yaml#? The bare
http://devicetree.org URIs cause make dt_binding_check to fail validation.

[ ... ]

Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +4 -0
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+

Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml line 42

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +10 -0
+  pwdn-gpios:
+    description: Active-low power-down GPIO.
+    maxItems: 1
+
+  vana-gpios:
+    description: Active-high analog power enable GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).

[Severity: Low]
pwdn-gpios is marked deprecated in Documentation/devicetree/bindings/gpio/gpio-consumer-common.yaml in favor of powerdown-gpios. Also, since avdd-supply is already required for the analog supply, a board-level GPIO enabling an external analog regulator or load switch should be modeled as a regulator-fixed node supplying avdd-supply rather than a custom vana-gpios property on the sensor node.

[ ... ]

Quoted 13 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +13 -0
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          data-lanes:
+            items:
+              - const: 0
+              - const: 1
+              - const: 2
+              - const: 3
+
+          link-frequencies: true

[ ... ]

Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml line 112

Quoted 7 lines
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +7 -0
+            port {
+                endpoint {
+                    data-lanes = <0 1 2 3>;
+                    remote-endpoint = <&csiphy0_ep>;
+                    link-frequencies = /bits/ 64 <216000000>;
+                };
+            };

[Severity: Medium]
Should data-lanes be 1-based (<1 2 3 4>) instead of 0-based (<0 1 2 3>)? Per Documentation/devicetree/bindings/media/video-interfaces.yaml and v4l2_fwnode_endpoint_parse_csi2_bus(), physical lane 0 on a MIPI CSI-2 D-PHY bus is the clock lane and data lane indices are 1..4, so constraining data-lanes to 0..3 collides with the default clock lane and rejects valid 1-based sensor endpoints.

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

Re: [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10

In reply to Hikmah Gumelar
Quoted 9 lines · Hikmah Gumelar

Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/ovti,ov12a10.yaml      | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml: warning: ignoring duplicate '$id' value 'http://devicetree.org' ./Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml: error checking schema file: cannot load meta-schema http://devicetree.org
./Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml: error checking schema file: cannot load meta-schema http://devicetree.org
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.example.dtb: /example-0/i2c/camera-sensor@10: failed to match any schema with compatible: ['ovti,ov12a10']

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#21 lore raw

PATCH v2 5/7 media: i2c: add ov12a10 image sensor driver

In reply to Hikmah Gumelar
---
 drivers/media/i2c/Kconfig   |   9 +
 drivers/media/i2c/Makefile  |   1 +
 drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++++++++++++++++++++
 3 files changed, 730 insertions(+)
 create mode 100644 drivers/media/i2c/ov12a10.c
drivers/media/i2c/Kconfig +9 -0
index 095a911c5043..280c8ba9a215 100644
@@ -538,6 +538,15 @@ config VIDEO_OV08X40
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov08x40.
 
+config VIDEO_OV12A10
+	tristate "OmniVision OV12A10 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  V4L2 sensor driver for OmniVision OV12A10.
+
 config VIDEO_OV13858
 	tristate "OmniVision OV13858 sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index bdcb8f34aca3..8148ee872a31 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
 obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o
 obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o
 obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o
+obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o
 obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
 obj-$(CONFIG_VIDEO_OV13B10) += ov13b10.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
drivers/media/i2c/ov12a10.c new file +720 -0

720 lines not on this page · raw message

Signature · 1 line
2.47.3
#22 lore raw

Re: [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver

Thank you for your contribution! Sashiko AI review found 11 potential issues to consider: - [High] media: i2c: ov12a10: missing IS_ERR() checks on GPIOs in ov12a10_probe() - [Medium] media: i2c…

Thank you for your contribution! Sashiko AI review found 11 potential issues to consider:
- [High] media: i2c: ov12a10: missing IS_ERR() checks on GPIOs in ov12a10_probe()
- [Medium] media: i2c: ov12a10: missing vana_gpio rollback in ov12a10_power_on()
- [Medium] media: i2c: ov12a10: missing v4l2_subdev_cleanup() in probe() and remove()
- [Medium] media: i2c: ov12a10: uninitialized active state in ov12a10_set_format()
- [Medium] media: i2c: ov12a10: runtime PM ordering in probe() and ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing test pattern enable bit in ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing exposure range update in ov12a10_set_ctrl()
- [Low] media: i2c: ov12a10: missing fwnode endpoint validation in ov12a10_probe()
- [Low] media: i2c: ov12a10: mismatched OV12A10_REG_EXPOSURE and unused macros
- [Low] media: i2c: ov12a10: missing pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS()
- [Low] media: i2c: ov12a10: empty commit message and coding style violations
--

commit 87e706783d08e4892b5ba94e037a4944e990a93f
Author: Hikmah Gumelar <[email protected]>

Quoted 3 lines

media: i2c: add ov12a10 image sensor driver

[Severity: Low]
This commit adds a new V4L2 image sensor driver with an empty commit message body. Please include a description of the OmniVision OV12A10 sensor and the features supported by the driver.

Quoted 6 lines
drivers/media/i2c/ov12a10.c new file +0 -0
new file mode 100644
index 0000000000000..ce2e01bc67e0c
@@ -0,0 +1,720 @@

[ ... ]

drivers/media/i2c/ov12a10.c line 26

Quoted 12 lines
drivers/media/i2c/ov12a10.c new file +12 -0
+#define OV12A10_CHIP_ID_REG		0x300a
+#define OV12A10_CHIP_ID			0x5612
+#define OV12A10_REG_MODE_SELECT		0x0100
+#define OV12A10_MODE_STANDBY		0x00
+#define OV12A10_MODE_STREAMING		0x01
+#define OV12A10_REG_VTS			0x380e
+#define OV12A10_REG_EXPOSURE		0x3501
+#define OV12A10_REG_ANALOG_GAIN		0x3508
+#define OV12A10_REG_TEST_PATTERN		0x5080
+#define OV12A10_XVCLK_FREQ		24000000
+#define OV12A10_LINK_FREQ_216MHZ		216000000ULL
+#define OV12A10_PIXEL_RATE		144000000ULL

[Severity: Low]
Should OV12A10_REG_EXPOSURE be 0x3500 instead of 0x3501? ov12a10_set_ctrl() performs a 3-byte write for V4L2_CID_EXPOSURE starting at hardcoded register 0x3500, leaving OV12A10_REG_EXPOSURE unused. OV12A10_MODE_STREAMING is also unused because ov12a10_set_stream() uses a local stream_on_regs[] table with raw values { 0x0100, 0x01 }.

drivers/media/i2c/ov12a10.c line 30

Quoted 4 lines
drivers/media/i2c/ov12a10.c new file +4 -0
+
+struct ov12a10_reg { u16 address;
+u8 val;
+};

[Severity: Low]
This isn't a bug, but the formatting of struct ov12a10_reg, the misaligned break statements in ov12a10_set_ctrl(), and the goto labels sharing lines with cleanup calls in ov12a10_probe() do not follow kernel coding style.

[ ... ]

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_power_on(struct device *dev)
+{
+	struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev));
+	int ret;
+
+	if (ov12a10->vana_gpio)
+		gpiod_set_value_cansleep(ov12a10->vana_gpio, 1);

drivers/media/i2c/ov12a10.c line 374

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+
+	ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(ov12a10->xvclk);
+	if (ret) {
+		regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
+		return ret;
+	}

[Severity: Medium]
Does ov12a10_power_on() leave ov12a10->vana_gpio asserted high when regulator_bulk_enable() or clk_prepare_enable() fails?

[ ... ]

drivers/media/i2c/ov12a10.c line 409

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler);
+	int ret = 0;
+
+	if (!pm_runtime_get_if_in_use(ov12a10->dev))
+		return 0;

[Severity: Medium]
Can pm_runtime_get_if_in_use() return -EINVAL here without incrementing the runtime PM usage counter?

When runtime PM is disabled (for example on a kernel without CONFIG_PM, or during the window in ov12a10_probe() where v4l2_async_register_subdev_sensor() runs before pm_runtime_enable()), pm_runtime_get_if_in_use() returns -EINVAL, so ov12a10_set_ctrl() proceeds to write registers and calls an unbalanced pm_runtime_put() that underflows usage_count. Checking pm_runtime_get_if_in_use(ov12a10->dev) <= 0 and enabling runtime PM before registering the async subdevice in ov12a10_probe() would avoid both issues.

drivers/media/i2c/ov12a10.c line 420

Quoted 11 lines
drivers/media/i2c/ov12a10.c new file +11 -0
+	switch (ctrl->id) {
+	case V4L2_CID_ANALOGUE_GAIN:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_ANALOG_GAIN, 2, ctrl->val);
+	break;
+	case V4L2_CID_EXPOSURE:
+		ret = ov12a10_write_reg(ov12a10, 0x3500, 3, ctrl->val << 4);
+	break;
+	case V4L2_CID_VBLANK:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_VTS, 2,
+				ov12a10->cur_mode->height + ctrl->val);
+	break;

[Severity: Medium]
Should changing V4L2_CID_VBLANK also update the range of ov12a10->exposure via __v4l2_ctrl_modify_range() before the pm_runtime_get_if_in_use() check? Without that, lowering V4L2_CID_VBLANK (for example to its minimum of 124, giving VTS = 844) leaves ov12a10->exposure with a maximum of 3360 and default of 2400, allowing exposure values that exceed VTS.

drivers/media/i2c/ov12a10.c line 423

Quoted 3 lines
drivers/media/i2c/ov12a10.c new file +3 -0
+	case V4L2_CID_TEST_PATTERN:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_TEST_PATTERN, 1, ctrl->val);
+	break;

[Severity: Medium]
Does writing ctrl->val directly to OV12A10_REG_TEST_PATTERN (0x5080) leave the test pattern generator disabled for non-zero menu items? On OmniVision sensors using register 0x5080, BIT(7) must be set to enable test pattern output.

[ ... ]

drivers/media/i2c/ov12a10.c line 516

Quoted 13 lines
drivers/media/i2c/ov12a10.c new file +13 -0
+static int ov12a10_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state,
+		struct v4l2_subdev_format *fmt)
+{
+	struct ov12a10 *ov12a10 = to_ov12a10(sd);
+
+	ov12a10_update_pad_format(&supported_modes[0], &fmt->format);
+	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+		*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+	else
+		ov12a10->cur_mode = &supported_modes[0];
+
+	return 0;
+}

[Severity: Medium]
Does this leave sd->active_state uninitialized when fmt->which is V4L2_SUBDEV_FORMAT_ACTIVE?

ov12a10_probe() calls v4l2_subdev_init_finalize(), but ov12a10_internal_ops implements .open instead of .init_state and ov12a10_set_format() only writes to sd_state for V4L2_SUBDEV_FORMAT_TRY. As a result, sd->active_state->pads[0].format stays zero-initialized for the lifetime of the subdevice, breaking format queries or link validation in callers that inspect active subdev state.

[ ... ]

drivers/media/i2c/ov12a10.c line 633

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct ov12a10 *ov12a10;
+	u32 val = 0;
+	unsigned int i;
+	int ret;

[Severity: Low]
Should ov12a10_probe() parse and validate the fwnode graph endpoint using v4l2_fwnode_endpoint_alloc_parse()? The DT binding requires a port endpoint with 4 CSI-2 data lanes and a 216 MHz link-frequencies property, which are currently never checked.

Quoted 5 lines
drivers/media/i2c/ov12a10.c new file +5 -0
+
+	ov12a10 = devm_kzalloc(dev, sizeof(*ov12a10), GFP_KERNEL);
+	if (!ov12a10)
+		return -ENOMEM;
+	ov12a10->dev = dev;

drivers/media/i2c/ov12a10.c line 648

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+	v4l2_i2c_subdev_init(&ov12a10->sd, client, &ov12a10_subdev_ops);
+	ov12a10->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+	if (IS_ERR(ov12a10->xvclk))
+		return dev_err_probe(dev, PTR_ERR(ov12a10->xvclk), "xvclk\n");
+	clk_set_rate(ov12a10->xvclk, OV12A10_XVCLK_FREQ);
+	ov12a10->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	ov12a10->vana_gpio = devm_gpiod_get_optional(dev, "vana", GPIOD_OUT_LOW);
+	ov12a10->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH);
+	if (IS_ERR(ov12a10->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(ov12a10->reset_gpio), "reset\n");

[Severity: High]
What happens if devm_gpiod_get_optional() returns an error or -EPROBE_DEFER for ov12a10->vana_gpio or ov12a10->pwdn_gpio?

Because only ov12a10->reset_gpio is checked with IS_ERR(), a non-NULL ERR_PTR stored in vana_gpio or pwdn_gpio passes the truthiness checks in ov12a10_power_on() and ov12a10_power_off() and is passed straight to gpiod_set_value_cansleep(), triggering a warning in gpiolib and breaking probe deferral.

[ ... ]

Quoted 15 lines
drivers/media/i2c/ov12a10.c new file +15 -0
+	ret = v4l2_subdev_init_finalize(&ov12a10->sd);
+	if (ret)
+		goto err_media;
+	ret = v4l2_async_register_subdev_sensor(&ov12a10->sd);
+	if (ret)
+		goto err_media;
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+	return 0;
+err_media: media_entity_cleanup(&ov12a10->sd.entity);
+err_ctrl: v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler);
+err_mutex: mutex_destroy(&ov12a10->mutex);
+err_power: ov12a10_power_off(dev);
+	return ret;

drivers/media/i2c/ov12a10.c line 702

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+}
+
+static void ov12a10_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct ov12a10 *ov12a10 = to_ov12a10(sd);
+
+	v4l2_async_unregister_subdev(sd);
+	media_entity_cleanup(&sd->entity);
+	v4l2_ctrl_handler_free(sd->ctrl_handler);

[Severity: Medium]
Does omitting v4l2_subdev_cleanup() in ov12a10_remove() and on the v4l2_async_register_subdev_sensor() error path in ov12a10_probe() leak sd->active_state allocated by v4l2_subdev_init_finalize()?

[ ... ]

drivers/media/i2c/ov12a10.c line 715

Quoted 6 lines
drivers/media/i2c/ov12a10.c new file +6 -0
+static const struct dev_pm_ops ov12a10_pm_ops = { SET_RUNTIME_PM_OPS(ov12a10_power_off,
+		ov12a10_power_on, NULL) };
+static const struct of_device_id ov12a10_of_match[] = { { .compatible = "ovti,ov12a10" }, { } };
+MODULE_DEVICE_TABLE(of, ov12a10_of_match);
+static struct i2c_driver ov12a10_i2c_driver = {
+	.driver = { .name = "ov12a10", .pm = &ov12a10_pm_ops, .of_match_table = ov12a10_of_match },

[Severity: Low]
This isn't a bug, but using DEFINE_RUNTIME_DEV_PM_OPS() for ov12a10_pm_ops and wrapping .pm with pm_ptr(&ov12a10_pm_ops) would allow the PM callbacks to be dropped when CONFIG_PM is disabled.

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

PATCH v2 6/7 arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states

In reply to Hikmah Gumelar

Add the camera subsystem (CAMSS) node and MCLK0/1/2 pin control states to the Qualcomm MSM8953 SoC Devicetree.

---
 arch/arm64/boot/dts/qcom/msm8953.dtsi | 155 ++++++++++++++++++++++++++
 1 file changed, 155 insertions(+)
arch/arm64/boot/dts/qcom/msm8953.dtsi +155 -0
index 753167c3f861..2e64fb8bbb2e 100644
@@ -902,6 +902,27 @@ sdc1_cmd_off: sdc1-cmd-off-state {
 				drive-strength = <2>;
 			};
 
+			camss_mclk0_default: camss-mclk0-default-state {
+				pins = "gpio26";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
+			camss_mclk1_default: camss-mclk1-default-state {
+				pins = "gpio27";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
+			camss_mclk2_default: camss-mclk2-default-state {
+				pins = "gpio28";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
 			sdc1_data_on: sdc1-data-on-state {
 				pins = "sdc1_data";
 				bias-pull-up;
@@ -1257,6 +1278,140 @@ cci_i2c1: i2c-bus@1 {
 			};
 		};
 
+		camss: camss@1b00020 {
+			compatible = "qcom,msm8953-camss";
+
+			reg = <0x1b00020 0x10>,
+			      <0x1b30000 0x100>,
+			      <0x1b30400 0x100>,
+			      <0x1b30800 0x100>,
+			      <0x1b34000 0x1000>,
+			      <0x1b00030 0x4>,
+			      <0x1b35000 0x1000>,
+			      <0x1b00038 0x4>,
+			      <0x1b36000 0x1000>,
+			      <0x1b00040 0x4>,
+			      <0x1b31000 0x500>,
+			      <0x1b10000 0x1000>,
+			      <0x1b14000 0x1000>;
+			reg-names = "csi_clk_mux",
+				    "csid0",
+				    "csid1",
+				    "csid2",
+				    "csiphy0",
+				    "csiphy0_clk_mux",
+				    "csiphy1",
+				    "csiphy1_clk_mux",
+				    "csiphy2",
+				    "csiphy2_clk_mux",
+				    "ispif",
+				    "vfe0",
+				    "vfe1";
+
+			clocks = <&gcc GCC_CAMSS_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI0_CLK>,
+				 <&gcc GCC_CAMSS_CSI0_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI0RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI1_CLK>,
+				 <&gcc GCC_CAMSS_CSI1_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI1RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI2_CLK>,
+				 <&gcc GCC_CAMSS_CSI2_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI2RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI_VFE0_CLK>,
+				 <&gcc GCC_CAMSS_CSI_VFE1_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_ISPIF_AHB_CLK>,
+				 <&gcc GCC_CAMSS_MICRO_AHB_CLK>,
+				 <&gcc GCC_CAMSS_TOP_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_AXI_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_AXI_CLK>;
+			clock-names = "ahb",
+				      "csi0",
+				      "csi0_ahb",
+				      "csi0_phy",
+				      "csi0_pix",
+				      "csi0_rdi",
+				      "csi1",
+				      "csi1_ahb",
+				      "csi1_phy",
+				      "csi1_pix",
+				      "csi1_rdi",
+				      "csi2",
+				      "csi2_ahb",
+				      "csi2_phy",
+				      "csi2_pix",
+				      "csi2_rdi",
+				      "csi_vfe0",
+				      "csi_vfe1",
+				      "csiphy0_timer",
+				      "csiphy1_timer",
+				      "csiphy2_timer",
+				      "ispif_ahb",
+				      "micro_ahb",
+				      "top_ahb",
+				      "vfe0",
+				      "vfe0_ahb",
+				      "vfe0_axi",
+				      "vfe1",
+				      "vfe1_ahb",
+				      "vfe1_axi";
+
+			interrupts = <GIC_SPI 51 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 52 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 153 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 55 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 29 IRQ_TYPE_EDGE_RISING>;
+			interrupt-names = "csid0",
+					  "csid1",
+					  "csid2",
+					  "csiphy0",
+					  "csiphy1",
+					  "csiphy2",
+					  "ispif",
+					  "vfe0",
+					  "vfe1";
+
+			iommus = <&apps_iommu 0x14>;
+
+			interconnects = <&snoc_mm MAS_VFE0 RPM_ACTIVE_TAG
+					 &bimc SLV_EBI RPM_ACTIVE_TAG>,
+					<&snoc_mm MAS_VFE1 RPM_ACTIVE_TAG
+					 &bimc SLV_EBI RPM_ACTIVE_TAG>,
+					<&bimc MAS_APPS_PROC RPM_ACTIVE_TAG
+					 &pcnoc SLV_CAMERA_SS_CFG RPM_ACTIVE_TAG>;
+			interconnect-names = "cam_vfe0_mem",
+					     "cam_vfe1_mem",
+					     "cam_ahb";
+
+			power-domains = <&gcc VFE0_GDSC>,
+					<&gcc VFE1_GDSC>;
+			power-domain-names = "vfe0", "vfe1";
+
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+		};
+
 		gpu: gpu@1c00000 {
 			compatible = "qcom,adreno-506.0", "qcom,adreno";
 			reg = <0x01c00000 0x40000>;
Signature · 1 line
2.47.3
#24 lore raw

Re: [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] arm64: dts: qcom: msm8953: undocumented interconnects on camss@1b00020 - [Low] arm64: dts: qcom…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] arm64: dts: qcom: msm8953: undocumented interconnects on camss@1b00020
- [Low] arm64: dts: qcom: msm8953: camss@1b00020 placed out of address order
- [Low] arm64: dts: qcom: msm8953: camss_mclk pinctrl states placed out of order
--

commit 27cc0ba26aa55e15a280cb981915e46ef83e3448
Author: Hikmah Gumelar <[email protected]>

arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states

This commit adds the camera subsystem (CAMSS) device node and MCLK0/1/2 pinctrl state nodes to the Qualcomm MSM8953 SoC devicetree.

Quoted 22 lines
arch/arm64/boot/dts/qcom/msm8953.dtsi +14 -0
index 753167c3f8619..2e64fb8bbb2ee 100644
@@ -902,6 +902,27 @@ sdc1_cmd_off: sdc1-cmd-off-state {
 				drive-strength = <2>;
 			};
 
+			camss_mclk0_default: camss-mclk0-default-state {
+				pins = "gpio26";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
+			camss_mclk1_default: camss-mclk1-default-state {
+				pins = "gpio27";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+

arch/arm64/boot/dts/qcom/msm8953.dtsi sdc1_cmd_off: sdc1-cmd-off-state { · line 928

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953.dtsi +7 -0
+			camss_mclk2_default: camss-mclk2-default-state {
+				pins = "gpio28";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
 			sdc1_data_on: sdc1-data-on-state {
 				pins = "sdc1_data";
 				bias-pull-up;

[Severity: Low]
Should these pinctrl state nodes for gpio26, gpio27, and gpio28 be placed between i2c_6_sleep (gpio22, gpio23) and cci0_default (gpio29, gpio30) instead of splitting the sdc1_* states? Commit 589deb6bc275 ("arm64:
dts: qcom: msm8953: Re-sort tlmm pinctrl states") sorted the tlmm child nodes by the pins property.

arch/arm64/boot/dts/qcom/msm8953.dtsi cci_i2c1: i2c-bus@1 { · line 1282

Quoted 6 lines
arch/arm64/boot/dts/qcom/msm8953.dtsi +2 -0
@@ -1257,6 +1278,140 @@ cci_i2c1: i2c-bus@1 {
 			};
 		};
 
+		camss: camss@1b00020 {
+			compatible = "qcom,msm8953-camss";

[Severity: Low]
Should camss@1b00020 be placed before cci@1b0c000 (immediately after display-subsystem@1a00000) to keep child nodes under soc@0 sorted in ascending unit-address order?

[ ... ]

arch/arm64/boot/dts/qcom/msm8953.dtsi cci_i2c1: i2c-bus@1 { · line 1401

Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8953.dtsi +9 -0
+			interconnects = <&snoc_mm MAS_VFE0 RPM_ACTIVE_TAG
+					 &bimc SLV_EBI RPM_ACTIVE_TAG>,
+					<&snoc_mm MAS_VFE1 RPM_ACTIVE_TAG
+					 &bimc SLV_EBI RPM_ACTIVE_TAG>,
+					<&bimc MAS_APPS_PROC RPM_ACTIVE_TAG
+					 &pcnoc SLV_CAMERA_SS_CFG RPM_ACTIVE_TAG>;
+			interconnect-names = "cam_vfe0_mem",
+					     "cam_vfe1_mem",
+					     "cam_ahb";

[Severity: Medium]
Does adding interconnects and interconnect-names here cause dtbs_check validation failures for all boards that include msm8953.dtsi? Documentation/devicetree/bindings/media/qcom,msm8953-camss.yaml specifies
additionalProperties: false and does not document interconnects or interconnect-names.

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

PATCH v2 7/7 arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

In reply to Hikmah Gumelar

Enable the CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear camera and Samsung S5K5E8 front camera on Xiaomi Mi A1 (tissot).

---
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 114 ++++++++++++++++++
 1 file changed, 114 insertions(+)
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +114 -0
index fccb9c4360ca..5d4fd7f42042 100644
@@ -308,6 +308,20 @@ ts_int_default: ts-int-default-state {
 		drive-strength = <2>;
 		bias-pull-up;
 	};
+
+	cam_sensor_rear_default: cam-sensor-rear-default-state {
+		pins = "gpio33", "gpio39", "gpio62";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
+
+	cam_sensor_front_default: cam-sensor-front-default-state {
+		pins = "gpio129";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
 };
 
 &uart_0 {
@@ -325,3 +339,103 @@ &usb3_dwc3 {
 	/delete-property/ usb-role-switch;
 	dr_mode = "peripheral";
 };
+
+&camss {
+	status = "okay";
+	vdda-supply = <&pm8953_s3>;
+
+	ports {
+		port@0 {
+			reg = <0>;
+			csiphy0_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&rear_cam_ep>;
+			};
+		};
+
+		port@2 {
+			reg = <2>;
+			csiphy2_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1>;
+				remote-endpoint = <&front_cam_ep>;
+			};
+		};
+	};
+};
+
+&cci {
+	pinctrl-names = "default";
+	pinctrl-0 = <&cci0_default>,
+		    <&cci1_default>,
+		    <&camss_mclk0_default>,
+		    <&camss_mclk1_default>,
+		    <&camss_mclk2_default>;
+
+	status = "okay";
+};
+
+&cci_i2c0 {
+	camera-sensor@10 {
+		compatible = "ovti,ov12a10";
+		reg = <0x10>;
+		clocks = <&gcc GCC_CAMSS_MCLK0_CLK>;
+		pinctrl-0 = <&cam_sensor_rear_default>;
+		pinctrl-names = "default";
+		reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+		pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+		vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l2>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <270>;
+		orientation = <1>;
+		status = "okay";
+		port {
+			rear_cam_ep: endpoint {
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&csiphy0_ep>;
+				link-frequencies = /bits/ 64 <216000000>;
+			};
+		};
+	};
+};
+
+&cci_i2c1 {
+	camera-sensor@2d {
+		compatible = "samsung,s5k5e8";
+		reg = <0x2d>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK1_CLK>;
+		pinctrl-0 = <&cam_sensor_front_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l23>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <90>;
+		orientation = <0>;
+
+		status = "okay";
+
+		port {
+			front_cam_ep: endpoint {
+				data-lanes = <0 1>;
+				remote-endpoint = <&csiphy2_ep>;
+				link-frequencies = /bits/ 64 <418000000>;
+			};
+		};
+	};
+};
+
+&pm8953_l23 {
+	regulator-min-microvolt = <1200000>;
+};
+
+&pm8953_l2 {
+	regulator-min-microvolt = <1200000>;
+	regulator-max-microvolt = <1225000>;
+};
Signature · 1 line
2.47.3
#26 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Low] arm64: dts: qcom: tissot: redundant pm8953_l2 and pm8953_l23 overrides - [Low] arm64: dts: qcom…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Low] arm64: dts: qcom: tissot: redundant pm8953_l2 and pm8953_l23 overrides
- [Low] arm64: dts: qcom: tissot: sensor MCLK and unused MCLK2 pinctrl on cci node
- [Low] arm64: dts: qcom: tissot: non-generic camera node names and unsorted nodes
--

commit 32dade37fcf383efdbda253ebb3dd130e1b41698
Author: Hikmah Gumelar <[email protected]>

arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

This commit enables the CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear and Samsung S5K5E8 front camera sensors in the Xiaomi Mi A1 device tree.

Quoted 55 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +40 -0
index fccb9c4360cae..5d4fd7f420420 100644
@@ -308,6 +308,20 @@ ts_int_default: ts-int-default-state {
 		drive-strength = <2>;
 		bias-pull-up;
 	};
+
+	cam_sensor_rear_default: cam-sensor-rear-default-state {
+		pins = "gpio33", "gpio39", "gpio62";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
+
+	cam_sensor_front_default: cam-sensor-front-default-state {
+		pins = "gpio129";
+		function = "gpio";
+		bias-disable;
+		drive-strength = <2>;
+	};
 };
 
 &uart_0 {
@@ -325,3 +339,103 @@ &usb3_dwc3 {
 	/delete-property/ usb-role-switch;
 	dr_mode = "peripheral";
 };
+
+&camss {
+	status = "okay";
+	vdda-supply = <&pm8953_s3>;
+
+	ports {
+		port@0 {
+			reg = <0>;
+			csiphy0_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&rear_cam_ep>;
+			};
+		};
+
+		port@2 {
+			reg = <2>;
+			csiphy2_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <0 1>;
+				remote-endpoint = <&front_cam_ep>;
+			};
+		};
+	};
+};
+

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts &usb3_dwc3 { · line 377

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +10 -0
+&cci {
+	pinctrl-names = "default";
+	pinctrl-0 = <&cci0_default>,
+		    <&cci1_default>,
+		    <&camss_mclk0_default>,
+		    <&camss_mclk1_default>,
+		    <&camss_mclk2_default>;
+
+	status = "okay";
+};

[Severity: Low]
Should camss_mclk0_default and camss_mclk1_default be attached to their respective camera sensor nodes instead of &cci, and camss_mclk2_default be dropped?

The CCI node in msm8953.dtsi already configures cci0_default and cci1_default, while GCC_CAMSS_MCLK0_CLK and GCC_CAMSS_MCLK1_CLK belong to the rear and front sensors and MCLK2 (gpio28) is unused on this board. Putting the MCLK pinctrl states on &cci ties sensor clock pin muxing to the I2C controller and claims an unused pin, whereas &cci only needs status = "okay".

Quoted 45 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +45 -0
+
+&cci_i2c0 {
+	camera-sensor@10 {
+		compatible = "ovti,ov12a10";
+		reg = <0x10>;
+		clocks = <&gcc GCC_CAMSS_MCLK0_CLK>;
+		pinctrl-0 = <&cam_sensor_rear_default>;
+		pinctrl-names = "default";
+		reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+		pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+		vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l2>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <270>;
+		orientation = <1>;
+		status = "okay";
+		port {
+			rear_cam_ep: endpoint {
+				data-lanes = <0 1 2 3>;
+				remote-endpoint = <&csiphy0_ep>;
+				link-frequencies = /bits/ 64 <216000000>;
+			};
+		};
+	};
+};
+
+&cci_i2c1 {
+	camera-sensor@2d {
+		compatible = "samsung,s5k5e8";
+		reg = <0x2d>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK1_CLK>;
+		pinctrl-0 = <&cam_sensor_front_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l23>;
+		dovdd-supply = <&pm8953_l6>;
+		rotation = <90>;
+		orientation = <0>;
+
+		status = "okay";

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts &usb3_dwc3 { · line 432

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +10 -0
+
+		port {
+			front_cam_ep: endpoint {
+				data-lanes = <0 1>;
+				remote-endpoint = <&csiphy2_ep>;
+				link-frequencies = /bits/ 64 <418000000>;
+			};
+		};
+	};
+};

[Severity: Low]
This isn't a bug, but the Devicetree specification and Qualcomm DTS style use generic camera@10 and camera@2d node names rather than camera-sensor@10 and camera-sensor@2d.

Also, status = "okay" is redundant on new board-level child nodes, and the new &camss, &cci, &cci_i2c0, &cci_i2c1 references and &tlmm pinctrl states are appended at the end rather than kept in alphabetical order with the rest of this file.

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts &usb3_dwc3 { · line 441

Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +9 -0
+
+&pm8953_l23 {
+	regulator-min-microvolt = <1200000>;
+};
+
+&pm8953_l2 {
+	regulator-min-microvolt = <1200000>;
+	regulator-max-microvolt = <1225000>;
+};

[Severity: Low]
Are these &pm8953_l23 and &pm8953_l2 overrides redundant? Both regulators are already defined earlier in this file under &rpm_requests with regulator-min-microvolt = <1200000> and regulator-max-microvolt = <1225000>.

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

v3 cover arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

In reply to Hikmah Gumelar

Enable both the front (Samsung S5K5E8) and rear (OmniVision OV12A10) MIPI CSI-2 cameras on Xiaomi Mi A1 (msm8953-xiaomi-tissot).

Changes in v3:
- Add Fixes trailer to clk: qcom: gcc-msm8953 commit.
- Fix $id and $schema URIs and switch MIPI CSI-2 data-lanes to 1-based.
- Replace deprecated pwdn-gpios with powerdown-gpios and model GPIO62 as a fixed regulator (vreg_cam_avdd) supplying avdd-supply.
- Drop unneeded <linux/mod_devicetable.h> includes from s5k5e8.c and ov12a10.c (suggested by Uwe Kleine-Koenig).
- Fix runtime PM ordering, pm_runtime_get_if_in_use() <= 0 checks, active state initialization (.init_state), v4l2_subdev_cleanup(), exposure range updates on VBLANK change, test pattern enable bit, and endpoint/clock checks.
- Drop undocumented interconnects from camss@1b00020 and sort nodes/pins.

Changes in v2:
- Rebased onto linux-media/media-committers.git next branch.
- Updated set_fmt and get_selection pad ops signatures for v7.4-rc.
- Added MSM8953 SoC CAMSS node and MCLK pinctrl states to msm8953.dtsi.

Hikmah Gumelar (7):
clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent
media: dt-bindings: media: i2c: add Samsung S5K5E8
media: i2c: add s5k5e8 image sensor driver
media: dt-bindings: media: i2c: add OmniVision OV12A10
media: i2c: add ov12a10 image sensor driver
arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states
arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

 .../bindings/media/i2c/ovti,ov12a10.yaml      | 110 +++
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 +++
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 119 +++
 arch/arm64/boot/dts/qcom/msm8953.dtsi         | 145 ++++
 drivers/clk/qcom/gcc-msm8953.c                |   2 +-
 drivers/media/i2c/Kconfig                     |  22 +
 drivers/media/i2c/Makefile                    |   2 +
 drivers/media/i2c/ov12a10.c                   | 719 ++++++++++++++++++
 drivers/media/i2c/s5k5e8.c                    | 555 ++++++++++++++
 9 files changed, 1776 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
 create mode 100644 drivers/media/i2c/ov12a10.c
 create mode 100644 drivers/media/i2c/s5k5e8.c
Signature · 1 line
2.47.3
#28 lore raw

PATCH v3 1/7 clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot).

Fixes 9bb6cfc3c77e ("clk: qcom: Add Global Clock Controller driver for MSM8953")
---
 drivers/clk/qcom/gcc-msm8953.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-msm8953.c +1 -1
index 8fe1d3e42144..8aec5600e837 100644
@@ -964,7 +964,7 @@ static struct clk_rcg2 csi2p_clk_src = {
 };
 
 static const struct freq_tbl ftbl_csi_phytimer_clk_src[] = {
-	F(100000000, P_GPLL0_DIV2, 4, 0, 0),
+	F(100000000, P_GPLL0, 8, 0, 0),
 	F(200000000, P_GPLL0, 4, 0, 0),
 	F(266670000, P_GPLL0, 3, 0, 0),
 	{ }
Signature · 1 line
2.47.3
#29 lore raw

Re: [PATCH v3 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent

Quoted 4 lines · Hikmah Gumelar

The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot).

Fixes 9bb6cfc3c77e ("clk: qcom: Add Global Clock Controller driver for MSM8953")

Please read through this before sending other patches:

https://docs.kernel.org/process/submitting-patches.html

#30 lore raw

PATCH v3 2/7 media: dt-bindings: media: i2c: add Samsung S5K5E8

In reply to Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/samsung,s5k5e8.yaml    | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file +103 -0
new file mode 100644
index 000000000000..7c538e48ca25
@@ -0,0 +1,103 @@
+# 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 1/5-inch 5Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  Samsung S5K5E8 is a 1/5-inch 5-megapixel CMOS active-pixel digital image
+  sensor with a 2-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: samsung,s5k5e8
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@2d {
+            compatible = "samsung,s5k5e8";
+            reg = <0x2d>;
+            clocks = <&camss_mclk1>;
+            reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+            avdd-supply = <&pm8953_l22>;
+            dvdd-supply = <&pm8953_l23>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <1 2>;
+                    remote-endpoint = <&csiphy2_ep>;
+                    link-frequencies = /bits/ 64 <418000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#31 lore raw

Re: [PATCH v3 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8

Quoted 1 line · Hikmah Gumelar

Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

Please wrap the commit messages at 72 chars

Konrad

#32 lore raw

PATCH v3 3/7 media: i2c: add s5k5e8 image sensor driver

In reply to Hikmah Gumelar

Add V4L2 subdev driver for the Samsung S5K5E8 1/5-inch 5-megapixel MIPI CSI-2 CMOS image sensor supporting 2592x1944 10-bit Bayer output.

---
 drivers/media/i2c/Kconfig  |  13 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/s5k5e8.c | 555 +++++++++++++++++++++++++++++++++++++
 3 files changed, 569 insertions(+)
 create mode 100644 drivers/media/i2c/s5k5e8.c
drivers/media/i2c/Kconfig +13 -0
index 162b8ea02601..3ef98f32dae6 100644
@@ -879,6 +879,19 @@ config VIDEO_S5K3M5
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5k3m5.
 
+config VIDEO_S5K5E8
+	tristate "Samsung S5K5E8 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor-level driver for the Samsung
+	  S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k5e8.
+
 config VIDEO_S5K5BAF
 	tristate "Samsung S5K5BAF sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index a750942e9c62..bdcb8f34aca3 100644
@@ -136,6 +136,7 @@ obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o
 obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
+obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
drivers/media/i2c/s5k5e8.c new file +555 -0

555 lines not on this page · raw message

Signature · 1 line
2.47.3
#33 lore raw

Re: [PATCH v3 3/7] media: i2c: add s5k5e8 image sensor driver

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider: - [Medium] media: i2c: s5k5e8: broken !PM check and unchecked range update in s5k5e8_set_ctrl() - [Medium]…

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider:
- [Medium] media: i2c: s5k5e8: broken !PM check and unchecked range update in s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: skipped startup delay in s5k5e8_power_on() without reset_gpio
- [Medium] media: i2c: s5k5e8: unset colorimetry and missing stream check in s5k5e8_set_format()
- [Low] media: i2c: s5k5e8: explicit clk_set_rate() call in s5k5e8_probe()
- [Low] media: i2c: s5k5e8: open-coded CCI I2C helpers instead of v4l2-cci framework
- [Low] media: i2c: s5k5e8: legacy s_stream and manual mutex/streaming state
- [Low] media: i2c: s5k5e8: redundant Kconfig selects, unsorted entries, no MAINTAINERS
- [Low] media: i2c: s5k5e8: unused definitions, indentation issues, and redundant Kconfig
--

commit 282d70890b56a8ec58d98af6f85d1c752c59afcd
Author: Hikmah Gumelar <[email protected]>

media: i2c: add s5k5e8 image sensor driver

This commit adds a V4L2 subdevice driver for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.

Quoted 29 lines
drivers/media/i2c/Kconfig +13 -0
index 9e42b380e3f20..fb6bb91f897cb 100644
@@ -881,6 +881,19 @@ config VIDEO_S5K3M5
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5k3m5.
 
+config VIDEO_S5K5E8
+	tristate "Samsung S5K5E8 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor-level driver for the Samsung
+	  S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called s5k3m5.
+
 config VIDEO_S5K5BAF
 	tristate "Samsung S5K5BAF sensor support"
 	help
drivers/media/i2c/Makefile +0 -0
index 604b19dbc7b75..7be5217889916 100644

drivers/media/i2c/Makefile obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o · line 143

Quoted 7 lines
drivers/media/i2c/Makefile +1 -0
@@ -137,6 +137,7 @@ obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o
 obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
 obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
 obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
+obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
 obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
 obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
 obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o

[Severity: Low]
This isn't a bug, but VIDEO_S5K5E8 is inside the if VIDEO_DEV and if VIDEO_CAMERA_SENSOR blocks in drivers/media/i2c/Kconfig, which already depend on I2C and select MEDIA_CONTROLLER, VIDEO_V4L2_SUBDEV_API and V4L2_FWNODE. Also, VIDEO_S5K5E8 and s5k5e8.o are placed before VIDEO_S5K5BAF / s5k5baf.o instead of in alphabetical order, and no MAINTAINERS entry is added for the new driver.

Quoted 6 lines
drivers/media/i2c/s5k5e8.c new file +0 -0
new file mode 100644
index 0000000000000..b4f0783593e93
@@ -0,0 +1,555 @@

[ ... ]

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+#define S5K5E8_CHIP_ID_REG		0x0000
+#define S5K5E8_CHIP_ID			0x5e80
+#define S5K5E8_REG_MODE_SELECT		0x0100
+#define S5K5E8_MODE_STANDBY		0x00
+#define S5K5E8_MODE_STREAMING		0x01
+#define S5K5E8_REG_VTS			0x0340
+#define S5K5E8_REG_EXPOSURE		0x0202
+#define S5K5E8_REG_ANALOG_GAIN		0x0204
+#define S5K5E8_REG_TEST_PATTERN		0x0600
+#define S5K5E8_XVCLK_FREQ		24000000

drivers/media/i2c/s5k5e8.c line 33

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+#define S5K5E8_LINK_FREQ_418MHZ		418000000ULL
+#define S5K5E8_PIXEL_RATE		167200000ULL
+
+struct s5k5e8_reg { u16 address;
+u8 val;
+};
+struct s5k5e8_mode {
+	u32 width, height, hts_def, vts_def, vts_min, num_regs;
+	const struct s5k5e8_reg *regs;
+};

[Severity: Low]
This isn't a bug, but there are a few unused definitions and indentation issues in this driver:

- S5K5E8_MODE_STREAMING is unused because stream_on_regs[] hardcodes { 0x0100, 0x01 }.
- vts_def and vts_min in struct s5k5e8_mode are never read because s5k5e8_init_controls() hardcodes 24 for V4L2_CID_VBLANK, and pixel_rate and vblank in struct s5k5e8 are assigned in s5k5e8_init_controls() but never read.
- struct s5k5e8_reg and the break statements in s5k5e8_set_ctrl() have broken indentation.

[ ... ]

Quoted 37 lines
drivers/media/i2c/s5k5e8.c new file +37 -0
+static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
+	struct i2c_msg msgs[2];
+	u8 addr_buf[2], data_buf[4] = { 0 };
+	int ret;
+
+	put_unaligned_be16(reg, addr_buf);
+	msgs[0].addr = client->addr;
+	msgs[0].flags = 0;
+	msgs[0].len = 2;
+	msgs[0].buf = addr_buf;
+	msgs[1].addr = client->addr;
+	msgs[1].flags = I2C_M_RD;
+	msgs[1].len = len;
+	msgs[1].buf = &data_buf[4 - len];
+	ret = i2c_transfer(client->adapter, msgs, 2);
+	if (ret != 2)
+		return ret < 0 ? ret : -EIO;
+	*val = get_unaligned_be32(data_buf);
+	return 0;
+}
+
+static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
+	u8 buf[6];
+	int ret;
+
+	put_unaligned_be16(reg, buf);
+	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
+	ret = i2c_master_send(client, buf, len + 2);
+	return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO);
+}
+
+static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len)
+{

drivers/media/i2c/s5k5e8.c line 146

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	u32 i;
+	int ret;
+
+	for (i = 0; i < len; i++) {
+		ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}

[Severity: Low]
Could this use the v4l2-cci framework (select V4L2_CCI_I2C in Kconfig, devm_cci_regmap_init_i2c(), cci_read(), cci_write() and cci_multi_reg_write()) instead of open-coding 16-bit big-endian I2C register accessors? Similarly, s5k5e8_probe() could use v4l2_link_freq_to_bitmap() to validate link-frequencies.

Quoted 11 lines
drivers/media/i2c/s5k5e8.c new file +11 -0
+
+static int s5k5e8_power_on(struct device *dev)
+{
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev));
+	int ret = regulator_bulk_enable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
+
+	if (ret)
+		return ret;
+	ret = clk_prepare_enable(s5k5e8->xvclk);
+	if (ret) {
+		regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);

drivers/media/i2c/s5k5e8.c line 167

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+		return ret;
+	}
+	if (s5k5e8->reset_gpio) {
+		gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1);
+		usleep_range(1000, 2000);
+		gpiod_set_value_cansleep(s5k5e8->reset_gpio, 0);
+		usleep_range(3000, 5000);
+	}
+	return 0;
+}

[Severity: Medium]
Does s5k5e8_power_on() skip the 3-5 ms post-power-on stabilization delay when the optional reset_gpio is NULL? On boards without reset-gpios, s5k5e8_power_on() returns immediately after clk_prepare_enable() and s5k5e8_probe() issues an I2C read of S5K5E8_CHIP_ID_REG with no startup delay (and gpiod_set_value_cansleep() already accepts a NULL descriptor).

[ ... ]

Quoted 4 lines
drivers/media/i2c/s5k5e8.c new file +4 -0
+static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler);
+	int ret = 0;

drivers/media/i2c/s5k5e8.c line 193

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+
+	if (ctrl->id == V4L2_CID_VBLANK) {
+		s64 exp_max = s5k5e8->cur_mode->height + ctrl->val - 4;
+		s64 exp_def = min_t(s64, 1960, exp_max);
+
+		__v4l2_ctrl_modify_range(s5k5e8->exposure, 4, exp_max, 1, exp_def);
+	}
+
+	if (pm_runtime_get_if_in_use(s5k5e8->dev) <= 0)
+		return 0;

[Severity: Medium]
Does checking pm_runtime_get_if_in_use(s5k5e8->dev) <= 0 skip all control register writes when CONFIG_PM is disabled?

When CONFIG_PM is disabled (or runtime PM is disabled on the device), pm_runtime_get_if_in_use() returns -EINVAL, so s5k5e8_set_ctrl() returns 0 without writing S5K5E8_REG_ANALOG_GAIN, S5K5E8_REG_EXPOSURE, S5K5E8_REG_VTS or S5K5E8_REG_TEST_PATTERN even during stream start via __v4l2_ctrl_handler_setup(). Using pm_runtime_get_if_active() (or checking pm_runtime_get_if_in_use() == 0) allows writes to proceed when runtime PM is disabled. Also, the return value of __v4l2_ctrl_modify_range() above is ignored.

[ ... ]

Quoted 14 lines
drivers/media/i2c/s5k5e8.c new file +14 -0
+static void s5k5e8_update_pad_format(const struct s5k5e8_mode *mode,
+		struct v4l2_mbus_framefmt *fmt)
+{
+	fmt->width = mode->width;
+	fmt->height = mode->height;
+	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+	fmt->field = V4L2_FIELD_NONE;
+	fmt->colorspace = V4L2_COLORSPACE_SRGB;
+}
+
+static int s5k5e8_set_format(struct v4l2_subdev *sd,
+			     const struct v4l2_subdev_client_info *ci,
+			     struct v4l2_subdev_state *sd_state,
+			     struct v4l2_subdev_format *fmt)

drivers/media/i2c/s5k5e8.c line 289

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+{
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+
+	s5k5e8_update_pad_format(&supported_modes[0], &fmt->format);
+	*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+	if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+		s5k5e8->cur_mode = &supported_modes[0];
+
+	return 0;
+}

[Severity: Medium]
Does s5k5e8_update_pad_format() leave fmt->ycbcr_enc, fmt->quantization and fmt->xfer_func uninitialized? In VIDIOC_SUBDEV_S_FMT, any arbitrary values passed by userspace in those fields are copied directly into the subdev pad state. Also, when fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE, s5k5e8_set_format() does not check if the sensor is streaming and return -EBUSY.

[ ... ]

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+static int s5k5e8_set_stream(struct v4l2_subdev *sd, int enable)
+{
+	struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
+	int ret = 0;
+
+	mutex_lock(&s5k5e8->mutex);
+	if (s5k5e8->streaming == enable) {
+		mutex_unlock(&s5k5e8->mutex);
+		return 0;
+	}

[ ... ]

Quoted 1 line

+static const struct v4l2_subdev_video_ops s5k5e8_video_ops = { .s_stream = s5k5e8_set_stream };

[Severity: Low]
Could this driver implement .enable_streams and .disable_streams in s5k5e8_pad_ops with .s_stream = v4l2_subdev_s_stream_helper instead of open-coding .s_stream and s5k5e8->streaming? With active subdev state management, s5k5e8->sd.state_lock can also be aliased directly to s5k5e8->ctrl_handler.lock, dropping the separate s5k5e8->mutex.

[ ... ]

drivers/media/i2c/s5k5e8.c line 447

Quoted 10 lines
drivers/media/i2c/s5k5e8.c new file +10 -0
+	s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+	if (IS_ERR(s5k5e8->xvclk))
+		return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "failed to get xvclk\n");
+
+	ret = clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to set xvclk rate\n");
+
+	if (clk_get_rate(s5k5e8->xvclk) != S5K5E8_XVCLK_FREQ)
+		return dev_err_probe(dev, -EINVAL, "unexpected xvclk rate\n");

[Severity: Low]
Should clk_set_rate() be dropped here? devm_v4l2_sensor_clk_get() already handles setting the clock rate on non-OF platforms while leaving OF clock rate assignment to firmware (assigned-clock-rates), so camera sensor drivers should only check clk_get_rate().

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

PATCH v3 4/7 media: dt-bindings: media: i2c: add OmniVision OV12A10

In reply to Hikmah Gumelar

Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor.

---
 .../bindings/media/i2c/ovti,ov12a10.yaml      | 110 ++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file +110 -0
new file mode 100644
index 000000000000..f27c304843ad
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/ovti,ov12a10.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OmniVision OV12A10 1/2.8-inch 12Mp CMOS Image Sensor
+
+maintainers:
+  - Hikmah Gumelar <[email protected]>
+
+description:
+  OmniVision OV12A10 is a 1/2.8-inch 12-megapixel CMOS active-pixel digital
+  image sensor with a 4-lane MIPI CSI-2 interface and I2C control bus.
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: ovti,ov12a10
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  reset-gpios:
+    description: Active-low reset GPIO.
+    maxItems: 1
+
+  powerdown-gpios:
+    description: Active-low power-down GPIO.
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog power supply (2.8V).
+
+  dvdd-supply:
+    description: Digital core power supply (1.2V).
+
+  dovdd-supply:
+    description: Digital I/O power supply (1.8V).
+
+  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
+              - const: 3
+              - const: 4
+
+          link-frequencies: true
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - avdd-supply
+  - dvdd-supply
+  - dovdd-supply
+  - port
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera-sensor@10 {
+            compatible = "ovti,ov12a10";
+            reg = <0x10>;
+            clocks = <&camss_mclk0>;
+            reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+            powerdown-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+            avdd-supply = <&vreg_cam_avdd>;
+            dvdd-supply = <&pm8953_l2>;
+            dovdd-supply = <&pm8953_l6>;
+
+            port {
+                endpoint {
+                    data-lanes = <1 2 3 4>;
+                    remote-endpoint = <&csiphy0_ep>;
+                    link-frequencies = /bits/ 64 <216000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.47.3
#35 lore raw

PATCH v3 5/7 media: i2c: add ov12a10 image sensor driver

In reply to Hikmah Gumelar

Add V4L2 subdev driver for the OmniVision OV12A10 1/2.8-inch 12-megapixel MIPI CSI-2 CMOS image sensor supporting 1280x720 binned 10-bit Bayer output.

---
 drivers/media/i2c/Kconfig   |   9 +
 drivers/media/i2c/Makefile  |   1 +
 drivers/media/i2c/ov12a10.c | 719 ++++++++++++++++++++++++++++++++++++
 3 files changed, 729 insertions(+)
 create mode 100644 drivers/media/i2c/ov12a10.c
drivers/media/i2c/Kconfig +9 -0
index 3ef98f32dae6..a4204f1456f2 100644
@@ -538,6 +538,15 @@ config VIDEO_OV08X40
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov08x40.
 
+config VIDEO_OV12A10
+	tristate "OmniVision OV12A10 sensor support"
+	depends on I2C && VIDEO_DEV
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  V4L2 sensor driver for OmniVision OV12A10.
+
 config VIDEO_OV13858
 	tristate "OmniVision OV13858 sensor support"
 	help
drivers/media/i2c/Makefile +1 -0
index bdcb8f34aca3..8148ee872a31 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
 obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o
 obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o
 obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o
+obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o
 obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
 obj-$(CONFIG_VIDEO_OV13B10) += ov13b10.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
drivers/media/i2c/ov12a10.c new file +719 -0

719 lines not on this page · raw message

Signature · 1 line
2.47.3
#36 lore raw

Re: [PATCH v3 5/7] media: i2c: add ov12a10 image sensor driver

Thank you for your contribution! Sashiko AI review found 12 potential issues to consider: - [High] media: i2c: ov12a10: missing IS_ERR() GPIO checks and name mismatch in probe() - [Medium] media…

Thank you for your contribution! Sashiko AI review found 12 potential issues to consider:
- [High] media: i2c: ov12a10: missing IS_ERR() GPIO checks and name mismatch in probe()
- [Medium] media: i2c: ov12a10: missing v4l2_subdev_cleanup() in probe() and remove()
- [Medium] media: i2c: ov12a10: missing vana_gpio rollback in ov12a10_power_on()
- [Medium] media: i2c: ov12a10: runtime PM bugs in ov12a10_probe() and ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing exposure range update in ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: missing test pattern enable bit in ov12a10_set_ctrl()
- [Medium] media: i2c: ov12a10: uninitialized subdev state in get_fmt() and set_fmt()
- [Medium] media: i2c: ov12a10: wrong native and crop rectangles in ov12a10_get_selection()
- [Low] media: i2c: ov12a10: missing fwnode endpoint and clk_set_rate() checks in ov12a10_probe()
- [Low] media: i2c: ov12a10: missing DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr()
- [Low] media: i2c: ov12a10: mismatched OV12A10_REG_EXPOSURE and unused macros
- [Low] media: i2c: ov12a10: coding style violations in struct, switch, and error labels
--

commit b4d54d6ecb617bf73cbccd2d0578b1858ed17a67
Author: Hikmah Gumelar <[email protected]>

media: i2c: add ov12a10 image sensor driver

This commit adds a V4L2 subdevice driver for the OmniVision OV12A10 MIPI CSI-2 image sensor supporting 1280x720 binned 10-bit Bayer output.

Quoted 6 lines
drivers/media/i2c/ov12a10.c new file +0 -0
new file mode 100644
index 0000000000000..48e7a5e981972
@@ -0,0 +1,719 @@

[ ... ]

drivers/media/i2c/ov12a10.c line 20

Quoted 5 lines
drivers/media/i2c/ov12a10.c new file +5 -0
+#define OV12A10_REG_MODE_SELECT		0x0100
+#define OV12A10_MODE_STANDBY		0x00
+#define OV12A10_MODE_STREAMING		0x01
+#define OV12A10_REG_VTS			0x380e
+#define OV12A10_REG_EXPOSURE		0x3501

[Severity: Low]
Should OV12A10_REG_EXPOSURE be defined as 0x3500 and used in ov12a10_set_ctrl()? The 24-bit exposure write in ov12a10_set_ctrl() hardcodes 0x3500 (the MSB of 0x3500..0x3502), leaving OV12A10_REG_EXPOSURE unused at 0x3501. OV12A10_MODE_STREAMING is also unused because ov12a10_set_stream() hardcodes { 0x0100, 0x01 } in stream_on_regs[].

[ ... ]

drivers/media/i2c/ov12a10.c line 29

Quoted 3 lines
drivers/media/i2c/ov12a10.c new file +3 -0
+struct ov12a10_reg { u16 address;
+u8 val;
+};

[Severity: Low]
This isn't a bug, but struct ov12a10_reg does not follow kernel coding style, and the same applies to the misaligned break statements in ov12a10_set_ctrl() and the single-line goto labels at the bottom of ov12a10_probe().

[ ... ]

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_power_on(struct device *dev)
+{
+	struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev));
+	int ret;
+
+	if (ov12a10->vana_gpio)
+		gpiod_set_value_cansleep(ov12a10->vana_gpio, 1);

drivers/media/i2c/ov12a10.c line 373

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+
+	ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(ov12a10->xvclk);
+	if (ret) {
+		regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
+		return ret;
+	}

[Severity: Medium]
Does ov12a10_power_on() leave vana_gpio asserted high when regulator_bulk_enable() or clk_prepare_enable() fails?

[ ... ]

drivers/media/i2c/ov12a10.c line 408

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler);
+	int ret = 0;
+
+	if (!pm_runtime_get_if_in_use(ov12a10->dev))
+		return 0;

[Severity: Medium]
Should this check pm_runtime_get_if_in_use(ov12a10->dev) <= 0? When runtime PM is disabled (or CONFIG_PM is unset), pm_runtime_get_if_in_use() returns -EINVAL without incrementing the usage count, so !ret is false and ov12a10_set_ctrl() writes to I2C and calls an unbalanced pm_runtime_put() that underflows dev->power.usage_count.

Also, in ov12a10_probe(), v4l2_async_register_subdev_sensor() is called before pm_runtime_set_active() and pm_runtime_enable(), so if the receiver binds synchronously during registration and starts streaming or sets controls, runtime PM is still disabled and marked suspended.

drivers/media/i2c/ov12a10.c line 419

Quoted 11 lines
drivers/media/i2c/ov12a10.c new file +11 -0
+	switch (ctrl->id) {
+	case V4L2_CID_ANALOGUE_GAIN:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_ANALOG_GAIN, 2, ctrl->val);
+	break;
+	case V4L2_CID_EXPOSURE:
+		ret = ov12a10_write_reg(ov12a10, 0x3500, 3, ctrl->val << 4);
+	break;
+	case V4L2_CID_VBLANK:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_VTS, 2,
+				ov12a10->cur_mode->height + ctrl->val);
+	break;

[Severity: Medium]
Does changing V4L2_CID_VBLANK need to update the range of ov12a10->exposure via __v4l2_ctrl_modify_range() before the pm_runtime_get_if_in_use() check? Without that update, lowering vblank down to its minimum of 124 (VTS = 844) leaves exposure's maximum at 3360 and default at 2400, allowing exposure values that exceed VTS.

drivers/media/i2c/ov12a10.c line 422

Quoted 3 lines
drivers/media/i2c/ov12a10.c new file +3 -0
+	case V4L2_CID_TEST_PATTERN:
+		ret = ov12a10_write_reg(ov12a10, OV12A10_REG_TEST_PATTERN, 1, ctrl->val);
+	break;

[Severity: Medium]
Does writing ctrl->val directly to OV12A10_REG_TEST_PATTERN (0x5080) leave the test pattern generator disabled? On OmniVision sensors using register 0x5080, BIT(7) is the test pattern enable bit and non-zero menu selections map to (ctrl->val - 1) | BIT(7).

[ ... ]

Quoted 15 lines
drivers/media/i2c/ov12a10.c new file +15 -0
+static int ov12a10_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state,
+		struct v4l2_subdev_format *fmt)
+{
+	struct ov12a10 *ov12a10 = to_ov12a10(sd);
+
+	fmt->format = (fmt->which == V4L2_SUBDEV_FORMAT_TRY) ? *v4l2_subdev_state_get_format(sd_state,
+			fmt->pad) : fmt->format;
+	if (fmt->which != V4L2_SUBDEV_FORMAT_TRY)
+		ov12a10_update_pad_format(ov12a10->cur_mode, &fmt->format);
+	return 0;
+}
+
+static int ov12a10_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state,
+		struct v4l2_subdev_format *fmt)
+{

drivers/media/i2c/ov12a10.c line 515

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+	struct ov12a10 *ov12a10 = to_ov12a10(sd);
+
+	ov12a10_update_pad_format(&supported_modes[0], &fmt->format);
+	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+		*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+	else
+		ov12a10->cur_mode = &supported_modes[0];
+
+	return 0;
+}

[Severity: Medium]
Does this leave sd->active_state unpopulated and active format queries partially uninitialized?

ov12a10_probe() calls v4l2_subdev_init_finalize(), which allocates sd->active_state and initializes it via internal_ops->init_state. Because ov12a10_internal_ops implements .open instead of .init_state, and ov12a10_set_format() only writes to v4l2_subdev_state_get_format(sd_state, fmt->pad) when fmt->which == V4L2_SUBDEV_FORMAT_TRY, sd->active_state stays zeroed. In addition, when fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE, ov12a10_get_format() self-assigns fmt->format and calls ov12a10_update_pad_format(), which only sets width, height, code, field, and colorspace, leaving ycbcr_enc, quantization, xfer_func, and flags uninitialized for in-kernel callers such as v4l2_subdev_link_validate_get_format().

Implementing .init_state in ov12a10_internal_ops, unconditionally updating *v4l2_subdev_state_get_format(sd_state, fmt->pad) in ov12a10_set_format(), and using v4l2_subdev_get_fmt as .get_fmt would fix all three issues.

[ ... ]

Quoted 8 lines
drivers/media/i2c/ov12a10.c new file +8 -0
+static int ov12a10_get_selection(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci,
+				struct v4l2_subdev_state *sd_state,
+				struct v4l2_subdev_selection *sel)
+{
+	switch (sel->target) {
+	case V4L2_SEL_TGT_CROP:
+	case V4L2_SEL_TGT_CROP_DEFAULT:
+	case V4L2_SEL_TGT_CROP_BOUNDS:

drivers/media/i2c/ov12a10.c line 610

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+	case V4L2_SEL_TGT_NATIVE_SIZE:
+		sel->r.left = 0;
+		sel->r.top = 0;
+		sel->r.width = 1280;
+		sel->r.height = 720;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}

[Severity: Medium]
Should ov12a10_get_selection() report the full 12MP pixel array for V4L2_SEL_TGT_NATIVE_SIZE / CROP_BOUNDS / CROP_DEFAULT and the pre-binning analog crop window for V4L2_SEL_TGT_CROP?

In ov12a10_common_regs, the full sensor array is 4112x3088 (active 4096x3072), and in ov12a10_1280x720_regs registers 0x3800..0x3807 configure an analog crop window from (800, 872) to (3391, 2343) before 2x2 binning down to 1280x720. Returning (0, 0, 1280, 720) for all targets misreports the sensor geometry and binning factor to userspace camera stacks.

[ ... ]

Quoted 7 lines
drivers/media/i2c/ov12a10.c new file +7 -0
+static int ov12a10_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct ov12a10 *ov12a10;
+	u32 val = 0;
+	unsigned int i;
+	int ret;

drivers/media/i2c/ov12a10.c line 642

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+
+	ov12a10 = devm_kzalloc(dev, sizeof(*ov12a10), GFP_KERNEL);
+	if (!ov12a10)
+		return -ENOMEM;
+	ov12a10->dev = dev;
+	v4l2_i2c_subdev_init(&ov12a10->sd, client, &ov12a10_subdev_ops);
+	ov12a10->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
+	if (IS_ERR(ov12a10->xvclk))
+		return dev_err_probe(dev, PTR_ERR(ov12a10->xvclk), "xvclk\n");
+	clk_set_rate(ov12a10->xvclk, OV12A10_XVCLK_FREQ);

[Severity: Low]
Should ov12a10_probe() check the return value of clk_set_rate() and validate the MIPI CSI-2 fwnode endpoint? The DT binding requires a 4-lane CSI-2 endpoint with a 216 MHz link-frequencies property, but the driver never parses the endpoint with v4l2_fwnode_endpoint_alloc_parse().

drivers/media/i2c/ov12a10.c line 647

Quoted 5 lines
drivers/media/i2c/ov12a10.c new file +5 -0
+	ov12a10->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	ov12a10->vana_gpio = devm_gpiod_get_optional(dev, "vana", GPIOD_OUT_LOW);
+	ov12a10->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH);
+	if (IS_ERR(ov12a10->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(ov12a10->reset_gpio), "reset\n");

[Severity: High]
What happens if devm_gpiod_get_optional() returns an error pointer (such as -EPROBE_DEFER) for vana_gpio or pwdn_gpio? Because neither pointer is checked with IS_ERR(), the non-NULL ERR_PTR is stored and passed straight to gpiod_set_value_cansleep() in ov12a10_power_on() instead of deferring or aborting probe.

Also, the DT binding (Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml) defines powerdown-gpios rather than pwdn-gpios (and does not document vana-gpios), so requesting "pwdn" will never match a conforming DT.

[ ... ]

Quoted 15 lines
drivers/media/i2c/ov12a10.c new file +15 -0
+	ret = v4l2_subdev_init_finalize(&ov12a10->sd);
+	if (ret)
+		goto err_media;
+	ret = v4l2_async_register_subdev_sensor(&ov12a10->sd);
+	if (ret)
+		goto err_media;
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+	return 0;
+err_media: media_entity_cleanup(&ov12a10->sd.entity);
+err_ctrl: v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler);
+err_mutex: mutex_destroy(&ov12a10->mutex);
+err_power: ov12a10_power_off(dev);
+	return ret;

drivers/media/i2c/ov12a10.c line 701

Quoted 10 lines
drivers/media/i2c/ov12a10.c new file +10 -0
+}
+
+static void ov12a10_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+	struct ov12a10 *ov12a10 = to_ov12a10(sd);
+
+	v4l2_async_unregister_subdev(sd);
+	media_entity_cleanup(&sd->entity);
+	v4l2_ctrl_handler_free(sd->ctrl_handler);

[Severity: Medium]
Does missing v4l2_subdev_cleanup(sd) in ov12a10_remove() and on the v4l2_async_register_subdev_sensor() error path in ov12a10_probe() leak sd->active_state? v4l2_subdev_init_finalize() allocates sd->active_state and its pad array, which are only freed by v4l2_subdev_cleanup().

[ ... ]

drivers/media/i2c/ov12a10.c line 714

Quoted 6 lines
drivers/media/i2c/ov12a10.c new file +6 -0
+static const struct dev_pm_ops ov12a10_pm_ops = { SET_RUNTIME_PM_OPS(ov12a10_power_off,
+		ov12a10_power_on, NULL) };
+static const struct of_device_id ov12a10_of_match[] = { { .compatible = "ovti,ov12a10" }, { } };
+MODULE_DEVICE_TABLE(of, ov12a10_of_match);
+static struct i2c_driver ov12a10_i2c_driver = {
+	.driver = { .name = "ov12a10", .pm = &ov12a10_pm_ops, .of_match_table = ov12a10_of_match },

[Severity: Low]
Could ov12a10_pm_ops use DEFINE_RUNTIME_DEV_PM_OPS() and be wired with .pm = pm_ptr(&ov12a10_pm_ops) so the PM ops are dropped when CONFIG_PM is disabled?

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

PATCH v3 6/7 arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states

In reply to Hikmah Gumelar

Add the camera subsystem (CAMSS) node and MCLK0/1/2 pin control states to the Qualcomm MSM8953 SoC Devicetree.

---
 arch/arm64/boot/dts/qcom/msm8953.dtsi | 145 ++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
arch/arm64/boot/dts/qcom/msm8953.dtsi +145 -0
index 753167c3f861..396472ba8f28 100644
@@ -753,6 +753,27 @@ i2c_6_sleep: i2c-6-sleep-state {
 				bias-disable;
 			};
 
+			camss_mclk0_default: camss-mclk0-default-state {
+				pins = "gpio26";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
+			camss_mclk1_default: camss-mclk1-default-state {
+				pins = "gpio27";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
+			camss_mclk2_default: camss-mclk2-default-state {
+				pins = "gpio28";
+				function = "cam_mclk";
+				drive-strength = <2>;
+				bias-disable;
+			};
+
 			cci0_default: cci0-default-state {
 				pins = "gpio29", "gpio30";
 				function = "cci_i2c";
@@ -1214,6 +1235,130 @@ mdss_dsi1_phy: phy@1a96400 {
 			};
 		};
 
+		camss: camss@1b00020 {
+			compatible = "qcom,msm8953-camss";
+
+			reg = <0x1b00020 0x10>,
+			      <0x1b30000 0x100>,
+			      <0x1b30400 0x100>,
+			      <0x1b30800 0x100>,
+			      <0x1b34000 0x1000>,
+			      <0x1b00030 0x4>,
+			      <0x1b35000 0x1000>,
+			      <0x1b00038 0x4>,
+			      <0x1b36000 0x1000>,
+			      <0x1b00040 0x4>,
+			      <0x1b31000 0x500>,
+			      <0x1b10000 0x1000>,
+			      <0x1b14000 0x1000>;
+			reg-names = "csi_clk_mux",
+				    "csid0",
+				    "csid1",
+				    "csid2",
+				    "csiphy0",
+				    "csiphy0_clk_mux",
+				    "csiphy1",
+				    "csiphy1_clk_mux",
+				    "csiphy2",
+				    "csiphy2_clk_mux",
+				    "ispif",
+				    "vfe0",
+				    "vfe1";
+
+			clocks = <&gcc GCC_CAMSS_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI0_CLK>,
+				 <&gcc GCC_CAMSS_CSI0_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI0RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI1_CLK>,
+				 <&gcc GCC_CAMSS_CSI1_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI1RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI2_CLK>,
+				 <&gcc GCC_CAMSS_CSI2_AHB_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PHY_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PIX_CLK>,
+				 <&gcc GCC_CAMSS_CSI2RDI_CLK>,
+				 <&gcc GCC_CAMSS_CSI_VFE0_CLK>,
+				 <&gcc GCC_CAMSS_CSI_VFE1_CLK>,
+				 <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_CSI2PHYTIMER_CLK>,
+				 <&gcc GCC_CAMSS_ISPIF_AHB_CLK>,
+				 <&gcc GCC_CAMSS_MICRO_AHB_CLK>,
+				 <&gcc GCC_CAMSS_TOP_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE0_AXI_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_AHB_CLK>,
+				 <&gcc GCC_CAMSS_VFE1_AXI_CLK>;
+			clock-names = "ahb",
+				      "csi0",
+				      "csi0_ahb",
+				      "csi0_phy",
+				      "csi0_pix",
+				      "csi0_rdi",
+				      "csi1",
+				      "csi1_ahb",
+				      "csi1_phy",
+				      "csi1_pix",
+				      "csi1_rdi",
+				      "csi2",
+				      "csi2_ahb",
+				      "csi2_phy",
+				      "csi2_pix",
+				      "csi2_rdi",
+				      "csi_vfe0",
+				      "csi_vfe1",
+				      "csiphy0_timer",
+				      "csiphy1_timer",
+				      "csiphy2_timer",
+				      "ispif_ahb",
+				      "micro_ahb",
+				      "top_ahb",
+				      "vfe0",
+				      "vfe0_ahb",
+				      "vfe0_axi",
+				      "vfe1",
+				      "vfe1_ahb",
+				      "vfe1_axi";
+
+			interrupts = <GIC_SPI 51 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 52 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 153 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 55 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 29 IRQ_TYPE_EDGE_RISING>;
+			interrupt-names = "csid0",
+					  "csid1",
+					  "csid2",
+					  "csiphy0",
+					  "csiphy1",
+					  "csiphy2",
+					  "ispif",
+					  "vfe0",
+					  "vfe1";
+
+			iommus = <&apps_iommu 0x14>;
+
+			power-domains = <&gcc VFE0_GDSC>,
+					<&gcc VFE1_GDSC>;
+			power-domain-names = "vfe0", "vfe1";
+
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+		};
+
 		cci: cci@1b0c000 {
 			compatible = "qcom,msm8953-cci";
 			reg = <0x1b0c000 0x4000>;
Signature · 1 line
2.47.3
#38 lore raw

PATCH v3 7/7 arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

In reply to Hikmah Gumelar

Enable CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear and Samsung S5K5E8 front image sensors on the Xiaomi Mi A1.

---
 .../boot/dts/qcom/msm8953-xiaomi-tissot.dts   | 119 ++++++++++++++++++
 1 file changed, 119 insertions(+)
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +119 -0
index fccb9c4360ca..e41cbd4d01b2 100644
@@ -74,6 +74,104 @@ vph_pwr: vph-pwr-regulator {
 		regulator-always-on;
 		regulator-boot-on;
 	};
+	vreg_cam_avdd: regulator-cam-avdd {
+		compatible = "regulator-fixed";
+		regulator-name = "vreg_cam_avdd";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		gpio = <&tlmm 62 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		pinctrl-0 = <&cam_vreg_avdd_default>;
+		pinctrl-names = "default";
+	};
+};
+
+&camss {
+	vdda-supply = <&pm8953_s3>;
+	status = "okay";
+
+	ports {
+		port@0 {
+			reg = <0>;
+
+			csiphy0_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <1 2 3 4>;
+				remote-endpoint = <&rear_cam_ep>;
+			};
+		};
+
+		port@2 {
+			reg = <2>;
+
+			csiphy2_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <1 2>;
+				remote-endpoint = <&front_cam_ep>;
+			};
+		};
+	};
+};
+
+&cci {
+	status = "okay";
+};
+
+&cci_i2c0 {
+	camera@10 {
+		compatible = "ovti,ov12a10";
+		reg = <0x10>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK0_CLK>;
+		pinctrl-0 = <&cam_sensor_rear_default &camss_mclk0_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+		powerdown-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&vreg_cam_avdd>;
+		dvdd-supply = <&pm8953_l2>;
+		dovdd-supply = <&pm8953_l6>;
+
+		rotation = <270>;
+		orientation = <1>;
+
+		port {
+			rear_cam_ep: endpoint {
+				data-lanes = <1 2 3 4>;
+				link-frequencies = /bits/ 64 <216000000>;
+				remote-endpoint = <&csiphy0_ep>;
+			};
+		};
+	};
+};
+
+&cci_i2c1 {
+	camera@2d {
+		compatible = "samsung,s5k5e8";
+		reg = <0x2d>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK1_CLK>;
+		pinctrl-0 = <&cam_sensor_front_default &camss_mclk1_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l23>;
+		dovdd-supply = <&pm8953_l6>;
+
+		rotation = <90>;
+		orientation = <0>;
+
+		port {
+			front_cam_ep: endpoint {
+				data-lanes = <1 2>;
+				link-frequencies = /bits/ 64 <418000000>;
+				remote-endpoint = <&csiphy2_ep>;
+			};
+		};
+	};
 };
 
 &hsusb_phy {
@@ -302,6 +400,27 @@ gpio_hall_sensor_default: gpio-hall-sensor-state {
 		bias-pull-up;
 	};
 
+	cam_sensor_front_default: cam-sensor-front-default-state {
+		pins = "gpio129";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	cam_sensor_rear_default: cam-sensor-rear-default-state {
+		pins = "gpio33", "gpio39";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	cam_vreg_avdd_default: cam-vreg-avdd-default-state {
+		pins = "gpio62";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
 	ts_int_default: ts-int-default-state {
 		pins = "gpio65";
 		function = "gpio";
Signature · 1 line
2.47.3
#39 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] arm64: dts: qcom: 1-based data-lanes in camss endpoints break camss_probe() - [High] arm64: dts…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] arm64: dts: qcom: 1-based data-lanes in camss endpoints break camss_probe()
- [High] arm64: dts: qcom: powerdown-gpios in camera@10 ignored by ov12a10_probe()
- [Medium] arm64: dts: qcom: missing vdd_l23-supply parent for camera@2d dvdd-supply
--

commit f90e380b7cfcacb30ebf79d76d723184343a3304
Author: Hikmah Gumelar <[email protected]>

arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras

This commit enables CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear and Samsung S5K5E8 front camera sensors on the Xiaomi Mi A1.

Quoted 4 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +0 -0
index fccb9c4360cae..e41cbd4d01b28 100644

[ ... ]

Quoted 16 lines

+&camss {

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +15 -0
+	vdda-supply = <&pm8953_s3>;
+	status = "okay";
+
+	ports {
+		port@0 {
+			reg = <0>;
+
+			csiphy0_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <1 2 3 4>;
+				remote-endpoint = <&rear_cam_ep>;
+			};
+		};
+
+		port@2 {

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts vph_pwr: vph-pwr-regulator { · line 114

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +10 -0
+			reg = <2>;
+
+			csiphy2_ep: endpoint {
+				clock-lanes = <7>;
+				data-lanes = <1 2>;
+				remote-endpoint = <&front_cam_ep>;
+			};
+		};
+	};
+};

[Severity: High]
Should data-lanes in csiphy0_ep and csiphy2_ep be 0-based (<0 1 2 3> and <0 1>)?

On MSM8953, the CAMSS endpoints connect directly to sensor endpoints rather than standalone PHY nodes, so camss_detect_legacy_phy() sets camss->legacy_phy = true and camss_parse_ports() passes lane_base = 0 to camss_parse_endpoint_node():

drivers/media/platform/qcom/camss/camss.c:camss_parse_endpoint_node() {
    ...
	for (i = 0; i < lncfg->num_data; i++) {
		u8 lane = mipi_csi2->data_lanes[i];

		if (lane < lane_base || lane - lane_base >= MSM_CSIPHY_MAX_DATA_LANE) {
			dev_err(dev, "invalid data-lane %u\n", lane);
			return -EINVAL;
		}

		lncfg->data[i].pos = mipi_csi2->data_lanes[i] - lane_base;
    ...
}

Because MSM_CSIPHY_MAX_DATA_LANE is 4, lane 4 in csiphy0_ep fails this check and aborts camss_probe() with -EINVAL. In csiphy2_ep, <1 2> with lane_base = 0 shifts lncfg->data[i].pos to physical data lanes 1 and 2 instead of lanes 0 and 1.

Quoted 6 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +6 -0
+
+&cci {
+	status = "okay";
+};
+
+&cci_i2c0 {

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts vph_pwr: vph-pwr-regulator { · line 130

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +10 -0
+	camera@10 {
+		compatible = "ovti,ov12a10";
+		reg = <0x10>;
+
+		clocks = <&gcc GCC_CAMSS_MCLK0_CLK>;
+		pinctrl-0 = <&cam_sensor_rear_default &camss_mclk0_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
+		powerdown-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;

[Severity: High]
Will ov12a10_probe() ignore powerdown-gpios here?

ov12a10_probe() requests the GPIO with con_id "pwdn" via devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH), and gpiolib has no OF rename entry mapping "pwdn" to "powerdown-gpios". The lookup silently returns NULL, so ov12a10_power_on() and ov12a10_power_off() never drive GPIO 39 and the rear sensor stays powered down.

[ ... ]

Quoted 4 lines

+&cci_i2c1 {

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +3 -0
+	camera@2d {
+		compatible = "samsung,s5k5e8";
+		reg = <0x2d>;

arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts vph_pwr: vph-pwr-regulator { · line 162

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +10 -0
+
+		clocks = <&gcc GCC_CAMSS_MCLK1_CLK>;
+		pinctrl-0 = <&cam_sensor_front_default &camss_mclk1_default>;
+		pinctrl-names = "default";
+
+		reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>;
+
+		avdd-supply = <&pm8953_l22>;
+		dvdd-supply = <&pm8953_l23>;
+		dovdd-supply = <&pm8953_l6>;

[Severity: Medium]
Does the rpm-pm8953-regulators node also need vdd_l23-supply = <&pm8953_s3>?

camera@2d is the first consumer of pm8953_l23 in this device tree, and rpm_pm8953_regulators in drivers/regulator/qcom_smd-regulator.c defines "vdd_l23" as l23's parent supply. Without vdd_l23-supply in the regulators node, pm8953_l23 falls back to dummy-regulator and enabling dvdd-supply in s5k5e8_power_on() does not vote for pm8953_s3.

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