The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
fb.h File Reference

Go to the source code of this file.

Data Structures

struct  fb_info_t
 framebuffer geometry and pixel format, filled by fbinfo(). More...

Functions

bool fb_init (const boot_info_t *boot)
 initialize the framebuffer from the boot info and map it into the address space.
bool fb_available (void)
 whether fb_init() found and mapped a framebuffer.
const fb_info_t * fb_get_info (void)
 read-only view of the framebuffer geometry/format.
uint32_t fb_pack_rgb (uint8_t r, uint8_t g, uint8_t b)
 compose a pixel value from 8-bit r/g/b according to the framebuffer masks.
void fb_put_pixel (uint32_t x, uint32_t y, uint32_t pixel)
 write one pixel.
void fb_fill_rect (uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t pixel)
 fill a rectangle with a packed pixel value.
void fb_clear (uint32_t pixel)
 clear the whole framebuffer to a packed pixel value.
void fb_copy_rect (uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y, uint32_t w, uint32_t h)
 copy a rectangle from one position to another (used for scrolling).
void fb_flush (void)
 push all pending drawing to the visible framebuffer.
void fb_release_graphics (void)
 give the screen back to the console (FBIO_GRAPHICS): the next fb_flush draws the whole console again.
bool fb_set_mode (uint32_t width, uint32_t height)
 change the mode with the display driver (32 bits per pixel).

Function Documentation

◆ fb_init()

bool fb_init ( const boot_info_t * boot)

initialize the framebuffer from the boot info and map it into the address space.

must be called after paging_init(), since the framebuffer lives at a high physical address outside the identity-mapped RAM range.

Parameters
bootthe boot information from the bootloader.
Returns
true if a usable framebuffer was set up, false if none is present.

◆ fb_available()

bool fb_available ( void )

whether fb_init() found and mapped a framebuffer.

◆ fb_get_info()

const fb_info_t * fb_get_info ( void )

read-only view of the framebuffer geometry/format.

valid after fb_init() returns true.

◆ fb_pack_rgb()

uint32_t fb_pack_rgb ( uint8_t r,
uint8_t g,
uint8_t b )

compose a pixel value from 8-bit r/g/b according to the framebuffer masks.

Returns
the packed pixel, ready to store at a pixel address.

◆ fb_put_pixel()

void fb_put_pixel ( uint32_t x,
uint32_t y,
uint32_t pixel )

write one pixel.

out-of-bounds coordinates are ignored.

Parameters
xcolumn,
yrow,
pixelpacked pixel from fb_pack_rgb().

◆ fb_fill_rect()

void fb_fill_rect ( uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
uint32_t pixel )

fill a rectangle with a packed pixel value.

clipped to the framebuffer.

◆ fb_clear()

void fb_clear ( uint32_t pixel)

clear the whole framebuffer to a packed pixel value.

◆ fb_copy_rect()

void fb_copy_rect ( uint32_t dst_x,
uint32_t dst_y,
uint32_t src_x,
uint32_t src_y,
uint32_t w,
uint32_t h )

copy a rectangle from one position to another (used for scrolling).

source and destination may overlap vertically; rows are copied in an order that is safe for an upward move (dst_y < src_y).

◆ fb_flush()

void fb_flush ( void )

push all pending drawing to the visible framebuffer.

when a back buffer is in use, drawing ops render into RAM and mark dirty scanlines; this copies the dirty range out to the (slow, uncached) linear framebuffer in one pass. cheap to call after every batch of output. a no-op when running unbuffered.

◆ fb_release_graphics()

void fb_release_graphics ( void )

give the screen back to the console (FBIO_GRAPHICS): the next fb_flush draws the whole console again.

a kernel panic calls it.

◆ fb_set_mode()

bool fb_set_mode ( uint32_t width,
uint32_t height )

change the mode with the display driver (32 bits per pixel).

the text grid stays as it is; what does not fit is not drawn.

Returns
false without a driver, or if the driver cannot set the size.