Video Driver ProgressivePAL 720x576 50 fps

Hello All,
We are trying to test Video Driver(Progressive-PAL-720576-50fps-CSI 4Lane) using Fpga CSI in Jetpack 4.2(L4T 32.2.1) for the Jetson Tx1 with our customize carrier board.
we compile Driver,v4l2 video node is OK ,I Set Video Driver to 720
576-50fps but it Configured as follows(736/576-50fps):

ls /dev/vid*
	/dev/video0

v4l2-ctl -V

Format Video Capture:
        Width/Height      : 736/576
        Pixel Format      : 'UYVY'
        Field             : None
        Bytes per Line    : 1472
        Size Image        : 847872
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             :
		

v4l2-ctl -d /dev/video0 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 720x576
                        Interval: Discrete 0.020s (50.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'NV16'
        Name        : Y/CbCr 4:2:2
                Size: Discrete 720x576
                        Interval: Discrete 0.020s (50.000 fps)

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 720x576
                        Interval: Discrete 0.020s (50.000 fps)

And in the recorded video, frames are one among the green,the video is attached!!
http://s000.tinyupload.com/download.php?file_id=00302658367971078451&t=0030265836797107845169906

In the following,we test Video Driver(Progressive-640*480-89fps-CSI 4Lane)
we compile Driver,v4l2 video node is OK,and
My video Node Spec is:

ls /dev/vid*

	/dev/video0

v4l2-ctl -V
 
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'UYVY'
        Field             : None
        Bytes per Line    : 1280
        Size Image        : 614400
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             :

v4l2-ctl -d /dev/video0 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.011s (89.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'NV16'
        Name        : Y/CbCr 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.011s (89.000 fps)

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.011s (89.000 fps)

In this test, the video received no problems,without green frame!!
http://s000.tinyupload.com/index.php?file_id=05500817468536454538

First question:
Why did I set the driver to 720-576 but set it to 736-576 in v4l2-ctl -V?
My question is How do I fix this?

Second question:
There is no sample (720*576 Progressive-Interlace) video driver,Kenel Source AND Device Tree in Jetson Family?

Thank you!!
test_4k_h264000.png
test_4k_h264002.png
test_4k_h264001.png
test_4k_h264003.png

hello hhami.2040,

you may review your sensor driver, since -V options to query (VIDIOC_G_FMT) the video capture format.
the --list-formats-ext options were reporting correct resolutions, (i.e. 720x576)

if you play the video frame-by-frame, it actually has two green frames between every normal images.
you may also dump the streaming by v4l2-ctl, and analysis it with 3rdparty viewing tools, such as 7yuv.
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10 --stream-to=test.raw

is there kernel failures? could you please also check with $ dmesg to gather more information.
also, some experience that this sometime related to pixel clock settings.
could you please check Sensor Pixel Clock and review your sensor device tree properties.
thanks

Thank you JerryChang,
Eventually,I didn’t find the reason,But when I changed the video driver resolution to 736*288-50fps-2lane,
The video received is correct,And the frames don’t have green images!!

http://s000.tinyupload.com/index.php?file_id=00061101666511895797

v4l2-ctl -V
 
v4l2-ctl -V
Format Video Capture:
        Width/Height      : 736/288
        Pixel Format      : 'UYVY'
        Field             : None
        Bytes per Line    : 1472
        Size Image        : 423936
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             :

v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 736x288
                        Interval: Discrete 0.020s (50.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'NV16'
        Name        : Y/CbCr 4:2:2
                Size: Discrete 736x288
                        Interval: Discrete 0.020s (50.000 fps)

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Discrete 736x288
                        Interval: Discrete 0.020s (50.000 fps)

Probably the problem with pixel clock settings in deivce tree.
I set up all the drivers with this DT:

#include <dt-bindings/media/camera.h>
#include <dt-bindings/platform/t210/t210.h>

/ {
	host1x {
		vi {
			num-channels = <1>;
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					p3030_vi_in0: endpoint {
						port-index = <2>;
						bus-width = <2>;
						remote-endpoint = <&tpgfs_csi_out0>;
					};
				};
			};
		};
		nvcsi {
			num-channels = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			channel@0 {
				reg = <0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						p3030_csi_in0: endpoint@0 {
							port-index = <2>;
							bus-width = <2>;
							remote-endpoint = <&p3030_tpgfs_out0>;
						};
					};
					port@1 {
						reg = <1>;
						tpgfs_csi_out0: endpoint@1 {
							remote-endpoint = <&p3030_vi_in0>;
						};
					};
				};
			};
		};
		i2c@546c0000 {
			avdd_dsi_csi-supply = <&max77620_ldo0>;

			status = "okay";
			#address-cells = <1>;
			#size-cells = <0>;
			tpgfs_c@10 {
				compatible = "nvidia,tpgfs";
				/* I2C device address */
				reg = <0x10>;

				/* V4L2 device node location */
				devnode = "video0";

				/* Physical dimensions of sensor */
				physical_w = "3.680";
				physical_h = "2.760";

				/* Sensor output flip settings */
				vertical-flip = "true";
			
				/* Define any required hw resources needed by driver */
				/* ie. clocks, io pins, power sources */
				avdd-reg = "vana";
				iovdd-reg = "vif";

				
				mode0 { /* TPGFS_MODE_736x288_50FPS */
		 			
					mclk_khz = "24000";
					num_lanes = "2";
					tegra_sinterface = "serial_c";
					phy_mode = "DPHY";
					discontinuous_clk = "yes";
					dpcm_enable = "false";
					cil_settletime = "0";
					active_w = "1920";
					active_h = "1080";
					
					
					pixel_t  = "yuv_uyvy16";
					readout_orientation = "90";
					line_length = "3448";
					inherent_gain = "1";
					mclk_multiplier = "25";/*mclk_multiplier = "9.33";*/
					pix_clk_hz = "182400000";
					
					gain_factor = "16";
					framerate_factor = "1000000";
					exposure_factor = "1000000";
					min_gain_val = "16"; /* 1.00x */
					max_gain_val = "170"; /* 10.66x */
					step_gain_val = "1";
					default_gain = "16"; /* 1.00x */
					min_hdr_ratio = "1";
					max_hdr_ratio = "1";
					
					min_framerate = "1500000";
					max_framerate = "120000000"; /* 120.0 fps */
					step_framerate = "1";
					default_framerate = "50000000"; /* 50.0 fps */
					
					
					min_exp_time = "13"; /* us */
					max_exp_time = "683709"; /* us */
					step_exp_time = "1";
					default_exp_time = "2495"; /* us */		  
					embedded_metadata_height = "0";/*embedded_metadata_height = "2";*/
   
				};

				ports {
					#address-cells = <1>;
					#size-cells = <0>;

					port@0 {
						reg = <0>;
						p3030_tpgfs_out0: endpoint {
							port-index = <2>;
							bus-width = <2>;
							remote-endpoint = <&p3030_csi_in0>;
						};
					};
				};
			};
		};
	};

	tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
		/**
		* Physical settings to calculate max ISO BW
		*
		* num_csi_lanes = <>;
		* Total number of CSI lanes when all cameras are active
		*
		* max_lane_speed = <>;
		* Max lane speed in Kbit/s
		*
		* min_bits_per_pixel = <>;
		* Min bits per pixel
		*
		* vi_peak_byte_per_pixel = <>;
		* Max byte per pixel for the VI ISO case
		*
		* vi_bw_margin_pct = <>;
		* Vi bandwidth margin in percentage
		*
		* isp_peak_byte_per_pixel = <>;
		* Max byte per pixel for the ISP ISO case
		*
		* isp_bw_margin_pct = <>;
		* Isp bandwidth margin in percentage
		*/
		num_csi_lanes = <2>;
		max_lane_speed = <1500000>;
		min_bits_per_pixel = <10>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		isp_peak_byte_per_pixel = <2>;
		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 = "p3030_front_P5V27C";
				position = "rear";
				orientation = "1";
				drivernode0 {
					/* Declare PCL support driver (classically known as guid)  */
					pcl_id = "v4l2_sensor";
					/* Driver's v4l2 device name */
					devname = "tpgfs 6-0010";
					/* Declare the device-tree hierarchy to driver instance */
					proc-device-tree = "/proc/device-tree/host1x/i2c@546c0000/tpgfs_c@10";
				};

			};
		};
	};
};

