Make blank_fb() into a more generic write_bool() function

This commit is contained in:
Cameron Gutman 2022-11-08 21:45:27 -06:00
parent b2192eda25
commit f16dc469af
3 changed files with 10 additions and 10 deletions

View File

@ -104,13 +104,13 @@ void platform_start(enum platform system) {
switch (system) { switch (system) {
#ifdef HAVE_AML #ifdef HAVE_AML
case AML: case AML:
blank_fb("/sys/class/graphics/fb0/blank", true); write_bool("/sys/class/graphics/fb0/blank", true);
blank_fb("/sys/class/graphics/fb1/blank", true); write_bool("/sys/class/graphics/fb1/blank", true);
break; break;
#endif #endif
#if defined(HAVE_PI) | defined(HAVE_MMAL) #if defined(HAVE_PI) | defined(HAVE_MMAL)
case PI: case PI:
blank_fb("/sys/class/graphics/fb0/blank", true); write_bool("/sys/class/graphics/fb0/blank", true);
break; break;
#endif #endif
} }
@ -120,13 +120,13 @@ void platform_stop(enum platform system) {
switch (system) { switch (system) {
#ifdef HAVE_AML #ifdef HAVE_AML
case AML: case AML:
blank_fb("/sys/class/graphics/fb0/blank", false); write_bool("/sys/class/graphics/fb0/blank", false);
blank_fb("/sys/class/graphics/fb1/blank", false); write_bool("/sys/class/graphics/fb1/blank", false);
break; break;
#endif #endif
#if defined(HAVE_PI) | defined(HAVE_MMAL) #if defined(HAVE_PI) | defined(HAVE_MMAL)
case PI: case PI:
blank_fb("/sys/class/graphics/fb0/blank", false); write_bool("/sys/class/graphics/fb0/blank", false);
break; break;
#endif #endif
} }

View File

@ -25,13 +25,13 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
int blank_fb(char *path, bool clear) { int write_bool(char *path, bool val) {
int fd = open(path, O_RDWR); int fd = open(path, O_RDWR);
if(fd >= 0) { if(fd >= 0) {
int ret = write(fd, clear ? "1" : "0", 1); int ret = write(fd, val ? "1" : "0", 1);
if (ret < 0) if (ret < 0)
fprintf(stderr, "Failed to clear framebuffer %s: %d\n", path, ret); fprintf(stderr, "Failed to write %d to %s: %d\n", val ? 1 : 0, path, ret);
close(fd); close(fd);
return 0; return 0;

View File

@ -19,5 +19,5 @@
#include <stdbool.h> #include <stdbool.h>
int blank_fb(char *path, bool clear); int write_bool(char *path, bool val);
int read_file(char *path, char *output, int output_len); int read_file(char *path, char *output, int output_len);