Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: v4l2-common.h: document helper functions

There are several helper functions that aren't documented.

Document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+96 -25
-14
drivers/media/v4l2-core/v4l2-common.c
··· 320 320 return x; 321 321 } 322 322 323 - /* Bound an image to have a width between wmin and wmax, and height between 324 - * hmin and hmax, inclusive. Additionally, the width will be a multiple of 325 - * 2^walign, the height will be a multiple of 2^halign, and the overall size 326 - * (width*height) will be a multiple of 2^salign. The image may be shrunk 327 - * or enlarged to fit the alignment constraints. 328 - * 329 - * The width or height maximum must not be smaller than the corresponding 330 - * minimum. The alignments must not be so high there are no possible image 331 - * sizes within the allowed bounds. wmin and hmin must be at least 1 332 - * (don't use 0). If you don't care about a certain alignment, specify 0, 333 - * as 2^0 is 1 and one byte alignment is equivalent to no alignment. If 334 - * you only want to adjust downward, specify a maximum that's the same as 335 - * the initial value. 336 - */ 337 323 void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, 338 324 unsigned int walign, 339 325 u32 *h, unsigned int hmin, unsigned int hmax,
+96 -11
include/media/v4l2-common.h
··· 28 28 29 29 #include <media/v4l2-dev.h> 30 30 31 - /* Common printk constucts for v4l-i2c drivers. These macros create a unique 31 + /* Common printk constructs for v4l-i2c drivers. These macros create a unique 32 32 prefix consisting of the driver name, the adapter number and the i2c 33 33 address. */ 34 34 #define v4l_printk(level, name, adapter, addr, fmt, arg...) \ ··· 174 174 */ 175 175 unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); 176 176 177 + /** 178 + * enum v4l2_i2c_tuner_type - specifies the range of tuner address that 179 + * should be used when seeking for I2C devices. 180 + * 181 + * @ADDRS_RADIO: Radio tuner addresses. 182 + * Represent the following I2C addresses: 183 + * 0x10 (if compiled with tea5761 support) 184 + * and 0x60. 185 + * @ADDRS_DEMOD: Demod tuner addresses. 186 + * Represent the following I2C addresses: 187 + * 0x42, 0x43, 0x4a and 0x4b. 188 + * @ADDRS_TV: TV tuner addresses. 189 + * Represent the following I2C addresses: 190 + * 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62, 191 + * 0x63 and 0x64. 192 + * @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this 193 + * excludes addresses used by the demodulator 194 + * from the list of candidates. 195 + * Represent the following I2C addresses: 196 + * 0x60, 0x61, 0x62, 0x63 and 0x64. 197 + * 198 + * NOTE: All I2C addresses above use the 7-bit notation. 199 + */ 177 200 enum v4l2_i2c_tuner_type { 178 - ADDRS_RADIO, /* Radio tuner addresses */ 179 - ADDRS_DEMOD, /* Demod tuner addresses */ 180 - ADDRS_TV, /* TV tuner addresses */ 181 - /* TV tuner addresses if demod is present, this excludes 182 - addresses used by the demodulator from the list of 183 - candidates. */ 201 + ADDRS_RADIO, 202 + ADDRS_DEMOD, 203 + ADDRS_TV, 184 204 ADDRS_TV_WITH_DEMOD, 185 205 }; 186 - /* Return a list of I2C tuner addresses to probe. Use only if the tuner 187 - addresses are unknown. */ 206 + /** 207 + * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe. 208 + * 209 + * @type: type of the tuner to seek, as defined by 210 + * &enum v4l2_i2c_tuner_type. 211 + * 212 + * NOTE: Use only if the tuner addresses are unknown. 213 + */ 188 214 const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); 189 215 190 216 /* ------------------------------------------------------------------------- */ ··· 254 228 * FIXME: these remaining ioctls/structs should be removed as well, but they 255 229 * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET). 256 230 * To remove these ioctls some more cleanup is needed in those modules. 231 + * 232 + * It doesn't make much sense on documenting them, as what we really want is 233 + * to get rid of them. 257 234 */ 258 235 259 236 /* s_config */ ··· 272 243 273 244 /* Miscellaneous helper functions */ 274 245 275 - void v4l_bound_align_image(unsigned int *w, unsigned int wmin, 246 + /** 247 + * v4l_bound_align_image - adjust video dimensions according to 248 + * a given constraints. 249 + * 250 + * @width: pointer to width that will be adjusted if needed. 251 + * @wmin: minimum width. 252 + * @wmax: maximum width. 253 + * @walign: least significant bit on width. 254 + * @height: pointer to height that will be adjusted if needed. 255 + * @hmin: minimum height. 256 + * @hmax: maximum height. 257 + * @halign: least significant bit on width. 258 + * @salign: least significant bit for the image size (e. g. 259 + * :math:`width * height`). 260 + * 261 + * Clip an image to have @width between @wmin and @wmax, and @height between 262 + * @hmin and @hmax, inclusive. 263 + * 264 + * Additionally, the @width will be a multiple of :math:`2^{walign}`, 265 + * the @height will be a multiple of :math:`2^{halign}`, and the overall 266 + * size :math:`width * height` will be a multiple of :math:`2^{salign}`. 267 + * 268 + * .. note:: 269 + * 270 + * #. The clipping rectangle may be shrunk or enlarged to fit the alignment 271 + * constraints. 272 + * #. @wmax must not be smaller than @wmin. 273 + * #. @hmax must not be smaller than @hmin. 274 + * #. The alignments must not be so high there are no possible image 275 + * sizes within the allowed bounds. 276 + * #. @wmin and @hmin must be at least 1 (don't use 0). 277 + * #. For @walign, @halign and @salign, if you don't care about a certain 278 + * alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment 279 + * is equivalent to no alignment. 280 + * #. If you only want to adjust downward, specify a maximum that's the 281 + * same as the initial value. 282 + */ 283 + void v4l_bound_align_image(unsigned int *width, unsigned int wmin, 276 284 unsigned int wmax, unsigned int walign, 277 - unsigned int *h, unsigned int hmin, 285 + unsigned int *height, unsigned int hmin, 278 286 unsigned int hmax, unsigned int halign, 279 287 unsigned int salign); 280 288 289 + /** 290 + * v4l2_find_nearest_format - find the nearest format size among a discrete 291 + * set of resolutions. 292 + * 293 + * @sizes: array of &struct v4l2_frmsize_discrete image sizes. 294 + * @num_sizes: length of @sizes array. 295 + * @width: desired width. 296 + * @height: desired height. 297 + * 298 + * Finds the closest resolution to minimize the width and height differences 299 + * between what requested and the supported resolutions. 300 + */ 281 301 const struct v4l2_frmsize_discrete * 282 302 v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes, 283 303 const size_t num_sizes, 284 304 s32 width, s32 height); 285 305 306 + /** 307 + * v4l2_get_timestamp - helper routine to get a timestamp to be used when 308 + * filling streaming metadata. Internally, it uses ktime_get_ts(), 309 + * which is the recommended way to get it. 310 + * 311 + * @tv: pointer to &struct timeval to be filled. 312 + */ 286 313 void v4l2_get_timestamp(struct timeval *tv); 287 314 288 315 #endif /* V4L2_COMMON_H_ */