Jetson Xavier NX: CSI Camera Streaming Problem

Hi, I am trying to capture frames from a CSI camera on Jetson Xavier NX (32.4.4). The driver is able to recognise the camera and /dev/video0 is created.

However when I try to capture frames or view the camera stream, I get the following errors on dmesg.

[22037.075692] tegra194-vi5 15c10000.vi: vi_capture_setup: control failed, errno 1
[22037.075938] tegra194-vi5 15c10000.vi: vi capture setup failed
[22459.840699] tegra194-vi5 15c10000.vi: vi_capture_setup: control failed, errno 1
[22459.841098] tegra194-vi5 15c10000.vi: vi capture setup failed

I looked up errno 1, and it seems to be CAPTURE_ERROR_INVALID_PARAMETER error.

I get a similar error when I do cat /dev/video0 for instance

cat: /dev/video0: Invalid argument

or when I try to stream using v4l2-ctl I get

VIDIOC_STREAMON: failed: Invalid argument

My questions are:

  1. What is meant by invalid argument/parameter? Is it something that I have specified wrongly on the device tree for instance?
  2. How can I find out which argument/parameter is invalid? Is there a way to get more information from the logs?

I am attaching the trace log as well as full dmesg log (sensor is ov2311).
nx-dmesg-cam1.txt (62.6 KB)
tracelog.txt (59.5 KB)

P.S There is no issue with the camera hardware as it works fine on a jetson nano.

hello kunalshrivastava.iitr,

here’re related error messages reported.

[   10.679213] ov2311 10-004a: ov2311_probe[3519]:GPIO reset Fail, err:0
[   10.679433] ov2311: probe of 10-004a failed with error -22
[   10.679585] RESET = fffffdfb 
[   10.679592] ar0234 9-0042: Unable to toggle RESET GPIO
[   10.679714] ar0234: probe of 9-0042 failed with error -22
[   10.679805] RESET = fffffdfb 
[   10.679810] ar0234 10-0042: Unable to toggle RESET GPIO
[   10.679960] ar0234: probe of 10-0042 failed with error -22

please review your device tree definition, you should check whether you’re using GPIO control correctly.
you may also check Sensor Software Driver Programming to review your driver implementation,
thanks

Hi @JerryChang those messages are because ov2311 is actually connected to 09-004a and ar0234 is not connected at all. If you look again you will find the following messages.

[   10.511840]  ISP Already Initialized !! 
[   10.634638]  mcu_cam_stream_off 2773MCU Stream Off Success !! 
[   10.671741]  Menu Element 0 : Full FOV Auto Mode 
[   10.671749]  Menu Element 1 : Manual Mode 
[   10.671761] 0. Initialized Custom Ctrl 0x009a0901 - Exposure, Auto 
[   10.671768] 1. Initialized Control 0x009a0902 - Exposure Time, Absolute 
[   10.671794] 2. Initialized Control 0x00980913 - Gain 
[   10.677521] 3. Initialized Custom Ctrl 0x009a0930 - Brightness 
[   10.677578] 4. Initialized Custom Ctrl 0x009a0932 - Set calibration data 
[   10.677609] 5. Initialized Custom Ctrl 0x009a0931 - Get calibration data 
[   10.677614] 6. Initialized Custom Ctrl 0x009a0933 - Verify calibration data 
[   10.677618] 7. Initialized Custom Ctrl 0x009a0934 - Tara Present 
[   10.677622] 8. Initialized Custom Ctrl 0x009a0935 - Tara password 
[   10.677628] 9. Initialized Custom Ctrl 0x009a0936 - Tara Unique ID 
[   10.677634] 10. Initialized Custom Ctrl 0x009a0937 - Tara Get FW version 
[   10.677644] tegra194-vi5 15c10000.vi: subdev ov2311 9-004a bound
[   10.679003] ov2311 9-004a: Detected OV2311 Sensor 

Here is the output of v4l2-compliance:

v4l2-compliance SHA   : not available

Driver Info:
	Driver name   : tegra-video
	Card type     : vi-output, ov2311 9-004a
	Bus info      : platform:15c10000.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: 13 Private Controls: 12

	Format ioctls:
		test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
		test VIDIOC_G/S_PARM: OK
		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)
		test Scaling: OK (Not Supported)

	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: 43, Failed: 0, Warnings: 0

