| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- //
- // Copyright 2026 Aarav Ravindra Kharade
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- //
- /*
- * ArkOS Framebuffer Helper
- * ------------------------
- * Thin C wrappers around Linux framebuffer ioctl calls.
- * These are called from Swift via @_silgen_name interop since
- * Swift cannot directly invoke ioctl with its variadic signature.
- *
- * Functions:
- * get_vinfo() — Query variable screen info (resolution, bpp)
- * get_finfo() — Query fixed screen info (line length, memory size)
- * set_vinfo() — Set variable screen info (mode changes)
- * pan_display() — Page flip (swap front/back buffer)
- * blank_display() — Blank or unblank the display (power management)
- */
- #include <sys/ioctl.h>
- #include <linux/fb.h>
- /* Query the current video mode (resolution, bits per pixel, etc.) */
- int get_vinfo(int fd, struct fb_var_screeninfo *vinfo) {
- return ioctl(fd, FBIOGET_VSCREENINFO, vinfo);
- }
- /* Query fixed screen parameters (line length, framebuffer size, etc.) */
- int get_finfo(int fd, struct fb_fix_screeninfo *finfo) {
- return ioctl(fd, FBIOGET_FSCREENINFO, finfo);
- }
- /* Set variable screen info (used for mode changes and virtual resolution) */
- int set_vinfo(int fd, struct fb_var_screeninfo *vinfo) {
- return ioctl(fd, FBIOPUT_VSCREENINFO, vinfo);
- }
- /* Page flip — sets the visible portion of the virtual framebuffer */
- int pan_display(int fd, struct fb_var_screeninfo *vinfo) {
- return ioctl(fd, FBIOPAN_DISPLAY, vinfo);
- }
- /* Blank or unblank the display (0=unblank, 1=blank for power saving) */
- int blank_display(int fd, int mode) {
- return ioctl(fd, FBIOBLANK, mode);
- }
|