diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-27 16:17:16 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-27 16:17:16 +0200 |
commit | 611aa4a16e1fd8976dd853d1b2f2192a20b2c067 (patch) | |
tree | d02d19111f844fa149144b32a1009b0f63abbfe2 | |
parent | 0de1bfc5f4b79ed4cce3078e4abcfa3a47793a59 (diff) | |
download | piboot-611aa4a16e1fd8976dd853d1b2f2192a20b2c067.tar piboot-611aa4a16e1fd8976dd853d1b2f2192a20b2c067.tar.bz2 piboot-611aa4a16e1fd8976dd853d1b2f2192a20b2c067.tar.zst |
-rw-r--r-- | piboot.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -16,10 +16,12 @@ */ #include <errno.h> #include <fcntl.h> +#include <linux/fb.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/ioctl.h> #include <unistd.h> int main(int argc, char **argv) { @@ -28,11 +30,18 @@ int main(int argc, char **argv) { fbpath = argv[1]; int fd = open(fbpath, O_CLOEXEC | O_WRONLY); if (fd < 0) { - fprintf(stderr, "cannot open fb0: %s\n", strerror(errno)); + fprintf(stderr, "cannot open fbdev %s: %s\n", fbpath, strerror(errno)); return 1; } - int w = 1920, h = 1080; + struct fb_var_screeninfo sinfo; + int res = ioctl(fd, FBIOGET_VSCREENINFO, &sinfo); + if (res < 0) { + fprintf(stderr, "cannot get fbdev info: %s\n", strerror(errno)); + return 1; + } + + int w = sinfo.xres_virtual, h = sinfo.yres_virtual; int sidepad = (w - h) / 2; uint8_t *frame = malloc(w * h * 4); memset(frame, 0, w * h * 4); @@ -48,7 +57,7 @@ int main(int argc, char **argv) { frame[base + 2] = 255 - v; } - int res = write(fd, frame, w * h * 4); + res = write(fd, frame, w * h * 4); if (res < 0) { fprintf(stderr, "cannot write to fb0: %s\n", strerror(errno)); return 1; |