v4l_bound_align_image(9)
π v4l_bound_align_image β Kernel API Manual, bestie edition π
okay so picture this: you're deep in the kernel, you've got a video image, and its dimensions are lowkey a mess. enter v4l_bound_align_image β the function that β¨adjusts your video dimensions according to a given constraintsβ¨. yes bestie, the original NAME really does say "a given constraints" and I'm not fixing it, that's canon π
β¨ SYNOPSIS β¨
void v4l_bound_align_image (unsigned int *width , unsigned int wmin ,
unsigned int wmax , unsigned int walign , unsigned int *height ,
unsigned int hmin , unsigned int hmax , unsigned int halign , unsigned
int salign );
like, nine arguments. nine. she's got a lot going on but she's iconic for it π
π«Ά ARGUMENTS π«Ά
widthβ pointer to the width, which will be adjusted if needed. it's a pointer, so she gets edited in place, no cap πwminβ the minimum width. the floor, the bare minimum, the "girl you deserve better than this" threshold.wmaxβ the maximum width. the ceiling βwalignβ least significant bit on width. yes, "least significant bit on width", that's the actual wording, keep it πheightβ pointer to the height, adjusted if needed. same deal aswidth, also in-place.hminβ minimum height. short king protection clause.hmaxβ maximum height. no vertical overachievers allowed.halignβ least significant bit on height.salignβ least significant bit for the image size, e.g.width * height. this one's about the whole vibe, not just one dimension π
π DESCRIPTION π
So what she actually does: she clips an image so its width lands between wmin and wmax, and its height lands between hmin and hmax β inclusive, both ends, we're generous β¨
On top of that, the width will be a multiple of 2^{walign}, the height will be a multiple of 2^{halign}, and the overall size width * height will be a multiple of 2^{salign}. alignment for days, honestly π
π¨ NOTE π¨
read this part. seriously. don't skim it, bestie π
- The clipping rectangle may be shrunk or enlarged to fit the alignment constraints. it's not a one-way trip, she can go either direction.
wmaxmust not be smaller thanwmin. that's just physics.hmaxmust not be smaller thanhmin. same energy.- The alignments must not be so high that there are no possible image sizes within the allowed bounds. like, if you over-align yourself out of existence, that's on you π
wminandhminmust be at least 1 β don't use0. periodt.- For
walign,halignandsalign, if you don't care about a certain alignment, specify0, because2^0 = 1and one byte alignment is equivalent to no alignment. zero is the "idk, whatever" option π¦ - If you only want to adjust downward, specify a maximum that's the same as the initial value. cute lil trick, no extra options needed π
πΈ SEE ALSO πΈ
Kernel file ./include/media/v4l2-common.h, plus the whole friend group:
v4l2_ctrl_query_fill(9)enum v4l2_i2c_tuner_type(9)v4l2_i2c_new_subdev(9)v4l2_i2c_new_subdev_board(9)v4l2_i2c_subdev_set_name(9)v4l2_i2c_subdev_init(9)v4l2_i2c_subdev_addr(9)v4l2_i2c_tuner_addrs(9)v4l2_i2c_subdev_unregister(9)v4l2_spi_new_subdev(9)v4l2_spi_subdev_init(9)v4l2_spi_subdev_unregister(9)v4l2_find_nearest_size_conditional(9)v4l2_find_nearest_size(9)v4l2_g_parm_cap(9)v4l2_s_parm_cap(9)enum v4l2_pixel_encoding(9)struct v4l2_format_info(9)v4l2_get_link_freq(9)v4l2_get_active_data_lanes(9)v4l2_link_freq_to_bitmap(9)devm_v4l2_sensor_clk_get(9)devm_v4l2_sensor_clk_get_legacy(9)
ok that's the whole page, go align something π
and that's the tea, bestie β this whole thing lives in ./include/media and it's dated October 2026, so like, future iconic energy βπ¦ go forth and bound those images, mwah π
π¦ 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