v4l2_find_ne..._conditional(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ v4l2_find_ne..._conditional(9) β€” Kernel API Manual, but make it make sense πŸ’…

okay so bestie, gather round, because we're talking about v4l2_find_nearest_size_conditional ✨ this is a Kernel API Manual page, and honestly? it's giving "small function, big job" energy πŸŽ€


🌸 NAME 🌸

v4l2_find_nearest_size_conditional β€” finds the nearest size among a discrete set of resolutions, all sitting pretty inside an array of a driver specific struct, and it can conditionally exclude certain modes πŸ¦‹ (yes, "exclusion", we're being fancy)


✨ SYNOPSIS ✨

v4l2_find_nearest_size_conditional (array , array_size , width_field ,
       height_field , width , height , func , context );

πŸ’– ARGUMENTS πŸ’–

  • array β€” a driver specific array of image sizes. it's the lineup, the roster, the main-character list πŸ“‹
  • array_size β€” the length of that driver specific array of image sizes. gotta know how many we're working with, no cap πŸ”’
  • width_field β€” the name of the width field in the driver specific struct πŸŽ€
  • height_field β€” the name of the height field in the driver specific struct πŸŽ€ (sibling energy to width_field, we love a matching set)
  • width β€” desired width. what you want πŸ’­
  • height β€” desired height. also what you want πŸ’­
  • func β€” ignores a mode if it returns false. it's the vibe check function, basically πŸ™ˆ
  • context β€” context for the function. gotta pass it along so it knows what's up 🫢

πŸ”₯ DESCRIPTION πŸ”₯

So what does it actually do? It finds the closest resolution β€” the one that minimizes the width and height differences between what you requested and the supported resolutions πŸ’« literally just "get me as close as you can, bestie".

Important detail, do NOT skip this: the size of the width and height fields in the driver specific must equal that of u32, i.e. four bytes. four. bytes. periodt πŸ‘‘

And about func β€” it gets called for each mode considered, and a mode is ignored if func returns false for it. so it's a filter, a bouncer, a "you're not on the list" situation πŸ’€

Returns the best match or NULL if the length of the array is zero. yeah, empty array = nothing to give, you get NULL 😭

🌈 SEE ALSO 🌈

Kernel file ./include/media/v4l2-common.h, plus the whole friend group:


and that's the whole page, bestie, you ate that πŸ“πŸ’œ

cute little sign-off: this one lives in ./include/media, dated October 2026, and it's v4l2_find_ne..._conditional(9) β€” go forth and find your nearest size, icon 🧚✨
πŸ“¦ where this page comes from