Device tree (pix_clk_hz) setting for xavier nx - camera input

I would like to know how to calculate the correct pix_clk_hz setting in the device tree.
See below for details.
In the application we are developing, the adv7481’s CSI-2 output is connected to the Xavier nx’s CSI-2 input. D-PHY x 4 lanes are used. The data format is YUV 8-bit.
First of all, as an experiment, I tried transferring some images from the adv7481 to xavier at 1280*720p (50FPS), and there was no problem to capture the images. (The ADV7481 register’s set on SDR mode). The device tree and setting value at this time was :
mode0 { // ADV7481_MODE_1280x720_50FPS_4LANES
mclk_khz = “74250”;
num_lanes = “4”;
tegra_sinterface = “serial_a”;
phy_mode = “DPHY”;
discontinuous_clk = “yes”;
dpcm_enable = “false”;
cil_settletime = “0”;
active_w = “1280”;
active_h = “720”;

			mode_type = "yuv";
                			pixel_phase = "uyvy";
                			csi_pixel_bit_depth = "8";
			pixel_t  = "yuv_uyvy16";
			readout_orientation = "90";
			line_length = "3448";
			inherent_gain = "1";
			
			mclk_multiplier = "4";
			pix_clk_hz = "297000000";
		
			gain_factor = "16";
			framerate_factor = "1000000";
			exposure_factor = "1000000";
			min_gain_val = "16"; 
			max_gain_val = "170"; 
			step_gain_val = "1";
			default_gain = "16"; 
			min_hdr_ratio = "1";
			max_hdr_ratio = "1";
			min_framerate = "1500000"; 
			max_framerate = "120000000"; 
			step_framerate = "1";
			default_framerate = "50000000"; 
			min_exp_time = "13"; 
			max_exp_time = "683709"; 
			step_exp_time = "1";
			default_exp_time = "2495";
			embedded_metadata_height = "0";
		};

Then I changed the camera input resplution to 1920*1080p (30FPS), and there was no problem to capture the images. (The ADV7481 register’s set on SDR mode). The device tree and setting value at this time was :
mode1 { // ADV7481_MODE_1920x1080_30FPS_4LANES
mclk_khz = “74250”;
num_lanes = “4”;
tegra_sinterface = “serial_a”;
phy_mode = “DPHY”;
discontinuous_clk = “yes”;
dpcm_enable = “false”;
cil_settletime = “0”;

			active_w = "1920";
			active_h = "1080";
			mode_type = "yuv";
                			pixel_phase = "uyvy";
                			csi_pixel_bit_depth = "8";
			pixel_t  = "yuv_uyvy16";
			readout_orientation = "90";
			line_length = "3448";				
			inherent_gain = "1";

			mclk_multiplier = "4";
			pix_clk_hz = "297000000";
			
			gain_factor = "16";
			framerate_factor = "1000000";
			exposure_factor = "1000000";
			min_gain_val = "16"; 
			max_gain_val = "170";
			step_gain_val = "1";
			default_gain = "16";
			min_hdr_ratio = "1";
			max_hdr_ratio = "1";
			min_framerate = "1500000"; 
			max_framerate = "120000000"; 
			step_framerate = "1";
			default_framerate = "30000000"; 
			min_exp_time = "13";
			max_exp_time = "683709";
			step_exp_time = "1";
			default_exp_time = "2495";
			embedded_metadata_height = "0";
		};

finally I want to have the camera input resolution 1920*1080(50FPS), and could not capture the images with any setting of device tree. (The ADV7481 register’s set on SDR mode). The device tree and setting value at this time was :
mode2 { // ADV7481_MODE_1920x1080_50FPS_4LANES
mclk_khz = “148500”;
num_lanes = “4”;
tegra_sinterface = “serial_a”;
phy_mode = “DPHY”;
discontinuous_clk = “yes”;
dpcm_enable = “false”;
cil_settletime = “0”;
active_w = “1920”;
active_h = “1080”;

			mode_type = "yuv";
                			pixel_phase = "uyvy";
                			csi_pixel_bit_depth = "8";
			pixel_t  = "yuv_uyvy16";
			readout_orientation = "90";
			line_length = "3448";				
			inherent_gain = "1";

			mclk_multiplier = "4";		
			pix_clk_hz = "594000000";	
			
			gain_factor = "16";
			framerate_factor = "1000000";
			exposure_factor = "1000000";
			min_gain_val = "16"; 
			max_gain_val = "170";
			step_gain_val = "1";
			default_gain = "16";
			min_hdr_ratio = "1";
			max_hdr_ratio = "1";				
			min_framerate = "1500000"; 
			max_framerate = "120000000"; 
			step_framerate = "1";
			default_framerate = "50000000"; 
			min_exp_time = "13"; 
			max_exp_time = "683709"; 
			step_exp_time = "1";
			default_exp_time = "2495";
			embedded_metadata_height = "0";
		};

I tried the following settings but none of them were successful:
• I test the changed the pix_clk_hz setting value to 1250000000. (xavier nx series : 14 lanes - 2.5 Gb/s per pair, total up to 30 Gbps)
pixel_clk_hz = sensor data rate per lane (Mbps) * number of lanes / bits per pixel
pixel_clk_hz = (2.500.000.000 / 8 )* 4 = 1.250.000.000 bps
• I test the changed the pix_clk_hz setting value to 1250000000. ( sensor output size =22001125 )
pixel_clk_hz = sensor output size × frame rate
pixel_clk_hz = (2200
1125 )* 50= 123.750.000 bps
• I changed the ADV7481 register’s to DDR mode.
Which part am I doing wrong?
Thank you in advance for your cooperation.

hello shahabadi.p,

here’s another example to check with CSI date rate, for example, 4K(3840x2160),90-fps,10-bit.
CSI data-rate = 3840 * 2160 * 10 * 90 * 1.15 (15% overhead) ~= 8.584 Gbps
so… device tree configuration, pixel_clk_hz = 8600000000;

Hello JerryChang,

Thanks for the reply.
Please give an example also from mclk_khz (Standard MIPI driving clock frequency, in kilohertz).
Should the value of mclk_khz be changed in different mode with different resolutions?

And one more question about mclk_multiplier :
(mclk_multiplier : Deprecated. This switch is no longer needed because the value it specifies is calculated internally.)
Is it possible to delete this item by considering these explanations?

hello shahabadi.p,

BTW,
it might be the issue that driver side select incorrect settings, since you have two 1920x1080 sensor modes, i.e. 30-fps and 50-fps.
please refer to developer guide, Device Properties by adding use_sensor_mode_id = "true"; for sensor mode selection.

here’s sample pipeline for mode selection.
$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=4 --stream-mmap --stream-count=100

Hi Jerry,
It seems that the problem is in this part:
(8-BIT DIGITAL INPUT/OUTPUT PORT OF ADV7481:
The maximum input and output video resolution supported is 720p/1080i in both SDR and DDR modes.)

But, please answer my previous two questions (about : mclk_khz & mclk_multiplier ) to make me clear about the device tree correct configuration.
Thank you so much.

hello shahabadi.p,

this property has deprecated, it’s now using camera settings (i.e. pix_clk_hz, num_lanes, bit_depth…etc) to initialize camera software configuration internally.

when you configure cil_settletime = 0; it’s picking up mclk_khz and pix_clk_hz to do auto calibrate.

Hi Jerry,
Thanks a lot for the all replies.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.