Text of docs.kernel.org › fb › api.html as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

The Frame Buffer Device API — The Linux Kernel documentation

The Linux Kernel 7.4.0-rc3 Quick search Contents Working with the development community Development process Submitting patches Code of conduct Maintainer handbook All development-process docs Internal API manuals Core API Driver APIs Subsystems Core subsystems Human interfaces Input Documentation Human Interface Devices (HID) Sound Subsystem Documentation GPU Driver Developer’s Guide Frame Buffer LEDs Networking interfaces Storage interfaces Other subsystems Locking Development tools and processes Licensing rules Writing documentation Development tools Testing guide Hacking guide Tracing Fault injection Livepatching Rust User-oriented documentation Administration Build system Reporting issues Userspace tools Userspace API Firmware-related documentation Firmware Firmware and Devicetree Architecture-specific documentation CPU architectures Other documentation Unsorted documentation Translations Translations This Page Show Source The Frame Buffer Device API ¶ Last revised: June 21, 2011 0.

Introduction ¶ This document describes the frame buffer API used by applications to interact with frame buffer devices. In-kernel APIs between device drivers and the frame buffer core are not described. Due to a lack of documentation in the original frame buffer API, drivers behaviours differ in subtle (and not so subtle) ways. This document describes the recommended API implementation, but applications should be prepared to deal with different behaviours.

1. Capabilities ¶ Device and driver capabilities are reported in the fixed screen information capabilities field: struct fb_fix_screeninfo { ... __u16 capabilities; /* see FB_CAP_* */ ... }; Application should use those capabilities to find out what features they can expect from the device and driver. FB_CAP_FOURCC The driver supports the four character code (FOURCC) based format setting API. When supported, formats are configured using a FOURCC instead of manually specifying color components layout.

2. Types and visuals ¶ Pixels are stored in memory in hardware-dependent formats. Applications need to be aware of the pixel storage format in order to write image data to the frame buffer memory in the format expected by the hardware. Formats are described by frame buffer types and visuals. Some visuals require additional information, which are stored in the variable screen information bits_per_pixel, grayscale, red, green, blue and transp fields.

Visuals describe how color information is encoded and assembled to create macropixels. Types describe how macropixels are stored in memory. The following types and visuals are supported. FB_TYPE_PACKED_PIXELS Macropixels are stored contiguously in a single plane. If the number of bits per macropixel is not a multiple of 8, whether macropixels are padded to the next multiple of 8 bits or packed together into bytes depends on the visual.

Padding at end of lines may be present and is then reported through the fixed screen information line_length field. FB_TYPE_PLANES Macropixels are split across multiple planes. The number of planes is equal to the number of bits per macropixel, with plane i’th storing i’th bit from all macropixels. Planes are located contiguously in memory. FB_TYPE_INTERLEAVED_PLANES Macropixels are split across multiple planes. The number of planes is equal to the number of bits per macropixel, with plane i’th storing i’th bit from all macropixels.

Planes are interleaved in memory. The interleave factor, defined as the distance in bytes between the beginning of two consecutive interleaved blocks belonging to different planes, is stored in the fixed screen information type_aux field. FB_TYPE_FOURCC Macropixels are stored in memory as described by the format FOURCC identifier stored in the variable screen information grayscale field. FB_VISUAL_MONO01 Pixels are black or white and stored on a number of bits (typically one) specified by the variable screen information bpp field.

Black pixels are represented by all bits set to 1 and white pixels by all bits set to 0. When the number of bits per pixel is smaller than 8, several pixels are packed together in a byte. FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only. FB_VISUAL_MONO10 Pixels are black or white and stored on a number of bits (typically one) specified by the variable screen information bpp field. Black pixels are represented by all bits set to 0 and white pixels by all bits set to 1.

When the number of bits per pixel is smaller than 8, several pixels are packed together in a byte. FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only. FB_VISUAL_TRUECOLOR Pixels are broken into red, green and blue components, and each component indexes a read-only lookup table for the corresponding value. Lookup tables are device-dependent, and provide linear or non-linear ramps. Each component is stored in a macropixel according to the variable screen information red, green, blue and transp fields.

FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR Pixel values are encoded as indices into a colormap that stores red, green and blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR and read-write for FB_VISUAL_PSEUDOCOLOR. Each pixel value is stored in the number of bits reported by the variable screen information bits_per_pixel field. FB_VISUAL_DIRECTCOLOR Pixels are broken into red, green and blue components, and each component indexes a programmable lookup table for the corresponding value.

Each component is stored in a macropixel according to the variable screen information red, green, blue and transp fields. FB_VISUAL_FOURCC Pixels are encoded and interpreted as described by the format FOURCC identifier stored in the variable screen information grayscale field. 3. Screen information ¶ Screen information are queried by applications using the FBIOGET_FSCREENINFO and FBIOGET_VSCREENINFO ioctls. Those ioctls take a pointer to a fb_fix_screeninfo and fb_var_screeninfo structure respectively. struct fb_fix_screeninfo stores device independent unchangeable information about the frame buffer device and the current format.

Those information can’t be directly modified by applications, but can be changed by the driver when an application modifies the format: struct fb_fix_screeninfo { char id[16]; /* identification string eg "TT Builtin" */ unsigned long smem_start; /* Start of frame buffer mem */ /* (physical address) */ __u32 smem_len; /* Length of frame buffer mem */ __u32 type; /* see FB_TYPE_* */ __u32 type_aux; /* Interleave for interleaved Planes */ __u32 visual; /* see FB_VISUAL_* */ __u16 xpanstep; /* zero if no hardware panning */ __u16 ypanstep; /* zero if no hardware panning */ __u16 ywrapstep; /* zero if no hardware ywrap */ __u32 line_length; /* length of a line in bytes */ unsigned long mmio_start; /* Start of Memory Mapped I/O */ /* (physical address) */ __u32 mmio_len; /* Length of Memory Mapped I/O */ __u32 accel; /* Indicate to driver which */ /* specific chip/card we have */ __u16 capabilities; /* see FB_CAP_* */ __u16 reserved[2]; /* Reserved for future compatibility */ }; struct fb_var_screeninfo stores device independent changeable information about a frame buffer device, its current format and video mode, as well as other miscellaneous parameters: struct fb_var_screeninfo { __u32 xres; /* visible resolution */ __u32 yres; __u32 xres_virtual; /* virtual resolution */ __u32 yres_virtual; __u32 xoffset; /* offset from virtual to visible */ __u32 yoffset; /* resolution */ __u32 bits_per_pixel; /* guess what */ __u32 grayscale; /* 0 = color, 1 = grayscale, */ /* >1 = FOURCC */ struct fb_bitfield red; /* bitfield in fb mem if true color, */ struct fb_bitfield green; /* else only length is significant */ struct fb_bitfield blue; struct fb_bitfield transp; /* transparency */ __u32 nonstd; /* != 0 Non standard pixel format */ __u32 activate; /* see FB_ACTIVATE_* */ __u32 height; /* height of picture in mm */ __u32 width; /* width of picture

The rest of this page is on the live site.