Skip to content

Commit

Permalink
media: venus: vdec: fix format enumeration
Browse files Browse the repository at this point in the history
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: 29f0133 media: venus: use helper function to check supported codecs

Signed-off-by: Alexandre Courbot <[email protected]>
Acked-by: Stanimir Varbanov <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Gnurou authored and mchehab committed Apr 4, 2018
1 parent 890f276 commit 82e071e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions drivers/media/platform/qcom/venus/vdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
13 changes: 7 additions & 6 deletions drivers/media/platform/qcom/venus/venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit 82e071e

Please sign in to comment.