Enumerate all pixels formats
Subsystems (5)
Benjamin Gaignard
maintainerv5 cover Enumerate all pixels formats
The goal of this series is to help userspace applications, like Gstreamer or Chromium, to categorize decoders and so avoid trying to use decoder that can't do the require task because it won't support the needed pixel format.
As example, in today implementation we need to simulate 10 bit header control to know if the driver support 10 bits pixel formats. With this new flag it will simpler for userspace applications know if driver support 10 bit pixel formats and if it is supported by userspace.
An example of how it can be used in GStreamer to discover the supported pixels formats for stateless decoders is available here:
https://gitlab.freedesktop.org/benjamin.gaignard1/gstreamer/-/commits/v4l2codecs_enum_all_supported_formats?ref_type=heads
v4l2-compliance test of this flag:
https://gitlab.collabora.com/benjamin.gaignard/v4l-utils/-/tree/enum_all_formats?ref_type=heads
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field.
- Make vicodec and visl test driver use the new flag
- Doing the same for Verisilicon driver.
changes in version 4:
- Explicitly document that the new flags are targeting mem2mem devices.
changes in version 3:
- Add a flag to inform userspace application that driver as take care of the flag.
changes in version 2:
- Clarify documentation.
- Only keep V4L2_FMT_FLAG_ALL_FORMATS flag in ioctl.
Benjamin
Benjamin Gaignard (3):
media: videodev2: Add flag to unconditionnaly enumerate pixels formats
media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
media: verisilicon: Use V4L2_FMT_FLAG_ENUM_ALL flag
.../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../media/videodev2.h.rst.exceptions | 1 + .../media/platform/verisilicon/hantro_v4l2.c | 17 ++++++++++++----- .../media/test-drivers/vicodec/vicodec-core.c | 7 ++++--- drivers/media/test-drivers/visl/visl-video.c | 11 +++++++---- include/uapi/linux/videodev2.h | 3 +++ 6 files changed, 38 insertions(+), 13 deletions(-)
Signature · 1 line
2.43.0
Benjamin Gaignard
maintainerPATCH v5 1/3 media: videodev2: Add flag to unconditionnaly enumerate pixels formats
When the index field is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL error code.
---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field.
.../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +11 -1
@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When the + index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore + any configuration and enumerate all the possible formats. Drivers + which do not support this flag yet always return an ``EINVAL`` + error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types
@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL`` + - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag + the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``. Return Value ============
Documentation/userspace-api/media/videodev2.h.rst.exceptions +1 -0
@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL fmtdesc-flags # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-type
include/uapi/linux/videodev2.h +3 -0
@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N
Signature · 1 line
2.43.0
Re: [PATCH v5 1/3] media: videodev2: Add flag to unconditionnaly enumerate pixels formats
Hey Benjamin,
in the subject line:
s/unconditionnaly enumerate pixels/unconditionally enumerate pixel/
Quoted 1 line · Benjamin Gaignard
When the index field is ORed with
V4L2_FMT_FLAG_ENUM_ALLthe driver
s/is ORed with/is set with/ (same meaning but a lot less confusing)
Quoted 2 lines
will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL
s/yet always/yet, always/
Quoted 18 lines
error code.
Signed-off-by Benjamin Gaignard <[email protected]>---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field..../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +0
-0
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 89
Quoted 6 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-1@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When the + index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore
s/ORed/set/ (same as above)
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 91
Quoted 2 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-0+ any configuration and enumerate all the possible formats. Drivers + which do not support this flag yet always return an ``EINVAL``
s/yet always/yet, always/
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 243
Quoted 11 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +4
-0+ error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL`` + - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag
s/applications/application/
s/ORs/sets/
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 246
Quoted 3 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +3
-0+ the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``.
s/yet always/yet, always/
Quoted 20 lines
Return Value
============Documentation/userspace-api/media/videodev2.h.rst.exceptions +0
-0@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flagsreplace define
V4L2_FMT_FLAG_CSC_HSV_ENCfmtdesc-flags replace defineV4L2_FMT_FLAG_CSC_QUANTIZATIONfmtdesc-flags replace defineV4L2_FMT_FLAG_META_LINE_BASEDfmtdesc-flags +replace defineV4L2_FMT_FLAG_ENUM_ALLfmtdesc-flags# V4L2 timecode types
replace defineV4L2_TC_TYPE_24FPStimecode-typeinclude/uapi/linux/videodev2.h +0
-0
include/uapi/linux/videodev2.h struct v4l2_fmtdesc { · line 907
Quoted 4 lines
include/uapi/linux/videodev2.h +1
-0@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */
s/ORed/set/
Regards,
Sebastian
Quoted 12 lines
include/uapi/linux/videodev2.h +2
-0+#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N Signature · 6 lines
2.43.0 _______________________________________________ Kernel mailing list -- [email protected] To unsubscribe send an email to [email protected] This list is managed by https://mailman.collabora.com
Re: [PATCH v5 1/3] media: videodev2: Add flag to unconditionnaly enumerate pixels formats
In reply to Benjamin GaignardQuoted 21 lines · Benjamin Gaignard
When the index field is ORed with
V4L2_FMT_FLAG_ENUM_ALLthe driver will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL error code.Signed-off-by Benjamin Gaignard <[email protected]>---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field..../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +0
-0
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 88
Quoted 5 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +1
-1@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When the
You need to start a new paragraph before 'When'. Otherwise you might read that the 'When' sentence is somehow related to the previous sentence.
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 90
Quoted 2 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-0+ index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore + any configuration and enumerate all the possible formats. Drivers
I'd rephrase this a little bit:
the driver will enumerate all the possible formats, ignoring any limitations from the current configuration.
And after that I would like to see an example of a use-case.
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 241
Quoted 10 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +3
-0+ which do not support this flag yet always return an ``EINVAL`` + error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL``
I am not really happy with this name since the prefix is identical to that of other V4L2_FMT_FLAG_ defines. How about: V4L2_FMTDESC_FLAG_ENUM_ALL? Or V4L2_FMT_IDX_ENUM_ALL?
Quoted 25 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +5
-0+ - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag + the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``. Return Value ============Documentation/userspace-api/media/videodev2.h.rst.exceptions +1
-0@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL fmtdesc-flags # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-typeinclude/uapi/linux/videodev2.h +0
-0
include/uapi/linux/videodev2.h struct v4l2_fmtdesc { · line 912
Quoted 9 lines
include/uapi/linux/videodev2.h +3
-0@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N
Regards,
Hans
Re: [PATCH v5 1/3] media: videodev2: Add flag to unconditionnaly enumerate pixels formats
Quoted 34 lines · Hans Verkuil
Quoted 21 lines · Benjamin Gaignard
When the index field is ORed with
V4L2_FMT_FLAG_ENUM_ALLthe driver will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL error code.Signed-off-by Benjamin Gaignard <[email protected]>---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field..../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +0
-0Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 88
Quoted 5 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +1
-1@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When theYou need to start a new paragraph before 'When'. Otherwise you might read that the 'When' sentence is somehow related to the previous sentence.
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 90
Quoted 2 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-0+ index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore + any configuration and enumerate all the possible formats. Drivers
Quoted 6 lines
I'd rephrase this a little bit:
the driver will enumerate all the possible formats, ignoring any limitations from the current configuration.
And after that I would like to see an example of a use-case.
Should the flag be kept on return of VIDIOC_ENUM_FMT or should it be cleared? For reference: VIDIOC_QUERYCTRL will clear the V4L2_CTRL_FLAG_NEXT_CTRL flag.
Regardless of what we pick, it should be documented.
Regards,
Hans
Quoted 55 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 241
Quoted 11 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +3
-0+ which do not support this flag yet always return an ``EINVAL`` + error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL``I am not really happy with this name since the prefix is identical to that of other
V4L2_FMT_FLAG_defines. How about:V4L2_FMTDESC_FLAG_ENUM_ALL? OrV4L2_FMT_IDX_ENUM_ALL?Quoted 25 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +5
-0+ - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag + the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``. Return Value ============Documentation/userspace-api/media/videodev2.h.rst.exceptions +1
-0@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL fmtdesc-flags # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-typeinclude/uapi/linux/videodev2.h +0
-0include/uapi/linux/videodev2.h struct v4l2_fmtdesc { · line 912
Quoted 9 lines
include/uapi/linux/videodev2.h +3
-0@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N Regards,
Hans
Benjamin Gaignard
maintainerRe: [PATCH v5 1/3] media: videodev2: Add flag to unconditionnaly enumerate pixels formats
Le 30/07/2024 à 09:19, Hans Verkuil a écrit :
Quoted 35 lines · Hans Verkuil
Quoted 34 lines · Benjamin Gaignard
Quoted 21 lines
When the index field is ORed with
V4L2_FMT_FLAG_ENUM_ALLthe driver will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL error code.Signed-off-by Benjamin Gaignard <[email protected]>---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field..../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +0
-0Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 88
Quoted 5 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +1
-1@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When theYou need to start a new paragraph before 'When'. Otherwise you might read that the 'When' sentence is somehow related to the previous sentence.
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 90
Quoted 2 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-0+ index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore + any configuration and enumerate all the possible formats. DriversI'd rephrase this a little bit:
Quoted 8 lines
Quoted 4 lines
the driver will enumerate all the possible formats, ignoring any limitations from the current configuration.
And after that I would like to see an example of a use-case.
Should the flag be kept on return of
VIDIOC_ENUM_FMTor should it be cleared? For reference:VIDIOC_QUERYCTRLwill clear theV4L2_CTRL_FLAG_NEXT_CTRLflag.Regardless of what we pick, it should be documented.
I believe most of the flags are cleared in v4l2 so I will to do the same and document it.
Quoted 58 lines
Regards,
Hans
Quoted 52 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 241
Quoted 10 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +3
-0+ which do not support this flag yet always return an ``EINVAL`` + error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL``I am not really happy with this name since the prefix is identical to that of other
V4L2_FMT_FLAG_defines. How about:V4L2_FMTDESC_FLAG_ENUM_ALL? OrV4L2_FMT_IDX_ENUM_ALL?Quoted 25 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +5
-0+ - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag + the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``. Return Value ============Documentation/userspace-api/media/videodev2.h.rst.exceptions +1
-0@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL fmtdesc-flags # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-typeinclude/uapi/linux/videodev2.h +0
-0include/uapi/linux/videodev2.h struct v4l2_fmtdesc { · line 912
Quoted 9 lines
include/uapi/linux/videodev2.h +3
-0@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N Regards,
Hans
Benjamin Gaignard
maintainerRe: [PATCH v5 1/3] media: videodev2: Add flag to unconditionnaly enumerate pixels formats
In reply to Hans VerkuilLe 30/07/2024 à 09:08, Hans Verkuil a écrit :
Quoted 39 lines · Benjamin Gaignard
Quoted 21 lines
When the index field is ORed with
V4L2_FMT_FLAG_ENUM_ALLthe driver will ignore any configuration and enumerate all the possible formats. Drivers which do not support this flag yet always return an EINVAL error code.Signed-off-by Benjamin Gaignard <[email protected]>---
changes in version 5:
- Reset the proposal to follow Hans's advices
- Add new flag to be used with index field..../userspace-api/media/v4l/vidioc-enum-fmt.rst | 12 +++++++++++- .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-)Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +0
-0Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 88
Quoted 5 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +1
-1@@ -85,7 +85,11 @@ the ``mbus_code`` field is handled differently: * - __u32 - ``index`` - Number of the format in the enumeration, set by the application. - This is in no way related to the ``pixelformat`` field. + This is in no way related to the ``pixelformat`` field. When theYou need to start a new paragraph before 'When'. Otherwise you might read that the 'When' sentence is somehow related to the previous sentence.
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 90
Quoted 2 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +2
-0+ index is ORed with V4L2_FMT_FLAG_ENUM_ALL the driver will ignore + any configuration and enumerate all the possible formats. DriversI'd rephrase this a little bit:
the driver will enumerate all the possible formats, ignoring any limitations from the current configuration.
And after that I would like to see an example of a use-case.
Quoted 13 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst the ``mbus_code`` field is handled differently: · line 241
Quoted 10 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +3
-0+ which do not support this flag yet always return an ``EINVAL`` + error code. * - __u32 - ``type`` - Type of the data stream, set by the application. Only these types@@ -234,6 +238,12 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL``I am not really happy with this name since the prefix is identical to that of other
V4L2_FMT_FLAG_defines. How about:V4L2_FMTDESC_FLAG_ENUM_ALL? OrV4L2_FMT_IDX_ENUM_ALL?
I will use V4L2_FMTDESC_FLAG_ENUM_ALL in the next version.
Regards,
Benjamin
Quoted 39 lines
Quoted 26 lines
Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +5
-0+ - 0x80000000 + - When the applications ORs ``index`` with ``V4L2_FMT_FLAG_ENUM_ALL`` flag + the driver enumerates all the possible pixel formats without taking care + of any already set configuration. Drivers which do not support this flag + yet always return ``EINVAL``. Return Value ============Documentation/userspace-api/media/videodev2.h.rst.exceptions +1
-0@@ -216,6 +216,7 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL fmtdesc-flags # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-typeinclude/uapi/linux/videodev2.h +0
-0include/uapi/linux/videodev2.h struct v4l2_fmtdesc { · line 912
Quoted 9 lines
include/uapi/linux/videodev2.h +3
-0@@ -904,6 +904,9 @@ struct v4l2_fmtdesc {#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +/* Format description flag, to be ORed with the index */ +#define V4L2_FMT_FLAG_ENUM_ALL 0x80000000 +/* Frame Size and frame rate enumeration */ /* * F R A M E S I Z E E N U M E R A T I O N Regards,
Hans
Benjamin Gaignard
maintainerPATCH v5 2/3 media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
In reply to Benjamin GaignardSince V4L2_FMT_FLAG_ENUM_ALL flag mostly targeting stateless decoder pixel formats enumeration, update vicodec visl test drivers to use it.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 7 ++++--- drivers/media/test-drivers/visl/visl-video.c | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/media/test-drivers/vicodec/vicodec-core.c +4 -3
@@ -706,6 +706,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, bool is_out) {bool is_uncomp = (ctx->is_enc && is_out) || (!ctx->is_enc && !is_out); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ;if (V4L2_TYPE_IS_MULTIPLANAR (f->type) && !multiplanar)return -EINVAL ;
@@ -718,18 +719,18 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,if (ctx->is_enc || !vb2_is_streaming (&ctx->fh.m2m_ctx->cap_q_ctx.q)) - info =v4l2_fwht_get_pixfmt (f->index); + info =v4l2_fwht_get_pixfmt (index);else info =v4l2_fwht_find_nth_fmt (info->width_div, info->height_div, info->components_num, info->pixenc, - f->index); + index);if (!info)return -EINVAL ; f->pixelformat = info->id; }else { -if (f->index) +if (index)return -EINVAL ; f->pixelformat = ctx->is_stateless ?V4L2_PIX_FMT_FWHT_STATELESS :V4L2_PIX_FMT_FWHT ;
drivers/media/test-drivers/visl/visl-video.c +7 -4
@@ -341,21 +341,24 @@ static int visl_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) {struct visl_ctx *ctx =visl_file_to_ctx (file); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; -if (f->index >= ctx->coded_format_desc->num_decoded_fmts) +if (index >= ctx->coded_format_desc->num_decoded_fmts)return -EINVAL ; - f->pixelformat = ctx->coded_format_desc->decoded_fmts[f->index]; + f->pixelformat = ctx->coded_format_desc->decoded_fmts[index];return 0 ; }static int visl_enum_fmt_vid_out (struct file *file,void *priv,struct v4l2_fmtdesc *f) { -if (f->index >=ARRAY_SIZE (visl_coded_fmts)) +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; + +if (index >=ARRAY_SIZE (visl_coded_fmts))return -EINVAL ; - f->pixelformat = visl_coded_fmts[f->index].pixelformat; + f->pixelformat = visl_coded_fmts[index].pixelformat;return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH v5 2/3] media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
Hey Benjamin,
Quoted 1 line · Benjamin Gaignard
Since
V4L2_FMT_FLAG_ENUM_ALLflag mostly targeting stateless
s/Since/Since the/
s/targeting/targets/
Quoted 1 line
decoder pixel formats enumeration, update vicodec visl test
s/pixel formats/pixel-format/
Quoted 1 line
drivers to use it.
s/drivers/driver/
The rest below basically just strips the flag from every use-case of the index, before using it.
I wonder couldn't we implement a macro for this, as I believe this will have to be done in a lot of places, something like:
/*
* Drivers can support an enumeration of all formats, by ORing the
* V4L2_FMT_FLAG_ENUM_ALL flag into the index field.
* In order to use the index field, strip the flag first. *
* See vidioc-enum-fmt.rst documentation for more details. */
#define STRIP_ENUM_ALL_FLAG(index) \
index & ~V4L2_FMT_FLAG_ENUM_ALL
And then use it like this:
u32 index = STRIP_ENUM_ALL_FLAG(f->index);
If we define this in a common header, then every driver can easily utilize it and you have built-in documentation.
What do you think?
Regards,
Sebastian
Quoted 81 lines
Signed-off-by Benjamin Gaignard <[email protected]>---
drivers/media/test-drivers/vicodec/vicodec-core.c| 7 ++++---drivers/media/test-drivers/visl/visl-video.c| 11 +++++++----2 files changed, 11 insertions(+), 7 deletions(-)drivers/media/test-drivers/vicodec/vicodec-core.c +4
-3@@ -706,6 +706,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, bool is_out) {bool is_uncomp = (ctx->is_enc && is_out) || (!ctx->is_enc && !is_out); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ;if (V4L2_TYPE_IS_MULTIPLANAR (f->type) && !multiplanar)return -EINVAL ;@@ -718,18 +719,18 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,if (ctx->is_enc || !vb2_is_streaming (&ctx->fh.m2m_ctx->cap_q_ctx.q)) - info =v4l2_fwht_get_pixfmt (f->index); + info =v4l2_fwht_get_pixfmt (index);else info =v4l2_fwht_find_nth_fmt (info->width_div, info->height_div, info->components_num, info->pixenc, - f->index); + index);if (!info)return -EINVAL ; f->pixelformat = info->id; }else { -if (f->index) +if (index)return -EINVAL ; f->pixelformat = ctx->is_stateless ?V4L2_PIX_FMT_FWHT_STATELESS :V4L2_PIX_FMT_FWHT ;drivers/media/test-drivers/visl/visl-video.c +7
-4@@ -341,21 +341,24 @@ static int visl_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) {struct visl_ctx *ctx =visl_file_to_ctx (file); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; -if (f->index >= ctx->coded_format_desc->num_decoded_fmts) +if (index >= ctx->coded_format_desc->num_decoded_fmts)return -EINVAL ; - f->pixelformat = ctx->coded_format_desc->decoded_fmts[f->index]; + f->pixelformat = ctx->coded_format_desc->decoded_fmts[index];return 0 ; }static int visl_enum_fmt_vid_out (struct file *file,void *priv,struct v4l2_fmtdesc *f) { -if (f->index >=ARRAY_SIZE (visl_coded_fmts)) +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; + +if (index >=ARRAY_SIZE (visl_coded_fmts))return -EINVAL ; - f->pixelformat = visl_coded_fmts[f->index].pixelformat; + f->pixelformat = visl_coded_fmts[index].pixelformat;return 0 ; }Signature · 6 lines
2.43.0 _______________________________________________ Kernel mailing list -- [email protected] To unsubscribe send an email to [email protected] This list is managed by https://mailman.collabora.com
Re: [PATCH v5 2/3] media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
Quoted 32 lines · Sebastian Fricke
Hey Benjamin,
Quoted 1 line · Benjamin Gaignard
Since
V4L2_FMT_FLAG_ENUM_ALLflag mostly targeting statelesss/Since/Since the/
s/targeting/targets/Quoted 1 line
decoder pixel formats enumeration, update vicodec visl test
s/pixel formats/pixel-format/
Quoted 1 line
drivers to use it.
s/drivers/driver/
The rest below basically just strips the flag from every use-case of the index, before using it.
I wonder couldn't we implement a macro for this, as I believe this will have to be done in a lot of places, something like:
/*
* Drivers can support an enumeration of all formats, by ORing the
*V4L2_FMT_FLAG_ENUM_ALLflag into the index field.
* In order to use the index field, strip the flag first. *
* Seevidioc-enum-fmt.rstdocumentation for more details. */
#defineSTRIP_ENUM_ALL_FLAG(index)\
index & ~V4L2_FMT_FLAG_ENUM_ALL
Quoted 3 lines
And then use it like this:
u32 index =
STRIP_ENUM_ALL_FLAG(f->index);
There is really no advantage to that. It is much better to be explicit about it rather than hiding it in a define.
Regards,
Hans
Quoted 91 lines
If we define this in a common header, then every driver can easily utilize it and you have built-in documentation.
What do you think?
Regards,
SebastianQuoted 81 lines
Signed-off-by Benjamin Gaignard <[email protected]>---
drivers/media/test-drivers/vicodec/vicodec-core.c| 7 ++++--- drivers/media/test-drivers/visl/visl-video.c | 11 +++++++----2 files changed, 11 insertions(+), 7 deletions(-)drivers/media/test-drivers/vicodec/vicodec-core.c +1
-0@@ -706,6 +706,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, bool is_out) { bool is_uncomp = (ctx->is_enc && is_out) || (!ctx->is_enc && !is_out); + u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL; if (V4L2_TYPE_IS_MULTIPLANAR(f->type) && !multiplanar) return -EINVAL;@@ -718,18 +719,18 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,if (
ctx->is_enc|| !vb2_is_streaming(&ctx->fh.m2m_ctx->cap_q_ctx.q)) - info =v4l2_fwht_get_pixfmt(f->index); + info =v4l2_fwht_get_pixfmt(index); else
info = v4l2_fwht_find_nth_fmt(info->width_div,info->height_div,info->components_num,info->pixenc,
-f->index);
+ index);
if (!info)
return-EINVAL;
f->pixelformat=info->id;
} else {
- if (f->index)
+ if (index)
return-EINVAL;
f->pixelformat=ctx->is_stateless?V4L2_PIX_FMT_FWHT_STATELESS:V4L2_PIX_FMT_FWHT;drivers/media/test-drivers/visl/visl-video.c +7
-4@@ -341,21 +341,24 @@ static int visl_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) { struct visl_ctx *ctx = visl_file_to_ctx(file); + u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL; - if (f->index >= ctx->coded_format_desc->num_decoded_fmts) + if (index >= ctx->coded_format_desc->num_decoded_fmts) return -EINVAL; - f->pixelformat = ctx->coded_format_desc->decoded_fmts[f->index]; + f->pixelformat = ctx->coded_format_desc->decoded_fmts[index]; return 0; }static int visl_enum_fmt_vid_out (struct file *file,void *priv, struct v4l2_fmtdesc *f) { - if (f->index >= ARRAY_SIZE(visl_coded_fmts)) + u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL; + + if (index >= ARRAY_SIZE(visl_coded_fmts)) return -EINVAL; - f->pixelformat = visl_coded_fmts[f->index].pixelformat; + f->pixelformat = visl_coded_fmts[index].pixelformat; return 0; }--
2.43.0_______________________________________________
Kernel mailing list -- [email protected]
To unsubscribe send an email to [email protected] This list is managed by https://mailman.collabora.com
Re: [PATCH v5 2/3] media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
In reply to Benjamin GaignardQuoted 15 lines · Benjamin Gaignard
Since
V4L2_FMT_FLAG_ENUM_ALLflag mostly targeting stateless decoder pixel formats enumeration, update vicodec visl test drivers to use it.Signed-off-by Benjamin Gaignard <[email protected]>--- drivers/media/test-drivers/vicodec/vicodec-core.c | 7 ++++--- drivers/media/test-drivers/visl/visl-video.c | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-)drivers/media/test-drivers/vicodec/vicodec-core.c +0
-0
drivers/media/test-drivers/vicodec/vicodec-core.c static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, · line 709
Quoted 4 lines
drivers/media/test-drivers/vicodec/vicodec-core.c +1
-0@@ -706,6 +706,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, bool is_out) {bool is_uncomp = (ctx->is_enc && is_out) || (!ctx->is_enc && !is_out); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ;
This is not what I am looking for: to properly test this in v4l2-compliance this flag actually has to make a difference in the result. I.e. you actually have to add some limitation. This might be easier to do in visl than vicodec. As long as at least one test-driver support this, then that's good enough for me.
Regards,
Hans
Quoted 58 lines
drivers/media/test-drivers/vicodec/vicodec-core.c +3
-3if (V4L2_TYPE_IS_MULTIPLANAR (f->type) && !multiplanar)return -EINVAL ;@@ -718,18 +719,18 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,if (ctx->is_enc || !vb2_is_streaming (&ctx->fh.m2m_ctx->cap_q_ctx.q)) - info =v4l2_fwht_get_pixfmt (f->index); + info =v4l2_fwht_get_pixfmt (index);else info =v4l2_fwht_find_nth_fmt (info->width_div, info->height_div, info->components_num, info->pixenc, - f->index); + index);if (!info)return -EINVAL ; f->pixelformat = info->id; }else { -if (f->index) +if (index)return -EINVAL ; f->pixelformat = ctx->is_stateless ?V4L2_PIX_FMT_FWHT_STATELESS :V4L2_PIX_FMT_FWHT ;drivers/media/test-drivers/visl/visl-video.c +7
-4@@ -341,21 +341,24 @@ static int visl_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) {struct visl_ctx *ctx =visl_file_to_ctx (file); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; -if (f->index >= ctx->coded_format_desc->num_decoded_fmts) +if (index >= ctx->coded_format_desc->num_decoded_fmts)return -EINVAL ; - f->pixelformat = ctx->coded_format_desc->decoded_fmts[f->index]; + f->pixelformat = ctx->coded_format_desc->decoded_fmts[index];return 0 ; }static int visl_enum_fmt_vid_out (struct file *file,void *priv,struct v4l2_fmtdesc *f) { -if (f->index >=ARRAY_SIZE (visl_coded_fmts)) +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; + +if (index >=ARRAY_SIZE (visl_coded_fmts))return -EINVAL ; - f->pixelformat = visl_coded_fmts[f->index].pixelformat; + f->pixelformat = visl_coded_fmts[index].pixelformat;return 0 ; }
Benjamin Gaignard
maintainerRe: [PATCH v5 2/3] media: test-drivers: Use V4L2_FMT_FLAG_ENUM_ALL flag
Le 30/07/2024 à 09:13, Hans Verkuil a écrit :
Quoted 11 lines · Benjamin Gaignard
Quoted 10 lines
Since
V4L2_FMT_FLAG_ENUM_ALLflag mostly targeting stateless decoder pixel formats enumeration, update vicodec visl test drivers to use it.Signed-off-by Benjamin Gaignard <[email protected]>--- drivers/media/test-drivers/vicodec/vicodec-core.c | 7 ++++--- drivers/media/test-drivers/visl/visl-video.c | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-)
Quoted 13 lines
drivers/media/test-drivers/vicodec/vicodec-core.c static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, · line 709
Quoted 9 lines
drivers/media/test-drivers/vicodec/vicodec-core.c +1
-0@@ -706,6 +706,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, bool is_out) {bool is_uncomp = (ctx->is_enc && is_out) || (!ctx->is_enc && !is_out); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ;This is not what I am looking for: to properly test this in v4l2-compliance this flag actually has to make a difference in the result. I.e. you actually have to add some limitation. This might be easier to do in visl than vicodec. As long as at least one test-driver support this, then that's good enough for me.
Ok I will focus on visl and made it return another list of formats when the flag is set.
Regards,
Benjamin
Quoted 63 lines
Regards,
Hans
Quoted 58 lines
drivers/media/test-drivers/vicodec/vicodec-core.c +3
-3if (V4L2_TYPE_IS_MULTIPLANAR (f->type) && !multiplanar)return -EINVAL ;@@ -718,18 +719,18 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,if (ctx->is_enc || !vb2_is_streaming (&ctx->fh.m2m_ctx->cap_q_ctx.q)) - info =v4l2_fwht_get_pixfmt (f->index); + info =v4l2_fwht_get_pixfmt (index);else info =v4l2_fwht_find_nth_fmt (info->width_div, info->height_div, info->components_num, info->pixenc, - f->index); + index);if (!info)return -EINVAL ; f->pixelformat = info->id; }else { -if (f->index) +if (index)return -EINVAL ; f->pixelformat = ctx->is_stateless ?V4L2_PIX_FMT_FWHT_STATELESS :V4L2_PIX_FMT_FWHT ;drivers/media/test-drivers/visl/visl-video.c +7
-4@@ -341,21 +341,24 @@ static int visl_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) {struct visl_ctx *ctx =visl_file_to_ctx (file); +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; -if (f->index >= ctx->coded_format_desc->num_decoded_fmts) +if (index >= ctx->coded_format_desc->num_decoded_fmts)return -EINVAL ; - f->pixelformat = ctx->coded_format_desc->decoded_fmts[f->index]; + f->pixelformat = ctx->coded_format_desc->decoded_fmts[index];return 0 ; }static int visl_enum_fmt_vid_out (struct file *file,void *priv,struct v4l2_fmtdesc *f) { -if (f->index >=ARRAY_SIZE (visl_coded_fmts)) +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; + +if (index >=ARRAY_SIZE (visl_coded_fmts))return -EINVAL ; - f->pixelformat = visl_coded_fmts[f->index].pixelformat; + f->pixelformat = visl_coded_fmts[index].pixelformat;return 0 ; }
Benjamin Gaignard
maintainerPATCH v5 3/3 media: verisilicon: Use V4L2_FMT_FLAG_ENUM_ALL flag
In reply to Benjamin GaignardBy adding support of V4L2_FMT_FLAG_ENUM_ALL flag into the driver we allowing userspce applications to discover all possible pixel formats of the hardware block. This way userspace can decide of which decoder to use given the support pixel formats.
--- .../media/platform/verisilicon/hantro_v4l2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/media/platform/verisilicon/hantro_v4l2.c +12 -5
@@ -201,7 +201,14 @@ static int vidioc_enum_fmt(struct file *file, void *priv,struct hantro_ctx *ctx =fh_to_ctx (priv);const struct hantro_fmt *fmt, *formats;unsigned int num_fmts, i, j =0 ; -bool skip_mode_none; +bool skip_mode_none, enum_all_formats; +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ; + +/* +* If V4L2_FMT_FLAG_ENUM_ALL flag is set, we want to enumerate all +* hardware supported pixels formats +*/ + enum_all_formats = !!(f->index &V4L2_FMT_FLAG_ENUM_ALL );/* * When dealing with an encoder:
@@ -222,9 +229,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,if (skip_mode_none == mode_none)continue ; -if (!hantro_check_depth_match (fmt, ctx->bit_depth)) +if (!hantro_check_depth_match (fmt, ctx->bit_depth) && !enum_all_formats)continue ; -if (j == f->index) { +if (j == index) { f->pixelformat = fmt->fourcc;return 0 ; }
@@ -242,9 +249,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,for (i =0 ; i < num_fmts; i++) { fmt = &formats[i]; -if (!hantro_check_depth_match (fmt, ctx->bit_depth)) +if (!hantro_check_depth_match (fmt, ctx->bit_depth) && !enum_all_formats)continue ; -if (j == f->index) { +if (j == index) { f->pixelformat = fmt->fourcc;return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH v5 3/3] media: verisilicon: Use V4L2_FMT_FLAG_ENUM_ALL flag
Hey Benjamin,
Quoted 1 line · Benjamin Gaignard
By adding support of
V4L2_FMT_FLAG_ENUM_ALLflag into the driver
s/support of/support for the/
Quoted 1 line
we allowing userspce applications to discover all possible
Either:
s/we allowing/we allow/
or
s/we allowing/we are allowing/
are correct.
s/userspce/userspace/
Quoted 2 lines
pixel formats of the hardware block. This way userspace can decide of which decoder to use given the support pixel formats.
s/of which/which/
s/support/supported/
Quoted 11 lines
Signed-off-by Benjamin Gaignard <[email protected]>---
.../media/platform/verisilicon/hantro_v4l2.c| 17 ++++++++++++-----1 file changed, 12 insertions(+), 5 deletions(-)drivers/media/platform/verisilicon/hantro_v4l2.c +0
-0
drivers/media/platform/verisilicon/hantro_v4l2.c static int vidioc_enum_fmt(struct file *file, void *priv, · line 205
Quoted 6 lines
drivers/media/platform/verisilicon/hantro_v4l2.c +2
-1@@ -201,7 +201,14 @@ static int vidioc_enum_fmt(struct file *file, void *priv,struct hantro_ctx *ctx =fh_to_ctx (priv);const struct hantro_fmt *fmt, *formats;unsigned int num_fmts, i, j =0 ; -bool skip_mode_none; +bool skip_mode_none, enum_all_formats; +u32 index = f->index & ~V4L2_FMT_FLAG_ENUM_ALL ;
As described in the previous patch, I think this operation will turn out to be very common, so maybe we can add a macro for that.
drivers/media/platform/verisilicon/hantro_v4l2.c static int vidioc_enum_fmt(struct file *file, void *priv, · line 208
Quoted 3 lines
drivers/media/platform/verisilicon/hantro_v4l2.c +3
-0+ +/* +* If V4L2_FMT_FLAG_ENUM_ALL flag is set, we want to enumerate all
s/If/If the/
drivers/media/platform/verisilicon/hantro_v4l2.c static int vidioc_enum_fmt(struct file *file, void *priv, · line 209
Quoted 1 line
drivers/media/platform/verisilicon/hantro_v4l2.c +1
-0+* hardware supported pixels formats
s/pixels/pixel/
Greetings,
Sebastian
Quoted 36 lines
drivers/media/platform/verisilicon/hantro_v4l2.c +6
-4+*/ + enum_all_formats = !!(f->index &V4L2_FMT_FLAG_ENUM_ALL );/* * When dealing with an encoder: @@ -222,9 +229,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,if (skip_mode_none == mode_none)continue ; -if (!hantro_check_depth_match (fmt, ctx->bit_depth)) +if (!hantro_check_depth_match (fmt, ctx->bit_depth) && !enum_all_formats)continue ; -if (j == f->index) { +if (j == index) { f->pixelformat = fmt->fourcc;return 0 ; }@@ -242,9 +249,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,for (i =0 ; i < num_fmts; i++) { fmt = &formats[i]; -if (!hantro_check_depth_match (fmt, ctx->bit_depth)) +if (!hantro_check_depth_match (fmt, ctx->bit_depth) && !enum_all_formats)continue ; -if (j == f->index) { +if (j == index) { f->pixelformat = fmt->fourcc;return 0 ; }Signature · 6 lines
2.43.0 _______________________________________________ Kernel mailing list -- [email protected] To unsubscribe send an email to [email protected] This list is managed by https://mailman.collabora.com