Hi Hans,

On Mon, Sep 16, 2019 at 11:00:46AM +0200, Hans Verkuil wrote:
> Add new macros V4L2_FOURCC_CONV and V4L2_FOURCC_ARGS for use
> in code that prints a fourcc. These macros can be used in both
> kernel and userspace.
> 
> Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>
> Suggested-by: Sakari Ailus <sakari.ai...@iki.fi>
> ---
>  include/uapi/linux/videodev2.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 530638dffd93..7a34eb93437e 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -82,6 +82,19 @@
>       ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 
> 24))
>  #define v4l2_fourcc_be(a, b, c, d)   (v4l2_fourcc(a, b, c, d) | (1U << 31))
>  
> +/*
> + * Helper macros to print a fourcc in a standard format. E.g.:
> + *
> + * printf("fourcc is " V4L2_FOURCC_CONV "\n", V4L2_FOURCC_ARGS(fourcc));
> + *
> + * Note that V4L2_FOURCC_ARGS reuses fourcc, so this can't be an
> + * expression with side-effects.
> + */
> +#define V4L2_FOURCC_CONV "%c%c%c%c%s"
> +#define V4L2_FOURCC_ARGS(fourcc) \
> +     (fourcc) & 0x7f, ((fourcc) >> 8) & 0x7f, ((fourcc) >> 16) & 0x7f, \
> +     ((fourcc) >> 24) & 0x7f, ((fourcc) & (1U << 31) ? "-BE" : "")
> +
>  /*
>   *   E N U M S
>   */

KernelDoc comments would be nice. Such as in here:

<URL:https://patchwork.linuxtv.org/patch/48372/>

I'm fine with either patch though.

-- 
Sakari Ailus

Reply via email to