[COMMON] media: mfc: DRV4.0: find dec/enc formats using pixelformat
authorJeonghee Kim <jhhhh.kim@samsung.com>
Fri, 8 Jun 2018 04:54:49 +0000 (13:54 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Mon, 23 Jul 2018 06:12:18 +0000 (15:12 +0900)
Change-Id: I9dfcf2ee5a93672cf7dfc9e996103fa120ca279e
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc_dec.c
drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h
drivers/media/platform/exynos/mfc/s5p_mfc_enc.c
drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h

index 2f5048b4cf20a76769182ea29fb5a779185fda48..3ed7ad86fc9e4b78f1779ae5f9011d9d40c919c1 100644 (file)
 #define MAX_FRAME_SIZE         (2*1024*1024)
 
 /* Find selected format description */
-static struct s5p_mfc_fmt *mfc_dec_find_format(struct v4l2_format *f, unsigned int t)
+static struct s5p_mfc_fmt *mfc_dec_find_format(unsigned int pixelformat)
 {
        unsigned long i;
 
        for (i = 0; i < NUM_FORMATS; i++) {
-               if (dec_formats[i].fourcc == f->fmt.pix_mp.pixelformat &&
-                   dec_formats[i].type == t)
+               if (dec_formats[i].fourcc == pixelformat)
                        return (struct s5p_mfc_fmt *)&dec_formats[i];
        }
 
@@ -159,23 +158,23 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx)
                case V4L2_PIX_FMT_NV16M:
                case V4L2_PIX_FMT_NV12M_S10B:
                case V4L2_PIX_FMT_NV12M_P010:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[14];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M_S10B);
                        break;
                case V4L2_PIX_FMT_NV21M:
                case V4L2_PIX_FMT_NV61M:
                case V4L2_PIX_FMT_NV21M_S10B:
                case V4L2_PIX_FMT_NV21M_P010:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[17];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV61M_S10B);
                        break;
                default:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[14];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M_S10B);
                        break;
                }
                ctx->raw_buf.num_planes = 2;
        } else if (ctx->is_10bit && !ctx->is_422format) {
                if (ctx->dst_fmt->mem_planes == 1) {
                        /* YUV420 only supports the single plane */
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[8];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12N_10B);
                } else {
                        switch (org_fmt) {
                        case V4L2_PIX_FMT_NV12M_S10B:
@@ -188,16 +187,16 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx)
                        case V4L2_PIX_FMT_NV16M:
                        case V4L2_PIX_FMT_NV16M_S10B:
                        case V4L2_PIX_FMT_NV16M_P210:
-                               ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[9];
+                               ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_P010);
                                break;
                        case V4L2_PIX_FMT_NV21M:
                        case V4L2_PIX_FMT_NV61M:
                        case V4L2_PIX_FMT_NV61M_S10B:
                        case V4L2_PIX_FMT_NV61M_P210:
-                               ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[11];
+                               ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV21M_S10B);
                                break;
                        default:
-                               ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[9];
+                               ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_P010);
                                break;
                        }
                }
@@ -213,17 +212,17 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx)
                case V4L2_PIX_FMT_NV16M_S10B:
                case V4L2_PIX_FMT_NV12M_P010:
                case V4L2_PIX_FMT_NV16M_P210:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[13];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M);
                        break;
                case V4L2_PIX_FMT_NV21M:
                case V4L2_PIX_FMT_NV21M_S10B:
                case V4L2_PIX_FMT_NV61M_S10B:
                case V4L2_PIX_FMT_NV21M_P010:
                case V4L2_PIX_FMT_NV61M_P210:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[16];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV61M);
                        break;
                default:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[13];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M);
                        break;
                }
                ctx->raw_buf.num_planes = 2;
@@ -235,14 +234,14 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx)
                case V4L2_PIX_FMT_NV16M_S10B:
                case V4L2_PIX_FMT_NV12M_P010:
                case V4L2_PIX_FMT_NV16M_P210:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[5];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M);
                        break;
                case V4L2_PIX_FMT_NV61M:
                case V4L2_PIX_FMT_NV21M_S10B:
                case V4L2_PIX_FMT_NV61M_S10B:
                case V4L2_PIX_FMT_NV21M_P010:
                case V4L2_PIX_FMT_NV61M_P210:
-                       ctx->dst_fmt = (struct s5p_mfc_fmt *)&dec_formats[10];
+                       ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV21M);
                        break;
                default:
                        /* It is right format */
@@ -374,27 +373,17 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        }
        mfc_debug(2, "Type is %d\n", f->type);
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-               fmt = mfc_dec_find_format(f, MFC_FMT_DEC);
+               fmt = mfc_dec_find_format(f->fmt.pix_mp.pixelformat);
                if (!fmt) {
                        mfc_err_dev("Unsupported format for source.\n");
                        return -EINVAL;
                }
        } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               fmt = mfc_dec_find_format(f, MFC_FMT_RAW);
-
+               fmt = mfc_dec_find_format(f->fmt.pix_mp.pixelformat);
                if (!fmt) {
                        mfc_err_dev("Unsupported format for destination.\n");
                        return -EINVAL;
                }
-
-               if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
-                       mfc_err_dev("Not supported format: NV12MT\n");
-                       return -EINVAL;
-               }
-               else if(fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
-                       mfc_err_dev("Not supported format: NV12MT_16X16\n");
-                       return -EINVAL;
-               }
        }
 
        return 0;
@@ -424,7 +413,7 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv,
        if (ret)
                return ret;
 
