media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt
authorDafna Hirschfeld <dafna3@gmail.com>
Wed, 6 Mar 2019 21:13:34 +0000 (16:13 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 25 Mar 2019 17:50:00 +0000 (13:50 -0400)
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>
drivers/media/platform/vicodec/codec-v4l2-fwht.c
drivers/media/platform/vicodec/codec-v4l2-fwht.h
drivers/media/platform/vicodec/vicodec-core.c

index f15d76fae45cc956f1b1d5ddb4699222c2eb992b..372ed95e1a1f51a64a5c8d22d43248ec822126d9 100644 (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--;
index 53eba97ebc8301547bcef63c7d87643885cabbe6..b59503d4049a149a75e590cf62f0806bf7f4173f 100644 (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,
index ab837d5cb2d83999e96302d76bd99fe0c30a1a88..f68c90f995b9895d50da65f0f489547aa2d973ef 100644 (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,