/* piboot Copyright 2025 metamuffin This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License only. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { char *fbpath = "/dev/fb0"; if (argc >= 2) fbpath = argv[1]; int fd = open(fbpath, O_CLOEXEC | O_WRONLY); if (fd < 0) { fprintf(stderr, "cannot open fbdev %s: %s\n", fbpath, strerror(errno)); return 1; } 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); for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { if (x < sidepad || x >= h + sidepad) continue; int base = (x + y * w) * 4; int u = (x - sidepad) * 256 / h, v = y * 256 / h; frame[base + 0] = v; frame[base + 1] = u; frame[base + 2] = 255 - v; } res = write(fd, frame, w * h * 4); if (res < 0) { fprintf(stderr, "cannot write to fb0: %s\n", strerror(errno)); return 1; } return 0; }