drm_rect_calc_hscale(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_rect_calc_hscale β€” like, the horizontal scaling factor calculator

okay bestie, welcome to the Kernel API Manual ✨ this one's a tiny little function from the DRM rect squad, and honestly? it's giving "small but crucial" energy. let's get into it πŸŽ€


✨ NAME ✨

drm_rect_calc_hscale β€” calculate the horizontal scaling factor 🌸

like, it figures out how much your rectangle is being stretched sideways. that's the whole vibe. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

int drm_rect_calc_hscale (const struct drm_rect *src , const struct drm_rect *dst , int min_hscale , int max_hscale );

yep, that's the whole signature, no cap. four args, one int coming back at ya. πŸ‘‘


πŸ“ ARGUMENTS πŸ“

  • src β€” the source window rectangle πŸ’œ this is the rectangle you're scaling from, the origin story if you will.
  • dst β€” the destination window rectangle ✨ the rectangle you're scaling to. where the glow-up happens.
  • min_hscale β€” minimum allowed horizontal scaling factor πŸŽ€ the floor, the "bestie please don't shrink past this" line.
  • max_hscale β€” maximum allowed horizontal scaling factor πŸ”₯ the ceiling, the "okay that's enough stretching" limit.

🌈 DESCRIPTION 🌈

so here's the tea β˜• this function calculates the horizontal scaling factor as (src width) / (dst width). literally just src width over dst width. simple. iconic. periodt. πŸ’…

and then there's the rounding rules, which are lowkey the main character here:

  • if the scale is below 1 << 16, it rounds down ⬇️
  • if the scale is above 1 << 16, it rounds up ⬆️

the way that this works out means you get the scale calculated with the most pessimistic limit calculation 😭 and yes, pessimistic is the exact word β€” this thing is not out here being optimistic about your limits, it's assuming the worst-case and acting accordingly. respect, honestly. 🫢


⭐ RETURN ⭐

the horizontal scaling factor πŸ’– or, if things go out of limits, the errno of out of limits πŸ™ˆ so like, check the return value, bestie. don't just assume it's a happy number.


πŸ”₯ SEE ALSO πŸ”₯

go read those too, the whole rect friend group is honestly so good πŸ’œ


aaaand that's the page! 🌸 this lil masterpiece comes to you from ./drivers/gpu/drm, dated October 2026, living in the Kernel API Manual (version 9, because of course). mwah, go scale those rectangles horizontally bestie πŸ’‹πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from