V4L2 Sub device Driver (OV5647) couldn't link with MIPI-CSI dev node

Problem statement : In V4L2 Sub device Driver (OV5647) couldn’t link with the MIPI-CSI dev node (/dev/video2)

Setup Details:
1. Base Board: Ixora v1.1
2. Module: Apalis iMX6D 1 GB IT
3. Kernel: Building Kernel image separately. (BSP 5.0: Branch - toradex_5.4-2.3.x-imx)
(git clone -b toradex_5.4-2.3.x-imx git://git.toradex.com/linux-toradex.git)
4. V4L2 Sub-device: OV5647 (drivers/media/platform/mxc/capture/ov5647_mipi.c)

After configuring toolchain, Kernel configuration done as below :

a) make apalis_imx6_defconfig

b) make menuconfig
	MXC_CAMERA_OV5647_MIPI [=y]
		-> Device Driver
		   -> Multi-media Support (MEDIA_SUPPORT [=y])
		      -> V4L Platform Devices (V4L_PLATFORM_DRIVERS [=y]) 
			 -> mxc mipi csi driver[=y]
			    -> MXC Camera/V4L2 PRP Features Support
				-> Omnivision ov5647 camera support using mipi[=y]
				-> Select Overlay Routing (Queue ipu device for overlay library)[=y]
				-> Pre-Processor Encoder Library [=y]
				-> IPU CSI Encoder Library [=y]
			
Depends on : MEDIA_SUPPORT [=y] && V4L_PLATFORM_DRIVERS [=y] && VIDEO_MXC_CAPTURE [=y] && MXC_MIPI_CSI [=y] && I2C [=y]

Below entries added in imx6q-apalis-eval.dts

ov5647_csi_cam: camera@36 {
            compatible = "ov5647_mipi";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_cam_mclk>;
            reg = <0x36>;
            /*
             * By default use the internal on-cam clock source
             * (Compatible with Toradex OV5640 v1.1b and later)
             */
            clocks = <&clk_ov5647_osc>;
            clock-names = "csi_mclk";
            DOVDD-supply = <&reg_ov5640_1v8_d_o_vdd>;
            AVDD-supply = <&reg_ov5640_2v8_a_vdd>;
            DVDD-supply = <&reg_ov5640_1v8_d_o_vdd>;
            pwn-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
            rst-gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
            ipu_id = <0>;
            csi_id = <1>;
            mipi_camera = <1>;
            mclk = <24000000>;
            mclk_source = <0>;
            status = "okay";     
    };					

Below are details from imx6qdl-apalis.dtsi

v4l2_cap_0 {
	compatible = "fsl,imx6q-v4l2-capture";
	ipu_id = <0>;
	csi_id = <0>;
	mclk_source = <0>;
	status = "okay";
};

v4l2_cap_1 { // second parallel camera
	compatible = "fsl,imx6q-v4l2-capture";
	ipu_id = <1>;
	csi_id = <1>;
	mclk_source = <0>;
	status = "okay";
};

v4l2_cap_2 { // mipi-csi2 camera
	compatible = "fsl,imx6q-v4l2-capture";
	ipu_id = <0>;
	csi_id = <1>;
	mclk_source = <0>;
	status = "okay";
};

After building zImage with above updated configuration when we load the kernel below are the observations.

1. ov5647_probe(): Successful.
	This Functions is calling below subdevice registration functions.
		- v4l2_i2c_subdev_init()
		- v4l2_async_register_subdev()

2. Linking the camera sensor with video device failing

3. After running "v4l2-clt -d /dev/video2 -l" showing below error
	[339.290200] 
	[339.290200] In MVC: mxc_v4l_open
	[339.294967]    device name is Mxc Camera
	[339.298897] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
	Failed to open /dev/video2: Resource temporarily unavailable

4. dmesg | grep ov5647 (Below is output)
	[4.303504] camera ov5647_mipi is found
	[4.311833] ***** Inside ov5647_probe@1704 : Camera OV5647_mipi is found.*****

5. Also we tried to build all as Kernel modules and loaded the same in below sequence.
	- modprobe ov5647_camera_mipi.ko
	- modprobe mxc_v4l2_capture.ko
   But observed the same behaviour as in case of static/in-built.

Can you please review our above configuration? Request to share if anything missing.

Hi @apurva,

Thanks for contacting Toradex Community.

Regarding your query can you please help me with below information to understand your setup.
What hardware and software version you are running?
Output of below commands
dmesg
media-ctl -p
exact connecting commands and error you get.
Complete device tree modification.

Please note we have never tested the combination of sensor you are testing.

Best Regards
Ritesh Kumar

Hello Ritesh,

Thanks for your inputs. Please find the requested details ;

  1. dmesg : Attached is the output log file.

  2. I/P : media-ctl -p
    O/P : Failed to enumerate /dev/media0 (-2)

  3. As observed /dev/mediaX node is not getting created. We couldn’t give any ‘media-ctl’ commands.
    Request to share ‘media-ctl’ commands to be used.

Thank you.

Regards,
Apurva
dmesg_ov5647_mipi_log.txt (29.0 KB)

Hi Ritesh and Team,
May I know if there’s an update on the same?

Thank you.

Regards,
Apurva

Hi @apurva,

Please share complete changes(device tree file) or output of git diff. From log it is not clear where exactly issue is coming apart from couple of write error.

Looking at nxp documentation and as per our understanding driver should create video device for camera capture so media-ctl link is not needed in this case.
Please note we only tested OV5640 and this is working good.

Also please check at your end if you can share camera hardware we can try to test existing driver to help you with issue.

Best Regards
Ritesh Kumar

Hello Ritesh,

Please find attached modified device tree files. As mentioned in the first thread above, the other details are;
imx6qdl-apalis.dtsi (34.8 KB)
imx6q-apalis-eval.dts (6.9 KB)
imx6q.dtsi (14.1 KB)

  1. Base Board: Ixora v1.1
  2. Module: Apalis iMX6D 1 GB IT
  3. Kernel: Building Kernel image separately. (BSP 5.0: Branch - toradex_5.4-2.3.x-imx)
    (git clone -b toradex_5.4-2.3.x-imx git://git.toradex.com/linux-toradex.git)
  4. V4L2 Sub-device: OV5647 (drivers/media/platform/mxc/capture/ov5647_mipi.c)

Thank you.

Regards,
Apurva Kulkarni

Hi @apurva,

We can see there are lot of debug message from driver. Are you sharing all the changes you have made? Please note we do not have experience with this sensor, from here without actual hardware it is difficult figure out exact issue.

From shared device tree there are two node for ov5647 sensor, seems like you are trying to use two driver. I will recommend to test one at a time. Please remove ov5647@36 node and check if default driver is loading. Share lsmod command also.
Other then this please check if you are getting proper clock and able to see any data on data bus.

Best Regards
Ritesh Kumar