-       ctx->dst_fmt = mfc_dec_find_format(f, MFC_FMT_RAW);
+       ctx->dst_fmt = mfc_dec_find_format(f->fmt.pix_mp.pixelformat);
        if (!ctx->dst_fmt) {
                mfc_err_ctx("Unsupported format for destination.\n");
                return -EINVAL;
@@ -499,7 +488,7 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *priv,
        if (ret)
                return ret;
 
-       ctx->src_fmt = mfc_dec_find_format(f, MFC_FMT_DEC);
+       ctx->src_fmt = mfc_dec_find_format(f->fmt.pix_mp.pixelformat);
        ctx->codec_mode = ctx->src_fmt->codec_mode;
        mfc_info_ctx("Dec input codec(%d): %s\n",
                        ctx->codec_mode, ctx->src_fmt->name);
index 4fb5aa0680e24e1811f58121c0f720b66cdd9d08..0a19cb38c63afa0f57236c7e1d650e9e1d1f2ee0 100644 (file)
@@ -40,22 +40,6 @@ struct s5p_mfc_fmt dec_formats[] = {
                .num_planes = 3,
                .mem_planes = 3,
        },
-       {
-               .name = "4:2:0 2 Planes 16x16 Tiles",
-               .fourcc = V4L2_PIX_FMT_NV12MT_16X16,
-               .codec_mode = MFC_FORMATS_NO_CODEC,
-               .type = MFC_FMT_RAW,
-               .num_planes = 2,
-               .mem_planes = 2,
-       },
-       {
-               .name = "4:2:0 2 Planes 64x32 Tiles",
-               .fourcc = V4L2_PIX_FMT_NV12MT,
-               .codec_mode = MFC_FORMATS_NO_CODEC,
-               .type = MFC_FMT_RAW,
-               .num_planes = 2,
-               .mem_planes = 2,
-       },
        {
                .name = "4:2:0 2 Planes Y/CbCr",
                .fourcc = V4L2_PIX_FMT_NV12M,
index 274250d7c8bec2c5e29877f70fcda7d3ccb125cc..82e2f361c8763e98ea87dd97860e98be416166fd 100644 (file)
 #include "s5p_mfc_buf.h"
 #include "s5p_mfc_mem.h"
 
-static struct s5p_mfc_fmt *mfc_enc_find_format(struct v4l2_format *f, unsigned int t)
+static struct s5p_mfc_fmt *mfc_enc_find_format(unsigned int pixelformat)
 {
        unsigned long i;
 
        for (i = 0; i < NUM_FORMATS; i++) {
-               if (enc_formats[i].fourcc == f->fmt.pix_mp.pixelformat &&
-                   enc_formats[i].type == t)
+               if (enc_formats[i].fourcc == pixelformat)
                        return (struct s5p_mfc_fmt *)&enc_formats[i];
        }
 
@@ -234,7 +233,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               fmt = mfc_enc_find_format(f, MFC_FMT_ENC);
+               fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat);
                if (!fmt) {
                        mfc_err_dev("failed to try capture format\n");
                        return -EINVAL;
@@ -248,7 +247,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                pix_fmt_mp->plane_fmt[0].bytesperline =
                        pix_fmt_mp->plane_fmt[0].sizeimage;
        } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-               fmt = mfc_enc_find_format(f, MFC_FMT_RAW);
+               fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat);
                if (!fmt) {
                        mfc_err_dev("failed to try output format\n");
                        return -EINVAL;
@@ -321,7 +320,7 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv,
                return -EBUSY;
        }
 
-       fmt = mfc_enc_find_format(f, MFC_FMT_ENC);
+       fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat);
        if (!fmt) {
                mfc_err_ctx("failed to set capture format\n");
                return -EINVAL;
@@ -435,18 +434,11 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *priv,
                return 0;
        }
 
-       fmt = mfc_enc_find_format(f, MFC_FMT_RAW);
+       fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat);
        if (!fmt) {
                mfc_err_ctx("failed to set output format\n");
                return -EINVAL;
        }
-       if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
-               mfc_err_ctx("Not supported format: NV12MT\n");
-               return -EINVAL;
-       } else if (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
-               mfc_err_ctx("Not supported format: NV12MT_16X16\n");
-               return -EINVAL;
-       }
 
        if (fmt->mem_planes != pix_fmt_mp->num_planes) {
                mfc_err_ctx("plane number is different (%d != %d)\n",
index 2af7ef229c434656e3fc4fd31b5a9413a01d8c78..b21397bcb1bfbbdbd13984c571196d1ddb97ab0f 100644 (file)
@@ -49,22 +49,6 @@ struct s5p_mfc_fmt enc_formats[] = {
                .num_planes = 3,
                .mem_planes = 3,
        },
-       {
-               .name = "4:2:0 2 Planes 16x16 Tiles",
-               .fourcc = V4L2_PIX_FMT_NV12MT_16X16,
-               .codec_mode = MFC_FORMATS_NO_CODEC,
-               .type = MFC_FMT_RAW,
-               .num_planes = 2,
-               .mem_planes = 2,
-       },
-       {
-               .name = "4:2:0 2 Planes 64x32 Tiles",
-               .fourcc = V4L2_PIX_FMT_NV12MT,
-               .codec_mode = MFC_FORMATS_NO_CODEC,
-               .type = MFC_FMT_RAW,
-               .num_planes = 2,
-               .mem_planes = 2,
-       },
        {
                .name = "4:2:0 2 Planes",
                .fourcc = V4L2_PIX_FMT_NV12M,