Camera driver only working when 3 camera instances are defined. Using 1 or 2 cameras causes the Tegra-capture-vi to throw errors

Hi

I have been developing the Linux kernel drivers for a LVDS signal, from a block camera, to MIPI/DPHY adapter. The MIPI/DPHY uses the 15 pin ribbon cable (with 2 DPHY bus lanes) in order to connect it to either a Raspberry Pi or a Jetson Orin AGX (via Auvidea J20 carrier board). Using Ridgerun’s example of the J20 to get the imx477 RPi camera, as starting point

I’ve developed our own sensor driver following the docs

In order to get our solution working I HAVE to define three separate camera instances. Namely

port-index = 0 : vi(0) → nvcsi ch0 → ap23_a@18 (on i2c@31e0000)
port-index = 2 : vi(1) → nvcsi ch1 → ap23_c@18 (on i2c@3180000)
port-index = 4 : vi(2) → nvcsi ch2 → ap23_e@18 (on i2c@c240000)

i.e. There are 3 instances of my ap23 device driver for (ap23_a, ap23_c and ap23_e). When setup like this I am able to correctly aquire the camera video and the tegra-capture-vi is not throwing an error on nearly every frame. Namely it works for each of the defined cameras.

However when I define only one camera instance via my device tree overlay the video capture no longer works with tegra-capture-vi driver throwing error nearly every frame.

[   37.495178] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 5, flags: 0, err_data 512
[   37.529743] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 6, flags: 0, err_data 512
[   37.565070] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 7, flags: 0, err_data 512
[   37.598482] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 8, flags: 0, err_data 512
[   37.695119] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 3, flags: 0, err_data 512
[   37.728830] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 4, flags: 0, err_data 512

Then again when I define two camera instances in my device tree overlay the video capture is slightly better but the tegra-capture-vi driver is throwing an error nearly every frame. It is ONLY when I have THREE camera instances defined that my video capture is working and I can’t for life figure out why?

Now I was originally using JetPack 5.1.1 but have upgraded to JetPack 6. Also I have applied the fix such that I can capture the output as PNG without the image problem. To help diagnose this problem I have created the following output with vi kernel tracing turned on.

Now with 1 camera defined in my device tree
tegra234-p3737-camera-ap23-02-overlay.dts.txt (4.4 KB)

The following shows the image captured from J1_1 port which is attached to CSI-A/0 (port-index = 0).

Here the vi is capturing 2 horizontal lines per actual horizontal line. Note that the test pattern repeats itself on the left and right. It never seems to capture more than a quarter of the final image.

Thanks for any help that can be provided in helping me try and figure this out.

Stuart MacLean

P.S. I would like to have added the logs of the kernel and trace. Plus the images from the 3 camera instance capture which works and the 2 camera instance which doesn’t work. But due to forum rules it doesn’t allow me add this metadata.

The kernel log for where 1 camera instance is defined

j1_1_1inst_kernel.txt (96.2 KB)

The trace log from /sys/kernel/debug/tracing/trace for 1 camera is

j1_1_1inst_trace.txt (5.1 MB)

In the case of the 2 camera instance the device tree overlay is

tegra234-p3737-camera-ap23-02-overlay.dts.txt (6.7 KB)

In this case the captured image looks like

Unlike the vi capture from the 1 camera instance. Here in the 2 camera instance the full horizontal line data is almost complete. It never seems to capture more than half of the final image.

Sorry for the multiple posts… but I want to try and present all the evidence I collected.

The kernel log for the 2 camera instance is

j1_2_2inst_kernel.txt (126.9 KB)

Along with the associated trace log from /sys/kernel/debug/tracing/trace

j1_2_2inst_trace.txt (8.0 MB)

Finally there is the 3 camera instance device tree.

tegra234-p3737-camera-ap23-02-overlay.dts.txt (8.9 KB)
tegra234-p3737-camera-ap23-modes.dtsi.txt (2.6 KB)

This version of the device tree gives me a working camera. I’ve included the defined modes from which you can see we are using a YUV-4:2:2 camera.

The image capture as you can see works showing the full test pattern

Note the image were captured using gstreamer and the v4l2src via the command

gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoconvert ! pngenc ! filesink location=testpattern.png

The kernel logs for the working 3 camera instance

j1_2_3inst_kernel.txt (92.7 KB)

and the associated trace

j1_2_3inst_trace.txt (220.3 KB)

Again thank you for any help that can be provided in helping me resolve this problem.

All the best,

Stuart

As an update, I tried boosting the clocks as described

With a single camera instance as defined in the device tree

tegra234-p3737-camera-ap23-02-overlay.dts.txt (4.7 KB)
tegra234-p3737-camera-ap23-modes.dtsi.txt (2.6 KB)

With the clocks boosted I am now actually getting a continuous working video feed from the camera on a device tree with only 1 camera instance defined. The pixel clock calculations for the 1080p30 mode is

1080p30 is 2200 x 1125 x 30 = 74250000Hz

and 720p60

720p60 is 1650 x 750 x 60 = 74250000Hz

Hence
pix_clk_hz = “74250000”;

Stuart

Adjust the pix_clk_hz to acquire match bandwidth if boost the clock help on it.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.