chore: Apply code formatting
This commit is contained in:
@@ -28,7 +28,8 @@ typedef uint32_t (*ddr_io_read_pad_t)(void);
|
||||
typedef void (*ddr_io_set_lights_extio_t)(uint32_t extio_lights);
|
||||
typedef void (*ddr_io_set_lights_p3io_t)(uint32_t p3io_lights);
|
||||
typedef void (*ddr_io_set_lights_hdxs_panel_t)(uint32_t hdxs_lights);
|
||||
typedef void (*ddr_io_set_lights_hdxs_rgb_t)(uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
|
||||
typedef void (*ddr_io_set_lights_hdxs_rgb_t)(
|
||||
uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
|
||||
typedef void (*ddr_io_fini_t)(void);
|
||||
|
||||
static HMODULE _child_ddr_io_module;
|
||||
@@ -66,10 +67,7 @@ static int _io_thread_proc(void *ctx)
|
||||
|
||||
uint32_t local_tmp;
|
||||
|
||||
atomic_store_explicit(
|
||||
&_io_thread_proc_running,
|
||||
true,
|
||||
memory_order_seq_cst);
|
||||
atomic_store_explicit(&_io_thread_proc_running, true, memory_order_seq_cst);
|
||||
|
||||
log_info("IO thread running");
|
||||
|
||||
@@ -85,18 +83,16 @@ static int _io_thread_proc(void *ctx)
|
||||
local_tmp = _child_ddr_io_read_pad();
|
||||
|
||||
atomic_store_explicit(
|
||||
&_child_ddr_io_data_pad,
|
||||
local_tmp,
|
||||
memory_order_relaxed);
|
||||
&_child_ddr_io_data_pad, local_tmp, memory_order_relaxed);
|
||||
|
||||
// Only update outputs when they change gives this loop a major performance boost
|
||||
// The write calls on a p3io for the outputs are very expensive (~12 ms) as they
|
||||
// are executed over the ACIO protocol compared to only the input read
|
||||
// calls (~4 ms) which have a dedicated IOCTL call/endpoint
|
||||
// Only update outputs when they change gives this loop a major
|
||||
// performance boost The write calls on a p3io for the outputs are very
|
||||
// expensive (~12 ms) as they are executed over the ACIO protocol
|
||||
// compared to only the input read calls (~4 ms) which have a dedicated
|
||||
// IOCTL call/endpoint
|
||||
|
||||
local_tmp = atomic_load_explicit(
|
||||
&_child_ddr_io_data_extio_lights,
|
||||
memory_order_relaxed);
|
||||
&_child_ddr_io_data_extio_lights, memory_order_relaxed);
|
||||
|
||||
if (local_tmp != prev_child_ddr_io_data_extio_lights) {
|
||||
_child_ddr_io_set_lights_extio(local_tmp);
|
||||
@@ -104,9 +100,8 @@ static int _io_thread_proc(void *ctx)
|
||||
}
|
||||
|
||||
local_tmp = atomic_load_explicit(
|
||||
&_child_ddr_io_data_p3io_lights,
|
||||
memory_order_relaxed);
|
||||
|
||||
&_child_ddr_io_data_p3io_lights, memory_order_relaxed);
|
||||
|
||||
if (local_tmp != prev_child_ddr_io_data_p3io_lights) {
|
||||
_child_ddr_io_set_lights_p3io(local_tmp);
|
||||
prev_child_ddr_io_data_p3io_lights = local_tmp;
|
||||
@@ -121,22 +116,23 @@ static int _io_thread_proc(void *ctx)
|
||||
time_end = time_get_counter();
|
||||
total_time = time_get_elapsed_us(time_end - time_start);
|
||||
|
||||
log_info("IO thread performance: total iterations %lld, avg. loop cycle time %f us",
|
||||
loop_counter, ((double) total_time) / loop_counter);
|
||||
log_info(
|
||||
"IO thread performance: total iterations %lld, avg. loop cycle time %f "
|
||||
"us",
|
||||
loop_counter,
|
||||
((double) total_time) / loop_counter);
|
||||
|
||||
atomic_store_explicit(
|
||||
&_io_thread_proc_running,
|
||||
false,
|
||||
memory_order_seq_cst);
|
||||
&_io_thread_proc_running, false, memory_order_seq_cst);
|
||||
|
||||
log_info("IO thread shut down");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* _load_function(HMODULE module, const char* name)
|
||||
static void *_load_function(HMODULE module, const char *name)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
ptr = GetProcAddress(module, name);
|
||||
|
||||
@@ -175,13 +171,19 @@ bool ddr_io_init(
|
||||
return false;
|
||||
}
|
||||
|
||||
_child_ddr_io_set_loggers = _load_function(_child_ddr_io_module, "ddr_io_set_loggers");
|
||||
_child_ddr_io_set_loggers =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_set_loggers");
|
||||
_child_ddr_io_init = _load_function(_child_ddr_io_module, "ddr_io_init");
|
||||
_child_ddr_io_read_pad = _load_function(_child_ddr_io_module, "ddr_io_read_pad");
|
||||
_child_ddr_io_set_lights_extio = _load_function(_child_ddr_io_module, "ddr_io_set_lights_extio");
|
||||
_child_ddr_io_set_lights_p3io = _load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io");
|
||||
_child_ddr_io_set_lights_hdxs_panel = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel");
|
||||
_child_ddr_io_set_lights_hdxs_rgb = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb");
|
||||
_child_ddr_io_read_pad =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_read_pad");
|
||||
_child_ddr_io_set_lights_extio =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_set_lights_extio");
|
||||
_child_ddr_io_set_lights_p3io =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io");
|
||||
_child_ddr_io_set_lights_hdxs_panel =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel");
|
||||
_child_ddr_io_set_lights_hdxs_rgb =
|
||||
_load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb");
|
||||
_child_ddr_io_fini = _load_function(_child_ddr_io_module, "ddr_io_fini");
|
||||
|
||||
_child_ddr_io_set_loggers(
|
||||
@@ -199,10 +201,7 @@ bool ddr_io_init(
|
||||
return false;
|
||||
}
|
||||
|
||||
atomic_store_explicit(
|
||||
&_io_thread_proc_loop,
|
||||
true,
|
||||
memory_order_seq_cst);
|
||||
atomic_store_explicit(&_io_thread_proc_loop, true, memory_order_seq_cst);
|
||||
|
||||
if (!thread_create(_io_thread_proc, NULL, 16384, 0)) {
|
||||
log_warning("Creating IO thread failed");
|
||||
@@ -224,17 +223,13 @@ uint32_t ddr_io_read_pad(void)
|
||||
void ddr_io_set_lights_extio(uint32_t extio_lights)
|
||||
{
|
||||
atomic_store_explicit(
|
||||
&_child_ddr_io_data_extio_lights,
|
||||
extio_lights,
|
||||
memory_order_relaxed);
|
||||
&_child_ddr_io_data_extio_lights, extio_lights, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void ddr_io_set_lights_p3io(uint32_t p3io_lights)
|
||||
{
|
||||
atomic_store_explicit(
|
||||
&_child_ddr_io_data_p3io_lights,
|
||||
p3io_lights,
|
||||
memory_order_relaxed);
|
||||
&_child_ddr_io_data_p3io_lights, p3io_lights, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void ddr_io_set_lights_hdxs_panel(uint32_t lights)
|
||||
@@ -249,14 +244,12 @@ void ddr_io_set_lights_hdxs_rgb(uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
|
||||
|
||||
void ddr_io_fini(void)
|
||||
{
|
||||
atomic_store_explicit(
|
||||
&_io_thread_proc_loop,
|
||||
false,
|
||||
memory_order_seq_cst);
|
||||
atomic_store_explicit(&_io_thread_proc_loop, false, memory_order_seq_cst);
|
||||
|
||||
log_info("Shutting down IO thread and waiting for it to finish...");
|
||||
|
||||
while (atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) {
|
||||
while (
|
||||
atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) {
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user