From 028effd278bc905d65d1dfc807ef1f0d0c1e4749 Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Fri, 8 Jun 2018 13:54:49 +0900 Subject: [PATCH] [COMMON] media: mfc: DRV4.0: find dec/enc formats using pixelformat Change-Id: I9dfcf2ee5a93672cf7dfc9e996103fa120ca279e Signed-off-by: Jeonghee Kim --- .../media/platform/exynos/mfc/s5p_mfc_dec.c | 47 +++++++------------ .../exynos/mfc/s5p_mfc_dec_internal.h | 16 ------- .../media/platform/exynos/mfc/s5p_mfc_enc.c | 20 +++----- .../exynos/mfc/s5p_mfc_enc_internal.h | 16 ------- 4 files changed, 24 insertions(+), 75 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c index 2f5048b4cf20..3ed7ad86fc9e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c @@ -27,13 +27,12 @@ #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); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h index 4fb5aa0680e2..0a19cb38c63a 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h @@ -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, diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index 274250d7c8be..82e2f361c876 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -24,13 +24,12 @@ #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", diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h index 2af7ef229c43..b21397bcb1bf 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h @@ -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, -- 2.20.1