How to implement 2 cameras working simultaneously in one MAX9286?

Hi guys,

I’m developing MAX9286/MAX96705 on AGX Xavier(L4T-R32.3.1), now Xavier can get two camera node, and /dev/video0 works fine, but when I try to open /dev/video1, can’t get any preview video data but csi signal can be measured.

Now I have some question about multi-cameras using MAX9286+MAX96705, anyone can help me? Thanks so much.

  1. What commands to open multi-cameras ? First open camera0 and then open camera1 using gst-launch-1.0 right? but just get one gst-lauch window on screen.
    $gst-launch-1.0 v4l2src device=/dev/video0 ! ‘video/x-raw,width=1280,height=720,format=(string)YUY2’ ! nvvidconv ! ‘video/x-raw’ ! xvimagesink (ok)
    $gst-launch-1.0 v4l2src device=/dev/video1 ! ‘video/x-raw,width=1280,height=720,format=(string)YUY2’ ! nvvidconv ! ‘video/x-raw’ ! xvimagesink (ok)

  2. MAX9286/MAX96705 register setting is different while opening camera0/camera1, we are using 50Hz wave to MAX9286 FRSYNC/GPI Pin and set MAX96705 GPO for multi-cameras frame sync(external frame sync)
    Open camera0:
    MAX96705: 0x0f=0xbf
    MAX9286: 0x00=0xe1, 0x01=0x00 (not using frame sync), and get preivew camera0 success(0x31 get is 0x40)
    Open camera1: (camera0 is opened using “1” commands)
    MAX96705: 0x0f=0xbf
    MAX9286: 0x00=0xe3, 0x01=0xe2 (using external frame sync), and camera1 can’t get any preivew (0x31 get is 0x00)

  3. Here is the dtsi setting for gmsl camera with VC-ID, the setting is right or not?

