Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_led_sync_refinement.c File Reference

A routine to automatically refine latency offsets of LED blink times using constellation samples. More...

#include "util/u_var.h"
#include "util/u_debug.h"
#include "math/m_api.h"
#include "os/os_time.h"
#include "t_led_sync_refinement.h"
Include dependency graph for t_led_sync_refinement.c:

Macros

#define LOG_TRACE(refinement, ...)   U_LOG_IFL_T(refinement->log_level, __VA_ARGS__)
 
#define LOG_DEBUG(refinement, ...)   U_LOG_IFL_D(refinement->log_level, __VA_ARGS__)
 
#define LOG_INFO(refinement, ...)   U_LOG_IFL_I(refinement->log_level, __VA_ARGS__)
 
#define LOG_WARN(refinement, ...)   U_LOG_IFL_W(refinement->log_level, __VA_ARGS__)
 
#define LOG_ERROR(refinement, ...)   U_LOG_IFL_E(refinement->log_level, __VA_ARGS__)
 
#define MAX_SAMPLE_LATENCY   3
 The amount of frames to not see it for consider a device "not found" during an active search.
 

Functions

static time_duration_ns change_good_cutoff (struct t_led_sync_refinement *refinement)
 The amount of time of which a change under this amount is considered "good" and we can exit the binary search.
 
static uint32_t frames_since_sample_apply (struct t_led_sync_refinement *refinement, timepoint_ns now_ns)
 The amount of frames since the sample was applied to the controller.
 
static void set_offset_duration (struct t_led_sync_refinement *refinement, time_duration_ns latency_offset_ns, time_duration_ns fudge_offset_ns, time_duration_ns blink_duration_ns)
 
static void set_centered_duration (struct t_led_sync_refinement *refinement, time_duration_ns blink_duration_ns)
 
static time_duration_ns get_search_period_locked (struct t_led_sync_refinement *refinement)
 Gets the period to iterate over when searching for a latency offset.
 
static void set_phase_locked (struct t_led_sync_refinement *refinement, enum t_led_sync_phase new_phase)
 
static void handle_find_initial_offset (struct t_led_sync_refinement *refinement)
 
static void handle_find_right_edge (struct t_led_sync_refinement *refinement)
 
static void handle_find_left_edge (struct t_led_sync_refinement *refinement)
 
static void handle_refine_blink_duration (struct t_led_sync_refinement *refinement)
 
static void handle_maintain_offset (struct t_led_sync_refinement *refinement)
 
static void handle_timing_event_locked (struct t_led_sync_refinement *refinement, const struct t_timing_event_camera_exposure_start *event)
 
static void handle_constellation_sample_locked (struct t_led_sync_refinement *refinement, const struct t_constellation_tracker_sample *sample)
 
int t_led_sync_refinement_init (struct t_led_sync_refinement *refinement, const struct t_led_sync_refinement_options *options)
 
void t_led_sync_refinement_destroy (struct t_led_sync_refinement *refinement)
 
void t_led_sync_push_timing_event (struct t_led_sync_refinement *refinement, const struct t_timing_event_camera_exposure_start *event)
 
void t_led_sync_push_constellation_sample (struct t_led_sync_refinement *refinement, const struct t_constellation_tracker_sample *sample)
 
bool t_led_sync_get_sample (struct t_led_sync_refinement *refinement, struct t_led_sync_sample *out_sample)
 
void t_led_sync_mark_latest_sample_applied (struct t_led_sync_refinement *refinement, timepoint_ns apply_time_ns)
 
void t_led_sync_update_minimum_blink_time (struct t_led_sync_refinement *refinement, time_duration_ns new_minimum_ns)
 

Detailed Description

A routine to automatically refine latency offsets of LED blink times using constellation samples.

Author
Beyley Cardellio ep1cm.nosp@m.1n10.nosp@m.n123@.nosp@m.gmai.nosp@m.l.com

Macro Definition Documentation

◆ MAX_SAMPLE_LATENCY

#define MAX_SAMPLE_LATENCY   3

The amount of frames to not see it for consider a device "not found" during an active search.

Function Documentation

◆ change_good_cutoff()

static time_duration_ns change_good_cutoff ( struct t_led_sync_refinement refinement)
static

The amount of time of which a change under this amount is considered "good" and we can exit the binary search.

References t_led_sync_refinement::current_blink_duration_ns, t_led_sync_refinement::exposure_time_ns, and MIN.

◆ frames_since_sample_apply()

static uint32_t frames_since_sample_apply ( struct t_led_sync_refinement refinement,
timepoint_ns  now_ns 
)
static

The amount of frames since the sample was applied to the controller.

References t_led_sync_refinement::exposure_interval_ns, and t_led_sync_refinement::last_sample_apply_time_ns.

◆ get_search_period_locked()

static time_duration_ns get_search_period_locked ( struct t_led_sync_refinement refinement)
static