Why does my sensor driver have several more modes?

Hi:
硬件平台: xaiver nx
BSP: JP5.0.2

  为什么我用工具查看多出两种模式? 

v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture

    [0]: 'UYVY' (UYVY 4:2:2)
            Size: Discrete 1280x960
                    Interval: Discrete 0.033s (30.000 fps)
    [1]: 'NV16' (Y/CbCr 4:2:2)**
            Size: Discrete 1280x960**
                    Interval: Discrete 0.033s (30.000 fps)**
    [2]: 'UYVY' (UYVY 4:2:2)**
           Size: Discrete 1280x960**
                    Interval: Discrete 0.033s (30.000 fps)**

模式1 和2 是多出来的。

  my dtsi
  ```

i2c@3160000 {
x01f10@36 {//FPV
compatible = “nvidia,x01f10”;
/* I2C device address */
reg = <0x36>;

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

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

  		sensor_model = "x01f10";

  		use_sensor_mode_id = "true";

  		/**
  		* ==== Modes ====
  		* A modeX node is required to support v4l2 driver
  		* implementation with NVIDIA camera software stack
  		*
  		* == Signal properties ==
  		*
  		* phy_mode = "";
  		* PHY mode used by the MIPI lanes for this device
  		*
  		* tegra_sinterface = "";
  		* CSI Serial interface connected to tegra
  		* Incase of virtual HW devices, use virtual
  		* For SW emulated devices, use host
  		*
  		* pix_clk_hz = "";
  		* Sensor pixel clock used for calculations like exposure and framerate
  		*
  		* readout_orientation = "0";
  		* Based on camera module orientation.
  		* Only change readout_orientation if you specifically
  		* Program a different readout order for this mode
  		*
  		* == Image format Properties ==
  		*
  		* active_w = "";
  		* Pixel active region width
  		*
  		* active_h = "";
  		* Pixel active region height
  		*
  		* pixel_t = "";
  		* The sensor readout pixel pattern
  		*
  		* line_length = "";
  		* Pixel line length (width) for sensor mode.
  		*
  		* == Source Control Settings ==
  		*
  		* Gain factor used to convert fixed point integer to float
  		* Gain range [min_gain/gain_factor, max_gain/gain_factor]
  		* Gain step [step_gain/gain_factor is the smallest step that can be configured]
  		* Default gain [Default gain to be initialized for the control.
  		*     use min_gain_val as default for optimal results]
  		* Framerate factor used to convert fixed point integer to float
  		* Framerate range [min_framerate/framerate_factor, max_framerate/framerate_factor]
  		* Framerate step [step_framerate/framerate_factor is the smallest step that can be configured]
  		* Default Framerate [Default framerate to be initialized for the control.
  		*     use max_framerate to get required performance]
  		* Exposure factor used to convert fixed point integer to float
  		* For convenience use 1 sec = 1000000us as conversion factor
  		* Exposure range [min_exp_time/exposure_factor, max_exp_time/exposure_factor]
  		* Exposure step [step_exp_time/exposure_factor is the smallest step that can be configured]
  		* Default Exposure Time [Default exposure to be initialized for the control.
  		*     Set default exposure based on the default_framerate for optimal exposure settings]
  		*
  		* gain_factor = ""; (integer factor used for floating to fixed point conversion)
  		* min_gain_val = ""; (ceil to integer)
  		* max_gain_val = ""; (ceil to integer)
  		* step_gain_val = ""; (ceil to integer)
  		* default_gain = ""; (ceil to integer)
  		* Gain limits for mode
  		*
  		* exposure_factor = ""; (integer factor used for floating to fixed point conversion)
  		* min_exp_time = ""; (ceil to integer)
  		* max_exp_time = ""; (ceil to integer)
  		* step_exp_time = ""; (ceil to integer)
  		* default_exp_time = ""; (ceil to integer)
  		* Exposure Time limits for mode (sec)
  		*
  		* framerate_factor = ""; (integer factor used for floating to fixed point conversion)
  		* min_framerate = ""; (ceil to integer)
  		* max_framerate = ""; (ceil to integer)
  		* step_framerate = ""; (ceil to integer)
  		* default_framerate = ""; (ceil to integer)
  		* Framerate limits for mode (fps)
  		*
  		* embedded_metadata_height = "";
  		* Sensor embedded metadata height in units of rows.
  		* If sensor does not support embedded metadata value should be 0.
  		*/
  		mode0 { /* xc9080_MODE_2560x1280_30FPS */
  			mclk_khz = "24000";
  			num_lanes = "2";
  			tegra_sinterface = "serial_b";
  			phy_mode = "DPHY";
  			discontinuous_clk = "no";
  			dpcm_enable = "false";
  			cil_settletime = "0";

  			active_w = "1280";
  			active_h = "960";
  			/*mode_type = "bayer";
  			pixel_phase = "rggb";
  			csi_pixel_bit_depth = "8";*/
  			mode_type = "yuv";
                pixel_phase = "uyvy";
                csi_pixel_bit_depth = "16";

  			readout_orientation = "0";
  			line_length = "1280";
  			inherent_gain = "1";
  			mclk_multiplier = "9.33";
  			pix_clk_hz = "120000000";

  			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 = "30000000"; /* 2.0 fps */
  			max_framerate = "30000000"; /* 21.0 fps */
  			step_framerate = "1";
  			default_framerate = "30000000"; /* 21.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";
  		};

  		ports {
  			#address-cells = <1>;
  			#size-cells = <0>;
  			port@0 {
  				reg = <0>;
  				x01f10_out5: endpoint {
  					status = "okay";
  					port-index = <1>;
  					bus-width = <2>;
  					remote-endpoint = <&x01f10_csi_in5>;
  				};
  			};
  		};
  	};

hello 542270618,

instead of checking device tree, v4l2-ctl -d /dev/video0 --list-formats-ext it’s actually examine the driver side to report the formats.
I did see the same with YUV or USB cameras. I have not dig into this since it doesn’t affect the real camera use-case.

支持的格式如下
camera_common_frmfmt

};

endif

enum {

X01F10_MODE_1280x960_30FPS = 0,

};

static const int x01f10_30fps = {

30,

};

/*

  • WARNING: frmfmt ordering need to match mode definition in

  • device tree!

*/

static const struct camera_common_frmfmt x01f10_frmfmt = {

{{1280, 960}, x01f10_30fps, 1, 0, X01F10_MODE_1280x960_30FPS},

};

endif /*X01F10_I2C_TABLES */
x01f10_mode_tbls.h (215.2 KB)
nv_0X01F10.c (20.0 KB)

麻烦帮看下,谢谢!

We use this camera to push video stream in rtsp, and use test-lunch. When the client is closed and opened again, the server will automatically exit and check related logs, while the server is switching video mode, which leads to this problem

./test-launch “v4l2src device=/dev/video0 ! video/x-raw,format=UYVY,width=1280,height=960,framerate=30/1 ! nvvidconv ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96”

The client is opened for the first time
log:

stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 846000
NVMEDIA: Need to set EMC bandwidth : 846000
NVMEDIA_ENC: bBlitMode is set to TRUE

After the client is closed and then enabled
log:

0:00:26.972195004 4318 0xffff84046760 FIXME default gstutils.c:3980:gst_pad_create_stream_id_internal:appsrc1:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Opening in BLOCKING MODE
0:00:27.085960029 4318 0xffff84017de0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xffff44008a30 Failed to determine interlace mode
0:00:27.086098208 4318 0xffff84017de0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xffff44008a30 Failed to determine interlace mode
0:00:27.086182721 4318 0xffff84017de0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xffff44008a30 Failed to determine interlace mode
0:00:27.086263811 4318 0xffff84017de0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xffff44008a30 Failed to determine interlace mode
0:00:27.086474311 4318 0xffff84017de0 WARN v4l2 gstv4l2object.c:4481:gst_v4l2_object_probe_caps:nvv4l2h264enc1:src Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
Available Sensor modes :
Resolution: 1280 x 960 ; Framerate = 29.999999; Analog Gain Range Min 1.000000, Max 10.625000, Exposure Range Min 13000, Max 683709000

DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
0:00:27.397554128 4318 0xffff84017460 WARN v4l2 gstv4l2object.c:4209:gst_v4l2_object_probe_caps:v4l2src1:src Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
0:00:27.397590704 4318 0xffff84017de0 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query: Can’t give latency since framerate isn’t fixated !
0:00:27.397740627 4318 0xffff84017460 WARN v4l2 gstv4l2object.c:2448:gst_v4l2_object_probe_caps_for_format_and_size:v4l2src1:src no range added, leaving default
0:00:27.402908661 4318 0xffff84017de0 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query: Can’t give latency since framerate isn’t fixated !
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:27.409382991 4318 0xffff84017460 WARN v4l2bufferpool gstv4l2bufferpool.c:1082:gst_v4l2_buffer_pool_start:nvv4l2h264enc1:pool:src Uncertain or not enough buffers, enabling copy threshold
Not Implemented
Segmentation fault (core dumped)

It looks like the program is automatically switching modes

If you have the same problem, could you check the problem of test-lunch together

hello 542270618,

may I know where is this test-lunch came from?

moreover,
since you’ve device tree settings use_sensor_mode_id = "true";
please have a try as following to execute v4l pipeline for sensor mode selection.
for example,
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=0 --stream-mmap --stream-count=100

Hi Jerry.

 test-lunch is a tool in gst-rtsp-server.

 Is there a way for gstreamer to select a mode ? Thanks

Hi Jerry:

There is only one mode registered in my device tree, 1-4 modes is useless

uatair@uatair:~/gst-rtsp-server/examples$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=0 --stream-mmap --stream-count=100
The pixelformat ‘RG10’ is invalid
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<^C
uatair@uatair:~/gst-rtsp-server/examples$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=1 --stream-mmap --stream-count=100
The pixelformat ‘RG10’ is invalid
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<^C
uatair@uatair:~/gst-rtsp-server/examples$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=2 --stream-mmap --stream-count=100
The pixelformat ‘RG10’ is invalid
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<^C
uatair@uatair:~/gst-rtsp-server/examples$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=RG10 --set-ctrl bypass_mode=0 --set-ctrl sensor_mode=3 --stream-mmap --stream-count=100
The pixelformat ‘RG10’ is invalid
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps
<<<<<<<<<<<<<<<<<<<<<^C

hello 542270618,

what’s the issue here? that looks the stream works normally.

This is the link to gst-rtsp-server

Jerry

My final goal is to use gst-launch tool not to switch modes automatically, but to drive two more modes.

Cause me to use a client, such as vlc, when I quit the client, restart the client, the server will make an error

When the server passes setup complete.
./test-launch --gst-debug-level=0 “(v4l2src device=/dev/video0! videoconvert ! video/x-raw, format=(string)UYVY, width=1280, height=960, framerate=30/1 ! nvvidconv ! nvv4l2h264enc maxperf-enable=1 bitrate=8000000 ! h264parse ! rtph264pay name=pay0 pt=96)”

When the client is run for the first time, the video stream can be previewed normally.

**When you close the client and restart the client again, the preview fails, Looks like the program is trying to switch modes **

log :
Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
Available Sensor modes :
Resolution: 1280 x 960 ; Framerate = 29.999999; Analog Gain Range Min 1.000000, Max 10.625000, Exposure Range Min 13000, Max 683709000

DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
0:00:10.540004717 4187 0xaaaaef1b3a40 WARN v4l2 gstv4l2object.c:4209:gst_v4l2_object_probe_caps:v4l2src1:src Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
0:00:10.540107376 4187 0xaaaaef1b3a40 WARN v4l2 gstv4l2object.c:2448:gst_v4l2_object_probe_caps_for_format_and_size:v4l2src1:src no range added, leaving default
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:10.551742895 4187 0xaaaaef1b3a40 WARN v4l2bufferpool gstv4l2bufferpool.c:1082:gst_v4l2_buffer_pool_start:nvv4l2h264enc1:pool:src Uncertain or not enough buffers, enabling copy threshold
Not Implemented
Segmentation fault (core dumped)
uatair@uatair:~/gst-rtsp-server/examples$

The following is the normal log of opening the client:

uatair@uatair:~/gst-rtsp-server/examples$ ./test-launch --gst-debug-level=3 “( v4l2src device=/dev/video0 ! videoconvert ! vide o/x-raw, format=(string)UYVY, width=1280, height=960, framerate=30/1 ! nvvidconv ! nvv4l2h264enc maxperf-enable=1 bitrate=80000 00 ! h264parse ! rtph264pay name=pay0 pt=96 )”

stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
0:00:03.433425116 4187 0xffffb4003760 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fffb418f5b0 Failed to determine interlace mode
0:00:03.433599939 4187 0xffffb4003760 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fffb418f5b0 Failed to determine interlace mode
0:00:03.433709703 4187 0xffffb4003760 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fffb418f5b0 Failed to determine interlace mode
0:00:03.433816010 4187 0xffffb4003760 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fffb418f5b0 Failed to determine interlace mode
0:00:03.434008625 4187 0xffffb4003760 WARN v4l2 gstv4l2object.c:4481:gst_v4l2_object_probe_caps: Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:03.449778859 4187 0xffff8800ec60 WARN v4l2bufferpool gstv4l2bufferpool.c:1082:gst_v4l2_buffer_pool_start: Uncertain or not enough buffers, enabling copy threshold
0:00:03.456765383 4187 0xffff8800ec60 WARN v4l2bufferpool gstv4l2bufferpool.c:809:gst_v4l2_buffer_pool_start:<v4l2src 0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:03.546972288 4187 0xffff8800ec60 WARN v4l2src gstv4l2src.c:914:gst_v4l2src_create: Timestamp do es not correlate with any clock, ignoring driver timestamps
H264: Profile = 66, Level = 0
0:00:03.576142141 4187 0xffff8800ec60 WARN bufferpool gstbufferpool.c:1235:default_reset_buffer:<nvv4l2h264enc0:p ool:sink> Buffer 0xffff8c0fea20 without the memory tag has maxsize (192) that is smaller than the configured buffer pool size ( 1843200). The buffer will be not be reused. This is most likely a bug in this GstBufferPool subclass
NVMEDIA: Need to set EMC bandwidth : 846000
NVMEDIA: Need to set EMC bandwidth : 846000
NVMEDIA_ENC: bBlitMode is set to TRUE

The following is an abnormal log when the client is opened:

Opening in BLOCKING MODE
0:00:10.249738147 4187 0xffff640061e0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fff6400b5e0 Failed to determine interlace mode
0:00:10.249873832 4187 0xffff640061e0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fff6400b5e0 Failed to determine interlace mode
0:00:10.249957259 4187 0xffff640061e0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fff6400b5e0 Failed to determine interlace mode
0:00:10.250035981 4187 0xffff640061e0 WARN v4l2 gstv4l2object.c:2395:gst_v4l2_object_add_interlace_mode:0xf fff6400b5e0 Failed to determine interlace mode
0:00:10.250239125 4187 0xffff640061e0 WARN v4l2 gstv4l2object.c:4481:gst_v4l2_object_probe_caps: Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
Available Sensor modes :
Resolution: 1280 x 960 ; Framerate = 29.999999; Analog Gain Range Min 1.000000, Max 10.625000, Exposure Range Min 13000, Max 68 3709000

DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
DEFAULT no IOCTL called
0:00:10.540004717 4187 0xaaaaef1b3a40 WARN v4l2 gstv4l2object.c:4209:gst_v4l2_object_probe_caps:<v4l2src1:s rc> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument
0:00:10.540107376 4187 0xaaaaef1b3a40 WARN v4l2 gstv4l2object.c:2448:gst_v4l2_object_probe_caps_for_format_ and_size:v4l2src1:src no range added, leaving default
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:10.551742895 4187 0xaaaaef1b3a40 WARN v4l2bufferpool gstv4l2bufferpool.c:1082:gst_v4l2_buffer_pool_start: Uncertain or not enough buffers, enabling copy threshold
Not Implemented
Segmentation fault (core dumped)

quick question, would you like to stick with JP-5.0.2? since JP-5.0.2 isn’t quick stable for camera functionality.

Are you sure it’s related to the SDK version? It will be upgraded to JP5.1.1 later

Jerry

你好!

   我目前升级到JP5.1.1也有同样的问题,麻烦帮看下,谢谢!

hello 542270618,

FYI,
we’ve RTSP test case on JP-5.1.1 and it was passed.
could you please check with videotestsrc to narrow down the issue?
for example,
Sender
$ ./test-launch "videotestsrc is-live=1 ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 idrinterval=30 ! h264parse ! rtph264pay name=pay0
Receiver
$ python3 gstreamer_rtsp.py

Hi:

Jerry!

 ./test-launch "videotestsrc is-live=1 ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 idrinterval=30 ! h264parse ! rtph264pay name=pay0


 No such problem!