Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write directly to linux framebuffer?

How to write directly to linux framebuffer?

like image 377
SomeUser Avatar asked Oct 06 '09 17:10

SomeUser


People also ask

How do I access framebuffer in Linux?

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.

How does framebuffer work Linux?

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.

How do I write to Dev fb0?

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.

Where is the framebuffer located?

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.


1 Answers

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 );
like image 75
stijn Avatar answered Sep 17 '22 17:09

stijn