[PATCH v2] v4l2: Add support for interpreting remaining fields in VIDIOC_ENUMINPUT struct v4l2_input

Dmitry V. Levin ldv at altlinux.org
Sat Feb 26 19:36:03 UTC 2022


On Fri, Feb 25, 2022 at 07:07:52AM +0100, Marek Vasut wrote:
> Interpret $audioset as flags, $tuner as integer. Add ID list for
> v4l2_std_id. Add flags for status and capabilities and interpret
> them.
> 
> This is based off Linux 5.15.y:
> https://www.kernel.org/doc/html/v5.15/userspace-api/media/v4l/vidioc-enuminput.html

A reference to a recent kernel looks as if these fields were new,
but all of them were introduced in the Linux kernel long time ago,
the latest of them was "capabilities" introduced by Linux kernel
commit v2.6.33-rc1~70^2~91.

> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> V2: Fill in tests/ioctl_v4l2-success.c so make check would pass
>     and to test the new field decoding
> ---
>  src/v4l2.c                                |  16 +
>  src/xlat/v4l2_input_capabilities_flags.h  |  77 +++++
>  src/xlat/v4l2_input_capabilities_flags.in |   4 +
>  src/xlat/v4l2_input_status_flags.h        | 245 +++++++++++++
>  src/xlat/v4l2_input_status_flags.in       |  16 +
>  src/xlat/v4l2_std_ids.h                   | 399 ++++++++++++++++++++++
>  src/xlat/v4l2_std_ids.in                  |  27 ++
>  tests/ioctl_v4l2-success.c                |  71 +++-
>  8 files changed, 842 insertions(+), 13 deletions(-)
>  create mode 100644 src/xlat/v4l2_input_capabilities_flags.h
>  create mode 100644 src/xlat/v4l2_input_capabilities_flags.in
>  create mode 100644 src/xlat/v4l2_input_status_flags.h
>  create mode 100644 src/xlat/v4l2_input_status_flags.in
>  create mode 100644 src/xlat/v4l2_std_ids.h
>  create mode 100644 src/xlat/v4l2_std_ids.in

All src/xlat/*.h files are generated, please do not include them into the
patch.

> @@ -779,6 +782,19 @@ print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
>  		tprint_struct_next();
>  		PRINT_FIELD_XVAL(i, type, v4l2_input_types,
>  				 "V4L2_INPUT_TYPE_???");
> +		tprint_struct_next();
> +		PRINT_FIELD_X(i, audioset);
> +		tprint_struct_next();
> +		PRINT_FIELD_U(i, tuner);

Is "tuner" field an arbitrary integer, or should it rather be printed
as an enum using v4l2_tuner_types, e.g.
	PRINT_FIELD_XVAL(i, tuner, v4l2_tuner_types, "V4L2_TUNER_???");
?

> diff --git a/src/xlat/v4l2_input_capabilities_flags.in b/src/xlat/v4l2_input_capabilities_flags.in
> new file mode 100644
> index 000000000..cd7a13467
> --- /dev/null
> +++ b/src/xlat/v4l2_input_capabilities_flags.in
> @@ -0,0 +1,4 @@
> +#unconditional
> +V4L2_IN_CAP_DV_TIMINGS		0x00000002
> +V4L2_IN_CAP_STD			0x00000004
> +V4L2_IN_CAP_NATIVE_SIZE		0x00000008

Fallback definitions for #unconditional constants have no sense,
please do not add them.


-- 
ldv


More information about the Strace-devel mailing list