Monado OpenXR Runtime
Loading...
Searching...
No Matches
led_sync_internal.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 Internal routines for LED sync code
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup tracking
8 */
9
10#pragma once
11
13
14#include "os/os_time.h"
15
16#include "util/u_time.h"
17
18
19/*
20 *
21 * Defines
22 *
23 */
24
25#define LOG_TRACE(refinement, ...) U_LOG_IFL_T(refinement->log_level, __VA_ARGS__)
26#define LOG_DEBUG(refinement, ...) U_LOG_IFL_D(refinement->log_level, __VA_ARGS__)
27#define LOG_INFO(refinement, ...) U_LOG_IFL_I(refinement->log_level, __VA_ARGS__)
28#define LOG_WARN(refinement, ...) U_LOG_IFL_W(refinement->log_level, __VA_ARGS__)
29#define LOG_ERROR(refinement, ...) U_LOG_IFL_E(refinement->log_level, __VA_ARGS__)
30
31//! The amount of frames to not see it for consider a device "not found" during an active search
32#define MAX_SAMPLE_LATENCY 3
33
34/*
35 *
36 * Helper functions
37 *
38 */
39
40static bool
41phase_uses_led_selection(enum t_led_sync_phase phase)
42{
43 switch (phase) {
46 default: return false;
47 }
48}
49
50//! The best frame period estimate, falling back to the per-frame interval until there is a long-run one.
51static double
53{
54 if (refinement->period_estimate.period_ns > 0.0) {
55 return refinement->period_estimate.period_ns;
56 }
57
58 return (double)refinement->exposure_interval_ns;
59}
60
61//! The host->device offset to publish, corrected by the LEDs' offset from the exposure so it follows the camera.
64{
65 return refinement->optical_driven_offset.saved_offset + clock_offset_ns +
66 (time_duration_ns)refinement->delta_sync.led_error_ns;
67}
68
70max_right_edge(struct t_led_sync_refinement *refinement)
71{
73 return refinement->options.latency_cap_ns;
74 } else {
75 return refinement->exposure_interval_ns - refinement->current_blink_duration_ns;
76 }
77}
78
79/*
80 *
81 * State update functions
82 *
83 */
84
85static void
86set_offset_duration_pssense(struct t_led_sync_refinement *refinement,
87 time_duration_ns clock_offset_ns,
88 time_duration_ns fudge_offset_ns,
89 time_duration_ns blink_duration_ns,
90 enum t_led_sync_sample_pssense_mode pssense_mode,
91 const struct t_led_sync_sample_pssense_data pssense_data)
92{
93 refinement->current_clock_offset_ns = clock_offset_ns;
94 refinement->current_blink_fudge_ns = fudge_offset_ns;
95 refinement->current_blink_duration_ns = blink_duration_ns;
96
97 refinement->has_sample_for_driver = true;
98 refinement->sample_applied = false;
99 refinement->sample_for_driver = XRT_C11_COMPOUND(struct t_led_sync_sample){
100 .timestamp.device_host_latency_ns = clock_offset_ns,
102 .fudge_offset_ns = fudge_offset_ns,
103 .blink_duration_ns = blink_duration_ns,
104 .pssense = pssense_data,
105 .pssense_mode = pssense_mode,
106 };
107
108 // If we're doing optical driven offset and have a saved offset, use that mode.
110 refinement->optical_driven_offset.has_saved_offset) {
111 refinement->sample_for_driver.timestamp_mode =
113 // In optical-driven mode the published offset is the host->device clock offset at the
114 // published epoch, while the skew term extrapolates away from that epoch. These two values
115 // must describe the same instant or IMU timestamp conversions will jump.
116 refinement->sample_for_driver.timestamp.host_device_clock_offset_ns =
117 model_clock_offset_ns(refinement, clock_offset_ns);
118 refinement->sample_for_driver.clock_skew = refinement->delta_sync.skew;
119 refinement->sample_for_driver.clock_epoch_ns = refinement->delta_sync.epoch_ns;
120 }
121
122 // Once BG has a base period, the controller's own cycle carries the skew.
123 if (refinement->delta_sync.base_period_ns > 0.0) {
125 refinement->delta_sync.base_period_ns * (1.0 + refinement->delta_sync.skew);
126 refinement->delta_sync.trim_pending = false;
127 }
128
129 LOG_TRACE(refinement,
130 "Setting offset to %" PRId64 "ns with fudge %" PRId64 "ns and blink duration to %" PRId64 "ns",
131 clock_offset_ns, fudge_offset_ns, blink_duration_ns);
132}
133
134static void
135set_offset_duration(struct t_led_sync_refinement *refinement,
136 time_duration_ns clock_offset_ns,
137 time_duration_ns fudge_offset_ns,
138 time_duration_ns blink_duration_ns)
139{
140 // Set some safe dummy data
141 struct t_led_sync_sample_pssense_data pssense_data = {
143 .leds = {0xFF, 0xFF, 0xFF, 0xFF},
144 };
145
146 set_offset_duration_pssense(refinement, //
147 clock_offset_ns, //
148 fudge_offset_ns, //
149 blink_duration_ns, //
151 pssense_data); //
152}
153
154static void
155set_centered_duration_from_binary_search(struct t_led_sync_refinement *refinement, time_duration_ns blink_duration_ns)
156{
157 // Find the clock offset, the offset needing to be applied to get blink start to line up with exposure
158 // start, this is the clock offset from the controller local clock (as we view it) -> host local clock.
159 time_duration_ns new_clock_offset_ns = refinement->found_left_edge_ns;
160
161 // Set the offset so that the center of the blink is at the center of the exposure, since latency and
162 // fudge offset are added together.
163 time_duration_ns new_fudge_offset_ns = (refinement->exposure_time_ns / 2) - (blink_duration_ns / 2);
164
165 set_offset_duration(refinement, new_clock_offset_ns, new_fudge_offset_ns, blink_duration_ns);
166}
167
168static void
169set_pssense_mode(struct t_led_sync_refinement *refinement, enum t_led_sync_sample_pssense_mode mode, uint8_t leds[4])
170{
171 const time_duration_ns blink_duration_ns = refinement->current_blink_duration_ns;
172
173 struct t_led_sync_sample_pssense_data data = {
174 .base_time_offset_ns = 0,
175 .leds =
176 {
177 0xFF,
178 0xFF,
179 0xFF,
180 0xFF,
181 },
182 };
183 if (leds != NULL) {
184 memcpy(data.leds, leds, sizeof(data.leds));
185 }
186
187 set_offset_duration_pssense(refinement, //
188 refinement->current_clock_offset_ns, //
189 refinement->current_blink_fudge_ns, //
190 blink_duration_ns, //
191 mode, //
192 data); //
193}
194
195XRT_CHECK_RESULT
196static bool
197advance_clock_offset_pssense_locked(struct t_led_sync_refinement *refinement, time_duration_ns offset_ns)
198{
199 // Assert that this is a pssense refinement.
201 // Assert that we're in a phase where base time moves are deltas.
202 assert(refinement->phase == T_LED_SYNC_PHASE_DECODE_GRAY ||
204 refinement->phase == T_LED_SYNC_PHASE_STABLE);
205
206 if (refinement->has_sample_for_driver) {
207 return false;
208 }
209
210 // Copy the latest data
211 struct t_led_sync_sample_pssense_data data = refinement->sample_for_driver.pssense;
212 // Push a new time offset
213 data.base_time_offset_ns = (int32_t)offset_ns;
214
215 set_offset_duration_pssense(refinement, //
216 refinement->current_clock_offset_ns + offset_ns, //
217 refinement->current_blink_fudge_ns, //
218 refinement->current_blink_duration_ns, //
219 refinement->sample_for_driver.pssense_mode, //
220 data); //
221
222 return true;
223}
224
225static void
226set_phase_locked(struct t_led_sync_refinement *refinement, enum t_led_sync_phase new_phase)
227{
228 enum t_led_sync_phase old_phase = refinement->phase;
229 refinement->phase = new_phase;
230
231 LOG_INFO(refinement, "Transitioning from search phase %d -> %d", old_phase, new_phase);
232
233 switch (old_phase) {
235 // If we're doing clock driven offset, now's when we save the offset, since we're about to start our
236 // binary search.
238 refinement->optical_driven_offset.has_saved_offset = true;
239 refinement->optical_driven_offset.saved_offset =
240 refinement->optical_driven_offset.driver_host_device_clock_offset_ns;
241 }
242
243 break;
244 }
246 // We should have both edges by now
247 assert(refinement->found_right_edge_ns > -1);
248 assert(refinement->found_left_edge_ns > -1);
249
250 set_centered_duration_from_binary_search(refinement, refinement->current_blink_duration_ns);
251 break;
252 }
253 default: break;
254 }
255
256 if (phase_uses_led_selection(new_phase)) {
257 refinement->leds_seen.last_selection_ns = 0; // reset
258 refinement->leds_seen.num_samples = 0; // reset
259 }
260
261 switch (new_phase) {
263 refinement->found_left_edge_ns = -1;
264 refinement->found_right_edge_ns = -1;
265
267
268 refinement->optical_driven_offset.has_saved_offset = false;
269
270 // Re-estimate the clock sync from scratch each BG session. These values were relative to the old saved
271 // offset, which is now cleared.
272 memset(&refinement->delta_sync, 0, sizeof(refinement->delta_sync));
273
274 set_offset_duration(refinement, 0, 0, refinement->current_blink_duration_ns);
275
276 break;
277 }
279 // Left bound is the current offset
280 refinement->binary_search_state.left_bound_ns = refinement->current_blink_fudge_ns;
281 // Right bound is the start of the next exposure minus the blink duration, we don't want to blink into
282 // the next frame, rather start at zero, since latency will always be >0.
283 refinement->binary_search_state.right_bound_ns = max_right_edge(refinement);
284
285 LOG_DEBUG(refinement,
286 "Starting binary search for right edge, left bound at: %" PRId64
287 "ns, right bound at: %" PRId64 "ns",
288 refinement->binary_search_state.left_bound_ns,
289 refinement->binary_search_state.right_bound_ns);
290
291 time_duration_ns new_offset_ns =
292 (refinement->binary_search_state.right_bound_ns + refinement->binary_search_state.left_bound_ns) /
293 2;
294 set_offset_duration(refinement, 0, new_offset_ns, refinement->current_blink_duration_ns);
295
296 break;
297 }
299 // We should always have a right edge by now
300 assert(refinement->found_right_edge_ns > -1);
301
302 // Left bound is when the exposure *should* be given zero latency
303 refinement->binary_search_state.left_bound_ns = 0;
304 // Right bound is the found right edge
305 refinement->binary_search_state.right_bound_ns = refinement->found_right_edge_ns;
306
307 LOG_DEBUG(refinement, "Starting binary search for left edge, right edge at: %" PRId64 "ns",
308 refinement->found_right_edge_ns);
309
310 time_duration_ns new_offset_ns =
311 (refinement->binary_search_state.right_bound_ns + refinement->binary_search_state.left_bound_ns) /
312 2;
313 set_offset_duration(refinement, 0, new_offset_ns, refinement->current_blink_duration_ns);
314
315 break;
316 }
318 // PSSENSE requires a period id of 42 (2.1ms) for BROAD
319 time_duration_ns new_blink_duration_ns = U_TIME_1US_IN_NS * 2100;
320
321 time_duration_ns new_fudge_offset_ns = (refinement->exposure_time_ns / 2) - (new_blink_duration_ns / 2);
322 // Pick the clock offset that will when added to the new blink fudge will produce the same value,
323 // this is our rough clock estimate that we are going to refine.
324 time_duration_ns new_clock_offset_ns = refinement->current_blink_fudge_ns - new_fudge_offset_ns;
325
326 // The absolute write below puts the LEDs exactly where the clock model says, track the cycle from here.
327 refinement->delta_sync.base_period_ns = frame_period_ns(refinement);
328 refinement->delta_sync.anchor_sequence_id = refinement->last_exposure_sequence_id;
329 refinement->delta_sync.anchor_ns = refinement->last_exposure_ns;
330
331 // Set the new offset/fudge so that our fudge is what we want, but we're about to refine the new clock
332 // offset.
333 set_offset_duration(refinement, new_clock_offset_ns, new_fudge_offset_ns, new_blink_duration_ns);
334
335 refinement->decode_gray.applied_gray_start = false;
336 refinement->decode_gray.matching_decodes = 0;
337 refinement->decode_gray.decoded_gray_code = 0;
338 refinement->decode_gray.last_accepted_gray_code_ns = os_monotonic_get_ns();
339
340 break;
341 }
343 // PSSENSE requires a period id of 30 (1.5ms) for BG
344 time_duration_ns new_blink_duration_ns = U_TIME_1US_IN_NS * 1500;
345
346 time_duration_ns new_fudge_offset_ns = (refinement->exposure_time_ns / 2) - (new_blink_duration_ns / 2);
347 time_duration_ns new_clock_offset_ns = refinement->current_clock_offset_ns;
348
349 // update us to the right offset when moving from broad to bg, keep blink centered with the new duration
350 refinement->sample_for_driver.pssense.base_time_offset_ns =
351 new_fudge_offset_ns - refinement->current_blink_fudge_ns;
352
353 struct t_led_sync_delta_sync *bg = &refinement->delta_sync;
354
355 // Back from STABLE the skew and clock model carry on, only the measurements start over.
356 if (old_phase == T_LED_SYNC_PHASE_STABLE) {
357 // Reset
358 memset(refinement->sample_for_driver.pssense.leds, 0xFF,
359 sizeof(refinement->optimize_brightness_curve.leds));
360 // Copy in the two LEDs
361 memcpy(refinement->sample_for_driver.pssense.leds, refinement->optimize_brightness_curve.leds,
362 sizeof(refinement->optimize_brightness_curve.leds));
363 bg->has_led_error = false;
364 bg->num_samples = 0;
365 bg->sum_t = bg->sum_tt = bg->sum_d = bg->sum_td = 0.0;
366 }
367
368 bg->num_windows = 0;
369 bg->converged_since_ns = 0;
371 refinement->optimize_brightness_curve.window_start_sequence_id = refinement->current_sequence_id + 1;
372
373 LOG_INFO(refinement, "BG base period %.1fns (estimate %.1fns, per-frame interval %" PRId64 "ns)",
374 refinement->delta_sync.base_period_ns, refinement->period_estimate.period_ns,
375 refinement->exposure_interval_ns);
376
377 set_offset_duration_pssense(refinement, //
378 new_clock_offset_ns, //
379 new_fudge_offset_ns, //
380 new_blink_duration_ns, //
382 refinement->sample_for_driver.pssense); //
383
384 break;
385 }
387 // PSSENSE uses a period id of 12 (600us) for STABLE, just wider than the exposure.
388 time_duration_ns new_blink_duration_ns = U_TIME_1US_IN_NS * 600;
389 time_duration_ns new_fudge_offset_ns = (refinement->exposure_time_ns / 2) - (new_blink_duration_ns / 2);
390
391 // Nothing is measured from here, so the LEDs take the last measured offset to land centered.
392 time_duration_ns residual_ns = (time_duration_ns)refinement->delta_sync.led_error_ns;
393 refinement->delta_sync.led_error_ns = 0.0;
394 refinement->delta_sync.been_stable = true;
395 refinement->delta_sync.stable_entry_ns = os_monotonic_get_ns();
396
397 // All the LEDs blink alike again, the sync pair is only needed for measuring.
398 struct t_led_sync_sample_pssense_data data = {
399 .base_time_offset_ns = new_fudge_offset_ns - refinement->current_blink_fudge_ns + residual_ns,
400 .leds = {0xFF, 0xFF, 0xFF, 0xFF},
401 };
402
403 LOG_INFO(refinement, "Entering STABLE, skew %f ppm, last offset %" PRId64 "ns",
404 refinement->delta_sync.skew * 1e6, residual_ns);
405
406 set_offset_duration_pssense(refinement, //
407 refinement->current_clock_offset_ns + residual_ns, //
408 new_fudge_offset_ns, //
409 new_blink_duration_ns, //
411 data); //
412
413 break;
414 }
416 refinement->blink_time_refinement_state.backing_off = false;
417 refinement->blink_time_refinement_state.last_good_blink_duration_ns =
418 refinement->current_blink_duration_ns;
419
420 break;
421 }
423 LOG_DEBUG(refinement, "Maintaining offset at: %" PRId64 "ns", refinement->current_clock_offset_ns);
424
425 break;
426 }
427 default: break;
428 }
429}
static int64_t os_monotonic_get_ns(void)
Return a monotonic clock in nanoseconds.
Definition os_time.h:317
int64_t time_duration_ns
Integer duration type in nanoseconds.
Definition u_time.h:88
static time_duration_ns model_clock_offset_ns(struct t_led_sync_refinement *refinement, time_duration_ns clock_offset_ns)
The host->device offset to publish, corrected by the LEDs' offset from the exposure so it follows the...
Definition led_sync_internal.h:63
static double frame_period_ns(struct t_led_sync_refinement *refinement)
The best frame period estimate, falling back to the per-frame interval until there is a long-run one.
Definition led_sync_internal.h:52
Wrapper around OS native time functions.
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
double period_ns
The last trusted estimate, 0 until there is one.
Definition t_led_sync_refinement.h:205
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
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
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
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
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
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
time_duration_ns exposure_interval_ns
The known interval between frames.
Definition t_led_sync_refinement.h:271
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 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
A routine to automatically refine latency offsets of LED blink times using constellation samples.
@ 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_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
@ 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_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_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
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
#define U_TIME_1US_IN_NS
The number of nanoseconds in a microsecond.
Definition u_time.h:61