v4l2-common.h (ef1c4a6fa91bbbe9b09f770d28eba31a9edf770c) v4l2-common.h (d2dc57b10ae2bd2e2e92ce26f2aaf24bcee17c53)
1/*
2 v4l2 common internal API header
3
4 This header contains internal shared ioctl definitions for use by the
5 internal low-level v4l2 drivers.
6 Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
7 define,
8

--- 306 unchanged lines hidden (view full) ---

315 unsigned int hmax, unsigned int halign,
316 unsigned int salign);
317
318/**
319 * v4l2_find_nearest_size - Find the nearest size among a discrete
320 * set of resolutions contained in an array of a driver specific struct.
321 *
322 * @array: a driver specific array of image sizes
1/*
2 v4l2 common internal API header
3
4 This header contains internal shared ioctl definitions for use by the
5 internal low-level v4l2 drivers.
6 Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
7 define,
8

--- 306 unchanged lines hidden (view full) ---

315 unsigned int hmax, unsigned int halign,
316 unsigned int salign);
317
318/**
319 * v4l2_find_nearest_size - Find the nearest size among a discrete
320 * set of resolutions contained in an array of a driver specific struct.
321 *
322 * @array: a driver specific array of image sizes
323 * @array_size: the length of the driver specific array of image sizes
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
325 * @width: desired width.
326 * @height: desired height.
327 *
328 * Finds the closest resolution to minimize the width and height differences
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.
334 */
324 * @width_field: the name of the width field in the driver specific struct
325 * @height_field: the name of the height field in the driver specific struct
326 * @width: desired width.
327 * @height: desired height.
328 *
329 * Finds the closest resolution to minimize the width and height differences
330 * between what requested and the supported resolutions. The size of the width
331 * and height fields in the driver specific must equal to that of u32, i.e. four
332 * bytes.
333 *
334 * Returns the best match or NULL if the length of the array is zero.
335 */
335#define v4l2_find_nearest_size(array, width_field, height_field, \
336#define v4l2_find_nearest_size(array, array_size, width_field, height_field, \
336 width, height) \
337 ({ \
338 BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
339 sizeof((array)->height_field) != sizeof(u32)); \
340 (typeof(&(*(array))))__v4l2_find_nearest_size( \
337 width, height) \
338 ({ \
339 BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
340 sizeof((array)->height_field) != sizeof(u32)); \
341 (typeof(&(*(array))))__v4l2_find_nearest_size( \
341 (array), ARRAY_SIZE(array), sizeof(*(array)), \
342 (array), array_size, 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);

--- 37 unchanged lines hidden ---
343 offsetof(typeof(*(array)), width_field), \
344 offsetof(typeof(*(array)), height_field), \
345 width, height); \
346 })
347const void *
348__v4l2_find_nearest_size(const void *array, size_t array_size,
349 size_t entry_size, size_t width_offset,
350 size_t height_offset, s32 width, s32 height);

--- 37 unchanged lines hidden ---