drm_fb_xrgb8888_to_mono(9)
π drm_fb_xrgb8888_to_mono(9) β from the Kernel API Manual, bestie π
okay so this one's from the Kernel API Manual and it's genuinely one of my faves because it's literally about making color β¨disappearβ¨ β turning your gorgeous XRGB8888 pixels into pure black-and-white. no cap, it's giving "minimalism era". let's get into it π¦
β¨ NAME β¨
drm_fb_xrgb8888_to_mono β Convert XRGB8888 to monochrome π
πΈ SYNOPSIS πΈ
so here's the whole signature, copy it exactly, don't be weird about it:
void drm_fb_xrgb8888_to_mono (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 π
every single one, and yes we're doing all of them:
dstβ array of monochrome destination buffers. and when i say monochrome i mean it's literally0=black,1=white. one bit. that's it. that's the whole vibe π€π€dst_pitchβ array of numbers of bytes between the start of two consecutive scanlines withindst. this one can beNULLif the scanlines are just stored next to each other, like they're besties holding hands π«Άsrcβ array of XRGB8888 source buffers. the colorful ones. the main characters πfbβ DRM framebuffer πclipβ clip rectangle area to copy. like a little crop tool but make it kernelstateβ transform and conversion state π
π DESCRIPTION π
okay so the way this works: it copies parts of a framebuffer to display memory AND converts the color format while it's doing it. multitasking icon. but heads up β destination and framebuffer formats must match. no mixing, no matching, that's the rule π
now, dst, dst_pitch and src are all arrays. each array must have at least as many entries as there are planes in fb's format, and each entry stores the value for that format's respective color plane at the same index. one entry per plane, in order, no skipping π
β οΈ important caveat time, bestie: this function does not apply clipping on dst β the destination is at the top-left corner, periodt. the first pixel (upper left corner of the clip rectangle) gets converted and copied to the first bit (LSB) in the first byte of the monochrome destination buffer. and if the caller needs the first pixel in a byte to be at an x-coordinate that's a multiple of 8? the caller has to take care of supplying a suitable clip rectangle themself. not us, not our problem, we don't do that π
and here's the lore: DRM doesn't have native monochrome support. shocking, i know. so drivers use this function for monochrome devices that don't support XRGB8888 natively. those drivers can announce the commonly supported XR24 format to userspace and then use this function to convert to the native format. slay, workaround queen π
also β internally, this function uses drm_fb_xrgb8888_to_gray8 to convert to grayscale first, and then that result gets converted from grayscale to monochrome. two-step glow-down, if you will. it ate πΈ
π¦ SEE ALSO π¦
the whole friend group, all of them, no one left out:
- Kernel file
./drivers/gpu/drm/drm_format_helper.c 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_xrgb8888_to_gray8(9),drm_fb_argb8888_to_argb4444(9),drm_fb_xrgb8888_to_gray2(9)
and that's the page! π«Ά this one lives in ./drivers/gpu/drm, dated October 2026 β literally the future, we stan. stay monochrome, bestie π€π€β¨
π¦ 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