some problems about the dts file of the csi camera on tx1

Hello,
I use tx1 devkit board ,kernel version 24.2.1
I want to use just one i2c bus (i2c-6) to control six csi-2 camera (imx219) which have the same i2c slave address 0x10.
I refer to the dts file of e3333 board. In that file I find some thing useful.

i2c@546c0000{
		#address-cells = <1>;
		#size-cells = <0>;
			
		tca9548@77{
			i2c@0{
				imx219_a@10{
					reg = <0x10>;
					
				}:
			};
			i2c@1{
				imx219_b@10{
					reg = <0x10>;
					
				}:
			};
			i2c@2{
				imx219_c@10{
					reg = <0x10>;
					
				}:
			};
			i2c@3{
				imx219_d@10{
					reg = <0x10>;
					
				}:
			};
			i2c@4{
				imx219_e@10{
					reg = <0x10>;
					
				}:
			};
			i2c@5{
				imx219_f@10{
					reg = <0x10>;
					
				}:
			};
		};
};

tca9548 is a i2c switch.I also use the microcontroller as a i2c switch.
I think on the e3333 board the i2c-6 should send 0x77 0x01 to switch the i2c to imx219_a, and send 0x77 0x02 to switch i2c to imx219_b,and send 0x77 0x04 to switch i2c to imx219_c,etc.
On my board ,I will send 0x12 0xfe to switch i2c to imx219_a, and 0x12 0xfd -> imx219_b, 0x12 0xfb -> imx219_c, 0x12 0xf7 -> imx219_d ,etc.
I don’t know how to write the dts. i tried :

i2c@546c0000{
		#address-cells = <1>;
		#size-cells = <0>;
			
		mcu@12{
			i2c@fe{
				imx219_a@10{
					reg = <0x10>;
					
				}:
			};
			i2c@fd{
				imx219_b@10{
					reg = <0x10>;
					
				}:
			};
			i2c@fb{
				imx219_c@10{
					reg = <0x10>;
					
				}:
			};
			i2c@f7{
				imx219_d@10{
					reg = <0x10>;
					
				}:
			};
			i2c@ef{
				imx219_e@10{
					reg = <0x10>;
					
				}:
			};
			i2c@df{
				imx219_f@10{
					reg = <0x10>;
					
				}:
			};
		};
};

then when I boot up ,I get the message :

i2c-6: of_i2c: modalias failure on /host1x/i2c@546c0000/mcu12

and I haven’t seen the video0 to video5 in /dev.
how should I write my dts to see video0-vide05 ? I need to write a c source driver for the mcu@12 ?

I have read the Sensor Driver Programming Guide, but it still can’t solve my problem.
Is there anybody konw how to solve my problem ? or what document should I refer to ?

Regards.

Have you verified your MC can work as a I2C expander as tca9548?

We used Leopard Imaging 6 camera adapters with tca9548 and they worked.

Hello yahoo2016,
1)My MC can work as i2c switch as tca9548. when using tca9548, the master send the command 0x77 0x01 to choose the chanel 1 of the tca9548 8 chanels.I can configure my MC send the command 0x12 0x01 to choose the chanel 1. So my MC will work as tca9548.

2)How did you write your dts file using tca9548.Did the structure of your dts like that I mentioned above :

