Software trigger with V4L2 camera

I am working on jetson TX2, with a FSM-IMX304M camera and I use V4L2 API.

I would like to use software trigger. Does anyone have an idea about how to use it ? I didn’t find anything about it.

I need to synchronize the camera with a turntable. The idea is to send x triggers every 50 ms (read-out time of the camera is around 50ms), to fill x buffers (the minimum buffer id is 3 and the maximal is 32). When the first buffer is filled, I send an other trigger to fill the second one, and during this time, the camera send the image to the jetson.

I try to implement this solution because it is consuming time to stop/start stream for each sequence (https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/vidioc-streamon.html). If this solution is not feasible, does someone have an other idea ?
As shown below, the command does not return trigger. I have no idea how activate it :

nvidia@nvidia-desktop:~$ v4l2-ctl --list-ctrls

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=1000000 step=1 default=27879 value=28 flags=slider
                 frame_rate 0x009a200b (int64)  : min=1500000 max=24000000 step=1 default=24000000 value=1500000 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 (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][34] 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
               test_pattern 0x009a206f (menu)   : min=0 max=3 default=0 value=0
             operation_mode 0x009a2071 (menu)   : min=0 max=1 default=0 value=0
                black_level 0x009a2074 (int64)  : min=0 max=4095 step=1 default=0 value=0 flags=slider

check_firmware_compatibility 0x009a2075 (menu) : min=0 max=2 default=1 value=1
global_shutter_mode 0x009a207b (menu) : min=0 max=1 default=0 value=0
sensor_modes 0x009a2082 (int) : min=0 max=30 step=1 default=30 value=3 flags=read-only
timing_generator_mode 0x009a208c (menu) : min=0 max=3 default=0 value=0
expanded_exposure 0x009a2099 (int64) : min=0 max=4294967295 step=1 default=0 value=0 flags=slider
delay_frame 0x009a209a (int64) : min=0 max=4294967295 step=1 default=0 value=0 flags=slider

Moreover, I try to change the exposure time of my camera. I just follow this tutorial : https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/control.html#example-enumerating-all-controls-including-compound-controls. To change the exposure time :

struct v4l2_queryctrl queryctrl;
struct v4l2_control control;

memset(&queryctrl, 0, sizeof(queryctrl));
queryctrl.id = V4L2_CID_EXPOSURE;

if (-1 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
if (errno != EINVAL) {
perror(“VIDIOC_QUERYCTRL”);
exit(EXIT_FAILURE);
} else {
printf(“V4L2_CID_EXPOSURE is not supported 1 \n”);
}
} else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
printf(“V4L2_CID_EXPOSURE is not supported 1 \n”);
} else {
memset(&control, 0, sizeof (control));
control.id = V4L2_CID_EXPOSURE;
control.value = queryctrl.default_value;

if (-1 == ioctl(fd, VIDIOC_S_CTRL, &control)) {
    perror("VIDIOC_S_CTRL");
    exit(EXIT_FAILURE);
}

}

The code returns : V4L2_CID_EXPOSURE is not supported 1 .

Maybe this command from linux command line can help you to figure out the issue :

nvidia@nvidia-desktop:~$ v4l2-compliance -d /dev/video0
v4l2-compliance SHA : not available

Driver Info:
Driver name : tegra-video
Card type : vi-output, imx304 30-001a
Bus info : platform:15700000.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: 1 Private Controls: 24

Format ioctls:
    test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
    fail: v4l2-test-formats.cpp(1184): ret && node->has_frmintervals
    test VIDIOC_G/S_PARM: FAIL
    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: 42, Failed: 1, Warnings: 0