As I mentioned the camera is getting detected and /dev/video0 is being created. I can even use v4l2 to change exposure and gain for instance. The only issue I am facing is that I cant stream any images.

There must be some issue with the driver, but I dont know where to look until I understand what “Invalid argument/parameter” actually means. Could you point me to the right direction?

hello kunalshrivastava.iitr,

may I know what’s your pipeline to enable camera streaming?
could you please check Approaches for Validating and Testing the V4L2 Driver for some samples to access the camera stream.

besides, your port binding and the sensor registration were corrects to enable v4l controls.
the properties of tegra-camera-platform{} were used by top-level drivers, please check the reference driver and examine those settings.
for example,

	tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
 		modules {
			module0 {
				...

Hi @JerryChang ,

Thanks for your response.

I have tried using V4l2 directly. Here is the output.

v4l2-ctl --set-fmt-video=width=3200,height=1300,pixelformat=GREY --stream-mmap --stream-count=1 -d /dev/video0 --stream-to=ov2311.raw
VIDIOC_STREAMON: failed: Invalid argument

Also examined tegra-camera-platform properties and they seemed ok. I am attaching my device tree here. Maybe you can spot some error?

tegra194-camera-jakku-ov2311.dtsi (16.9 KB)

hello kunalshrivastava.iitr,

please check v4l to report sensor formats, i.e. $ v4l2-ctl --list-formats
could you please also check you have pixelformat=GREY implemented in the low level driver side.
for example,
$L4T_Sources/r32.6.1/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/platform/tegra/camera/vi/camera_common.c

static const struct camera_common_colorfmt camera_common_color_fmts[] = {...}

please also check related topic as see-also, Topic 63277.
thanks

Hi @JerryChang

Yes, the format is extended in camera_common.c by this entry

	{
               MEDIA_BUS_FMT_Y8_1X8,
               V4L2_COLORSPACE_SRGB,
               V4L2_PIX_FMT_GREY,
	},

Here is the output of the command.

v4l2-ctl -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘GREY’
Name : 8-bit Greyscale

hello kunalshrivastava.iitr,

may I know the format dumps as following, i.e. $ v4l2-ctl -d /dev/video0 --list-formats-ext

Sure. Here it is.

v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'GREY'
	Name        : 8-bit Greyscale
		Size: Discrete 3200x1300
			Interval: Discrete 0.033s (30.000 fps)

@JerryChang

[16559.661764] tegra194-vi5 15c10000.vi: vi_capture_setup: control failed, errno 1
[16559.662081] tegra194-vi5 15c10000.vi: vi capture setup failed

Looking at the kernel code it seems the above error messages in dmesg come from

Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c

from the function tegra_channel_capture_setup

Where can I find more information on what this function does?

I figured that it further calls vi_capture_setup from capture.c. It seems like this function tries to setup the vi channel with some settings before images can be streamed, but I am not sure where these settings come from. Could you help me with some more information?

hello kunalshrivastava.iitr,

it’ll parse device tree properties to register the camera devices.
please review those CID controls,
you may also add some debug message to check which control caused the failure.
for example,
TEGRA_CAMERA_CID_GAIN
TEGRA_CAMERA_CID_FRAME_RATE
TEGRA_CAMERA_CID_EXPOSURE
TEGRA_CAMERA_CID_EXPOSURE_SHORT

there also the commands to enable dynamic debug flag,
you could follow below to enable dev_dbg for the specific files.
for example, capture.c
# cd /sys/kernel/debug/dynamic_debug/
# echo file capture.c +p > control

@JerryChang Thanks for these suggestions. I would actually like to add some debug messages to figure out which control is causing failure, but I am not able to figure out WHERE I should add them. I am relatively new to driver programming.

Could you please guide me further?

hello kunalshrivastava.iitr,

you may either enable debug logs for capture.c or adding debug message to check which function call return failures.
note,
you should check /boot/extlinux/extlinux.conf, the kernel image is by default loading via LINUX entry, you may replace your own compile image with that, reboot the system to make changes applied.
thanks

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