How to write directly to linux framebuffer?
The framebuffer console can be enabled by using your favorite kernel configuration tool. It is under Device Drivers->Graphics Support->Frame buffer Devices->Console display driver support->Framebuffer Console Support. Select 'y' to compile support statically or 'm' for module support. The module will be fbcon.
The frame buffer device provides an abstraction for the graphics hardware. It represents the frame buffer of some video hardware and allows application software to access the graphics hardware through a well-defined interface, so the software doesn't need to know anything about the low-level (hardware register) stuff.
Basically you open /dev/fb0, do some ioctls on it, then mmap it. Then you just write to the mmap'd area in your process.
A framebuffer is a continuous memory area, typically located within the address space of the CPU. In case of complex graphics systems (e.g. using OpenGL ES 2.0) a framebuffer is located within a separated video memory.
look at FBIOPUT_VSCREENINFO, ioctl and mmap
(I have the code but not at this pc, sorry)
edit: this should get you started
//open file descriptor and get info
inf fdScreen = open( "devicename", O_RDWR );
fb_var_screeninfo varInfo;
ioctl( fdScreen, FBIOGET_VSCREENINFO, &varInfo );
//set resolution/dpi/color depth/.. in varInfo, then write it back
ioctl( fdScreen, FBIOPUT_VSCREENINFO, &varInfo );
//get writable screen memory; unsigned short here for 16bit color
unsigned short* display = mmap( 0, nScreenSize,
PROT_READ | PROT_WRITE, MAP_SHARED, fdScreen, 0 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With