Frame Buffer Library
The frame buffer drivers depend heavily on four data structures. These structures are declared in include/linux/fb.h. They are fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. The last three can be made available to and from userland.
fb_info defines the current state of a particular video card. Inside fb_info, there exists a fb_ops structure which is a collection of needed functions to make fbdev and fbcon work. fb_info is only visible to the kernel.
fb_var_screeninfo is used to describe the features of a video card that are user defined. With fb_var_screeninfo, things such as depth and the resolution may be defined.
The next structure is fb_fix_screeninfo. This defines the properties of a card that are created when a mode is set and can't be changed otherwise. A good example of this is the start of the frame buffer memory. This "locks" the address of the frame buffer memory, so that it cannot be changed or moved.
The last structure is fb_monospecs. In the old API, there was little importance for fb_monospecs. This allowed for forbidden things such as setting a mode of 800x600 on a fix frequency monitor. With the new API, fb_monospecs prevents such things, and if used correctly, can prevent a monitor from being cooked. fb_monospecs will not be useful until kernels 2.5.x.
Frame Buffer Memory #
register_framebuffer() #
int registers a frame buffer device
Parameters
struct fb_info *fb_info: frame buffer info structure
Description
Registers a frame buffer device fb_info.
Returns negative errno on error, or zero for success.
unregister_framebuffer() #
void releases a frame buffer device
Parameters
struct fb_info *fb_info: frame buffer info structure
Description
Unregisters a frame buffer device fb_info.
Returns negative errno on error, or zero for success.
This function will also notify the framebuffer console to release the driver.
This is meant to be called within a driver's module_exit()
function. If this is called outside module_exit(), ensure
that the driver implements fb_open() and fb_release() to
check that no processes are using the device.
devm_register_framebuffer() #
int resource-managed frame buffer device registration
Parameters
struct device *dev: device the framebuffer belongs tostruct fb_info *fb_info: frame buffer info structure
Description
Registers a frame buffer device fb_info to device dev.
Returns negative errno on error, or zero for success.
fb_set_suspend() #
void low level driver signals suspend
Parameters
struct fb_info *info: framebuffer affectedint state: 0 = resuming, !=0 = suspending
Description
This is meant to be used by low level drivers to signal suspend/resume to the core & clients. It must be called with the console semaphore held
Frame Buffer Colormap #
fb_dealloc_cmap() #
void deallocate a colormap
Parameters
struct fb_cmap *cmap: frame buffer colormap structure
Description
Deallocates a colormap that was previously allocated with
fb_alloc_cmap().
fb_copy_cmap() #
int copy a colormap
Parameters
const struct fb_cmap *from: frame buffer colormap structurestruct fb_cmap *to: frame buffer colormap structure
Description
Copy contents of colormap from from to to.
fb_set_cmap() #
int set the colormap
Parameters
struct fb_cmap *cmap: frame buffer colormap structurestruct fb_info *info: frame buffer info structure
Description
Sets the colormap cmap for a screen of device info.
Returns negative errno on error, or zero on success.
fb_default_cmap() #
const struct fb_cmap * get default colormap
Parameters
int len: size of palette for a depth
Description
Gets the default colormap for a specific screen depth. len is the size of the palette for a particular screen depth.
Returns pointer to a frame buffer colormap structure.
fb_invert_cmaps() #
void invert all defaults colormaps
Parameters
void: no arguments
Description
Invert all default colormaps.
Frame Buffer Video Mode Database #
fb_try_mode() #
int test a video mode
Parameters
struct fb_var_screeninfo *var: frame buffer user defined part of displaystruct fb_info *info: frame buffer info structureconst struct fb_videomode *mode: frame buffer video mode structureunsigned int bpp: color depth in bits per pixel
Description
Tries a video mode to test it's validity for device info.
Returns 1 on success.
fb_delete_videomode() #
void removed videomode entry from modelist
Parameters
const struct fb_videomode *mode: videomode to removestruct list_head *head: struct list_head of modelist
NOTES
Will remove all matching mode entries
fb_find_mode() #
int finds a valid video mode
Parameters
struct fb_var_screeninfo *var: frame buffer user defined part of displaystruct fb_info *info: frame buffer info structureconst char *mode_option: string video mode to findconst struct fb_videomode *db: video mode databaseunsigned int dbsize: size of dbconst struct fb_videomode *default_mode: default video mode to fall back tounsigned int default_bpp: default color depth in bits per pixel
Description
Finds a suitable video mode, starting with the specified mode in mode_option with fallback to default_mode. If default_mode fails, all modes in the video mode database will be tried.
Valid mode specifiers for mode_option:
<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][p][m]
or
<name>[-<bpp>][@<refresh>]
with <xres>, <yres>, <bpp> and <refresh> decimal numbers and <name> a string.
If 'M' is present after yres (and before refresh/bpp if present), the function will compute the timings using VESA(tm) Coordinated Video Timings (CVT). If 'R' is present after 'M', will compute with reduced blanking (for flatpanels). If 'i' or 'p' are present, compute interlaced or progressive mode. If 'm' is present, add margins equal to 1.8% of xres rounded down to 8 pixels, and 1.8% of yres. The char 'i', 'p' and 'm' must be after 'M' and 'R'. Example:
1024x768MR-8@60m - Reduced blank with margins at 60Hz.
NOTE
The passed struct var is not cleared! This allows you to supply values for e.g. the grayscale and accel_flags fields.
Returns zero for failure, 1 if using specified mode_option, 2 if using specified mode_option with an ignored refresh rate, 3 if default mode is used, 4 if fall back to any valid mode.
fb_var_to_videomode() #
void convert fb_var_screeninfo to fb_videomode
Parameters
struct fb_videomode *mode: pointer to struct fb_videomodeconst struct fb_var_screeninfo *var: pointer to struct fb_var_screeninfo
fb_videomode_to_var() #
void convert fb_videomode to fb_var_screeninfo
Parameters
struct fb_var_screeninfo *var: pointer to struct fb_var_screeninfoconst struct fb_videomode *mode: pointer to struct fb_videomode
fb_mode_is_equal() #
int compare 2 videomodes
Parameters
const struct fb_videomode *mode1: first videomodeconst struct fb_videomode *mode2: second videomode
Return
1 if equal, 0 if not
fb_find_best_mode() #
const struct fb_videomode * find best matching videomode
Parameters
const struct fb_var_screeninfo *var: pointer to struct fb_var_screeninfostruct list_head *head: pointer to struct list_head of modelist
Return
struct fb_videomode, NULL if none found
Description
IMPORTANT: This function assumes that all modelist entries in info->modelist are valid.
NOTES
Finds best matching videomode which has an equal or greater dimension than var->xres and var->yres. If more than 1 videomode is found, will return the videomode with the highest refresh rate
fb_find_nearest_mode() #
const struct fb_videomode * find closest videomode
Parameters
const struct fb_videomode *mode: pointer to struct fb_videomodestruct list_head *head: pointer to modelist
Description
Finds best matching videomode, smaller or greater in dimension. If more than 1 videomode is found, will return the videomode with the closest refresh rate.
fb_match_mode() #
const struct fb_videomode * find a videomode which exactly matches the timings in var
Parameters
const struct fb_var_screeninfo *var: pointer to struct fb_var_screeninfostruct list_head *head: pointer to struct list_head of modelist
Return
struct fb_videomode, NULL if none found
fb_add_videomode() #
int adds videomode entry to modelist
Parameters
const struct fb_videomode *mode: videomode to addstruct list_head *head: struct list_head of modelist
NOTES
Will only add unmatched mode entries
fb_destroy_modelist() #
void destroy modelist
Parameters
struct list_head *head: struct list_head of modelist
fb_videomode_to_modelist() #
void convert mode array to mode list
Parameters
const struct fb_videomode *modedb: array of struct fb_videomodeint num: number of entries in arraystruct list_head *head: struct list_head of modelist
Frame Buffer Macintosh Video Mode Database #
mac_vmode_to_var() #
int converts vmode/cmode pair to var structure
Parameters
int vmode: MacOS video modeint cmode: MacOS color modestruct fb_var_screeninfo *var: frame buffer video mode structure
Description
Converts a MacOS vmode/cmode pair to a frame buffer video mode structure.
Returns negative errno on error, or zero for success.
mac_map_monitor_sense() #
int Convert monitor sense to vmode
Parameters
int sense: Macintosh monitor sense number
Description
Converts a Macintosh monitor sense number to a MacOS vmode number.
Returns MacOS vmode video mode number.
mac_find_mode() #
int find a video mode
Parameters
struct fb_var_screeninfo *var: frame buffer user defined part of displaystruct fb_info *info: frame buffer info structureconst char *mode_option: video mode name (see mac_modedb[])unsigned int default_bpp: default color depth in bits per pixel
Description
Finds a suitable video mode. Tries to set mode specified by mode_option. If the name of the wanted mode begins with 'mac', the Mac video mode database will be used, otherwise it will fall back to the standard video mode database.
Note
-
Function marked as __init and can only be used during
system boot.
Returns error code from fb_find_mode (see fb_find_mode function).
Frame Buffer Fonts #
Refer to the file lib/fonts/fonts.c for more information.