MIPI clock parameters settings for camera device

hello nikhil.karale,

you may also check the Camera Architecture Stack, [Camera Core] will handle the processing when you configure bypass mode.
here’s sample command to configure bypass mode settings.

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=2592,height=1944,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=100

actually, if you running with nvarguscamerasrc, it’ll skip the VI kernel driver and process the camera buffer with [Camera Core]
for example,

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

Hello JerryChang,

I tried the v4l2-ctl command using bypass mode, but the behaviour is same (getting same error as per comment #13).

Is it possible to modify tegra camera framework so that it will not consider the sync pulse on MIPI clock…? and fill the buffer with data available on MIPI bus.

Is there any way to do so…?

hello nikhil.karale,

sync pulse is for DSI. the pulse you saw on the oscilloscope is the blank frame at the end of each frame.

please check below two suggestions,

  1. please update your sensor device tree mclk setting to 45Mhz for your external clock source.
mode0 { /* AD903X_MODE_640x960_30FPS */
...
mclk_khz = "45000";
  1. you’re actually getting frames, but there are some short frame error reporting as below.
    please double confirm you had configure correct frame width/height in device tree.
[14404.221042] video4linux video0: TEGRA_VI_CSI_ERROR_STATUS 0x00000004
[14404.228122] vi 54080000.vi: TEGRA_CSI_PIXEL_PARSER_STATUS 0x00000180

Hi Jerry,

We are working on your inputs.

Thanks for the help.

Hi Jerry,

Thanks for all the support.

We were able to get video data after changing the virtual channel configuration in camera sensor.
Previous configuration had two virtual channels, which was probably causing the issue. Extra Start frame error we were getting earlier was likely due to the 2 virtual channels enabled as sensor was sending MIPI output with 2 Start frames.

With the new configuration of Sensor, we have one virtual channel and driver/framework no longer reports error. Further we also get correct data in the v4l2 buffers, most of the time.

We now see that 3 out of 4 frames received from V4L2 are having all zeroes, and 1 frame has correct data. We do not see any errors reported in dmesg log.

What could be the reason of getting some of the frames with all zeros…?

hello nikhil.karale,

glad to know you got your senor streaming.
couple of suggest as below for your testing.

  1. could you please check comment #21, are you able to preview camera streaming correctly with nvarguscamerasrc.
  2. could you please disable sensor 3A settings, had a try to configure coarse_time, frame_length, line_length by sensor’s default settings.
    thanks

Hi Jerry,

  1. I can not stream the camera using nvarguscamerasrc as it is custom camera sensor.
    I am using the v4l2-ctl command to test the camera output.

terminal log -

jetson@jetson:~$ v4l2-ctl -d /dev/video0 -w --verbose --set-fmt-video=width=672,height=750,pixelformat=RG12 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=3 --stream-to=data.raw
Opening in BLOCKING MODE 
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
	Width/Height      : 672/750
	Pixel Format      : 'RG12'
	Field             : None
	Bytes per Line    : 1344
	Size Image        : 1008000
	Colorspace        : sRGB
	Transfer Function : Default (maps to sRGB)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Full Range)
	Flags             : 
VIDIOC_REQBUFS: ok
VIDIOC_QUERYBUF: ok
VIDIOC_QBUF: ok
VIDIOC_QUERYBUF: ok
VIDIOC_QBUF: ok
VIDIOC_QUERYBUF: ok
VIDIOC_QBUF: ok
VIDIOC_QUERYBUF: ok
VIDIOC_QBUF: ok
VIDIOC_STREAMON: ok
	Index    : 0
	Type     : Video Capture
	Flags    : mapped
	Field    : None
	Sequence : 0
	Length   : 1008000
	Bytesused: 1008000
	Timestamp: 0.000000s (Monotonic, End-of-Frame)

	Index    : 1
	Type     : Video Capture
	Flags    : mapped
	Field    : None
	Sequence : 1
	Length   : 1008000
	Bytesused: 1008000
	Timestamp: 0.000000s (Monotonic, End-of-Frame)

	Index    : 2
	Type     : Video Capture
	Flags    : mapped
	Field    : None
	Sequence : 2
	Length   : 1008000
	Bytesused: 1008000
	Timestamp: 0.000000s (Monotonic, End-of-Frame)

VIDIOC_STREAMOFF: ok

dmesg log:-

jetson@jetson:~$ dmesg
[ 1755.665426] camxxx 6-0064: Program AFE
[ 1755.665433] camxxx 6-0064: camxxx_programAfe
[ 1756.377429] camxxx 6-0064: camxxx_programAfe completed
[ 1756.377438] camxxx 6-0064: s_stream 1
[ 1756.377447] vi 54080000.vi: Calibrate csi port 0
[ 1756.377600] camxxx 6-0064: s_stream 0
[ 1756.435491] camxxx 6-0064: camxxx set_format 0 0 
[ 1756.435496] camxxx 6-0064: call camera_common_try_fmt
[ 1756.435505] camxxx 6-0064: camera_common_try_fmt: size 672 x 750
[ 1756.435510] camxxx 6-0064: camera_common_try_fmt: use_sensor_mode_id 0
[ 1756.435522] camxxx 6-0064: camxxx set_format 0 0 
[ 1756.435525] camxxx 6-0064: call camera_common_try_fmt
[ 1756.435529] camxxx 6-0064: camera_common_try_fmt: size 672 x 750
[ 1756.435532] camxxx 6-0064: camera_common_try_fmt: use_sensor_mode_id 0
[ 1756.435535] camxxx 6-0064: camxxx set_format 1 0 
[ 1756.435538] camxxx 6-0064: call camera_common_s_fmt
[ 1756.435543] camxxx 6-0064: camera_common_s_fmt(12306) size 672 x 750
[ 1756.435547] camxxx 6-0064: camera_common_try_fmt: size 672 x 750
[ 1756.435558] camxxx 6-0064: camera_common_try_fmt: use_sensor_mode_id 0
[ 1765.894428] vi 54080000.vi: cil_settingtime is pulled from device
[ 1765.894432] vi 54080000.vi: cil_settingtime was autocalculated
[ 1765.894437] vi 54080000.vi: csi clock settle time: 13, cil settle time: 10
[ 1765.894446] camxxx 6-0064: Program AFE
[ 1765.894452] camxxx 6-0064: camxxx_programAfe
[ 1766.513523] camxxx 6-0064: camxxx_programAfe completed
[ 1766.513529] camxxx 6-0064: s_stream 1
[ 1766.694264] video4linux video0: Syncpoint already enabled at capture done!0
[ 1766.895289] video4linux video0: tegra_channel_capture_done: MW_ACK_DONE syncpoint time out!0
[ 1766.904619] video4linux video0: TEGRA_VI_CSI_ERROR_STATUS 0x00000001
[ 1766.904655] vi 54080000.vi: TEGRA_CSI_PIXEL_PARSER_STATUS 0x00000000
[ 1766.904675] vi 54080000.vi: TEGRA_CSI_CIL_STATUS 0x00000000
[ 1766.904693] vi 54080000.vi: TEGRA_CSI_CILX_STATUS 0x00000000
[ 1766.904892] vi 54080000.vi: cil_settingtime is pulled from device
[ 1766.904916] vi 54080000.vi: cil_settingtime was autocalculated
[ 1766.904941] vi 54080000.vi: csi clock settle time: 13, cil settle time: 10
[ 1766.905023] camxxx 6-0064: s_stream 0
  1. Could you please elaborate on suggestion 2. what are the sensor 3A settings…? Also how to set coarse_time and frame_length parameters in device tree

hello nikhil.karale,

  1. here’s line width failure from the kernel log, you should update device tree to correct it.
    please also access [Tegra X1 (SoC) Technical Reference Manual] from Jetson Download Center, and you could check the session [31.2.6.1 VI Error Status and Interrupts] for the TEGRA_VI_CSI_ERROR_STATUS reporting.

  2. sensor 3A settings were execute in the sensor kernel driver, you may check CID controls to have more details.
    for example,

TEGRA_CAMERA_CID_GAIN,
TEGRA_CAMERA_CID_EXPOSURE,
TEGRA_CAMERA_CID_FRAME_RATE,

Hi Jerry,

We able to resolve the issue of blank frames (all zero data).
We were getting line width error as sensor was sending extra data of 4 pixel data,
After re-configuring the sensor, we are getting valid frame data.

Thanks for all your support.