diff --git a/c_src/device/cairo/cairo_fb.c b/c_src/device/cairo/cairo_fb.c index a4934f1..85286e2 100644 --- a/c_src/device/cairo/cairo_fb.c +++ b/c_src/device/cairo/cairo_fb.c @@ -2,11 +2,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "cairo_ctx.h" #include "comms.h" @@ -14,6 +16,7 @@ #include "fontstash.h" #include "scenic_ops.h" +#define FB0_TIMEOUT 60 //seconds const char* device = "/dev/fb0"; typedef struct { @@ -95,7 +98,15 @@ int device_init(const device_opts_t* p_opts, p_info->v_ctx = p_ctx; - if ((g_cairo_fb.fd = open(device, O_RDWR)) == -1) { + time_t fb0_timer_start = time(NULL); + while ((time(NULL) - fb0_timer_start) < FB0_TIMEOUT) { + if ((g_cairo_fb.fd = open(device, O_RDWR)) != -1) { + break; + } + sched_yield(); + } + + if (g_cairo_fb.fd == -1) { log_error("Failed to open device %s: %s", device, strerror(errno)); return -1; }