drm_universal_plane_init(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… drm_universal_plane_init(9) โ€” like, the kernel API manual, but make it make sense ๐ŸŽ€

okay bestie, so this is a page from the Kernel API Manual, and it's all about drm_universal_plane_init โ€” the lil function that births a brand-new universal plane object into the world โœจ no cap, it's giving "congratulations, it's a plane" energy.


โœจ NAME โœจ

drm_universal_plane_init โ€” initializes a new universal plane object ๐Ÿฆ‹ (yes that's literally the whole job, and it eats every time)


๐ŸŒธ SYNOPSIS ๐ŸŒธ

int drm_universal_plane_init (struct drm_device *dev , struct drm_plane
*plane , uint32_t possible_crtcs , const struct drm_plane_funcs *funcs ,
const uint32_t *formats , unsigned int format_count , const uint64_t
*format_modifiers , enum drm_plane_type type , const char *name , ... );

like, look at all those arguments ๐Ÿ˜ญ she's high maintenance but she's worth it


๐Ÿ’– ARGUMENTS ๐Ÿ’–

  • dev โ€” the DRM device, the whole main character here ๐Ÿ‘‘
  • plane โ€” the plane object to init, i.e. the baby we're delivering ๐Ÿผ
  • possible_crtcs โ€” bitmask of possible CRTCs, lowkey just a vibe map of who's allowed to hang with this plane
  • funcs โ€” callbacks for the new plane, her whole personality basically
  • formats โ€” array of supported formats (DRM_FORMAT_ โ€ฆ yeah the manpage cuts off mid-token there, that's just how it is, we don't gatekeep ๐Ÿ’€)
  • format_count โ€” number of elements in formats, the count, the receipts, the number of things ๐Ÿงฎ
  • format_modifiers โ€” array of struct drm_format modifiers terminated by DRM_FORMAT_MOD_INVALID (the DRM_FORMAT_MOD_INVALID is literally the periodt at the end of the sentence, it's how you know she's done)
  • type โ€” type of plane (overlay, primary, cursor) โ€” pick her aesthetic ๐Ÿ’…
  • name โ€” printf style format string for the plane name, or NULL for the default name (no thoughts, head empty, default name it is)
  • ... โ€” variable arguments, the surprise guests at the party ๐ŸŽ‰

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So like, this function initializes a plane object of type type. That's the entire plot.

The drm_plane_funcs.destroy hook should call drm_plane_cleanup and kfree the plane structure โ€” both, bestie, not one, not the other, both ๐Ÿซถ

๐Ÿšจ and listen: the plane structure should not be allocated with devm_kzalloc. Do not do that. I'm serious. Not the move. ๐Ÿ™ˆ

๐Ÿ’€ NOTE ๐Ÿ’€

okay so first thing โ€” consider using drmm_universal_plane_alloc instead of drm_universal_plane_init, because that way you let the DRM managed resource infrastructure take care of cleanup and deallocation for you. That's it. That's the whole tip. Let the infrastructure be your unproblematic fave โœจ

Second thing โ€” drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set format_modifiers to NULL. When you do that, the plane will advertise the linear modifier. (yes the original says "support" twice like that, we're leaving it, it's iconic ๐Ÿ˜Œ)


๐ŸŒˆ RETURN ๐ŸŒˆ

  • Zero on success ๐Ÿ”ฅ
  • error code on failure ๐Ÿ˜ญ

that's it. zero means slay. anything else means go read the error code, babe.


โญ SEE ALSO โญ

the whole group chat, fr fr:


and that's the page ๐ŸŽ€ this little masterpiece lives under ./drivers/gpu/drm, and the version stamp says October 2026 โ€” so mark your calendars, she's dated and she's slaying, periodt ๐Ÿ’œ iykyk

๐Ÿ“ฆ where this page comes from