Just using the framebuffer - nanochan


oc/ - Original Content - Share your own art, code, and music



Onion Details



Page Clicks: 0

First Seen: 03/11/2024

Last Indexed: 10/21/2024

Domain Index Total: 313



Onion Content



/oc/ - Original Content Share your own art, code, and music [Make a Post] Just using the framebuffer Nanonymous 2020-11-21 22:56:56 No. 967 (L) [D] [S] [L] [A] [C] Here's some C that works for /dev/fb0: // * #include #include #include #include #include #include #include #include int main() { const char *fbPath = "/dev/fb0"; int fb = open(fbPath, O_RDWR); if (fb < 0) err(EX_OSFILE, "%s", fbPath); struct fb_var_screeninfo info; int error = ioctl(fb, FBIOGET_VSCREENINFO, &info); if (error) err(EX_IOERR, "%s", fbPath); size_t size = 4 * info.xres * info.yres; uint32_t *buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0); if (buf == MAP_FAILED) err(EX_IOERR, "%s", fbPath); for (int i=2000; i<2500; i++) { uint8_t red = 155; uint8_t green = 255; uint8_t blue = 55; buf[i] = red << 16 | green << 8 | blue; } return 0; } // * But I was having trouble using a common lisp mmap like https://shinmera.github.io/mmap/ ;; (require 'mmap) ;; works for a file ~/foo: (mmap:with-mmap (addr fd size #p"~/foo" :open :write :protection :write :mmap :shared) (setf (cffi:mem-aref addr :int 0) 255) (mmap::u-msync addr size 4)) ;; Doesn't work: (mmap:with-mmap (addr fd size #p"/dev/fb0" :open :write :protection :write :mmap :shared) (setf (cffi:mem-aref addr :int 0) 255) (mmap::u-msync addr size 4)) ;; I guess I can exactly reproduce that C using osicat-posix and cffi. I would like to use as little c and as much lisp as possible. Nanonymous 2020-11-21 23:11:33 No. 968 [D] ultimately you're going to have to deal with the C braindamage of reconstructing the C structures in LISP. The best way to go about this is to write OS from scratch. hapas already have DRM framebuffer code in SML lol Nanonymous 2021-06-08 22:43:30 No. 1732 [D] You should probably not deal with the framebuffer yourself, IMO. [Catalog] [Overboard] [Update] [Reply] 0 files, 2 replies