Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_led_sync_refinement.h
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief A routine to automatically refine latency offsets of LED blink times using constellation samples.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup tracking
8 */
9
10#pragma once
11
12#include "util/u_time.h"
13#include "util/u_logging.h"
14
15#include "os/os_threading.h"
16
17#include "tracking/t_tracking.h"
20
21
22//! 5 seconds after last visually seen sample to resync
23#define T_LED_SYNC_DEFAULT_RESYNC_TIME (time_duration_ns)(U_TIME_1S_IN_NS * 5LL)
24
25#define T_LED_SYNC_SELECTED_LEDS 2
26
27//! How many elements are in the seen LEDs ring buffer
28#define T_LED_SYNC_SEEN_LEDS_ACCUMULATION_BUFFER_SIZE 5
29//! The amount of bits in the full gray code we're decoding
30#define T_LED_SYNC_GRAY_CODE_SIZE_BITS 11
31//! 20 frames per sample
32#define T_LED_SYNC_BRIGHTNESS_CURVE_NUM_SAMPLES 20
33
34// @todo Remove this once clang-format is updated in CI
35// clang-format off
36#define T_LED_SYNC_SEEN_LED_BUFFER_INDEX(sequence_id) ((sequence_id) % T_LED_SYNC_SEEN_LEDS_ACCUMULATION_BUFFER_SIZE)
37#define T_LED_SYNC_GRAY_CODE_BUFFER_INDEX(camera_index, sequence_id, led_idx) \
38 (((((camera_index) * T_LED_SYNC_GRAY_CODE_SIZE_BITS) + ((sequence_id) % T_LED_SYNC_GRAY_CODE_SIZE_BITS)) * \
39 T_LED_SYNC_SELECTED_LEDS) + \
40 (led_idx))
41// clang-format on
42
43//! Flags to control the behavior of the LED sync refinement routine.
45{
46 T_LED_SYNC_REFINEMENT_FLAGS_NONE = 0,
47 //! Whether to try to optimize the blink duration after finding an offset, to lessen power usage.
49 /*!
50 * Whether to lock in a clock offset and have it be driven entirely by the sync refinement, utilizing the
51 * optical samples to measure clock skew/offset between the device and host, rather than the driver's normal
52 * remote clock synchronization.
53 *
54 * Use this flag when the driver's clock tracking is very noisy and is causing LED sync to be unreliable. But
55 * currently will cause LED sync to eventually drift as clock skew between the devices takes effect.
56 */
58 /*!
59 * Whether the device has specified a maximum latency cap. This prevents the sync refinement from searching
60 * parts of the exposure that aren't possible, which can cause refinement to sometimes take longer.
61 */
63 /*!
64 * Whether the device we're syncing is specifically a PS VR2 controller ("pssense"), and so has access to the
65 * extra Gray code (BROAD) and brightness curve integral (BG) syncing modes.
66 */
68};
69
70//! Options for the LED sync refinement.
72{
73 //! The flags to use when refining.
75
76 //! How long the LEDs should be initially blinking for, in nanoseconds.
78
79 //! The minimum duration to use for the LED blinks, if using reduction.
81 //! The maximum duration to use for the LED blinks, if using reduction.
83
84 //! Time to wait after the last visually seen sample before resyncing.
86 //! Frames to wait after the sample was applied to let the device settle.
87 uint32_t settle_frames;
88
89 //! The maximum latency offset to use, if using a latency cap.
91};
92
94{
95 T_LED_SYNC_SAMPLE_TIMESTAMP_MODE_INVALID = 0,
96 //! Used when the LED sync refinement is just computing a basic latency offset.
98 //! Used when the LED sync refinement is fully deriving the clock offset, latency included.
100};
101
103{
104 //! "PRESCAN", used to scan for an initial offset to then refine.
106 /*!
107 * "BROAD", blink certain LEDs in an 11-frame Gray code to refine where we are in the offset faster than a
108 * binary search can.
109 */
111 /*!
112 * "BG", blink certain LEDs with a brightness curve over a set of frames, then fit a curve to that measured
113 * data, allowing us to get sub-frame accuracy in terms of where we are.
114 */
116 //! "STABLE", all LEDs blink narrowly on the trimmed cycle, holding sync with nothing measured.
118};
119
121{
122 //! The base time offset to send to the controller (in nanoseconds).
124 //! The LEDs to enable, or 0xff if we don't have a selection.
125 uint8_t leds[4];
126};
127
128//! A sample read out from the driver, to pass to the device in question.
130{
131 union {
132 //! The latency offset from the device timestamps to the host.
134
135 //! The clock offset from the host timestamp to the device.
137 } timestamp;
138 enum t_led_sync_sample_timestamp_mode timestamp_mode;
139
140 /*!
141 * Clock skew (device vs host, in ns per ns) and its host-time epoch. Only used in
142 * HOST_DEVICE_CLOCK_OFFSET mode: device_ts = host_ts + offset + skew * (host_ts - epoch).
143 */
145 timepoint_ns clock_epoch_ns;
146
147 //! The LED cycle period in device ns, already trimmed for the skew. 0 lets the driver use its own estimate.
149
150 //! The latency offset to apply to fudge the blink to line up as best as possible with the exposure.
152 //! The duration to make the LEDs blink for, in nanoseconds.
154
155 struct t_led_sync_sample_pssense_data pssense;
156 enum t_led_sync_sample_pssense_mode pssense_mode;
157};
158
160{
161 //! The initial phase, where we haven't made any adjustments yet.
163 //! Trying to find some offset that gets us in sync at all.
165 //! Trying to align the rising edge of the LED blinks with the falling edge of the camera exposure.
167 //! Trying to align the falling edge of the LED blinks with the rising edge of the camera exposure.
169 //! Trying to decode the Gray codes present in the LEDs we've selected.
171 //! Trying to optimize the brightness curve for the correct time offset.
173 //! We've found an offset, now we can optimize the blink duration to something that keeps it tracking.
175 //! We've found an offset and optimized the center of the LED blink to the center of the exposure.
177 //! PS Sense only, BG has converged so the LEDs hold sync on the trimmed cycle until BG checks them again.
179};
180
182{
183 //! How many times it's been seen
185 //! How "facing" the camera it was
187};
188
189//! One camera's view of the selected LEDs in one frame, brightness is the blob's greysum, 0 if it wasn't seen.
191{
192 uint64_t sequence_id;
193 float brightness[T_LED_SYNC_SELECTED_LEDS];
194 float facing_dot[T_LED_SYNC_SELECTED_LEDS];
195};
196
197//! Frame period measured over a long run of frames, so it's steady enough to base the LED cycle on.
199{
200 uint64_t anchor_sequence_id;
201 timepoint_ns anchor_ns;
202 //! The previous run's estimate, the next one has to agree with it to be trusted.
204 //! The last trusted estimate, 0 until there is one.
205 double period_ns;
206};
207
208//! Clock sync from BROAD on: the LED cycle, the clock model kept on it, and BG's offset servo and skew fit.
210{
211 //! The camera frame the clock model last matched the LED cycle at, its drift is measured from here.
213 timepoint_ns anchor_ns;
214
215 //! Host time the published offset is valid at, the skew extrapolates from here.
217 //! Estimated clock skew, device vs host, in ns per ns.
218 double skew;
219 //! Sum of all servo corrections this BG session.
221 //! Smoothed offset of the LEDs from the exposure, as the servo correction that would center them.
223 bool has_led_error;
224
225 //! The frame period the LED cycle is trimmed from, set when BROAD starts and moved onto each trusted estimate.
227 //! The skew changed and the new cycle still has to be sent.
229 //! Host time of the last accepted measurement, for the no-data watchdog.
231
232 //! Skew windows fitted since BG was entered.
233 uint32_t num_windows;
234 //! When the fitted rate last started staying under the STABLE gate, 0 if it isn't.
236 //! Whether this sync has reached STABLE, BG comes back from it warm.
238 //! Host time STABLE was entered.
240
241 //! Least-squares window of the phase deviation against time.
242 uint32_t num_samples;
243 timepoint_ns window_start_ns;
244 double sum_t, sum_tt, sum_d, sum_td;
245};
246
248{
249 //! Whether the structure has been fully initialized.
251
252 enum u_logging_level log_level;
253
254 //! The options to use for refinement
256
257 struct os_mutex lock;
258
259 /*
260 * Exposure Info
261 */
262
263 /*!
264 * Whether we know the actual exposure time of the frames. We may not, so we have to work without it in some
265 * cases.
266 */
268 //! The known time the frame was exposed for.
270 //! The known interval between frames.
272 struct t_led_sync_period_estimate period_estimate;
273 //! The latest timing event's frame and exposure time.
275 timepoint_ns last_exposure_ns;
276
277 /*
278 * Driver Sample
279 */
280
281 //! Whether we have a sample ready to be sent to the driver/device.
283 //! The sample to be sent to the driver/device on it's next convenience.
285 //! Whether the sample has been applied
287
288 /*
289 * State
290 */
291
292 //! The current search phase
294
295 /*!
296 * The current estimated latency offset between the device and the host, in nanoseconds. This is what we are
297 * trying to refine.
298 */
300 /*!
301 * The amount of fudge between the latency offset and the actual blink start time, in nanoseconds, so we can
302 * place the blink at the optimal time for the exposure.
303 */
305
306 //! How long the LEDs blink for, each frame.
308
309 //! The amount of frames since the controller was last visually seen.
311
312 //! The sequence ID of the latest timing event we processed.
314
315 //! The time the latest sample was applied to the driver/device
317
318 //! The found left edge of the exposure, -1 if not found yet.
320 //! The found right edge of the exposure, -1 if not found yet.
322
323 struct
324 {
325 //! The current left bound of the binary search, if we're in a find edge phase.
327 //! The current right bound of the binary search, if we're in a find edge phase.
329 } binary_search_state;
330
331 struct
332 {
333 //! The index into the seen LEDs ring buffer
335
336 //! The time when we last selected the set of LEDs
338
339 uint32_t num_samples;
340
341 /*!
342 * The seen LEDs ring buffer.
343 *
344 * Indexed via `(leds_seen_idx * XRT_CONSTELLATION_MAX_LEDS_PER_DEVICE) + led_id`
345 */
348 } leds_seen;
349
350 struct
351 {
352 //! Whether or not we have applied the final cycle position or not.
354
355 /*!
356 * A ring buffer storing the last @ref T_LED_SYNC_GRAY_CODE_SIZE_BITS bits of the brightness sequence
357 * per camera.
358 *
359 * Indexed via @ref T_LED_SYNC_GRAY_CODE_BUFFER_INDEX
360 */
361 float led_brightnesses[T_LED_SYNC_GRAY_CODE_SIZE_BITS * XRT_TRACKING_MAX_FRAME_SOURCES *
362 T_LED_SYNC_SELECTED_LEDS];
363 /*!
364 * A ring buffer storing the last @ref T_LED_SYNC_GRAY_CODE_SIZE_BITS bits of the sequence, storing the
365 * facing directions of each sample, so that we can pick the value from the camera that saw the LED the
366 * best.
367 *
368 * Indexed via @ref T_LED_SYNC_GRAY_CODE_BUFFER_INDEX
369 */
370 float led_facing_dots[T_LED_SYNC_GRAY_CODE_SIZE_BITS * XRT_TRACKING_MAX_FRAME_SOURCES *
371 T_LED_SYNC_SELECTED_LEDS];
372
373 //! How many decodes we've had that match in a row, see @ref GRAY_CODE_MATCHES_NEEDED
375 //! The gray code we're trying
377 //! The last time we had an accepted gray code (or the start of this phase).
379 } decode_gray;
380
381 struct
382 {
383 //! The LEDs @ref frames were recorded for.
384 uint8_t leds[T_LED_SYNC_SELECTED_LEDS];
385 //! The first frame the next measurement may use.
387 //! Ring buffer of the last @ref T_LED_SYNC_BRIGHTNESS_CURVE_NUM_SAMPLES frames per camera.
388 struct t_led_sync_frame frames[XRT_TRACKING_MAX_FRAME_SOURCES][T_LED_SYNC_BRIGHTNESS_CURVE_NUM_SAMPLES];
389 } optimize_brightness_curve;
390
391 struct t_led_sync_delta_sync delta_sync;
392
393 struct
394 {
395 //! The last blink duration that didn't cause the device to become unstable.
397
398 //! Whether we're currently trying to back off a lower blink duration.
400 } blink_time_refinement_state;
401
402 struct
403 {
404 //! The latest estimated host->device clock offset from the driver.
406
407 bool has_saved_offset;
408 time_duration_ns saved_offset;
409 } optical_driven_offset;
410};
411
412int
413t_led_sync_refinement_init(struct t_led_sync_refinement *refinement,
414 const struct t_led_sync_refinement_options *options);
415
416void
417t_led_sync_refinement_destroy(struct t_led_sync_refinement *refinement);
418
419void
420t_led_sync_push_timing_event(struct t_led_sync_refinement *refinement,
421 const struct t_timing_event_camera_exposure_start *event);
422
423void
424t_led_sync_push_constellation_sample(struct t_led_sync_refinement *refinement,
425 const struct t_constellation_tracker_sample *sample);
426
427bool
428t_led_sync_get_sample(struct t_led_sync_refinement *refinement, struct t_led_sync_sample *out_sample);
429
430void
431t_led_sync_mark_latest_sample_applied(struct t_led_sync_refinement *refinement, timepoint_ns apply_time_ns);
432
433/*!
434 * Pushes a clock offset to the refinement routine, this is the offset *from* the host *to* the device.
435 *
436 * To convert a timestamp from host -> device domain, you would do:
437 * `device_timestamp = host_timestamp + clock_offset_ns`
438 */
439void
u_logging_level
Logging level enum.
Definition u_logging.h:45
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
int64_t time_duration_ns
Integer duration type in nanoseconds.
Definition u_time.h:88
Wrapper around OS threading native functions.
A wrapper around a native mutex.
Definition os_threading.h:69
Definition t_constellation.h:378
Clock sync from BROAD on: the LED cycle, the clock model kept on it, and BG's offset servo and skew f...
Definition t_led_sync_refinement.h:210
uint32_t num_windows
Skew windows fitted since BG was entered.
Definition t_led_sync_refinement.h:233
timepoint_ns converged_since_ns
When the fitted rate last started staying under the STABLE gate, 0 if it isn't.
Definition t_led_sync_refinement.h:235
bool trim_pending
The skew changed and the new cycle still has to be sent.
Definition t_led_sync_refinement.h:228
timepoint_ns epoch_ns
Host time the published offset is valid at, the skew extrapolates from here.
Definition t_led_sync_refinement.h:216
uint32_t num_samples
Least-squares window of the phase deviation against time.
Definition t_led_sync_refinement.h:242
uint64_t anchor_sequence_id
The camera frame the clock model last matched the LED cycle at, its drift is measured from here.
Definition t_led_sync_refinement.h:212
double base_period_ns
The frame period the LED cycle is trimmed from, set when BROAD starts and moved onto each trusted est...
Definition t_led_sync_refinement.h:226
double skew
Estimated clock skew, device vs host, in ns per ns.
Definition t_led_sync_refinement.h:218
double led_error_ns
Smoothed offset of the LEDs from the exposure, as the servo correction that would center them.
Definition t_led_sync_refinement.h:222
bool been_stable
Whether this sync has reached STABLE, BG comes back from it warm.
Definition t_led_sync_refinement.h:237
timepoint_ns stable_entry_ns
Host time STABLE was entered.
Definition t_led_sync_refinement.h:239
timepoint_ns last_measurement_ns
Host time of the last accepted measurement, for the no-data watchdog.
Definition t_led_sync_refinement.h:230
time_duration_ns servo_integral_ns
Sum of all servo corrections this BG session.
Definition t_led_sync_refinement.h:220
One camera's view of the selected LEDs in one frame, brightness is the blob's greysum,...
Definition t_led_sync_refinement.h:191
Frame period measured over a long run of frames, so it's steady enough to base the LED cycle on.
Definition t_led_sync_refinement.h:199
double period_ns
The last trusted estimate, 0 until there is one.
Definition t_led_sync_refinement.h:205
double candidate_ns
The previous run's estimate, the next one has to agree with it to be trusted.
Definition t_led_sync_refinement.h:203
Options for the LED sync refinement.
Definition t_led_sync_refinement.h:72
time_duration_ns time_to_resync_ns
Time to wait after the last visually seen sample before resyncing.
Definition t_led_sync_refinement.h:85
time_duration_ns min_blink_duration_ns
The minimum duration to use for the LED blinks, if using reduction.
Definition t_led_sync_refinement.h:80
uint32_t settle_frames
Frames to wait after the sample was applied to let the device settle.
Definition t_led_sync_refinement.h:87
time_duration_ns max_blink_duration_ns
The maximum duration to use for the LED blinks, if using reduction.
Definition t_led_sync_refinement.h:82
enum t_led_sync_refinement_flags flags
The flags to use when refining.
Definition t_led_sync_refinement.h:74
time_duration_ns initial_blink_duration_ns
How long the LEDs should be initially blinking for, in nanoseconds.
Definition t_led_sync_refinement.h:77
time_duration_ns latency_cap_ns
The maximum latency offset to use, if using a latency cap.
Definition t_led_sync_refinement.h:90
Definition t_led_sync_refinement.h:248
uint64_t last_exposure_sequence_id
The latest timing event's frame and exposure time.
Definition t_led_sync_refinement.h:274
timepoint_ns last_selection_ns
The time when we last selected the set of LEDs.
Definition t_led_sync_refinement.h:337
uint32_t frames_since_last_visually_seen
The amount of frames since the controller was last visually seen.
Definition t_led_sync_refinement.h:310
time_duration_ns found_left_edge_ns
The found left edge of the exposure, -1 if not found yet.
Definition t_led_sync_refinement.h:319
struct t_led_sync_seen_led buf[XRT_CONSTELLATION_MAX_LEDS_PER_DEVICE *5]
The seen LEDs ring buffer.
Definition t_led_sync_refinement.h:346
timepoint_ns last_accepted_gray_code_ns
The last time we had an accepted gray code (or the start of this phase).
Definition t_led_sync_refinement.h:378
time_duration_ns found_right_edge_ns
The found right edge of the exposure, -1 if not found yet.
Definition t_led_sync_refinement.h:321
time_duration_ns right_bound_ns
The current right bound of the binary search, if we're in a find edge phase.
Definition t_led_sync_refinement.h:328
bool has_sample_for_driver
Whether we have a sample ready to be sent to the driver/device.
Definition t_led_sync_refinement.h:282
time_duration_ns left_bound_ns
The current left bound of the binary search, if we're in a find edge phase.
Definition t_led_sync_refinement.h:326
bool sample_applied
Whether the sample has been applied.
Definition t_led_sync_refinement.h:286
uint64_t window_start_sequence_id
The first frame the next measurement may use.
Definition t_led_sync_refinement.h:386
float led_facing_dots[11 *XRT_TRACKING_MAX_FRAME_SOURCES *2]
A ring buffer storing the last T_LED_SYNC_GRAY_CODE_SIZE_BITS bits of the sequence,...
Definition t_led_sync_refinement.h:371
bool backing_off
Whether we're currently trying to back off a lower blink duration.
Definition t_led_sync_refinement.h:399
struct t_led_sync_sample sample_for_driver
The sample to be sent to the driver/device on it's next convenience.
Definition t_led_sync_refinement.h:284
float led_brightnesses[11 *XRT_TRACKING_MAX_FRAME_SOURCES *2]
A ring buffer storing the last T_LED_SYNC_GRAY_CODE_SIZE_BITS bits of the brightness sequence per cam...
Definition t_led_sync_refinement.h:362
uint64_t current_sequence_id
The sequence ID of the latest timing event we processed.
Definition t_led_sync_refinement.h:313
uint8_t leds[2]
The LEDs frames were recorded for.
Definition t_led_sync_refinement.h:384
time_duration_ns last_good_blink_duration_ns
The last blink duration that didn't cause the device to become unstable.
Definition t_led_sync_refinement.h:396
time_duration_ns exposure_time_ns
The known time the frame was exposed for.
Definition t_led_sync_refinement.h:269
time_duration_ns current_blink_duration_ns
How long the LEDs blink for, each frame.
Definition t_led_sync_refinement.h:307
enum t_led_sync_phase phase
The current search phase.
Definition t_led_sync_refinement.h:293
struct t_led_sync_frame frames[XRT_TRACKING_MAX_FRAME_SOURCES][20]
Ring buffer of the last T_LED_SYNC_BRIGHTNESS_CURVE_NUM_SAMPLES frames per camera.
Definition t_led_sync_refinement.h:388
bool initialized
Whether the structure has been fully initialized.
Definition t_led_sync_refinement.h:250
time_duration_ns current_blink_fudge_ns
The amount of fudge between the latency offset and the actual blink start time, in nanoseconds,...
Definition t_led_sync_refinement.h:304
bool applied_gray_start
Whether or not we have applied the final cycle position or not.
Definition t_led_sync_refinement.h:353
time_duration_ns driver_host_device_clock_offset_ns
The latest estimated host->device clock offset from the driver.
Definition t_led_sync_refinement.h:405
time_duration_ns current_clock_offset_ns
The current estimated latency offset between the device and the host, in nanoseconds.
Definition t_led_sync_refinement.h:299
timepoint_ns last_sample_apply_time_ns
The time the latest sample was applied to the driver/device.
Definition t_led_sync_refinement.h:316
bool has_exposure_time
Whether we know the actual exposure time of the frames.
Definition t_led_sync_refinement.h:267
time_duration_ns exposure_interval_ns
The known interval between frames.
Definition t_led_sync_refinement.h:271
uint32_t cur_sequence_id
The index into the seen LEDs ring buffer.
Definition t_led_sync_refinement.h:334
uint8_t decoded_gray_code
The gray code we're trying.
Definition t_led_sync_refinement.h:376
struct t_led_sync_refinement_options options
The options to use for refinement.
Definition t_led_sync_refinement.h:255
uint32_t matching_decodes
How many decodes we've had that match in a row, see GRAY_CODE_MATCHES_NEEDED.
Definition t_led_sync_refinement.h:374
Definition t_led_sync_refinement.h:121
time_duration_ns base_time_offset_ns
The base time offset to send to the controller (in nanoseconds).
Definition t_led_sync_refinement.h:123
uint8_t leds[4]
The LEDs to enable, or 0xff if we don't have a selection.
Definition t_led_sync_refinement.h:125
A sample read out from the driver, to pass to the device in question.
Definition t_led_sync_refinement.h:130
double cycle_period_ns
The LED cycle period in device ns, already trimmed for the skew. 0 lets the driver use its own estima...
Definition t_led_sync_refinement.h:148
time_duration_ns fudge_offset_ns
The latency offset to apply to fudge the blink to line up as best as possible with the exposure.
Definition t_led_sync_refinement.h:151
time_duration_ns host_device_clock_offset_ns
The clock offset from the host timestamp to the device.
Definition t_led_sync_refinement.h:136
double clock_skew
Clock skew (device vs host, in ns per ns) and its host-time epoch.
Definition t_led_sync_refinement.h:144
time_duration_ns device_host_latency_ns
The latency offset from the device timestamps to the host.
Definition t_led_sync_refinement.h:133
time_duration_ns blink_duration_ns
The duration to make the LEDs blink for, in nanoseconds.
Definition t_led_sync_refinement.h:153
Definition t_led_sync_refinement.h:182
float accum_facing_dot
How "facing" the camera it was.
Definition t_led_sync_refinement.h:186
uint8_t accum_seen_count
How many times it's been seen.
Definition t_led_sync_refinement.h:184
Marks beginning of a camera exposure, pushed from the source to the sink.
Definition t_time_sync.h:29
Header defining the tracking system integration in Monado.
#define XRT_CONSTELLATION_MAX_LEDS_PER_DEVICE
The maximum number of LEDs that a single device can have.
Definition t_constellation.h:37
void t_led_sync_push_host_device_clock_offset(struct t_led_sync_refinement *refinement, time_duration_ns clock_offset_ns)
Pushes a clock offset to the refinement routine, this is the offset from the host to the device.
Definition t_led_sync_refinement.c:680
t_led_sync_sample_timestamp_mode
Definition t_led_sync_refinement.h:94
@ T_LED_SYNC_SAMPLE_TIMESTAMP_MODE_HOST_DEVICE_CLOCK_OFFSET
Used when the LED sync refinement is fully deriving the clock offset, latency included.
Definition t_led_sync_refinement.h:99
@ T_LED_SYNC_SAMPLE_TIMESTAMP_MODE_DEVICE_HOST_LATENCY
Used when the LED sync refinement is just computing a basic latency offset.
Definition t_led_sync_refinement.h:97
t_led_sync_sample_pssense_mode
Definition t_led_sync_refinement.h:103
@ T_LED_SYNC_SAMPLE_PSSENSE_MODE_BROAD
"BROAD", blink certain LEDs in an 11-frame Gray code to refine where we are in the offset faster than...
Definition t_led_sync_refinement.h:110
@ T_LED_SYNC_SAMPLE_PSSENSE_MODE_PRESCAN
"PRESCAN", used to scan for an initial offset to then refine.
Definition t_led_sync_refinement.h:105
@ T_LED_SYNC_SAMPLE_PSSENSE_MODE_BG
"BG", blink certain LEDs with a brightness curve over a set of frames, then fit a curve to that measu...
Definition t_led_sync_refinement.h:115
@ T_LED_SYNC_SAMPLE_PSSENSE_MODE_STABLE
"STABLE", all LEDs blink narrowly on the trimmed cycle, holding sync with nothing measured.
Definition t_led_sync_refinement.h:117
#define T_LED_SYNC_SEEN_LEDS_ACCUMULATION_BUFFER_SIZE
How many elements are in the seen LEDs ring buffer.
Definition t_led_sync_refinement.h:28
t_led_sync_refinement_flags
Flags to control the behavior of the LED sync refinement routine.
Definition t_led_sync_refinement.h:45
@ T_LED_SYNC_REFINEMENT_FLAGS_PS_SENSE
Whether the device we're syncing is specifically a PS VR2 controller ("pssense"), and so has access t...
Definition t_led_sync_refinement.h:67
@ T_LED_SYNC_REFINEMENT_FLAGS_BLINK_DURATION
Whether to try to optimize the blink duration after finding an offset, to lessen power usage.
Definition t_led_sync_refinement.h:48
@ T_LED_SYNC_REFINEMENT_FLAGS_OPTICAL_DRIVEN_OFFSET
Whether to lock in a clock offset and have it be driven entirely by the sync refinement,...
Definition t_led_sync_refinement.h:57
@ T_LED_SYNC_REFINEMENT_FLAGS_HAS_LATENCY_CAP
Whether the device has specified a maximum latency cap.
Definition t_led_sync_refinement.h:62
t_led_sync_phase
Definition t_led_sync_refinement.h:160
@ T_LED_SYNC_PHASE_MAINTAIN_OFFSET
We've found an offset and optimized the center of the LED blink to the center of the exposure.
Definition t_led_sync_refinement.h:176
@ T_LED_SYNC_PHASE_REFINE_BLINK_DURATION
We've found an offset, now we can optimize the blink duration to something that keeps it tracking.
Definition t_led_sync_refinement.h:174
@ T_LED_SYNC_PHASE_OPTIMIZE_BRIGHTNESS_CURVE
Trying to optimize the brightness curve for the correct time offset.
Definition t_led_sync_refinement.h:172
@ T_LED_SYNC_PHASE_FIND_INITIAL_OFFSET
Trying to find some offset that gets us in sync at all.
Definition t_led_sync_refinement.h:164
@ T_LED_SYNC_PHASE_FIND_LEFT_EDGE
Trying to align the falling edge of the LED blinks with the rising edge of the camera exposure.
Definition t_led_sync_refinement.h:168
@ T_LED_SYNC_PHASE_STABLE
PS Sense only, BG has converged so the LEDs hold sync on the trimmed cycle until BG checks them again...
Definition t_led_sync_refinement.h:178
@ T_LED_SYNC_PHASE_DECODE_GRAY
Trying to decode the Gray codes present in the LEDs we've selected.
Definition t_led_sync_refinement.h:170
@ T_LED_SYNC_PHASE_INIT
The initial phase, where we haven't made any adjustments yet.
Definition t_led_sync_refinement.h:162
@ T_LED_SYNC_PHASE_FIND_RIGHT_EDGE
Trying to align the rising edge of the LED blinks with the falling edge of the camera exposure.
Definition t_led_sync_refinement.h:166
#define T_LED_SYNC_BRIGHTNESS_CURVE_NUM_SAMPLES
20 frames per sample
Definition t_led_sync_refinement.h:32
#define T_LED_SYNC_GRAY_CODE_SIZE_BITS
The amount of bits in the full gray code we're decoding.
Definition t_led_sync_refinement.h:30
Header defining interfaces for time synchronization in Monado.
Tracking API interface.
Basic logging functionality.
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.