Jetson AGX V4L2_MEMORY_USERPTR VIDIOC_QBUF returned -1 (Invalid argument)

I have the following CSI camera setup on the Jetson AGX Orin:

user@orin:~ v4l2-ctl -d /dev/video0 --all                               
Driver Info:
    Driver name      : tegra-video
    Card type        : vi-output, imx296 30-001a
    Bus info         : platform:tegra-capture-vi:0
    Driver version   : 5.10.104
    Capabilities     : 0x84200001
            Video Capture
            Streaming
            Extended Pix Format
            Device Capabilities
    Device Caps      : 0x04200001
            Video Capture
            Streaming
            Extended Pix Format
Media Driver Info:
    Driver name      : tegra-camrtc-ca
    Model            : NVIDIA Tegra Video Input Device
    Serial           : 
    Bus info         : 
    Media version    : 5.10.104
    Hardware revision: 0x00000003 (3)
    Driver version   : 5.10.104
Interface Info:
    ID               : 0x03000008
    Type             : V4L Video
Entity Info:
    ID               : 0x00000006 (6)
    Name             : vi-output, imx296 30-001a
    Function         : V4L2 I/O
    Pad 0x01000007   : 0: Sink
      Link 0x0200000c: from remote pad 0x1000003 of entity '13e40000.host1x:nvcsi@15a00000-': Data, Enabled
Priority: 2
Video input : 0 (Camera 0: ok)
Format Video Capture:
    Width/Height      : 1456/1088
    Pixel Format      : 'RG10' (10-bit Bayer RGRG/GBGB)
    Field             : None
    Bytes per Line    : 3072
    Size Image        : 3342336
    Colorspace        : sRGB
    Transfer Function : Default (maps to sRGB)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Full Range)
    Flags             : 

Camera Controls

                 group_hold 0x009a2003 (bool)   : default=0 value=0 flags=execute-on-write
                sensor_mode 0x009a2008 (int64)  : min=0 max=3 step=1 default=0 value=0 flags=slider
                       gain 0x009a2009 (int64)  : min=0 max=480 step=1 default=0 value=0 flags=slider
                   exposure 0x009a200a (int64)  : min=28 max=660000 step=1 default=10000 value=500 flags=update, slider
                 frame_rate 0x009a200b (int64)  : min=1500000 max=60378991 step=1 default=60000000 value=60000000 flags=update, slider
       sensor_configuration 0x009a2032 (u32)    : min=0 max=4294967295 step=1 default=0 [22] flags=read-only, volatile, has-payload
     sensor_mode_i2c_packet 0x009a2033 (u32)    : min=0 max=4294967295 step=1 default=0 [1026] flags=read-only, volatile, has-payload
  sensor_control_i2c_packet 0x009a2034 (u32)    : min=0 max=4294967295 step=1 default=0 [1026] flags=read-only, volatile, has-payload
                bypass_mode 0x009a2064 (intmenu): min=0 max=1 default=0 value=0
                            0: 0 (0x0)
                            1: 1 (0x1)
            override_enable 0x009a2065 (intmenu): min=0 max=1 default=0 value=0
                            0: 0 (0x0)
                            1: 1 (0x1)
               height_align 0x009a2066 (int)    : min=1 max=16 step=1 default=1 value=1
                 size_align 0x009a2067 (intmenu): min=0 max=2 default=0 value=0
                            0: 1 (0x1)
                            1: 65536 (0x10000)
                            2: 131072 (0x20000)
           write_isp_format 0x009a2068 (int)    : min=1 max=1 step=1 default=1 value=1
   sensor_signal_properties 0x009a2069 (u32)    : min=0 max=4294967295 step=1 default=0 [30][18] flags=read-only, has-payload
    sensor_image_properties 0x009a206a (u32)    : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
  sensor_control_properties 0x009a206b (u32)    : min=0 max=4294967295 step=1 default=0 [30][36] flags=read-only, has-payload
          sensor_dv_timings 0x009a206c (u32)    : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
           low_latency_mode 0x009a206d (bool)   : default=0 value=0
           preferred_stride 0x009a206e (int)    : min=0 max=65535 step=1 default=0 value=0
               test_pattern 0x009a2070 (menu)   : min=0 max=3 default=0 value=0
                            0: No Pattern
                            1: Sequence 1
                            2: Sequence 2
                            3: Gradiation
             streaming_mode 0x009a2071 (menu)   : min=0 max=2 default=0 value=0
                            0: Standalone
                            1: Sync Mode
                            2: External HW Sync Mode
             operation_mode 0x009a2072 (menu)   : min=0 max=1 default=0 value=0
                            0: Master Mode
                            1: Slave Mode
                black_level 0x009a2075 (int64)  : min=0 max=511 step=1 default=60 value=60 flags=slider, execute-on-write
        global_shutter_mode 0x009a207b (menu)   : min=0 max=1 default=0 value=0
                            0: Normal Mode
                            1: Sequential Trigger Mode
               sensor_modes 0x009a2082 (int)    : min=0 max=30 step=1 default=30 value=3 flags=read-only`

I am able to stream with mmap:

user@orin:~ v4l2-ctl -d /dev/video0 --stream-mmap
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60.00 fps

I’m not able to do so with userptr:

user@orin:~ v4l2-ctl -d /dev/video0 --stream-user
            VIDIOC_QBUF returned -1 (Invalid argument)

I modified the v4l-utils source as per this post but got the same invalid argument error message.

I am using the following setup:

cat /etc/nv_tegra_release 
# R35 (release), REVISION: 2.1, GCID: 32413640, BOARD: t186ref, EABI: aarch64, DATE: Tue Jan 24 23:38:33 UTC 2023

I was previously able to make use of userptr on the Jetson Xavier with the same camera on the following setup:

 cat /etc/nv_tegra_release 
# R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t186ref, EABI: aarch64, DATE: Fri Feb 19 16:50:29 UTC 2021

This used to work with both v4l2-ctl and my own code using cudaMallocManaged.

I also get the same error when building and running 18_v4l2_camera_cuda_rgb from the jetson multimedia api:

./v4l2_camera_cuda_rgb --userp
VIDIOC_QBUF error 22, Invalid argument

./v4l2_camera_cuda_rgb --userp --zcopy
VIDIOC_QBUF error 22, Invalid argument

according to Topic 261393, is it possible for moving to r35.3.1 for confirmation?

The camera drivers only support r35.2.1.

I gained access to the driver source and was able to build on r35.4.1. I still have the same problem:

user@orin:~ cat /etc/nv_tegra_release 
# R35 (release), REVISION: 4.1, GCID: 33958178, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug  1 19:57:35 UTC 2023
user@orin:~ v4l2-ctl -d /dev/video0 --stream-user
            VIDIOC_QBUF returned -1 (Invalid argument)

hello che,

could you please also check v4l2-compliance for the test results of QUERYBUF

Buffer ioctls (Input 0):
                fail: v4l2-test-buffers.cpp(715): q.create_bufs(node, 1, &fmt) != EINVAL
        test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL

it might be the same if you seen the failure with v4l2-compliance.

$ v4l2-ctl -d /dev/video0 --stream-user
                VIDIOC_QBUF returned -1 (Invalid argument)

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