Skip to contentSkip to conversation

venus: vdec: fix format enumeration

PATCH In review Alexandre Courbot 2 participants 3 messages Mar 19, 2018 – Mar 23, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 venus: vdec: fix format enumeration

find_format_by_index() stops enumerating formats as soon as the index matches, and returns NULL if venus_helper_check_codec() finds out that the format is not supported. This prevents formats to be properly enumerated if a non-supported format is present, as the enumeration will end with it.

Fix this by moving the call to venus_helper_check_codec() into the loop, and keep enumerating when it fails.

Fixes 29f0133ec6 media: venus: use helper function to check supported codecs
---
 drivers/media/platform/qcom/venus/vdec.c | 13 +++++++------
 drivers/media/platform/qcom/venus/venc.c | 13 +++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +7 -6
index c9e9576bb08a..49bbd1861d3a 100644
@@ -135,20 +135,21 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
 		return NULL;
 
 	for (i = 0; i < size; i++) {
+		bool valid;
+
 		if (fmt[i].type != type)
 			continue;
-		if (k == index)
+		valid = type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ||
+			venus_helper_check_codec(inst, fmt[i].pixfmt);
+		if (k == index && valid)
 			break;
-		k++;
+		if (valid)
+			k++;
 	}
 
 	if (i == size)
 		return NULL;
 
-	if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
-	    !venus_helper_check_codec(inst, fmt[i].pixfmt))
-		return NULL;
-
 	return &fmt[i];
 }
 
drivers/media/platform/qcom/venus/venc.c +7 -6
index e3a10a852cad..6b2ce479584e 100644
@@ -120,20 +120,21 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
 		return NULL;
 
 	for (i = 0; i < size; i++) {
+		bool valid;
+
 		if (fmt[i].type != type)
 			continue;
-		if (k == index)
+		valid = type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ||
+			venus_helper_check_codec(inst, fmt[i].pixfmt);
+		if (k == index && valid)
 			break;
-		k++;
+		if (valid)
+			k++;
 	}
 
 	if (i == size)
 		return NULL;
 
-	if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
-	    !venus_helper_check_codec(inst, fmt[i].pixfmt))
-		return NULL;
-
 	return &fmt[i];
 }
 
Signature · 1 line
2.16.2.804.g6dcf76e118-goog
Acked-by on v2 1/1
#1 lore raw

Hi Alex,

Thanks!

Quoted 9 lines · Alexandre Courbot

find_format_by_index() stops enumerating formats as soon as the index matches, and returns NULL if venus_helper_check_codec() finds out that the format is not supported. This prevents formats to be properly enumerated if a non-supported format is present, as the enumeration will end with it.

Fix this by moving the call to venus_helper_check_codec() into the loop, and keep enumerating when it fails.

Quoted 7 lines
Fixes 29f0133ec6 media: venus: use helper function to check supported codecs
---
 drivers/media/platform/qcom/venus/vdec.c | 13 +++++++------
 drivers/media/platform/qcom/venus/venc.c | 13 +++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)
Signature · 2 lines
regards,
Stan
#2 lore raw

Hi Hans,

Could you take this patch it not too late.

Quoted 16 lines · Stanimir Varbanov

Hi Alex,

Thanks!

Quoted 11 lines · Alexandre Courbot

find_format_by_index() stops enumerating formats as soon as the index matches, and returns NULL if venus_helper_check_codec() finds out that the format is not supported. This prevents formats to be properly enumerated if a non-supported format is present, as the enumeration will end with it.

Fix this by moving the call to venus_helper_check_codec() into the loop, and keep enumerating when it fails.

Fixes 29f0133ec6 media: venus: use helper function to check supported codecs
Quoted 8 lines
Quoted 5 lines
---
  drivers/media/platform/qcom/venus/vdec.c | 13 +++++++------
  drivers/media/platform/qcom/venus/venc.c | 13 +++++++------
  2 files changed, 14 insertions(+), 12 deletions(-)

regards,
Stan