Camera Frame Synchronization#

Camera Frame Synchronization (FSYNC)#

SIPL provides an interface that allows control over FSYNC signals. This topic covers FSYNC-related aspects, including modifying the properties of the FSYNC signals and customizing their start times..

Operating Modes#

SIPL frame synchronization operates in two distinct modes, allowing you to choose when FSYNC signals are generated for your camera applications.

Default Start Time

The default start mode of the camera software initiates all FSYNC signals automatically during the boot process of your Guest OS. This mode is suitable for scenarios where you want synchronization to start as soon as your system boots.

Custom Start Time

Custom Start Time mode gives you the flexibility to program the start time of FSYNC signals. This is particularly useful when the FSYNC signals need to be aligned to an external event.

The Configuring Custom Start Times section explains programming the start time for the FSYNC group.

Customizing Frequency, Duty Cycle, and Offsets#

SIPL allows customization for the properties of individual FSYNC signals to meet your requirements. You can adjust the frequency, duty cycle, and offsets in DT to fine-tune synchronization for camera applications.

Property

Description

Customizable

Optional

Value

freq_hz

Frequency of the signal, in hertz.

Yes

No

Hertz as an unsigned integer in the range (0, 120]

duty_cycle

Percentage duty cycle of the signal.

Yes

No

Unsigned in the range (0, 100)

offset_ms

Offset to shift the signal, in milliseconds.

Yes

No

Milliseconds as an unsigned integer in the range [0, 1000]

For a complete reference to DT node, refer to the “FSYNC Signal Generation” topic in the NVIDIA DriveOS SDK Developer Guide.

Configuring Custom Start Times#

To program custom start times for FSYNC signals, complete the following steps.

FSYNC Group DT Modification

  • To program a custom start time, one or more FSYNC signals must be grouped together into a fsync-group.

  • FSYNC groups may be freely composed provided that any given FSYNC signal doesn’t appear in more than one group.

  • Each group receives a unique user-defined group ID. This group ID is required to start the entire generator group at the specified time.

  • For additional information on setting up fsync-groups, refer the “FSYNC Signal Generation” topic in the NVIDIA DriveOS SDK Developer Guide.

In the Device Tree (DT), modify the FSYNC group configuration to enable custom start times.

fsync-groups {
    status = "okay";  # Set to "okay" to enable FSYNC groups
    fsync-group@0 {
        id = <0>;         # Unique group ID
        status = "okay";  # Set to "okay" to enable this group
        generators = <&gen0>, <&gen2>, <&gen3>;  # List of generator phandles
    };
    # Additional groups can be configured here
};

Note

Each generator can only be part of one fsync-group. Attempting to assign a generator to multiple groups will lead to an error.

Note

If fsync-groups are enabled in DT, it is mandatory to program start time, as mentioned in the following section, to start FSYNC signal generations

Programming Custom Start Times

Programming Custom Start Times#

To program custom start times for your FSYNC groups, use the cam_fsync_program_abs_start_value API. This API is part of the libcam_fsync.so library and is declared in NvCamFsync.h. The API accepts the group_id and start_time_in_tsc_ticks as arguments. The group_id is the id defined in DT..

Example code:

#include <NvCamFsync.h>


// ...


int group_id = 0;                     // Example group ID
int start_time_in_tsc_ticks = 50000;  // Example start time in TSC ticks


CAM_FSYNC_STATUS result = cam_fsync_program_abs_start_value(group_id, start_time_in_tsc_ticks);


if (result != CAM_FSYNC_OK) {
    // Handle any errors
} else {
    // Start time programmed successfully
}

Note

Providing a valid start time is the responsibility of your application using the FSYNC feature.

Note

The start time for FSYNC group can be programmed once. If reprogramming is required, the Guest OS must be rebooted

Integration With SIPL Sample Application#

The SIPL sample application, nvsipl_camera, provides an interface to program the start time for FSYNC group.

Use the -F flag to specify the group ID and start time for the first launch of the application.

Example command:

nvsipl_camera <args> -F "0 50000"

Note

You can program one FSYNC group at a time. Trying to program multiple FSYNC groups using nvsipl_camera will result in an unsuccessful operation.

Note

Complete the steps in the previous “FSYNC Group DT Modification” section to use this feature.