You think this pixel clock settings for video driver 736288-50fps-2lane is correct???
I used exactly the same settings for a imx219 driver (1920
1080-25fps) video format ,
Thank you for your help

JerryChang,
If possible, answer my second question in first post https://devtalk.nvidia.com/default/topic/1068011/jetson-tx1/video-driver-progressivepal-720x576-50-fps-/post/5409525/#5409525

Second question:
There is no sample (720*576 Progressive-Interlace) video driver,Kenel Source AND Device Tree in Jetson Family???

Thank you!!

hello hhami.2040,

glad to know issue resolved,
your pixel clock (182.4Mhz) looks slightly higher for streaming with 736x288@50-fps.
please refer to Sensor Pixel Clock chapter for the sample formulas to calculate the necessary pixel clock.

AFAIK, we don’t have video driver with interlace output.
since progressive and interlace having different data and also timing, you may refer to HDMI2CSI bridge driver to handle the signaling.
please access L4T Sources via download center, you should check below driver for configure the interlaced timing.

<i>$l4t-r32.2/public_sources/kernel_src/kernel/nvidia/drivers/media/i2c/tc358840.c</i>

static int tc358840_get_detected_timings(struct v4l2_subdev *sd, struct v4l2_dv_timings *timings)
{
...
        if (bt->interlaced == V4L2_DV_INTERLACED) {
                bt->height *= 2;
                bt->il_vsync = bt->vsync + 1;
                bt->pixelclock /= 2;

Thank yuo very much,JerryChang