/*
 * Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/ {
	host1x {
		vi@15c10000 {
			num-channels = <2>;
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					ar0143_vi_in0: endpoint {
						vc-id = <0>;
						port-index = <0>;
						bus-width = <4>;
						remote-endpoint = <&ar0143_csi_out0>;
					};
				};
				port@1 {
					reg = <1>;
					ar0143_vi_in1: endpoint {
						vc-id = <1>;
						port-index = <0>;
						bus-width = <4>;
						remote-endpoint = <&ar0143_csi_out1>;
					};
				};
			};
		};

		nvcsi@15a00000 {
			num-channels = <2>;
			#address-cells = <1>;
			#size-cells = <0>;
			channel@0 {
				reg = <0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						ar0143_csi_in0: endpoint@0 {
							port-index = <0>;
							bus-width = <4>;
							remote-endpoint = <&ar0143_ar0143_out0>;
						};
					};
					port@1 {
						reg = <1>;
						ar0143_csi_out0: endpoint@1 {
							remote-endpoint = <&ar0143_vi_in0>;
						};
					};
				};
			};
			channel@1 {
				reg = <1>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						ar0143_csi_in1: endpoint@2 {
							port-index = <0>;
							bus-width = <4>;
							remote-endpoint = <&ar0143_ar0143_out1>;
						};
					};
					port@1 {
						reg = <1>;
						ar0143_csi_out1: endpoint@3 {
							remote-endpoint = <&ar0143_vi_in1>;
						};
					};
				};
			};
		};
	};

	i2c@3180000 {
		ar0143_a@1b {
			compatible = "nvidia,ar0143";

			reg = <0x1b>;

			/* Physical dimensions of sensor */
			physical_w = "15.0";
			physical_h = "12.5";

			sensor_model ="ar0143";
			
			post_crop_frame_drop = "0";

			/* Convert Gain to unit of dB (decibel) befor passing to kernel driver */
			use_decibel_gain = "true";

			/* enable CID_SENSOR_MODE_ID for sensor modes selection */
			use_sensor_mode_id = "true";

			mode0 {/*mode AR0143_MODE_1280X720_CROP_30FPS*/
				mclk_khz = "24000";
				num_lanes = "4";
				tegra_sinterface = "serial_c";
				vc_id = "0";
				discontinuous_clk = "no";
				dpcm_enable = "false";
				cil_settletime = "0";
				/*
				dynamic_pixel_bit_depth = "12";
				csi_pixel_bit_depth = "12";
				mode_type = "bayer";
				pixel_phase = "rggb";
				*/
				dynamic_pixel_bit_depth = "8";
				csi_pixel_bit_depth = "8";
				mode_type = "yuv";
				pixel_phase = "yuyv";
				
				active_w = "1280";
				active_h = "720";
				readout_orientation = "0";
				line_length = "2200";
				inherent_gain = "1";
				pix_clk_hz = "74250000";
				serdes_pix_clk_hz = "833333333";

				gain_factor = "10";
				min_gain_val = "0"; /* dB */
				max_gain_val = "300"; /* dB */
				step_gain_val = "3"; /* 0.3 */
				default_gain = "0";
				min_hdr_ratio = "1";
				max_hdr_ratio = "1";
				framerate_factor = "1000000";
				min_framerate = "30000000";
				max_framerate = "30000000";
				step_framerate = "1";
				default_framerate = "30000000";
				exposure_factor = "1000000";
				min_exp_time = "59"; /*us, 2 lines*/
				max_exp_time = "33333";
				step_exp_time = "1";
				default_exp_time = "33333";/* us */
				embedded_metadata_height = "0";
			};
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					ar0143_ar0143_out0: endpoint {
						vc-id = <0>;
						port-index = <0>;
						bus-width = <4>;
						remote-endpoint = <&ar0143_csi_in0>;
						};
					};
				};
			gmsl-link {
				src-csi-port = "b";
				dst-csi-port = "a";
				serdes-csi-link = "a";
				csi-mode = "1x4";
				st-vc = <0>;
				vc-id = <0>;
				num-lanes = <4>;
				streams = "ued-u1", "raw12";
				};
			};

	ar0143_b@1c {
		compatible = "nvidia,ar0143";

		reg = <0x1c>;

		/* Physical dimensions of sensor */
		physical_w = "15.0";
		physical_h = "12.5";

		sensor_model ="ar0143";

		/* Defines number of frames to be dropped by driver internally after applying */
		/* sensor crop settings. Some sensors send corrupt frames after applying */
		/* crop co-ordinates */
		post_crop_frame_drop = "0";

		/* Convert Gain to unit of dB (decibel) befor passing to kernel driver */
		use_decibel_gain = "true";

		/* enable CID_SENSOR_MODE_ID for sensor modes selection */
		use_sensor_mode_id = "true";

		mode0 {/*mode AR0143_MODE_1280X720_CROP_30FPS*/
			mclk_khz = "24000";
			num_lanes = "4";
			tegra_sinterface = "serial_c";
			vc_id = "1";
			discontinuous_clk = "no";
			dpcm_enable = "false";
			cil_settletime = "0";
			/*
			dynamic_pixel_bit_depth = "12";
			csi_pixel_bit_depth = "12";
			mode_type = "bayer";
			pixel_phase = "rggb";
			*/
			dynamic_pixel_bit_depth = "8";
			csi_pixel_bit_depth = "8";
			mode_type = "yuv";
			pixel_phase = "yuyv";

			active_w = "1280";
			active_h = "720";
			readout_orientation = "0";
			line_length = "2200";
			inherent_gain = "1";
			pix_clk_hz = "74250000";
			serdes_pix_clk_hz = "833333333";

			gain_factor = "10";
			min_gain_val = "0"; /* dB */
			max_gain_val = "300"; /* dB */
			step_gain_val = "3"; /* 0.3 */
			default_gain = "0";
			min_hdr_ratio = "1";
			max_hdr_ratio = "1";
			framerate_factor = "1000000";
			min_framerate = "30000000";
			max_framerate = "30000000";
			step_framerate = "1";
			default_framerate = "30000000";
			exposure_factor = "1000000";
			min_exp_time = "59"; /*us, 2 lines*/
			max_exp_time = "33333";
			step_exp_time = "1";
			default_exp_time = "33333";/* us */
			embedded_metadata_height = "0";
		};
		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				ar0143_ar0143_out1: endpoint {
					vc-id = <1>;
					port-index = <0>;
					bus-width = <4>;
					remote-endpoint = <&ar0143_csi_in1>;
					};
				};
			};
		gmsl-link {
			src-csi-port = "b";
			dst-csi-port = "a";
			serdes-csi-link = "b";
			csi-mode = "1x4";
			st-vc = <0>;
			vc-id = <1>;
			num-lanes = <4>;
			streams = "ued-u1", "raw12";
			};
		};
	};
};

