drm_fb_xrgb8888_to_mono(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 literally 0=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 within dst. this one can be NULL if 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 kernel
  • state β€” 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:


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