media: venus: vdec: fix format enumeration
authorAlexandre Courbot <acourbot@chromium.org>
Mon, 19 Mar 2018 09:32:29 +0000 (05:32 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 4 Apr 2018 10:12:52 +0000 (06:12 -0400)
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
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/venc.c

index c9e9576bb08a4e1f568aec1ea55ad003e66dded6..49bbd1861d3a3f5d289825ff4e76921d7eaf0ce1 100644 (file)
@@ -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];
 }
 
index e3a10a852cade9cb8eca6b1768a73ce4cab8d0b0..6b2ce479584e9123af085aed83a2b5aa052050c8 100644 (file)
@@ -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];
 }