I am trying to connect Jetson Nano to a custom board with ADV7482 chip using CSI-2 connectors and capture video. However, there is no driver available for ADV7482 in linux kernel 4.9.
I tried the following 3 approaches, without any success. It should be noted that in the custom board, ADV7482 is clocked and configured externally and there is no need to read or write any configuration from I2C. Therefore, in these approaches I ignored reads and writes from I2C. Here are the approaches:
From kernel 4.14 the driver of this chip is added to the kernel sources. However it cannot be compiled on kernel 4.9 due to the V4l2 API changes mainly because of using fwnode in some parts. I commented the part that made compile errors. Now the code is compiled but /dev/video0 or any other similar device is not created. I tried both static and dynamic module modes because it’s noted in this post that dynamic modules my not work.
Source Files: adv748x-hdmi.c (20.4 KB) (no changes) adv748x-afe.c (13.3 KB) (no changes) adv748x-csi2.c (8.3 KB) (commented line 293) adv748x-core.c (24.5 KB) (ignoring reads and writes and hdmi and afe and txa) adv748x.h.txt (13.1 KB)
Device Tree: tegra210-adv7482.dtsi.txt (5.7 KB)
There is an older driver which is mentioned in this post from Renesas Electronics. This driver is for kernel 3.x and again can’t be compiled . Again some parts commented out and similarly /dev/video0 is not created nor statically nor dynamically.
Source: adv7482.c (76.0 KB)
Device Tree: tegra210-adv7482.dtsi.txt (4.9 KB)
I tried to change the IMX219 sensor driver as in our scenario there is no need for configurations and only capturing the video is needed. So Again I ignored the parts writing to registers and instead of reads, passed the values manually where it was needed. This time /dev/video0 is created but capturing using v4l2-ctrl results in the following error in kernel : tegra_channel_error_status:error 4000
Source: imx219.c (23.4 KB)
Device Tree: tegra210-camera-rbpcv2-dual-imx219.dtsi.txt (23.4 KB)
And here is the ADV7482 output video configuration :
Also for the first approach I compared struct v4l2_subdev code between the two kernel versions (4.9 v.s. 4.14), and found that it seems reasonable to change line 293 of adv748x-csi2.c from
tx->sd.fwnode = of_fwnode_handle(ep);
to
tx->sd.of_node = tx->sd.dev->of_node;
so the code will be compiled without any errors on kernel 4.9. However, still /dev/video0 is not created.
Also need to check the driver message why failed register the video node.
No errors. Albeit as I mentioned in the first post I have changed the code to ignore the writes and passed some constant values manually instead of reads.
Do you think the device tree is correct? And can the driver of TC358840 module be useful?
After almost a long time, we had some hardware changes and I had some progress on using ADV7482 driver from kernel 4.14. The most important change is that now ADV7482 is not configured externally and therefore, read and writes need to be done through I2C. Here are what I have done so far:
There are some small changes in the source codes. As mentioned earlier we need to do the following to compile the sources:
Next is setting ADV748X_PORT_TXA = 0 and ADV748X_PORT_TXB = 1 in adv748x.h to match with port numbers in the device tree.
I also ignored initializing TXB (second CSI output) in probe() function because we don’t use it.
I created a device tree based on the device tree of imx219 single mode and the device tree provided in this post.
Here are the sources and the device tree after all the changes. Source files includes a huge amount of print messages.
For the device tree we need to include it in Linux_for_Tegra/source/src_out/kernel_src_build/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-p3448-common.dtsi
and also remove imx219 related dtsi files by commenting the following lines:
Now after all these changes I am able to compile the driver and use it as a loadable module. After insmod, /dev/video0 device is created without any errors and problems in reads and writes. However, I am still not able to capture any frame using v4l-ctl tool with the following command:
jetson@jetson-nano:~$ v4l2-ctl -d /dev/video0 -w --verbose --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1000
Opening in BLOCKING MODE
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
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
Output of media-ctl command:
jetson@jetson-nano:~$ media-ctl -p -d /dev/media0
Media controller API version 0.1.0
Media device information
------------------------
driver vi
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 0.0.0
Device topology
- entity 1: adv748x 6-0070 txa (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:unknown/0x0]
-> "vi-output, adv748x 6-0070 txa":0 [ENABLED]
<- "adv748x 6-0070 hdmi":1 [ENABLED,IMMUTABLE]
pad1: Source
[fmt:unknown/0x0]
- entity 4: adv748x 6-0070 hdmi (2 pads, 1 link)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[dv.caps:BT.656/1120 min:640x480@13000000 max:1920x1200@162000000 stds:CEA-861,DMT caps:progressive]
pad1: Source
[fmt:RGB888_1X24/1280x720 field:none colorspace:srgb]
[dv.caps:BT.656/1120 min:640x480@13000000 max:1920x1200@162000000 stds:CEA-861,DMT caps:progressive]
[dv.query:no-link]
[dv.current:BT.656/1120 1280x720p30 (3300x750) stds:CEA-861 flags:can-reduce-fps,CE-video]
-> "adv748x 6-0070 txa":0 [ENABLED,IMMUTABLE]
- entity 9: vi-output, adv748x 6-0070 txa (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "adv748x 6-0070 txa":0 [ENABLED]
If we see the output graphically it’s a bit strange actually:
Output of v4l2-compliance:
jetson@jetson-nano:~$ v4l2-compliance -d /dev/video0
v4l2-compliance SHA : not available
Driver Info:
Driver name : tegra-video
Card type : vi-output, adv748x 6-0070 txa
Bus info : platform:54080000.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:
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: 3 Private Controls: 12
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
fail: v4l2-test-formats.cpp(330): !colorspace
fail: v4l2-test-formats.cpp(439): testColorspace(pix.pixelformat, pix.colorspace, pix.ycbcr_enc, pix.quantization)
test VIDIOC_G_FMT: FAIL
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
fail: v4l2-test-formats.cpp(1550): doioctl(node, VIDIOC_S_FMT, &fmt)
fail: v4l2-test-formats.cpp(1647): doioctl(node, VIDIOC_S_FMT, &fmt)
test Scaling: FAIL
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
fail: v4l2-test-buffers.cpp(574): VIDIOC_EXPBUF is supported, but the V4L2_MEMORY_MMAP support is missing, probably due to earlier failing format tests.
test VIDIOC_EXPBUF: OK (Not Supported)
Test input 0:
Total: 43, Succeeded: 41, Failed: 2, Warnings: 0
Output of dmesg after calling insmod containing my added messages:
A strange thing is that when calling v4l2-ctl no messages is added to dmesg. I check the power signal of TXA and it was down. Unexpectedly no where in the driver code I could find any call to power up TXA. I added a line at the end of proble() to power up the TXA. Then the power signal was up and I could see the data signal of TXA using oscilloscope. However, again was not able to capture any frame. And then I had no idea to progress more!
@ShaneCCC , Do you have any idea to overcome this problem?
I didn’t use nvcsi because in the device tree provided in this post it was not used. If I use nvcsi as in the device tree of imx219 I get the following error after insmod:
However, in the .dtsi file provided in the thread that I mentioned above this block does not exists. If I don’t use this block in my .dtsi file for ADV7482, insmod works without any problem but no frame can be captured as I explained before. If I create a .dtsi similar to the tegra210-camera-rbpcv2-imx219.dtsiwith the nvcsi block, insmod results in segmentation fault with the provided error in the previous posts.
I think the nvcsi should be the must have part for the camera capture.
For the kernel crash it could be the driver issue. You may reference to the tc358840 to implement the HDMI in device. tegra210-camera-imx274-hdmi.dtsi