media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt

Rename 'v4l2_fwht_default_fmt' to 'v4l2_fwht_find_nth_fmt'
and add a function 'v4l2_fwht_validate_fmt' to check if
a format info matches the parameters.
This function will also be used to validate the stateless
params when adding support for stateless codecs.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Dafna Hirschfeld 2019-03-06 16:13:34 -05:00 committed by Mauro Carvalho Chehab
parent 92dc64d412
commit 50e4c5e1b6
3 changed files with 23 additions and 8 deletions

View File

@ -37,7 +37,19 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
{ V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 0, 1, 1, 1, 1, FWHT_FL_PIXENC_RGB},
};
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div,
bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info,
u32 width_div, u32 height_div, u32 components_num,
u32 pixenc)
{
if (info->width_div == width_div &&
info->height_div == height_div &&
(!pixenc || info->pixenc == pixenc) &&
info->components_num == components_num)
return true;
return false;
}
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div,
u32 height_div,
u32 components_num,
u32 pixenc,
@ -46,10 +58,10 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div,
unsigned int i;
for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++) {
if (v4l2_fwht_pixfmts[i].width_div == width_div &&
v4l2_fwht_pixfmts[i].height_div == height_div &&
(!pixenc || v4l2_fwht_pixfmts[i].pixenc == pixenc) &&
v4l2_fwht_pixfmts[i].components_num == components_num) {
bool is_valid = v4l2_fwht_validate_fmt(&v4l2_fwht_pixfmts[i],
width_div, height_div,
components_num, pixenc);
if (is_valid) {
if (start_idx == 0)
return v4l2_fwht_pixfmts + i;
start_idx--;

View File

@ -48,7 +48,10 @@ struct v4l2_fwht_state {
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div,
bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info,
u32 width_div, u32 height_div, u32 components_num,
u32 pixenc);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div,
u32 height_div,
u32 components_num,
u32 pixenc,

View File

@ -401,7 +401,7 @@ info_from_header(const struct fwht_cframe_hdr *p_hdr)
FWHT_FL_COMPONENTS_NUM_OFFSET);
pixenc = (flags & FWHT_FL_PIXENC_MSK);
}
return v4l2_fwht_default_fmt(width_div, height_div,
return v4l2_fwht_find_nth_fmt(width_div, height_div,
components_num, pixenc, 0);
}
@ -622,7 +622,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,
if (!info || ctx->is_enc)
info = v4l2_fwht_get_pixfmt(f->index);
else
info = v4l2_fwht_default_fmt(info->width_div,
info = v4l2_fwht_find_nth_fmt(info->width_div,
info->height_div,
info->components_num,
info->pixenc,