Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for upto 60s for /dev/fb0 to become available #59

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion c_src/device/cairo/cairo_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>

#include "cairo_ctx.h"
#include "comms.h"
#include "device.h"
#include "fontstash.h"
#include "scenic_ops.h"

#define FB0_TIMEOUT 60 //seconds
crertel marked this conversation as resolved.
Show resolved Hide resolved
const char* device = "/dev/fb0";

typedef struct {
Expand Down Expand Up @@ -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;
}
Expand Down