i2c@546c0000{
		#address-cells = <1>;
		#size-cells = <0>;
			
		tca9548@77{
			i2c@0{
				imx219_a@10{
					reg = <0x10>;
					
				}:
			};
Did you write c file to support tca9548 in the kernel source code ? Because I haven't found what is the command the tx1 send to tca9548 just according to the dts file.

3)when I add my own dts file I mentioned above to the main dts tree,then I run the command make dtbs ,I get the warning :

Warning (reg_format): "reg" property in /host1x/i2c@546c0000/mcu@12/i2c@fe/imx219_a@10 has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Warning (avoid_default_addr_size): Relying on default #address-cells value for /host1x/i2c@546c0000/mcu@12/i2c@fe/imx219_a@10
I use this dtb on tx1 ,when booting up, the dmesg says:
i2c-6: of_i2c: modalias failure on /host1x/i2c@546c0000/mcu@12
I think it maybe the problem of address-cell and size-cell.but try to set them to 2 and 1 ,the warning remains. I have no idea on fixing it. Do you have any clues?

Regards.

The following is part of patch from Leopard Imaging for IMX185, it could save you a lot of time if you get one of their kits to get source of the driver as reference.

diff -urN kernel/arch/arm64/boot/dts/tegra210-platforms/tegra210-jetson-cv-camera-li-mipi-adpt-a00.dtsi kernel_185/arch/arm64/boot/dts/tegra210-platforms/tegra210-jetson-cv-camera-li-mipi-adpt-a00.dtsi
--- kernel/arch/arm64/boot/dts/tegra210-platforms/tegra210-jetson-cv-camera-li-mipi-adpt-a00.dtsi	2016-11-10 11:37:16.000000000 +0800
+++ kernel_185/arch/arm64/boot/dts/tegra210-platforms/tegra210-jetson-cv-camera-li-mipi-adpt-a00.dtsi	2017-02-27 13:10:44.811274150 +0800
@@ -17,6 +17,10 @@
 #include <tegra210-platforms/tegra210-camera-li-mipi-adpt-a00.dtsi>
 
 #define CAM0_RST	TEGRA_GPIO(S, 4)
+#define CAM1_RST_L	TEGRA_GPIO(S, 5)
+#define CAM0_PWDN	TEGRA_GPIO(S, 7)
+#define CAM1_PWDN	TEGRA_GPIO(T, 0)
+
 
 /* camera control gpio definitions */
 
@@ -48,23 +52,34 @@
 		* Isp bandwidth margin in percentage
 		*/
 		num_csi_lanes = <4>;
-		max_lane_speed = <1500000>;
+		max_lane_speed = <445500000>;
 		min_bits_per_pixel = <10>;
 		vi_peak_byte_per_pixel = <2>;
 		vi_bw_margin_pct = <25>;
-		isp_peak_byte_per_pixel = <5>;
+		isp_peak_byte_per_pixel = <2>;
 		isp_bw_margin_pct = <25>;
 	};
 
 	host1x {
 		i2c@546c0000 {
-			tca9546@70 {
-				compatible = "nxp,pca9546";
-				reg = <0x70>;
+			tca6408_77: tca6408@77 {
+				compatible = "ti,tca9539";
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x77>;
+				interrupt-parent = <&gpio>;
+				interrupts = <TEGRA_GPIO(L, 1) 0x0>;
+				#interrupt-cells = <2>;
+				interrupt-controller;
+			};
+			tca9546@77 {
+				compatible = "nxp,pca9548";
+				reg = <0x77>;
 				#address-cells = <1>;
 				#size-cells = <0>;
 				vif-supply = <&en_vdd_cam>;
 				vcc_lp = "vif";
+				reset-gpios = <&gpio CAM0_RST GPIO_ACTIVE_HIGH>;
 				i2c@0 {
 					reg = <0>;
 					i2c-mux,deselect-on-exit;
@@ -84,13 +99,88 @@
 /{
 	host1x {
 		i2c@546c0000 {
-			tca9546@70 {
+			tca9546@77 {
 				i2c@0 {
 					imx185_a@1a {
 						mclk = "cam_mclk1";
 						reset-gpios = <&gpio CAM0_RST GPIO_ACTIVE_HIGH>;
 					};
 				};
+				i2c@1 {
+					reg = <1>;
+					i2c-mux,deselect-on-exit;
+					#address-cells = <1>;
+					#size-cells = <0>;
+					imx185_b@1a {
+						mclk = "cam_mclk1";
+						reset-gpios = <&gpio CAM1_RST_L GPIO_ACTIVE_HIGH>;
+					};
+					pca9570_b@24 {
+						compatible = "nvidia,pca9570";
+						reg = <0x24>;
+						channel = "b";
+					};
+				};

@yahoo2016

Now I can get the six video node /dev/video0~5,but only video0 could get the preview image using gst-launch-1.0 command.
I read the dmesg after tx1 boot and find that the probe function runs correctly.Then I add printk in the tca9548 reg write function. I find when I set the sensor-id to 0,1,2,3,4 and 5,the selected channel is always channel 1 which matchs sensor-id=0 and video0.
Could you use “gst-launch-1.0 nvcamerasrc sensor-id=0/1/2/3/4/5” to get the video preview from the node /dev/video0/1/2/3/4/5 (these node match the sensor-id0~5), When you use tca9548.
Did you do any modification when you use gst-launch-1.0 ?

Regards.

can you follow this link:

https://devtalk.nvidia.com/default/topic/1010795/v4l2-on-jetson-tx2/

and try the following with parameters matching your camera driver/dtb:

v4l2-ctl --set-fmt-video=width=1920,height=1080, pixelformat=RG10 ,pixelformat=RG10 --stream-mmap --stream-count=1 -d /dev/video1 --stream-to=imx219.raw

v4l2-ctl --set-fmt-video=width=1920,height=1080, pixelformat=RG10 ,pixelformat=RG10 --stream-mmap --stream-count=1 -d /dev/video5 --stream-to=imx219.raw

Hi yahoo2016,

I can use the v4l2-ctl command you mentioned to get six bayer image from video0~5,
But the gst-launch-1.0 command still doesn’t work correctly. the command is :

gst-launch-1.0 nvcamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1, format=NV12' ! nvoverlaysink -ev

whatever sensor-id I set ,the i2c switch always enables the channel of video0.

pca954x_select_chan(struct i2c_adapter *adap, void *client ,u32 chan)

In the select channel function above, the chan value is always 0 ,even I set different sensor-id. When I use v4l2-ctl and choose different video num, the chan value changes with the video num.
Maybe it’s the nvcamerasrc problem.
Could you use gst-launch-1.0 to get six camera preview correctly ?

Regards.

The following command worked for 6 IMX185’s on Leopard Imaging adapter:

gst-launch-1.0 nvcamerasrc fpsRange="30.0 30.0" sensor-id=x ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! nvoverlaysink -e

The issue could be your dtb. Each imx219 should have a “phandle” (e.g., <0xd5>) which should be in “override”, e.g.

override@0 {
target = <0xd5>