drm_fb_xrgb8888_to_gray8(9)
π drm_fb_xrgb8888_to_gray8 β a Kernel API Manual moment
okay bestie, so this is a page from the Kernel API Manual and it's literally about drm_fb_xrgb8888_to_gray8. Yes that's a mouthful, no we're not renaming it, it's iconic as is π
β¨ NAME β¨
drm_fb_xrgb8888_to_gray8 β convert XRGB8888 to grayscale, no cap π
π¦ SYNOPSIS π¦
void drm_fb_xrgb8888_to_gray8 (struct iosys_map *dst , const unsigned
int *dst_pitch , const struct iosys_map *src , const struct
drm_framebuffer *fb , const struct drm_rect *clip , struct
drm_format_conv_state *state );
πΈ ARGUMENTS πΈ
dstβ array of 8-bit grayscale destination buffers, one per plane, slay πdst_pitchβ array of numbers of bytes between the start of two consecutive scanlines withindst; this one's allowed to beNULLif the scanlines are just stored next to each other (like they're holding hands π«Ά)srcβ array of XRGB8888 source buffersfbβ the DRM framebuffer, the main character honestly πclipβ clip rectangle area to copystateβ transform and conversion state
π DESCRIPTION π
so this function copies parts of a framebuffer to display memory AND converts the color format while it's at it β multitasking queen behavior fr fr. Just know that destination and framebuffer formats must match, that's not optional, that's the vibe check β
The parameters dst, dst_pitch and src refer to arrays. Each array must have at least as many entries as there are planes in fb's format. Each entry stores the value for the format's respective color plane at the same index. iykyk π§
Heads up bestie: this function does not apply clipping on dst β the destination is at the top-left corner. So like, no fancy positioning, it just goes π
Here's the lore: DRM doesn't have native monochrome or grayscale support. So drivers can use this function for grayscale devices that don't support XRGB8888 natively. Such drivers can announce the commonly supported XR24 format to userspace and use this function to convert to the native format β a whole glow-up pipeline β¨
Monochrome drivers will use the most significant bit, where 1 means foreground color and 0 background color. And for the RGB -> luma (brightness) conversion, ITU BT.601 is being used. Not 709, not vibes, BT.601 periodt π
π₯ SEE ALSO π₯
Kernel file ./drivers/gpu/drm/drm_format_helper.c β go read the source, it's giving lore drop π
drm_format_conv_state_init(9)drm_format_conv_state_copy(9)drm_format_conv_state_reserve(9)drm_format_conv_state_release(9)drm_fb_clip_offset(9)drm_fb_memcpy(9)drm_fb_swab(9)drm_fb_xrgb8888_to_rgb332(9)drm_fb_xrgb8888_to_rgb565(9)drm_fb_xrgb8888_to_rgb565be(9)drm_fb_xrgb8888_to_xrgb1555(9)drm_fb_xrgb8888_to_argb1555(9)drm_fb_xrgb8888_to_rgba5551(9)drm_fb_xrgb8888_to_rgb888(9)drm_fb_xrgb8888_to_bgr888(9)drm_fb_xrgb8888_to_argb8888(9)drm_fb_xrgb8888_to_abgr8888(9)drm_fb_xrgb8888_to_xbgr8888(9)drm_fb_xrgb8888_to_bgrx8888(9)drm_fb_xrgb8888_to_xrgb2101010(9)drm_fb_xrgb8888_to_argb2101010(9)drm_fb_argb8888_to_argb4444(9)drm_fb_xrgb8888_to_mono(9)drm_fb_xrgb8888_to_gray2(9)
okay that's the whole page bestie, go convert some pixels πβ¨
this one came from ./drivers/gpu/drm, dated October 2026 β that's the version and the date, we stan a documented timeline πβ mwah π
π¦ 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