aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-common.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-common.h')
-rw-r--r--include/media/v4l2-common.h60
1 files changed, 51 insertions, 9 deletions
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index e0d95a7c5d48..54b689247937 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -316,21 +316,37 @@ void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
316 unsigned int salign); 316 unsigned int salign);
317 317
318/** 318/**
319 * v4l2_find_nearest_format - find the nearest format size among a discrete 319 * v4l2_find_nearest_size - Find the nearest size among a discrete
320 * set of resolutions. 320 * set of resolutions contained in an array of a driver specific struct.
321 * 321 *
322 * @sizes: array of &struct v4l2_frmsize_discrete image sizes. 322 * @array: a driver specific array of image sizes
323 * @num_sizes: length of @sizes array. 323 * @width_field: the name of the width field in the driver specific struct
324 * @height_field: the name of the height field in the driver specific struct
324 * @width: desired width. 325 * @width: desired width.
325 * @height: desired height. 326 * @height: desired height.
326 * 327 *
327 * Finds the closest resolution to minimize the width and height differences 328 * Finds the closest resolution to minimize the width and height differences
328 * between what requested and the supported resolutions. 329 * between what requested and the supported resolutions. The size of the width
330 * and height fields in the driver specific must equal to that of u32, i.e. four
331 * bytes.
332 *
333 * Returns the best match or NULL if the length of the array is zero.
329 */ 334 */
330const struct v4l2_frmsize_discrete * 335#define v4l2_find_nearest_size(array, width_field, height_field, \
331v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes, 336 width, height) \
332 const size_t num_sizes, 337 ({ \
333 s32 width, s32 height); 338 BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
339 sizeof((array)->height_field) != sizeof(u32)); \
340 (typeof(&(*(array))))__v4l2_find_nearest_size( \
341 (array), ARRAY_SIZE(array), sizeof(*(array)), \
342 offsetof(typeof(*(array)), width_field), \
343 offsetof(typeof(*(array)), height_field), \
344 width, height); \
345 })
346const void *
347__v4l2_find_nearest_size(const void *array, size_t array_size,
348 size_t entry_size, size_t width_offset,
349 size_t height_offset, s32 width, s32 height);
334 350
335/** 351/**
336 * v4l2_get_timestamp - helper routine to get a timestamp to be used when 352 * v4l2_get_timestamp - helper routine to get a timestamp to be used when
@@ -341,4 +357,30 @@ v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes,
341 */ 357 */
342void v4l2_get_timestamp(struct timeval *tv); 358void v4l2_get_timestamp(struct timeval *tv);
343 359
360/**
361 * v4l2_g_parm_cap - helper routine for vidioc_g_parm to fill this in by
362 * calling the g_frame_interval op of the given subdev. It only works
363 * for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
364 * function name.
365 *
366 * @vdev: the struct video_device pointer. Used to determine the device caps.
367 * @sd: the sub-device pointer.
368 * @a: the VIDIOC_G_PARM argument.
369 */
370int v4l2_g_parm_cap(struct video_device *vdev,
371 struct v4l2_subdev *sd, struct v4l2_streamparm *a);
372
373/**
374 * v4l2_s_parm_cap - helper routine for vidioc_s_parm to fill this in by
375 * calling the s_frame_interval op of the given subdev. It only works
376 * for V4L2_BUF_TYPE_VIDEO_CAPTURE(_MPLANE), hence the _cap in the
377 * function name.
378 *
379 * @vdev: the struct video_device pointer. Used to determine the device caps.
380 * @sd: the sub-device pointer.
381 * @a: the VIDIOC_S_PARM argument.
382 */
383int v4l2_s_parm_cap(struct video_device *vdev,
384 struct v4l2_subdev *sd, struct v4l2_streamparm *a);
385
344#endif /* V4L2_COMMON_H_ */ 386#endif /* V4L2_COMMON_H_ */