diff mbox series

[PATCHv2] v4l2-compliance: only check function if an MC is present

Message ID b6bc652a-9e6e-0e82-5a86-2bd0f2df51f1@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series [PATCHv2] v4l2-compliance: only check function if an MC is present | expand

Commit Message

Hans Verkuil Feb. 18, 2022, 8:09 a.m. UTC
The codec tests checked if the function of the device as reported
by the media controller is that of an de/encoder. But that test
was also done for codecs without a MC, and then it fails.

So only do this test if an MC was found.

Also test that stateless codecs always have a MC since it is
required for such codecs.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
Nicolas, Stanimir, can you test? This is an improved version of the
patch fixing the function test for codecs.
---
 utils/v4l2-compliance/v4l2-compliance.cpp  | 1 +
 utils/v4l2-compliance/v4l2-compliance.h    | 1 +
 utils/v4l2-compliance/v4l2-test-codecs.cpp | 6 ++++--
 3 files changed, 6 insertions(+), 2 deletions(-)

Comments

Nícolas F. R. A. Prado Feb. 18, 2022, 4:05 p.m. UTC | #1
Hi Hans,

On Fri, Feb 18, 2022 at 09:09:26AM +0100, Hans Verkuil wrote:
> The codec tests checked if the function of the device as reported
> by the media controller is that of an de/encoder. But that test
> was also done for codecs without a MC, and then it fails.
> 
> So only do this test if an MC was found.
> 
> Also test that stateless codecs always have a MC since it is
> required for such codecs.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Just like v1, this patch fixes the following v4l-compliance fail I was seeing on
the mtk-vcodec-enc driver on mt8173-elm-hana:

	fail: v4l2-test-codecs.cpp(35): node->function != MEDIA_ENT_F_PROC_VIDEO_ENCODER
test VIDIOC_(TRY_)ENCODER_CMD: FAIL

So,

Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Thanks,
Nícolas

> ---
> Nicolas, Stanimir, can you test? This is an improved version of the
> patch fixing the function test for codecs.
> ---
>  utils/v4l2-compliance/v4l2-compliance.cpp  | 1 +
>  utils/v4l2-compliance/v4l2-compliance.h    | 1 +
>  utils/v4l2-compliance/v4l2-test-codecs.cpp | 6 ++++--
>  3 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> index c53a55ba..8d0e94e9 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> @@ -998,6 +998,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
>  			if (!node.is_v4l2())
>  				driver = mdinfo.driver;
>  			node.media_bus_info = mdinfo.bus_info;
> +			node.has_media = true;
>  		}
>  	}
> 
> diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
> index 7255161f..507187eb 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.h
> +++ b/utils/v4l2-compliance/v4l2-compliance.h
> @@ -120,6 +120,7 @@ struct base_node {
>  	struct node *node2;	/* second open filehandle */
>  	bool has_outputs;
>  	bool has_inputs;
> +	bool has_media;
>  	unsigned tuners;
>  	unsigned modulators;
>  	unsigned inputs;
> diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
> index 22175eef..1d76a17c 100644
> --- a/utils/v4l2-compliance/v4l2-test-codecs.cpp
> +++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
> @@ -31,7 +31,8 @@ int testEncoder(struct node *node)
>  	bool is_encoder = node->codec_mask & (STATEFUL_ENCODER | JPEG_ENCODER);
>  	int ret;
> 
> -	if (IS_ENCODER(node))
> +	fail_on_test((node->codec_mask & STATELESS_ENCODER) && !node->has_media);
> +	if (IS_ENCODER(node) && node->has_media)
>  		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_ENCODER);
>  	memset(&cmd, 0xff, sizeof(cmd));
>  	memset(&cmd.raw, 0, sizeof(cmd.raw));
> @@ -100,7 +101,8 @@ int testDecoder(struct node *node)
>  	bool is_decoder = node->codec_mask & (STATEFUL_DECODER | JPEG_DECODER);
>  	int ret;
> 
> -	if (IS_DECODER(node))
> +	fail_on_test((node->codec_mask & STATELESS_DECODER) && !node->has_media);
> +	if (IS_DECODER(node) && node->has_media)
>  		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_DECODER);
>  	memset(&cmd, 0xff, sizeof(cmd));
>  	memset(&cmd.raw, 0, sizeof(cmd.raw));
> -- 
> 2.34.1
>
Stanimir Varbanov Feb. 21, 2022, 12:35 p.m. UTC | #2
On 2/18/22 10:09, Hans Verkuil wrote:
> The codec tests checked if the function of the device as reported
> by the media controller is that of an de/encoder. But that test
> was also done for codecs without a MC, and then it fails.
> 
> So only do this test if an MC was found.
> 
> Also test that stateless codecs always have a MC since it is
> required for such codecs.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
> Nicolas, Stanimir, can you test? This is an improved version of the
> patch fixing the function test for codecs.
> ---
>  utils/v4l2-compliance/v4l2-compliance.cpp  | 1 +
>  utils/v4l2-compliance/v4l2-compliance.h    | 1 +
>  utils/v4l2-compliance/v4l2-test-codecs.cpp | 6 ++++--
>  3 files changed, 6 insertions(+), 2 deletions(-)
> 

Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>

> diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> index c53a55ba..8d0e94e9 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> @@ -998,6 +998,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
>  			if (!node.is_v4l2())
>  				driver = mdinfo.driver;
>  			node.media_bus_info = mdinfo.bus_info;
> +			node.has_media = true;
>  		}
>  	}
> 
> diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
> index 7255161f..507187eb 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.h
> +++ b/utils/v4l2-compliance/v4l2-compliance.h
> @@ -120,6 +120,7 @@ struct base_node {
>  	struct node *node2;	/* second open filehandle */
>  	bool has_outputs;
>  	bool has_inputs;
> +	bool has_media;
>  	unsigned tuners;
>  	unsigned modulators;
>  	unsigned inputs;
> diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
> index 22175eef..1d76a17c 100644
> --- a/utils/v4l2-compliance/v4l2-test-codecs.cpp
> +++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
> @@ -31,7 +31,8 @@ int testEncoder(struct node *node)
>  	bool is_encoder = node->codec_mask & (STATEFUL_ENCODER | JPEG_ENCODER);
>  	int ret;
> 
> -	if (IS_ENCODER(node))
> +	fail_on_test((node->codec_mask & STATELESS_ENCODER) && !node->has_media);
> +	if (IS_ENCODER(node) && node->has_media)
>  		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_ENCODER);
>  	memset(&cmd, 0xff, sizeof(cmd));
>  	memset(&cmd.raw, 0, sizeof(cmd.raw));
> @@ -100,7 +101,8 @@ int testDecoder(struct node *node)
>  	bool is_decoder = node->codec_mask & (STATEFUL_DECODER | JPEG_DECODER);
>  	int ret;
> 
> -	if (IS_DECODER(node))
> +	fail_on_test((node->codec_mask & STATELESS_DECODER) && !node->has_media);
> +	if (IS_DECODER(node) && node->has_media)
>  		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_DECODER);
>  	memset(&cmd, 0xff, sizeof(cmd));
>  	memset(&cmd.raw, 0, sizeof(cmd.raw));
diff mbox series

Patch

diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index c53a55ba..8d0e94e9 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -998,6 +998,7 @@  void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
 			if (!node.is_v4l2())
 				driver = mdinfo.driver;
 			node.media_bus_info = mdinfo.bus_info;
+			node.has_media = true;
 		}
 	}

diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index 7255161f..507187eb 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -120,6 +120,7 @@  struct base_node {
 	struct node *node2;	/* second open filehandle */
 	bool has_outputs;
 	bool has_inputs;
+	bool has_media;
 	unsigned tuners;
 	unsigned modulators;
 	unsigned inputs;
diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
index 22175eef..1d76a17c 100644
--- a/utils/v4l2-compliance/v4l2-test-codecs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
@@ -31,7 +31,8 @@  int testEncoder(struct node *node)
 	bool is_encoder = node->codec_mask & (STATEFUL_ENCODER | JPEG_ENCODER);
 	int ret;

-	if (IS_ENCODER(node))
+	fail_on_test((node->codec_mask & STATELESS_ENCODER) && !node->has_media);
+	if (IS_ENCODER(node) && node->has_media)
 		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_ENCODER);
 	memset(&cmd, 0xff, sizeof(cmd));
 	memset(&cmd.raw, 0, sizeof(cmd.raw));
@@ -100,7 +101,8 @@  int testDecoder(struct node *node)
 	bool is_decoder = node->codec_mask & (STATEFUL_DECODER | JPEG_DECODER);
 	int ret;

-	if (IS_DECODER(node))
+	fail_on_test((node->codec_mask & STATELESS_DECODER) && !node->has_media);
+	if (IS_DECODER(node) && node->has_media)
 		fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_DECODER);
 	memset(&cmd, 0xff, sizeof(cmd));
 	memset(&cmd.raw, 0, sizeof(cmd.raw));