How to set IMX219 mode in JetsonNano by the ioctl utilities

Hi Guys,
I am using the ioctl utilities to capture the bayer image on the JetsonNano-IMX219 platform.
It succeeded in the resolution of 3264x2464. But when I set the resolution to 1920x1080, it still captures the image of 3264x2464.

Below is the code for setting the operation mode.
#define IMAGEWIDTH 1920
#define IMAGEHEIGHT 1080

//set fmt
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SRGGB10;
fmt.fmt.pix.height = IMAGEHEIGHT;
fmt.fmt.pix.width = IMAGEWIDTH;
fmt.fmt.pix.field = V4L2_FIELD_NONE;

if(ioctl(fd, VIDIOC_S_FMT, &fmt) == -1)
{
    printf("Unable to set format\n");
    return FALSE;
}
if(ioctl(fd, VIDIOC_G_FMT, &fmt) == -1)
{
    printf("Unable to get format\n");
    return FALSE;
}
{
     printf("fmt.type:\t\t%d\n",fmt.type);
     printf("pix.pixelformat:\t%c%c%c%c\n",fmt.fmt.pix.pixelformat & 0xFF, (fmt.fmt.pix.pixelformat >> 8) & 0xFF,(fmt.fmt.pix.pixelformat >> 16) & 0xFF, (fmt.fmt.pix.pixelformat >> 24) & 0xFF);
     printf("pix.height:\t\t%d\n",fmt.fmt.pix.height);
     printf("pix.width:\t\t%d\n",fmt.fmt.pix.width);
     printf("pix.field:\t\t%d\n",fmt.fmt.pix.field);
}

Could you please give me some hint on how to change the resolution ? Thanks!

Hello @river,

1- Verify the supported resolutions with the following command:

v4l2-ctl --device /dev/video0 --list-formats-ext

2- If 1920x1080 resolution is listed then try to capture 1 frame with the following command to verify

v4l2-ctl --device /dev/video0 --stream-mmap --stream-count=1 --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --verbose

You should see a ‘<’ as the output.

If the previous command succeeded then a buffer from the camera was received.

3- Verify if the capture subsystem was configured with 1920x1080 resolution.

v4l2-ctl -d /dev/video0 --all
media-ctl -d /dev/media0 -p

Please provide the output of all the commands to analyze the results.

Regards,
Fabian
www.ridgerun.com

Thanks Fabian,
Below is the result of the execution for the commands.

river@river-desktop:~$ v4l2-ctl --device /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘RG10’
Name : 10-bit Bayer RGRG/GBGB
Size: Discrete 3264x2464
Interval: Discrete 0.048s (21.000 fps)
Size: Discrete 3264x1848
Interval: Discrete 0.036s (28.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)

river@river-desktop:~$ v4l2-ctl --device /dev/video0 --stream-mmap --stream-count=1 --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --verbose
VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 3264/2464
Pixel Format : ‘RG10’
Field : None
Bytes per Line : 6528
Size Image : 16084992
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
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
Index : 0
Type : Video Capture
Flags : mapped
Field : None
Sequence : 0
Length : 16084992
Bytesused: 16084992
Timestamp: 80987.479496s (Monotonic, End-of-Frame)

VIDIOC_STREAMOFF: ok

river@river-desktop:~$ v4l2-ctl -d /dev/video0 --all
Driver Info (not using libv4l2):
Driver name : tegra-video
Card type : vi-output, imx219 7-0010
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
Priority: 2
Video input : 0 (Camera 0: no power)
Format Video Capture:
Width/Height : 3264/2464
Pixel Format : ‘RG10’
Field : None
Bytes per Line : 6528
Size Image : 16084992
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=0 step=0 default=0 value=0 flags=slider
                       gain 0x009a2009 (int64)  : min=0 max=0 step=0 default=0 value=16 flags=slider
                   exposure 0x009a200a (int64)  : min=0 max=0 step=0 default=0 value=13 flags=slider
                 frame_rate 0x009a200b (int64)  : min=0 max=0 step=0 default=0 value=2000000 flags=slider
                bypass_mode 0x009a2064 (intmenu): min=0 max=1 default=0 value=0
            override_enable 0x009a2065 (intmenu): min=0 max=1 default=0 value=0
               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
           write_isp_format 0x009a2068 (bool)   : default=0 value=0
   sensor_signal_properties 0x009a2069 (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
    sensor_image_properties 0x009a206a (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
  sensor_control_properties 0x009a206b (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
          sensor_dv_timings 0x009a206c (u32)    : min=0 max=0 step=0 default=0 flags=read-only, has-payload
           low_latency_mode 0x009a206d (bool)   : default=0 value=0
               sensor_modes 0x009a2082 (int)    : min=0 max=30 step=1 default=30 value=5 flags=read-only

river@river-desktop:~$ media-ctl -d /dev/media0 -p
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: nvcsi–2 (2 pads, 2 links)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev0
    pad0: Sink
    ← “imx219 7-0010”:0 [ENABLED]
    pad1: Source
    → “vi-output, imx219 7-0010”:0 [ENABLED]

  • entity 4: nvcsi–1 (2 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    pad1: Source

  • entity 7: imx219 7-0010 (1 pad, 1 link)
    type V4L2 subdev subtype Sensor flags 0
    device node name /dev/v4l-subdev2
    pad0: Source
    [fmt:SRGGB10_1X10/3264x2464 field:none colorspace:srgb]
    → “nvcsi–2”:0 [ENABLED]

  • entity 9: vi-output, imx219 7-0010 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video0
    pad0: Sink
    ← “nvcsi–2”:1 [ENABLED]

Thanks for checking this!

Hi @river

Ok seems the driver is not changing the resolution and is always setting default resolution. Are you using the default driver that ships with L4T? What Jetpack version are you using?

Regards,
Fabian
www.ridgerun.com

Hi Fabian,
Yes I am using the default driver shipped with L4T. The Jetpack version is 4.3.

Thanks!

hello river,

could you please specify control property, i.e. --set-ctrl=sensor_mode=<N> to assign sensor modes.
I’m able to switch sensor modes with Nano/IMX219 by the following command lines.
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --set-ctrl=sensor_mode=3 --verbose
...
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
        Width/Height      : 1280/720
        Pixel Format      : 'RG10'
        Field             : None
        Bytes per Line    : 2560
        Size Image        : 1843200

Thanks! I think this could work. I will try it tomorrow.