Frame Buffer Library¶
The frame buffer drivers depend heavily on four data structures. Thesestructures are declared in include/linux/fb.h. They are fb_info,fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. The lastthree can be made available to and from userland.
fb_info defines the current state of a particular video card. Insidefb_info, there exists a fb_ops structure which is a collection ofneeded functions to make fbdev and fbcon work. fb_info is only visibleto the kernel.
fb_var_screeninfo is used to describe the features of a video cardthat are user defined. With fb_var_screeninfo, things such as depthand the resolution may be defined.
The next structure is fb_fix_screeninfo. This defines the propertiesof a card that are created when a mode is set and can’t be changedotherwise. A good example of this is the start of the frame buffermemory. This “locks” the address of the frame buffer memory, so that itcannot be changed or moved.
The last structure is fb_monospecs. In the old API, there was littleimportance for fb_monospecs. This allowed for forbidden things such assetting a mode of 800x600 on a fix frequency monitor. With the new API,fb_monospecs prevents such things, and if used correctly, can prevent amonitor from being cooked. fb_monospecs will not be useful untilkernels 2.5.x.
Frame Buffer Memory¶
- int
remove_conflicting_framebuffers(struct apertures_struct * a, const char * name, bool primary)¶ remove firmware-configured framebuffers
Parameters
structapertures_struct*a- memory range, users of which are to be removed
constchar*name- requesting driver name
boolprimary- also kick vga16fb if present
Description
This function removes framebuffer devices (initialized by firmware/bootloader)which use memory range described bya. Ifa is NULL all such devices areremoved.
- int
remove_conflicting_pci_framebuffers(struct pci_dev * pdev, const char * name)¶ remove firmware-configured framebuffers for PCI devices
Parameters
structpci_dev*pdev- PCI device
constchar*name- requesting driver name
Description
This function removes framebuffer devices (eg. initialized by firmware)using memory range configured for any ofpdev’s memory bars.
The function assumes that PCI device with shadowed ROM drives a primarydisplay and so kicks out vga16fb.
- int
register_framebuffer(struct fb_info * fb_info)¶ registers a frame buffer device
Parameters
structfb_info*fb_infoframe buffer info structure
Registers a frame buffer devicefb_info.
Returns negative errno on error, or zero for success.
- void
unregister_framebuffer(struct fb_info * fb_info)¶ releases a frame buffer device
Parameters
structfb_info*fb_infoframe buffer info structure
Unregisters a frame buffer devicefb_info.
Returns negative errno on error, or zero for success.
This function will also notify the framebuffer consoleto release the driver.
This is meant to be called within a driver’s
module_exit()function. If this is called outsidemodule_exit(), ensurethat the driver implements fb_open() and fb_release() tocheck that no processes are using the device.
- void
fb_set_suspend(struct fb_info * info, int state)¶ low level driver signals suspend
Parameters
structfb_info*info- framebuffer affected
intstate0 = resuming, !=0 = suspending
This is meant to be used by low level drivers tosignal suspend/resume to the core & clients.It must be called with the console semaphore held
Frame Buffer Colormap¶
- void
fb_dealloc_cmap(struct fb_cmap * cmap)¶ deallocate a colormap
Parameters
structfb_cmap*cmapframe buffer colormap structure
Deallocates a colormap that was previously allocated withfb_alloc_cmap().
- int
fb_copy_cmap(const struct fb_cmap * from, struct fb_cmap * to)¶ copy a colormap
Parameters
conststructfb_cmap*from- frame buffer colormap structure
structfb_cmap*toframe buffer colormap structure
Copy contents of colormap fromfrom toto.
- int
fb_set_cmap(struct fb_cmap * cmap, struct fb_info * info)¶ set the colormap
Parameters
structfb_cmap*cmap- frame buffer colormap structure
structfb_info*infoframe buffer info structure
Sets the colormapcmap for a screen of deviceinfo.
Returns negative errno on error, or zero on success.
- const struct fb_cmap *
fb_default_cmap(int len)¶ get default colormap
Parameters
intlensize of palette for a depth
Gets the default colormap for a specific screen depth.lenis the size of the palette for a particular screen depth.
Returns pointer to a frame buffer colormap structure.
- void
fb_invert_cmaps(void)¶ invert all defaults colormaps
Parameters
void- no arguments
Description
Invert all default colormaps.
Frame Buffer Video Mode Database¶
- int
fb_try_mode(struct fb_var_screeninfo * var, struct fb_info * info, const struct fb_videomode * mode, unsigned int bpp)¶ test a video mode
Parameters
structfb_var_screeninfo*var- frame buffer user defined part of display
structfb_info*info- frame buffer info structure
conststructfb_videomode*mode- frame buffer video mode structure
unsignedintbppcolor depth in bits per pixel
Tries a video mode to test it’s validity for deviceinfo.
Returns 1 on success.
- void
fb_delete_videomode(const struct fb_videomode * mode, struct list_head * head)¶ removed videomode entry from modelist
Parameters
conststructfb_videomode*mode- videomode to remove
structlist_head*head- struct list_head of modelist
NOTES
Will remove all matching mode entries
- int
fb_find_mode(struct fb_var_screeninfo * var, struct fb_info * info, const char * mode_option, const struct fb_videomode * db, unsigned int dbsize, const struct fb_videomode * default_mode, unsigned int default_bpp)¶ finds a valid video mode
Parameters
structfb_var_screeninfo*var- frame buffer user defined part of display
structfb_info*info- frame buffer info structure
constchar*mode_option- string video mode to find
conststructfb_videomode*db- video mode database
unsignedintdbsize- size ofdb
conststructfb_videomode*default_mode- default video mode to fall back to
unsignedintdefault_bpp- default color depth in bits per pixel
Description
Finds a suitable video mode, starting with the specified modeinmode_option with fallback todefault_mode. Ifdefault_mode fails, all modes in the video mode database willbe tried.
Valid mode specifiers formode_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) CoordinatedVideo Timings (CVT). If ‘R’ is present after ‘M’, will compute withreduced blanking (for flatpanels). If ‘i’ or ‘p’ are present, computeinterlaced or progressive mode. If ‘m’ is present, add margins equalto 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.
Returns zero for failure, 1 if using specifiedmode_option,2 if using specifiedmode_option with an ignored refresh rate,3 if default mode is used, 4 if fall back to any valid mode.
NOTE
The passed structvar is _not_ cleared! This allows youto supply values for e.g. the grayscale and accel_flags fields.
- void
fb_var_to_videomode(struct fb_videomode * mode, const struct fb_var_screeninfo * var)¶ convert fb_var_screeninfo to fb_videomode
Parameters
structfb_videomode*mode- pointer to struct fb_videomode
conststructfb_var_screeninfo*var- pointer to struct fb_var_screeninfo
- void
fb_videomode_to_var(struct fb_var_screeninfo * var, const struct fb_videomode * mode)¶ convert fb_videomode to fb_var_screeninfo
Parameters
structfb_var_screeninfo*var- pointer to struct fb_var_screeninfo
conststructfb_videomode*mode- pointer to struct fb_videomode
- int
fb_mode_is_equal(const struct fb_videomode * mode1, const struct fb_videomode * mode2)¶ compare 2 videomodes
Parameters
conststructfb_videomode*mode1- first videomode
conststructfb_videomode*mode2- second videomode
Return
1 if equal, 0 if not
- const struct fb_videomode *
fb_find_best_mode(const struct fb_var_screeninfo * var, struct list_head * head)¶ find best matching videomode
Parameters
conststructfb_var_screeninfo*var- pointer to struct fb_var_screeninfo
structlist_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 ininfo->modelist are valid.
NOTES
Finds best matching videomode which has an equal or greater dimension thanvar->xres and var->yres. If more than 1 videomode is found, will returnthe videomode with the highest refresh rate
- const struct fb_videomode *
fb_find_nearest_mode(const struct fb_videomode * mode, struct list_head * head)¶ find closest videomode
Parameters
conststructfb_videomode*mode- pointer to struct fb_videomode
structlist_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 withthe closest refresh rate.
- const struct fb_videomode *
fb_match_mode(const struct fb_var_screeninfo * var, struct list_head * head)¶ find a videomode which exactly matches the timings in var
Parameters
conststructfb_var_screeninfo*var- pointer to struct fb_var_screeninfo
structlist_head*head- pointer to struct list_head of modelist
Return
struct fb_videomode, NULL if none found
- int
fb_add_videomode(const struct fb_videomode * mode, struct list_head * head)¶ adds videomode entry to modelist
Parameters
conststructfb_videomode*mode- videomode to add
structlist_head*head- struct list_head of modelist
NOTES
Will only add unmatched mode entries
- void
fb_destroy_modelist(struct list_head * head)¶ destroy modelist
Parameters
structlist_head*head- struct list_head of modelist
- void
fb_videomode_to_modelist(const struct fb_videomode * modedb, int num, struct list_head * head)¶ convert mode array to mode list
Parameters
conststructfb_videomode*modedb- array of struct fb_videomode
intnum- number of entries in array
structlist_head*head- struct list_head of modelist
Frame Buffer Macintosh Video Mode Database¶
- int
mac_vmode_to_var(int vmode, int cmode, struct fb_var_screeninfo * var)¶ converts vmode/cmode pair to var structure
Parameters
intvmode- MacOS video mode
intcmode- MacOS color mode
structfb_var_screeninfo*varframe buffer video mode structure
Converts a MacOS vmode/cmode pair to a frame buffer videomode structure.
Returns negative errno on error, or zero for success.
- int
mac_map_monitor_sense(int sense)¶ Convert monitor sense to vmode
Parameters
intsenseMacintosh monitor sense number
Converts a Macintosh monitor sense number to a MacOSvmode number.
Returns MacOS vmode video mode number.
- int
mac_find_mode(struct fb_var_screeninfo * var, struct fb_info * info, const char * mode_option, unsigned int default_bpp)¶ find a video mode
Parameters
structfb_var_screeninfo*var- frame buffer user defined part of display
structfb_info*info- frame buffer info structure
constchar*mode_option- video mode name (see mac_modedb[])
unsignedintdefault_bppdefault color depth in bits per pixel
Finds a suitable video mode. Tries to set mode specifiedbymode_option. If the name of the wanted mode begins with‘mac’, the Mac video mode database will be used, otherwise itwill 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_modefunction).
Frame Buffer Fonts¶
Refer to the file lib/fonts/fonts.c for more information.