Failed to Port sensor driver from jetPack3.3 to jetPack4.2

Hi:
We have a custom designed board(tx2),everything is ok at jetPack3.3 .

After a lot of work,we ported sensor driver from jetPack3.3 to jetPack4.2。

But we meet a problem,just like this man:

[url]https://devtalk.nvidia.com/default/topic/1055536/jetson-tx2/jetpack-4-2-camera-bringup-issue/[/url]

I am really sure the code of sensor driver is ok,because if I do this:
“echo 1 | sudo tee /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked > /dev/null”

I can get the picture from video0 successfully.

I tried to disable ECC,useless.

I read some code about vi,nvcsi,v4l2.

So,may be the configuration about sensor at DT is wrong ?
can you just check the dts for me ?

The pipeline about csi input is:

ar0134(parallel)—>DS92LV16TVHG(serial)---->DS92LV16TVHG(deserial,parallel)---->FPGA(parallel)----->tc358748---->csi

There are 4 pipeline in the board,it means: 4 ar0134,4 tc358748.

The pix_clock of ar0134 is 60Mhz.

The output of tc358748 is:

2 lane
csi lane speed : 387.5 Mbps/lane
HS Byte clock: 48.4375 Mhz
Data format: Grey, 8Bits

dt.xvf.tar (40 KB)

The output frame size of ar0134 is : 1482861
The active area of frame is: 1280
800

hello XuXiang,

  1. could you please run below commands and share the results.
$ v4l2-ctl -d /dev/video0 --list-formats-ext
  1. could you please have a quick try to modify the 10-bit YUV,
  2. you may also enable VI tracing logs and share the analysis results.
  3. please also check similar topic, Topic 1055176 for reference.
    thanks

After do “v4l2-ctl -d /dev/video0 --list-formats-ext”,the output is:

ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'GREY'
	Name        : 8-bit Greyscale
		Size: Discrete 1280x800
			Interval: Discrete 0.021s (47.000 fps)

After do “v4l2-compliance -a”,the output is:

v4l2-compliance SHA   : not available

Driver Info:
	Driver name   : tegra-video
	Card type     : vi-output, ar0134a 2-0010
	Bus info      : platform:15700000.vi:0
	Driver version: 4.9.140
	Capabilities  : 0x84200001
		Video Capture
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps   : 0x04200001
		Video Capture
		Streaming
		Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
	test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
	test second video open: OK
	test VIDIOC_QUERYCAP: OK
	test VIDIOC_G/S_PRIORITY: OK
	test for unlimited opens: OK

Debug ioctls:
	test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
	test VIDIOC_LOG_STATUS: OK

Input ioctls:
	test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
	test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
	test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
	test VIDIOC_ENUMAUDIO: OK (Not Supported)
	test VIDIOC_G/S/ENUMINPUT: OK
	test VIDIOC_G/S_AUDIO: OK (Not Supported)
	Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
	test VIDIOC_G/S_MODULATOR: OK (Not Supported)
	test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
	test VIDIOC_ENUMAUDOUT: OK (Not Supported)
	test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
	test VIDIOC_G/S_AUDOUT: OK (Not Supported)
	Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
	test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
	test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
	test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
	test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

	Control ioctls:
		warn: v4l2-test-controls.cpp(90): Gain: (max - min) % step != 0
		warn: v4l2-test-controls.cpp(90): Exposure: (max - min) % step != 0
		test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
		test VIDIOC_QUERYCTRL: OK
		test VIDIOC_G/S_CTRL: OK
		test VIDIOC_G/S/TRY_EXT_CTRLS: OK
		test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
		test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
		Standard Controls: 1 Private Controls: 18

	Format ioctls:
		test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
		fail: v4l2-test-formats.cpp(1184): ret && node->has_frmintervals
		test VIDIOC_G/S_PARM: FAIL
		test VIDIOC_G_FBUF: OK (Not Supported)
		test VIDIOC_G_FMT: OK
		test VIDIOC_TRY_FMT: OK
		test VIDIOC_S_FMT: OK
		test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
		test Cropping: OK (Not Supported)
		test Composing: OK (Not Supported)
		fail: v4l2-test-formats.cpp(1630): node->can_scale && node->frmsizes_count[v4l_format_g_pixelformat(&cur)]
		test Scaling: OK

	Codec ioctls:
		test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
		test VIDIOC_G_ENC_INDEX: OK (Not Supported)
		test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

	Buffer ioctls:
		test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
		test VIDIOC_EXPBUF: OK

Test input 0:

Total: 43, Succeeded: 42, Failed: 1, Warnings: 2

First:

echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 2 > /sys/kernel/debug/camrtc/log-level
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace

Second,do this:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=800,pixelformat=GREY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1

The “v4l2-ctl -d …” can’t finish itself,I need use “Ctrl+C” to kill it.

And the log is:

vi_trace.txt (278 KB)

hello XuXiang,

  1. since you’d verified sensor streaming with JetPack-3.3, I believe you had already done the kernel driver implementation to extend default support formats.

  2. according to below tracing report.

CHANSEL_FAULT channel:0x00 frame:0 vi_tstamp:3241330403 data:0x00010200

it shows you got PIXEL_SHORT_LINE failures, which means the horizontal active pixels is less than expected.
please have a try to increase the active_w in your sensor device tree for testing,
BTW, please also check similar issue, Topic 1055616 for reference.
thanks

Yes,the left of picture is a black block,the width of it is 14 pixel.

I didn’t notice it before,and I test it at jetPack3.3,also has this black block.It seems jetPack4.2 more strict than jetPack3.3 .

file8.bmp (1000 KB)

I should decrease the active_w,NOT increase active_w ???

The value of active_w is 1280,I should set it to 1267,1266,1268 to test ???

some one may be need it.

I doubled the pix_clk_hz,and can get the picture now.
It seems nvidia modified the formula for pix_clk_hz.

In jetPack3.3,I used the formula : pixel_clk_hz = sensor output size * frame rate

In jetPack4.2,I used the formula :
pixel_clk_hz = sensor data rate per lane (Mbps) * number of lanes / bits per pixel

the output of tc358748xbg is: 1280*800@47.03fps sensor data rate per lane:387.5Mbps/lane 2lane

So,In jetPack3.3, the pix_clk_hz = 128080047.03 = 48158720 hz
In jetPack4.2, the pix_clk_hz = (387.5*2)/8 = 96000000 hz