fb_helper.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * ArkOS Framebuffer Helper
  3. * ------------------------
  4. * Thin C wrappers around Linux framebuffer ioctl calls.
  5. * These are called from Swift via @_silgen_name interop since
  6. * Swift cannot directly invoke ioctl with its variadic signature.
  7. *
  8. * Functions:
  9. * get_vinfo() — Query variable screen info (resolution, bpp)
  10. * get_finfo() — Query fixed screen info (line length, memory size)
  11. * set_vinfo() — Set variable screen info (mode changes)
  12. * pan_display() — Page flip (swap front/back buffer)
  13. * blank_display() — Blank or unblank the display (power management)
  14. */
  15. #include <sys/ioctl.h>
  16. #include <linux/fb.h>
  17. /* Query the current video mode (resolution, bits per pixel, etc.) */
  18. int get_vinfo(int fd, struct fb_var_screeninfo *vinfo) {
  19. return ioctl(fd, FBIOGET_VSCREENINFO, vinfo);
  20. }
  21. /* Query fixed screen parameters (line length, framebuffer size, etc.) */
  22. int get_finfo(int fd, struct fb_fix_screeninfo *finfo) {
  23. return ioctl(fd, FBIOGET_FSCREENINFO, finfo);
  24. }
  25. /* Set variable screen info (used for mode changes and virtual resolution) */
  26. int set_vinfo(int fd, struct fb_var_screeninfo *vinfo) {
  27. return ioctl(fd, FBIOPUT_VSCREENINFO, vinfo);
  28. }
  29. /* Page flip — sets the visible portion of the virtual framebuffer */
  30. int pan_display(int fd, struct fb_var_screeninfo *vinfo) {
  31. return ioctl(fd, FBIOPAN_DISPLAY, vinfo);
  32. }
  33. /* Blank or unblank the display (0=unblank, 1=blank for power saving) */
  34. int blank_display(int fd, int mode) {
  35. return ioctl(fd, FBIOBLANK, mode);
  36. }