drm_rect_calc_hscale(9)
π 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 π₯
- Kernel file
./drivers/gpu/drm/drm_rect.cπ (this is where the magic lives) drm_rect_intersect(9)drm_rect_clip_scaled(9)drm_rect_calc_vscale(9)β the vertical sibling πdrm_rect_debug_print(9)drm_rect_rotate(9)drm_rect_rotate_inv(9)
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
- 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