/ {

	tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
		
		num_csi_lanes = <4>;
		max_lane_speed = <4000000>;
		min_bits_per_pixel = <10>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		isp_peak_byte_per_pixel = <5>;
		isp_bw_margin_pct = <25>;

		/**
		 * The general guideline for naming badge_info contains 3 parts, and is as follows,
		 * The first part is the camera_board_id for the module; if the module is in a FFD
		 * platform, then use the platform name for this part.
		 * The second part contains the position of the module, ex. "rear" or "front".
		 * The third part contains the last 6 characters of a part number which is found
		 * in the module's specsheet from the vender.
		 */
		modules {
			module0 {
				badge = "ar0143_frontl";
				position = "rear";
				orientation = "1";
				drivernode0 {
					/* Declare PCL support driver (classically known as guid)  */
					pcl_id = "v4l2_sensor";
					/* Driver v4l2 device name */
					devname = "ar0143 2-001b";
					/* Declare the device-tree hierarchy to driver instance */
					proc-device-tree = "/proc/device-tree/i2c@3180000/ar0143_a@1b";
				};
			};
			module1 {
				badge = "ar0143_frontr";
				position = "front";
				orientation = "1";
				drivernode0 {
					/* Declare PCL support driver (classically known as guid)  */
					pcl_id = "v4l2_sensor";
					/* Driver v4l2 device name */
					devname = "ar0143 2-001c";
					/* Declare the device-tree hierarchy to driver instance */
					proc-device-tree = "/proc/device-tree/i2c@3180000/ar0143_b@1c";
				};
			};
		};
	};
};

You can try v4l2-ctl to check if can capture normally without preview.
For your problem it could be the bridge configure problem. You may need to consult with vendor to get the solution.

v4l2-ctl --stream-mmap --set-ctrl bypass_mode=0 --stream-count=100 -d /dev/video0

Dear ShaneCCC,

/dev/video0 open and preview success, my problem is /dev/video1 can’t be opened.

nvidia@xavier:~$ v4l2-ctl --stream-mmap --set-ctrl bypass_mode=0 --stream-count=100 -d /dev/video0
<<<<<<<<<<<<<<<<<<<<<<<<<< 25.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<< 25.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<< 25.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<

But /dev/video1 no output

nvidia@xavier:~$ v4l2-ctl --stream-mmap --set-ctrl bypass_mode=0 --stream-count=100 -d /dev/video1

Have a check the trace log

Hi ShaneCCC,

I have uploaded the csi trace log, while opening camera0 and camera1 , please help to check. Thanks

csi.mix.video01.05211440.log (429.1 KB)

The trace log show CHANSEL_FAULT of PIXEL_LONG_LINE.
That could be the output pixel per link more than expect. Have a adjust the width to try.

kworker/0:1-828 [000] … 172.872150: rtcpu_vinotify_event: tstamp:5644621779 tag:CHANSEL_FAULT channel:0x22 frame:145 vi_tstamp:5644486727 data:0x00000100

Hi ShaneCCC,

I have tried to modify different width or height but no effect, I think maybe multi-cameras frame sync problem, and I’m going on this.

Thanks.