aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-common.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 20:16:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 20:16:59 -0400
commitef1c4a6fa91bbbe9b09f770d28eba31a9edf770c (patch)
tree52f5d175031c553160d14890e876ffc5432d2467 /include/media/v4l2-common.h
parent147a89bc71e7db40f011454a40add7ff2d10f8d8 (diff)
parentf8a695c4b43d02c89b8bba9ba6058fd5db1bc71d (diff)
Merge tag 'media/v4.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - new CEC pin injection code for testing purposes - DVB frontend cxd2099 promoted from staging - new platform driver for Sony cxd2880 DVB devices - new sensor drivers: mt9t112, ov2685, ov5695, ov772x, tda1997x, tw9910.c - removal of unused cx18 and ivtv alsa mixers - the reneseas-ceu driver doesn't depend on soc_camera anymore and moved from staging - removed the mantis_vp3028 driver, unused since 2009 - s5p-mfc: add support for version 10 of the MSP - added a decoder for imon protocol - atomisp: lots of cleanups - imx074 and mt9t031: don't depend on soc_camera anymore, being promoted from staging - added helper functions to better support DVB I2C binding - lots of driver improvements and cleanups * tag 'media/v4.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (438 commits) media: v4l2-ioctl: rename a temp var that stores _IOC_SIZE(cmd) media: fimc-capture: get rid of two warnings media: dvb-usb-v2: fix a missing dependency of I2C_MUX media: uvc: to the right check at uvc_ioctl_enum_framesizes() media: cec-core: fix a bug at cec_error_inj_write() media: tda9840: cleanup a warning media: tm6000: avoid casting just to print pointer address media: em28xx-input: improve error handling code media: zr364xx: avoid casting just to print pointer address media: vivid-radio-rx: add a cast to avoid a warning media: saa7134-alsa: don't use casts to print a buffer address media: solo6x10: get rid of an address space warning media: zoran: don't cast pointers to print them media: ir-kbd-i2c: change the if logic to avoid a warning media: ir-kbd-i2c: improve error handling code media: saa7134-input: improve error handling media: s2255drv: fix a casting warning media: ivtvfb: Cleanup some warnings media: videobuf-dma-sg: Fix a weird cast soc_camera: fix a weird cast on printk ...
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_ */