STRUCT DRM_FORMAT_INFO(9)
π struct drm_format_info(9) β the kernel API manual, bestie edition π
okay so this is struct drm_format_info(9) from the Kernel API Manual and honestly? it's giving "the little struct that holds the whole vibe of a pixel format." let's get into it β¨
πΈ NAME πΈ
struct drm_format_info β literally just info about a DRM format, that's the whole thing, no cap π
β¨ SYNOPSIS β¨
struct drm_format_info {
u32 format;
u8 depth;
u8 num_planes;
union {
u8 cpp[DRM_FORMAT_MAX_PLANES];
u8 char_per_block[DRM_FORMAT_MAX_PLANES];
};
u8 block_w[DRM_FORMAT_MAX_PLANES];
u8 block_h[DRM_FORMAT_MAX_PLANES];
u8 hsub;
u8 vsub;
bool has_alpha;
bool is_yuv;
bool is_color_indexed;
};
look at her. gorgeous. iconic. every field accounted for π«Ά
π Members π
formatβ the 4CC format identifier (DRM_FORMAT_*). yes, four characters, yes it's a vibe check for pixels π¦depthβ color depth (number of bits per pixel excluding padding bits), and heads up: this only actually means anything for a subset of RGB formats. it's a legacy field bestie, so do not use it in new code and set it to0for new formats. πnum_planesβ number of color planes (from1to3). that's it, that's the range π{unnamed_union}β anonymous. she has no name and she doesn't need one πcppβ number of bytes per pixel (per plane), and this one is aliased withchar_per_block. it's deprecated in favour of using the tripletchar_per_block,block_w,block_hbecause that describes the pixel format way better. ngl, cpp is the older sister who's still cool but like... move on πchar_per_blockβ number of bytes per block (per plane), where blocks are defined as a rectangle of pixels which are stored next to each other in a byte aligned memory region. together withblock_wandblock_h, this is used to properly describe tiles in tiled formats, or to describe groups of pixels in packed formats for which the memory needed for a single pixel is not byte aligned. this is the main character field, fr fr β
so cpp has been kept for historical reasons because there are a lot of places in drivers where it's used β like, a lot a lot. but in drm core, for generic code paths, the preferred way is to use char_per_block, drm_format_info_block_width and drm_format_info_block_height, which lets you handle both block and non-block formats in the exact same way. slay, consistency π
for formats that are intended to be used only with non-linear modifiers: both cpp and char_per_block must be 0 in the generic format table. that's a hard requirement, not a suggestion, okay? π drivers could supply accurate information from their drm_mode_config.get_format_info hook if they want the core to be validating the pitch. iykyk π₯
block_wβ block width in pixels; this is intended to be accessed throughdrm_format_info_block_widthπ§block_hβ block height in pixels; this is intended to be accessed throughdrm_format_info_block_heightπ§hsubβ horizontal chroma subsampling factor πΈvsubβ vertical chroma subsampling factor πΈhas_alphaβ does the format embeds an alpha component? (yes/no, transparency girlie check) πis_yuvβ is it a YUV format? πis_color_indexedβ is it a color-indexed format? π
π¦ SEE ALSO π¦
kernel file ./include/drm/drm_fourcc.h, plus the whole friend group:
DRM_FORMAT_MAX_PLANES(9)drm_format_info_is_yuv_packed(9)drm_format_info_is_yuv_semiplanar(9)drm_format_info_is_yuv_planar(9)drm_format_info_is_yuv_sampling_410(9)drm_format_info_is_yuv_sampling_411(9)drm_format_info_is_yuv_sampling_420(9)drm_format_info_is_yuv_sampling_422(9)drm_format_info_is_yuv_sampling_444(9)drm_format_info_plane_width(9)drm_format_info_plane_height(9)
go read them, they ate π
and that's the whole page!! this one came from ./include/drm, in the October 2026 drop of the Kernel API Manual, filed under struct drm_format_info(9) β mwah, love u, go format some pixels responsibly πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms