From: Jeonghee Kim Date: Fri, 15 Jun 2018 11:07:43 +0000 (+0900) Subject: [COMMON] media: mfc: parse supported format information X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=24ac7eac409e4b6802513eacb58fd8fc09d9bcdc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] media: mfc: parse supported format information MFC driver returns the error when the set format is not supported. In addition, it does not change the format after header parsing if it is not supported. Change-Id: Id7927f62c9348d5ca362039e3526f1a199d1014d Signed-off-by: Jeonghee Kim --- diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc.c b/drivers/media/platform/exynos/mfc/s5p_mfc.c index c34e0fc8f6aa..0a880ccae668 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc.c @@ -981,6 +981,11 @@ static void mfc_parse_dt(struct device_node *np, struct s5p_mfc_dev *mfc) /* Default 10bit format for decoding */ of_property_read_u32(np, "P010_decoding", &pdata->P010_decoding); + /* Formats */ + of_property_read_u32(np, "support_10bit", &pdata->support_10bit); + of_property_read_u32(np, "support_422", &pdata->support_422); + of_property_read_u32(np, "support_rgb", &pdata->support_rgb); + /* Encoder default parameter */ of_property_read_u32(np, "enc_param_num", &pdata->enc_param_num); if (pdata->enc_param_num) { diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c b/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c index 7c54563b4f4c..0770d0efb895 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_buf.c @@ -332,7 +332,7 @@ static void mfc_calc_enc_codec_buffer_size(struct s5p_mfc_ctx *ctx) enc->chroma_dpb_size + enc->me_buffer_size)); break; case S5P_FIMV_CODEC_VP9_ENC: - if (ctx->is_10bit || ctx->is_422format) { + if (ctx->is_10bit || ctx->is_422) { enc->luma_dpb_size = ALIGN(ENC_VP9_LUMA_DPB_10B_SIZE(ctx->crop_width, ctx->crop_height), 64); enc->chroma_dpb_size = @@ -351,7 +351,7 @@ static void mfc_calc_enc_codec_buffer_size(struct s5p_mfc_ctx *ctx) break; case S5P_FIMV_CODEC_HEVC_ENC: case S5P_FIMV_CODEC_BPG_ENC: - if (ctx->is_10bit || ctx->is_422format) { + if (ctx->is_10bit || ctx->is_422) { enc->luma_dpb_size = ALIGN(ENC_HEVC_LUMA_DPB_10B_SIZE(ctx->crop_width, ctx->crop_height), 64); enc->chroma_dpb_size = diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index 522d4cf43fc1..ef3d98d7909d 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -97,9 +97,11 @@ #define MFC_CTRL_TYPE_SRC (MFC_CTRL_TYPE_SET | MFC_CTRL_TYPE_GET_SRC) #define MFC_CTRL_TYPE_DST (MFC_CTRL_TYPE_GET_DST) -#define MFC_FMT_DEC 0 -#define MFC_FMT_ENC 1 -#define MFC_FMT_RAW 2 +#define MFC_FMT_STREAM (1 << 0) +#define MFC_FMT_FRAME (1 << 1) +#define MFC_FMT_10BIT (1 << 2) +#define MFC_FMT_422 (1 << 3) +#define MFC_FMT_RGB (1 << 4) /* node check */ #define IS_DEC_NODE(n) ((n == EXYNOS_VIDEONODE_MFC_DEC) || \ diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index 89c78f1b84c1..73e599d6482c 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -402,6 +402,10 @@ struct s5p_mfc_platdata { struct s5p_mfc_feature static_info_enc; /* Default 10bit format for decoding */ unsigned int P010_decoding; + /* Formats */ + unsigned int support_10bit; + unsigned int support_422; + unsigned int support_rgb; /* Encoder default parameter */ unsigned int enc_param_num; unsigned int enc_param_addr[MFC_MAX_DEFAULT_PARAM]; @@ -1372,7 +1376,7 @@ struct s5p_mfc_ctx { /* Profile infomation */ int is_10bit; - int is_422format; + int is_422; /* for DRM */ int is_drm; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c index 18d2c136ce98..37cdee1c2cc4 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c @@ -66,6 +66,10 @@ static int mfc_info_show(struct seq_file *s, void *unused) seq_printf(s, " static_info_dec: %d(0x%x), enc: %d(0x%x)\n", dev->pdata->static_info_dec.support, dev->pdata->static_info_dec.version, dev->pdata->static_info_enc.support, dev->pdata->static_info_enc.version); + seq_printf(s, "[FORMATS] 10bit: %s, 422: %s, RGB: %s\n", + dev->pdata->support_10bit ? "supported" : "not supported", + dev->pdata->support_422 ? "supported" : "not supported", + dev->pdata->support_rgb ? "supported" : "not supported"); if (dev->nal_q_handle) seq_printf(s, "[NAL-Q] state: %d\n", dev->nal_q_handle->nal_q_state); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c index bc5a400c0f8a..57c51bc76640 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c @@ -27,16 +27,30 @@ #define MAX_FRAME_SIZE (2*1024*1024) /* Find selected format description */ -static struct s5p_mfc_fmt *mfc_dec_find_format(unsigned int pixelformat) +static struct s5p_mfc_fmt *mfc_dec_find_format(struct s5p_mfc_ctx *ctx, + unsigned int pixelformat) { + struct s5p_mfc_dev *dev = ctx->dev; + struct s5p_mfc_fmt *fmt = NULL; unsigned long i; for (i = 0; i < NUM_FORMATS; i++) { - if (dec_formats[i].fourcc == pixelformat) - return (struct s5p_mfc_fmt *)&dec_formats[i]; + if (dec_formats[i].fourcc == pixelformat) { + fmt = (struct s5p_mfc_fmt *)&dec_formats[i]; + break; + } } - return NULL; + if (!dev->pdata->support_10bit && (fmt->type & MFC_FMT_10BIT)) { + mfc_err_ctx("10bit is not supported\n"); + fmt = NULL; + } + if (!dev->pdata->support_422 && (fmt->type & MFC_FMT_422)) { + mfc_err_ctx("422 is not supported\n"); + fmt = NULL; + } + + return fmt; } static struct v4l2_queryctrl *mfc_dec_get_ctrl(int id) @@ -88,58 +102,49 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } -/* Enumerate format */ -static int mfc_dec_enum_fmt(struct v4l2_fmtdesc *f, bool mplane, bool out) +static int mfc_dec_enum_fmt(struct s5p_mfc_dev *dev, struct v4l2_fmtdesc *f, + unsigned int type) { struct s5p_mfc_fmt *fmt; unsigned long i, j = 0; for (i = 0; i < NUM_FORMATS; ++i) { - if (mplane && dec_formats[i].mem_planes == 1) - continue; - else if (!mplane && dec_formats[i].mem_planes > 1) + if (!(dec_formats[i].type & type)) continue; - if (out && dec_formats[i].type != MFC_FMT_DEC) + if (!dev->pdata->support_10bit && (dec_formats[i].type & MFC_FMT_10BIT)) continue; - else if (!out && dec_formats[i].type != MFC_FMT_RAW) + if (!dev->pdata->support_422 && (dec_formats[i].type & MFC_FMT_422)) continue; - if (j == f->index) - break; - ++j; - } - if (i == NUM_FORMATS) - return -EINVAL; + if (j == f->index) { + fmt = &dec_formats[i]; + strlcpy(f->description, fmt->name, + sizeof(f->description)); + f->pixelformat = fmt->fourcc; - fmt = &dec_formats[i]; - strlcpy(f->description, fmt->name, sizeof(f->description)); - f->pixelformat = fmt->fourcc; + return 0; + } - return 0; -} + ++j; + } -static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv, - struct v4l2_fmtdesc *f) -{ - return mfc_dec_enum_fmt(f, false, false); + return -EINVAL; } static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv, - struct v4l2_fmtdesc *f) + struct v4l2_fmtdesc *f) { - return mfc_dec_enum_fmt(f, true, false); -} + struct s5p_mfc_dev *dev = video_drvdata(file); -static int vidioc_enum_fmt_vid_out(struct file *file, void *prov, - struct v4l2_fmtdesc *f) -{ - return mfc_dec_enum_fmt(f, false, true); + return mfc_dec_enum_fmt(dev, f, MFC_FMT_FRAME); } static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *prov, - struct v4l2_fmtdesc *f) + struct v4l2_fmtdesc *f) { - return mfc_dec_enum_fmt(f, true, true); + struct s5p_mfc_dev *dev = video_drvdata(file); + + return mfc_dec_enum_fmt(dev, f, MFC_FMT_STREAM); } static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx) @@ -147,7 +152,7 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx) struct s5p_mfc_dev *dev = ctx->dev; u32 org_fmt = ctx->dst_fmt->fourcc; - if (ctx->is_10bit && ctx->is_422format) { + if (ctx->is_10bit && ctx->is_422) { switch (org_fmt) { case V4L2_PIX_FMT_NV16M_S10B: case V4L2_PIX_FMT_NV61M_S10B: @@ -159,23 +164,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 = mfc_dec_find_format(V4L2_PIX_FMT_NV16M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, 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 = mfc_dec_find_format(V4L2_PIX_FMT_NV61M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV61M_S10B); break; default: - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV16M_S10B); break; } ctx->raw_buf.num_planes = 2; - } else if (ctx->is_10bit && !ctx->is_422format) { + } else if (ctx->is_10bit && !ctx->is_422) { if (ctx->dst_fmt->mem_planes == 1) { /* YUV420 only supports the single plane */ - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12N_10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV12N_10B); } else { switch (org_fmt) { case V4L2_PIX_FMT_NV12M_S10B: @@ -189,26 +194,26 @@ static void mfc_dec_change_format(struct s5p_mfc_ctx *ctx) case V4L2_PIX_FMT_NV16M_S10B: case V4L2_PIX_FMT_NV16M_P210: if (dev->pdata->P010_decoding) - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_P010); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV12M_P010); else - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV12M_S10B); 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 = mfc_dec_find_format(V4L2_PIX_FMT_NV21M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV21M_S10B); break; default: if (dev->pdata->P010_decoding) - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_P010); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV12M_P010); else - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV12M_S10B); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV12M_S10B); break; } } ctx->raw_buf.num_planes = 2; - } else if (!ctx->is_10bit && ctx->is_422format) { + } else if (!ctx->is_10bit && ctx->is_422) { switch (org_fmt) { case V4L2_PIX_FMT_NV16M: case V4L2_PIX_FMT_NV61M: @@ -219,17 +224,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 = mfc_dec_find_format(V4L2_PIX_FMT_NV16M); + ctx->dst_fmt = mfc_dec_find_format(ctx, 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 = mfc_dec_find_format(V4L2_PIX_FMT_NV61M); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV61M); break; default: - ctx->dst_fmt = mfc_dec_find_format(V4L2_PIX_FMT_NV16M); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV16M); break; } ctx->raw_buf.num_planes = 2; @@ -241,14 +246,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 = mfc_dec_find_format(V4L2_PIX_FMT_NV12M); + ctx->dst_fmt = mfc_dec_find_format(ctx, 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 = mfc_dec_find_format(V4L2_PIX_FMT_NV21M); + ctx->dst_fmt = mfc_dec_find_format(ctx, V4L2_PIX_FMT_NV21M); break; default: /* It is right format */ @@ -266,7 +271,7 @@ static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *priv, { struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); struct s5p_mfc_dec *dec; - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct s5p_mfc_raw_info *raw; int i; @@ -305,28 +310,28 @@ static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *priv, rectangle. */ s5p_mfc_dec_calc_dpb_size(ctx); - pix_mp->width = ctx->img_width; - pix_mp->height = ctx->img_height; - pix_mp->num_planes = ctx->dst_fmt->mem_planes; + pix_fmt_mp->width = ctx->img_width; + pix_fmt_mp->height = ctx->img_height; + pix_fmt_mp->num_planes = ctx->dst_fmt->mem_planes; if (dec->is_interlaced) - pix_mp->field = V4L2_FIELD_INTERLACED; + pix_fmt_mp->field = V4L2_FIELD_INTERLACED; else - pix_mp->field = V4L2_FIELD_NONE; + pix_fmt_mp->field = V4L2_FIELD_NONE; /* Set pixelformat to the format in which MFC outputs the decoded frame */ - pix_mp->pixelformat = ctx->dst_fmt->fourcc; + pix_fmt_mp->pixelformat = ctx->dst_fmt->fourcc; for (i = 0; i < ctx->dst_fmt->mem_planes; i++) { - pix_mp->plane_fmt[i].bytesperline = raw->stride[i]; + pix_fmt_mp->plane_fmt[i].bytesperline = raw->stride[i]; if (ctx->dst_fmt->mem_planes == 1) { - pix_mp->plane_fmt[i].sizeimage = raw->total_plane_size; + pix_fmt_mp->plane_fmt[i].sizeimage = raw->total_plane_size; } else { if (ctx->is_10bit) - pix_mp->plane_fmt[i].sizeimage = raw->plane_size[i] + pix_fmt_mp->plane_fmt[i].sizeimage = raw->plane_size[i] + raw->plane_size_2bits[i]; else - pix_mp->plane_fmt[i].sizeimage = raw->plane_size[i]; + pix_fmt_mp->plane_fmt[i].sizeimage = raw->plane_size[i]; } } } @@ -341,7 +346,7 @@ static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *priv, { struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); struct s5p_mfc_dec *dec; - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; mfc_debug_enter(); @@ -355,13 +360,13 @@ static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *priv, /* This is run on OUTPUT The buffer contains compressed image so width and height have no meaning */ - pix_mp->width = 0; - pix_mp->height = 0; - pix_mp->field = V4L2_FIELD_NONE; - pix_mp->plane_fmt[0].bytesperline = dec->src_buf_size; - pix_mp->plane_fmt[0].sizeimage = dec->src_buf_size; - pix_mp->pixelformat = ctx->src_fmt->fourcc; - pix_mp->num_planes = ctx->src_fmt->mem_planes; + pix_fmt_mp->width = 0; + pix_fmt_mp->height = 0; + pix_fmt_mp->field = V4L2_FIELD_NONE; + pix_fmt_mp->plane_fmt[0].bytesperline = dec->src_buf_size; + pix_fmt_mp->plane_fmt[0].sizeimage = dec->src_buf_size; + pix_fmt_mp->pixelformat = ctx->src_fmt->fourcc; + pix_fmt_mp->num_planes = ctx->src_fmt->mem_planes; mfc_debug_leave(); @@ -371,27 +376,16 @@ static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *priv, /* Try format */ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) { - struct s5p_mfc_dev *dev = video_drvdata(file); + struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); struct s5p_mfc_fmt *fmt; + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); + fmt = mfc_dec_find_format(ctx, pix_fmt_mp->pixelformat); + if (!fmt) { + mfc_err_dev("Unsupported format for %s\n", + V4L2_TYPE_IS_OUTPUT(f->type) ? "source" : "destination"); return -EINVAL; } - mfc_debug(2, "Type is %d\n", f->type); - if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - 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->fmt.pix_mp.pixelformat); - if (!fmt) { - mfc_err_dev("Unsupported format for destination.\n"); - return -EINVAL; - } - } return 0; } @@ -400,27 +394,17 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv, struct v4l2_format *f) { - struct s5p_mfc_dev *dev = video_drvdata(file); struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - int ret = 0; + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; mfc_debug_enter(); - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - if (ctx->vq_dst.streaming) { mfc_err_ctx("queue busy\n"); return -EBUSY; } - ret = vidioc_try_fmt(file, priv, f); - if (ret) - return ret; - - ctx->dst_fmt = mfc_dec_find_format(f->fmt.pix_mp.pixelformat); + ctx->dst_fmt = mfc_dec_find_format(ctx, pix_fmt_mp->pixelformat); if (!ctx->dst_fmt) { mfc_err_ctx("Unsupported format for destination.\n"); return -EINVAL; @@ -469,49 +453,42 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *priv, { struct s5p_mfc_dev *dev = video_drvdata(file); struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct s5p_mfc_dec *dec; + struct s5p_mfc_dec *dec = ctx->dec_priv; + struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; int ret = 0; - struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; mfc_debug_enter(); - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - if (ctx->vq_src.streaming) { mfc_err_ctx("queue busy\n"); return -EBUSY; } - ret = vidioc_try_fmt(file, priv, f); - if (ret) - return ret; + ctx->src_fmt = mfc_dec_find_format(ctx, pix_fmt_mp->pixelformat); + if (!ctx->src_fmt) { + mfc_err_ctx("Unsupported format for source.\n"); + return -EINVAL; + } - 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); - ctx->pix_format = pix_mp->pixelformat; - if ((pix_mp->width > 0) && (pix_mp->height > 0)) { - ctx->img_height = pix_mp->height; - ctx->img_width = pix_mp->width; + + ctx->pix_format = pix_fmt_mp->pixelformat; + if ((pix_fmt_mp->width > 0) && (pix_fmt_mp->height > 0)) { + ctx->img_height = pix_fmt_mp->height; + ctx->img_width = pix_fmt_mp->width; } + /* As this buffer will contain compressed data, the size is set * to the maximum size. */ - if (pix_mp->plane_fmt[0].sizeimage) - dec->src_buf_size = pix_mp->plane_fmt[0].sizeimage; + if (pix_fmt_mp->plane_fmt[0].sizeimage) + dec->src_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage; else dec->src_buf_size = MAX_FRAME_SIZE; - mfc_debug(2, "sizeimage: %d\n", pix_mp->plane_fmt[0].sizeimage); - pix_mp->plane_fmt[0].bytesperline = 0; + mfc_debug(2, "sizeimage: %d\n", pix_fmt_mp->plane_fmt[0].sizeimage); + pix_fmt_mp->plane_fmt[0].bytesperline = 0; + MFC_TRACE_CTX_HWLOCK("**DEC s_fmt\n"); ret = s5p_mfc_get_hwlock_ctx(ctx); if (ret < 0) { @@ -1237,9 +1214,7 @@ static int vidioc_g_ext_ctrls(struct file *file, void *priv, /* v4l2_ioctl_ops */ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_out_mplane, 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 7e471795789d..07e88c58341b 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_internal.h @@ -20,7 +20,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 3 Planes Y/Cb/Cr", .fourcc = V4L2_PIX_FMT_YUV420M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 3, }, @@ -28,7 +28,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 3 Planes Y/Cb/Cr single", .fourcc = V4L2_PIX_FMT_YUV420N, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 1, }, @@ -36,7 +36,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 3 Planes Y/Cr/Cb", .fourcc = V4L2_PIX_FMT_YVU420M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 3, }, @@ -44,7 +44,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CbCr", .fourcc = V4L2_PIX_FMT_NV12M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 2, }, @@ -52,7 +52,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CbCr single", .fourcc = V4L2_PIX_FMT_NV12N, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 1, }, @@ -60,7 +60,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CbCr 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV12M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -68,7 +68,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CbCr 10bit single", .fourcc = V4L2_PIX_FMT_NV12N_10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 1, }, @@ -76,7 +76,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CbCr P010 10bit", .fourcc = V4L2_PIX_FMT_NV12M_P010, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -84,7 +84,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CrCb", .fourcc = V4L2_PIX_FMT_NV21M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 2, }, @@ -92,7 +92,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CrCb 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV21M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -100,7 +100,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:0 2 Planes Y/CrCb P010 10bit", .fourcc = V4L2_PIX_FMT_NV21M_P010, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -108,7 +108,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CbCr", .fourcc = V4L2_PIX_FMT_NV16M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -116,7 +116,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CbCr 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV16M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -124,7 +124,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CbCr P210 10bit", .fourcc = V4L2_PIX_FMT_NV16M_P210, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -132,7 +132,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CrCb", .fourcc = V4L2_PIX_FMT_NV61M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -140,7 +140,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CrCb 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV61M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -148,7 +148,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "4:2:2 2 Planes Y/CrCb P210 10bit", .fourcc = V4L2_PIX_FMT_NV61M_P210, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -156,7 +156,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "H264 Encoded Stream", .fourcc = V4L2_PIX_FMT_H264, .codec_mode = S5P_FIMV_CODEC_H264_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -164,7 +164,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "H264/MVC Encoded Stream", .fourcc = V4L2_PIX_FMT_H264_MVC, .codec_mode = S5P_FIMV_CODEC_H264_MVC_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -172,7 +172,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "H263 Encoded Stream", .fourcc = V4L2_PIX_FMT_H263, .codec_mode = S5P_FIMV_CODEC_H263_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -180,7 +180,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "MPEG1 Encoded Stream", .fourcc = V4L2_PIX_FMT_MPEG1, .codec_mode = S5P_FIMV_CODEC_MPEG2_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -188,7 +188,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "MPEG2 Encoded Stream", .fourcc = V4L2_PIX_FMT_MPEG2, .codec_mode = S5P_FIMV_CODEC_MPEG2_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -196,7 +196,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "MPEG4 Encoded Stream", .fourcc = V4L2_PIX_FMT_MPEG4, .codec_mode = S5P_FIMV_CODEC_MPEG4_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -204,7 +204,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "FIMV Encoded Stream", .fourcc = V4L2_PIX_FMT_FIMV, .codec_mode = S5P_FIMV_CODEC_MPEG4_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -212,7 +212,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "FIMV1 Encoded Stream", .fourcc = V4L2_PIX_FMT_FIMV1, .codec_mode = S5P_FIMV_CODEC_FIMV1_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -220,7 +220,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "FIMV2 Encoded Stream", .fourcc = V4L2_PIX_FMT_FIMV2, .codec_mode = S5P_FIMV_CODEC_FIMV2_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -228,7 +228,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "FIMV3 Encoded Stream", .fourcc = V4L2_PIX_FMT_FIMV3, .codec_mode = S5P_FIMV_CODEC_FIMV3_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -236,7 +236,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "FIMV4 Encoded Stream", .fourcc = V4L2_PIX_FMT_FIMV4, .codec_mode = S5P_FIMV_CODEC_FIMV4_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -244,7 +244,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "XviD Encoded Stream", .fourcc = V4L2_PIX_FMT_XVID, .codec_mode = S5P_FIMV_CODEC_MPEG4_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -252,7 +252,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "VC1 Encoded Stream", .fourcc = V4L2_PIX_FMT_VC1_ANNEX_G, .codec_mode = S5P_FIMV_CODEC_VC1_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -260,7 +260,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "VC1 RCV Encoded Stream", .fourcc = V4L2_PIX_FMT_VC1_ANNEX_L, .codec_mode = S5P_FIMV_CODEC_VC1_RCV_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -268,7 +268,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "VP8 Encoded Stream", .fourcc = V4L2_PIX_FMT_VP8, .codec_mode = S5P_FIMV_CODEC_VP8_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -276,7 +276,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "VP9 Encoded Stream", .fourcc = V4L2_PIX_FMT_VP9, .codec_mode = S5P_FIMV_CODEC_VP9_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -284,7 +284,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "HEVC Encoded Stream", .fourcc = V4L2_PIX_FMT_HEVC, .codec_mode = S5P_FIMV_CODEC_HEVC_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -292,7 +292,7 @@ struct s5p_mfc_fmt dec_formats[] = { .name = "BPG Encoded Stream", .fourcc = V4L2_PIX_FMT_BPG, .codec_mode = S5P_FIMV_CODEC_BPG_DEC, - .type = MFC_FMT_DEC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index 82e2f361c876..4cc695cbf052 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -24,16 +24,34 @@ #include "s5p_mfc_buf.h" #include "s5p_mfc_mem.h" -static struct s5p_mfc_fmt *mfc_enc_find_format(unsigned int pixelformat) +static struct s5p_mfc_fmt *mfc_enc_find_format(struct s5p_mfc_ctx *ctx, + unsigned int pixelformat) { + struct s5p_mfc_dev *dev = ctx->dev; + struct s5p_mfc_fmt *fmt = NULL; unsigned long i; for (i = 0; i < NUM_FORMATS; i++) { - if (enc_formats[i].fourcc == pixelformat) - return (struct s5p_mfc_fmt *)&enc_formats[i]; + if (enc_formats[i].fourcc == pixelformat) { + fmt = (struct s5p_mfc_fmt *)&enc_formats[i]; + break; + } } - return NULL; + if (!dev->pdata->support_10bit && (fmt->type & MFC_FMT_10BIT)) { + mfc_err_ctx("10bit is not supported\n"); + fmt = NULL; + } + if (!dev->pdata->support_422 && (fmt->type & MFC_FMT_422)) { + mfc_err_ctx("422 is not supported\n"); + fmt = NULL; + } + if (!dev->pdata->support_rgb && (fmt->type & MFC_FMT_RGB)) { + mfc_err_ctx("RGB is not supported\n"); + fmt = NULL; + } + + return fmt; } static struct v4l2_queryctrl *mfc_enc_get_ctrl(int id) @@ -127,20 +145,20 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } -static int mfc_enc_enum_fmt(struct v4l2_fmtdesc *f, bool mplane, bool out) +static int mfc_enc_enum_fmt(struct s5p_mfc_dev *dev, struct v4l2_fmtdesc *f, + unsigned int type) { struct s5p_mfc_fmt *fmt; - unsigned long i; - int j = 0; + unsigned long i, j = 0; for (i = 0; i < NUM_FORMATS; ++i) { - if (mplane && enc_formats[i].mem_planes == 1) + if (!(enc_formats[i].type & type)) continue; - else if (!mplane && enc_formats[i].mem_planes > 1) + if (!dev->pdata->support_10bit && (enc_formats[i].type & MFC_FMT_10BIT)) continue; - if (out && enc_formats[i].type != MFC_FMT_RAW) + if (!dev->pdata->support_422 && (enc_formats[i].type & MFC_FMT_422)) continue; - else if (!out && enc_formats[i].type != MFC_FMT_ENC) + if (!dev->pdata->support_rgb && (enc_formats[i].type & MFC_FMT_RGB)) continue; if (j == f->index) { @@ -158,28 +176,20 @@ static int mfc_enc_enum_fmt(struct v4l2_fmtdesc *f, bool mplane, bool out) return -EINVAL; } -static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv, - struct v4l2_fmtdesc *f) -{ - return mfc_enc_enum_fmt(f, false, false); -} - static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv, - struct v4l2_fmtdesc *f) + struct v4l2_fmtdesc *f) { - return mfc_enc_enum_fmt(f, true, false); -} + struct s5p_mfc_dev *dev = video_drvdata(file); -static int vidioc_enum_fmt_vid_out(struct file *file, void *prov, - struct v4l2_fmtdesc *f) -{ - return mfc_enc_enum_fmt(f, false, true); + return mfc_enc_enum_fmt(dev, f, MFC_FMT_STREAM); } static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *prov, - struct v4l2_fmtdesc *f) + struct v4l2_fmtdesc *f) { - return mfc_enc_enum_fmt(f, true, true); + struct s5p_mfc_dev *dev = video_drvdata(file); + + return mfc_enc_enum_fmt(dev, f, MFC_FMT_FRAME); } static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) @@ -229,37 +239,14 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) { + struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); struct s5p_mfc_fmt *fmt; 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->fmt.pix_mp.pixelformat); - if (!fmt) { - mfc_err_dev("failed to try capture format\n"); - return -EINVAL; - } - - if (pix_fmt_mp->plane_fmt[0].sizeimage == 0) { - mfc_err_dev("must be set encoding dst size\n"); - return -EINVAL; - } - - 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->fmt.pix_mp.pixelformat); - if (!fmt) { - mfc_err_dev("failed to try output format\n"); - return -EINVAL; - } - - if (fmt->mem_planes != pix_fmt_mp->num_planes) { - mfc_err_dev("plane number is different (%d != %d)\n", - fmt->mem_planes, pix_fmt_mp->num_planes); - return -EINVAL; - } - } else { - mfc_err_dev("invalid buf type (%d)\n", f->type); + fmt = mfc_enc_find_format(ctx, pix_fmt_mp->pixelformat); + if (!fmt) { + mfc_err_dev("Unsupported format for %s\n", + V4L2_TYPE_IS_OUTPUT(f->type) ? "source" : "destination"); return -EINVAL; } @@ -275,13 +262,13 @@ static void mfc_enc_check_format(struct s5p_mfc_ctx *ctx) case V4L2_PIX_FMT_NV61M_P210: mfc_debug(2, "is 422 and 10bit format\n"); ctx->is_10bit = 1; - ctx->is_422format = 1; + ctx->is_422 = 1; break; case V4L2_PIX_FMT_NV16M: case V4L2_PIX_FMT_NV61M: mfc_debug(2, "is 422 format\n"); ctx->is_10bit = 0; - ctx->is_422format = 1; + ctx->is_422 = 1; break; case V4L2_PIX_FMT_NV12M_S10B: case V4L2_PIX_FMT_NV12M_P010: @@ -289,14 +276,14 @@ static void mfc_enc_check_format(struct s5p_mfc_ctx *ctx) case V4L2_PIX_FMT_NV21M_P010: mfc_debug(2, "is 10bit format\n"); ctx->is_10bit = 1; - ctx->is_422format = 0; + ctx->is_422 = 0; break; default: ctx->is_10bit = 0; - ctx->is_422format = 0; + ctx->is_422 = 0; break; } - mfc_debug(2, "10bit: %d, 422: %d\n", ctx->is_10bit, ctx->is_422format); + mfc_debug(2, "10bit: %d, 422: %d\n", ctx->is_10bit, ctx->is_422); } static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv, @@ -305,28 +292,22 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv, struct s5p_mfc_dev *dev = video_drvdata(file); struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); struct s5p_mfc_enc *enc = ctx->enc_priv; - struct s5p_mfc_fmt *fmt; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; int ret = 0; mfc_debug_enter(); - ret = vidioc_try_fmt(file, priv, f); - if (ret) - return ret; - if (ctx->vq_dst.streaming) { mfc_err_ctx("dst queue busy\n"); return -EBUSY; } - fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat); - if (!fmt) { - mfc_err_ctx("failed to set capture format\n"); + ctx->dst_fmt = mfc_enc_find_format(ctx, pix_fmt_mp->pixelformat); + if (!ctx->dst_fmt) { + mfc_err_ctx("Unsupported format for destination.\n"); return -EINVAL; } - ctx->dst_fmt = fmt; ctx->codec_mode = ctx->dst_fmt->codec_mode; mfc_info_ctx("Enc output codec(%d) : %s\n", ctx->dst_fmt->codec_mode, ctx->dst_fmt->name); @@ -414,16 +395,10 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *priv, struct v4l2_format *f) { struct s5p_mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct s5p_mfc_fmt *fmt; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; - int ret = 0; mfc_debug_enter(); - ret = vidioc_try_fmt(file, priv, f); - if (ret) - return ret; - if (ctx->vq_src.streaming) { mfc_err_ctx("src queue busy\n"); return -EBUSY; @@ -434,19 +409,18 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *priv, return 0; } - fmt = mfc_enc_find_format(f->fmt.pix_mp.pixelformat); - if (!fmt) { - mfc_err_ctx("failed to set output format\n"); + ctx->src_fmt = mfc_enc_find_format(ctx, pix_fmt_mp->pixelformat); + if (!ctx->src_fmt) { + mfc_err_ctx("Unsupported format for source.\n"); return -EINVAL; } - if (fmt->mem_planes != pix_fmt_mp->num_planes) { + if (ctx->src_fmt->mem_planes != pix_fmt_mp->num_planes) { mfc_err_ctx("plane number is different (%d != %d)\n", - fmt->mem_planes, pix_fmt_mp->num_planes); + ctx->src_fmt->mem_planes, pix_fmt_mp->num_planes); return -EINVAL; } - ctx->src_fmt = fmt; ctx->raw_buf.num_planes = ctx->src_fmt->num_planes; ctx->img_width = pix_fmt_mp->width; ctx->img_height = pix_fmt_mp->height; @@ -1936,9 +1910,7 @@ static int vidioc_try_ext_ctrls(struct file *file, void *priv, static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = { .vidioc_querycap = vidioc_querycap, - .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, - .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, 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 6a176b86c940..80fbc0ef8582 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h @@ -29,7 +29,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 3 Planes Y/Cb/Cr", .fourcc = V4L2_PIX_FMT_YUV420M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 3, }, @@ -37,7 +37,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 3 Planes Y/Cb/Cr single", .fourcc = V4L2_PIX_FMT_YUV420N, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 1, }, @@ -45,7 +45,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 3 Planes Y/Cr/Cb", .fourcc = V4L2_PIX_FMT_YVU420M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 3, .mem_planes = 3, }, @@ -53,7 +53,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes", .fourcc = V4L2_PIX_FMT_NV12M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 2, }, @@ -61,7 +61,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CbCr single", .fourcc = V4L2_PIX_FMT_NV12N, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 1, }, @@ -69,7 +69,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CbCr 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV12M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -77,7 +77,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CbCr P010 10bit", .fourcc = V4L2_PIX_FMT_NV12M_P010, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -85,7 +85,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CrCb", .fourcc = V4L2_PIX_FMT_NV21M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 2, }, @@ -93,7 +93,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CrCb 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV21M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -101,7 +101,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:0 2 Planes Y/CrCb P010 10bit", .fourcc = V4L2_PIX_FMT_NV21M_P010, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT, .num_planes = 2, .mem_planes = 2, }, @@ -109,7 +109,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CbCr", .fourcc = V4L2_PIX_FMT_NV16M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -117,7 +117,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CbCr 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV16M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -125,7 +125,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CrCb 8+2 10bit", .fourcc = V4L2_PIX_FMT_NV61M_S10B, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -133,7 +133,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CbCr P210 10bit", .fourcc = V4L2_PIX_FMT_NV16M_P210, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -141,7 +141,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CrCb P210 10bit", .fourcc = V4L2_PIX_FMT_NV61M_P210, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_10BIT | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -149,7 +149,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "4:2:2 2 Planes Y/CrCb", .fourcc = V4L2_PIX_FMT_NV61M, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_422, .num_planes = 2, .mem_planes = 2, }, @@ -157,7 +157,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "RGB888 1 Plane 24bpp", .fourcc = V4L2_PIX_FMT_RGB24, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_RGB, .num_planes = 1, .mem_planes = 1, }, @@ -165,7 +165,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "RGB565 1 Plane 16bpp", .fourcc = V4L2_PIX_FMT_RGB565, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_RGB, .num_planes = 1, .mem_planes = 1, }, @@ -173,7 +173,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "RGBX8888 1 Plane 32bpp", .fourcc = V4L2_PIX_FMT_RGB32X, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_RGB, .num_planes = 1, .mem_planes = 1, }, @@ -181,7 +181,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "BGRA8888 1 Plane 32bpp", .fourcc = V4L2_PIX_FMT_BGR32, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_RGB, .num_planes = 1, .mem_planes = 1, }, @@ -189,7 +189,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "ARGB8888 1 Plane 32bpp", .fourcc = V4L2_PIX_FMT_ARGB32, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME | MFC_FMT_RGB, .num_planes = 1, .mem_planes = 1, }, @@ -197,7 +197,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "H264 Encoded Stream", .fourcc = V4L2_PIX_FMT_H264, .codec_mode = S5P_FIMV_CODEC_H264_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -205,7 +205,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "MPEG4 Encoded Stream", .fourcc = V4L2_PIX_FMT_MPEG4, .codec_mode = S5P_FIMV_CODEC_MPEG4_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -213,7 +213,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "H263 Encoded Stream", .fourcc = V4L2_PIX_FMT_H263, .codec_mode = S5P_FIMV_CODEC_H263_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -221,7 +221,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "VP8 Encoded Stream", .fourcc = V4L2_PIX_FMT_VP8, .codec_mode = S5P_FIMV_CODEC_VP8_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -229,7 +229,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "VP9 Encoded Stream", .fourcc = V4L2_PIX_FMT_VP9, .codec_mode = S5P_FIMV_CODEC_VP9_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -237,7 +237,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "HEVC Encoded Stream", .fourcc = V4L2_PIX_FMT_HEVC, .codec_mode = S5P_FIMV_CODEC_HEVC_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -245,7 +245,7 @@ struct s5p_mfc_fmt enc_formats[] = { .name = "BPG Encoded Stream", .fourcc = V4L2_PIX_FMT_BPG, .codec_mode = S5P_FIMV_CODEC_BPG_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c index 618bbc26d1a9..52de357a2a43 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c @@ -940,7 +940,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx) MFC_WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE); /* for only information about wrong setting */ - if (ctx->is_422format) { + if (ctx->is_422) { if ((p_vp9->vp9_version != S5P_FIMV_E_PROFILE_VP9_PROFILE1) && (p_vp9->vp9_version != S5P_FIMV_E_PROFILE_VP9_PROFILE3)) { mfc_err_ctx("4:2:2 format is not matched with profile(%d)\n", @@ -1114,7 +1114,7 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx) MFC_WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE); /* for only information about wrong setting */ - if (ctx->is_422format) { + if (ctx->is_422) { if ((p_hevc->profile != S5P_FIMV_E_PROFILE_HEVC_MAIN_422_10_INTRA) && (p_hevc->profile != S5P_FIMV_E_PROFILE_HEVC_MAIN_422_10)) { mfc_err_ctx("4:2:2 format is not matched with profile(%d)\n", @@ -1390,7 +1390,7 @@ void s5p_mfc_set_enc_params_bpg(struct s5p_mfc_ctx *ctx) reg |= (0x2 << 17); reg |= (0x2 << 20); /* fixed profile */ - if (ctx->is_422format) + if (ctx->is_422) reg |= 0x1; } MFC_WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_hwfc_internal.h b/drivers/media/platform/exynos/mfc/s5p_mfc_hwfc_internal.h index ba63cf2a0d21..c505bbe36f0e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_hwfc_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_hwfc_internal.h @@ -29,7 +29,7 @@ struct s5p_mfc_fmt enc_hwfc_formats[] = { .name = "4:2:0 2 Planes Y/CbCr single", .fourcc = V4L2_PIX_FMT_NV12N, .codec_mode = MFC_FORMATS_NO_CODEC, - .type = MFC_FMT_RAW, + .type = MFC_FMT_FRAME, .num_planes = 2, .mem_planes = 1, }, @@ -37,7 +37,7 @@ struct s5p_mfc_fmt enc_hwfc_formats[] = { .name = "H264 Encoded Stream", .fourcc = V4L2_PIX_FMT_H264, .codec_mode = S5P_FIMV_CODEC_H264_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, @@ -45,7 +45,7 @@ struct s5p_mfc_fmt enc_hwfc_formats[] = { .name = "HEVC Encoded Stream", .fourcc = V4L2_PIX_FMT_HEVC, .codec_mode = S5P_FIMV_CODEC_HEVC_ENC, - .type = MFC_FMT_ENC, + .type = MFC_FMT_STREAM, .num_planes = 1, .mem_planes = 1, }, diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index 9b1f2f77eea7..0669cf9ee036 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -1057,7 +1057,7 @@ static int mfc_handle_seq_dec(struct s5p_mfc_ctx *ctx) s5p_mfc_dec_store_crop_info(ctx); dec->mv_count = s5p_mfc_get_mv_count(); - if (CODEC_10BIT(ctx)) { + if (CODEC_10BIT(ctx) && dev->pdata->support_10bit) { if (s5p_mfc_get_luma_bit_depth_minus8() || s5p_mfc_get_chroma_bit_depth_minus8() || s5p_mfc_get_profile() == S5P_FIMV_D_PROFILE_HEVC_MAIN_10) { @@ -1068,9 +1068,9 @@ static int mfc_handle_seq_dec(struct s5p_mfc_ctx *ctx) s5p_mfc_get_chroma_bit_depth_minus8() + 8); } } - if (CODEC_422FORMAT(ctx)) { + if (CODEC_422FORMAT(ctx) && dev->pdata->support_422) { if (s5p_mfc_get_chroma_format() == S5P_FIMV_D_CHROMA_422) { - ctx->is_422format = 1; + ctx->is_422 = 1; mfc_info_ctx("422 chroma format\n"); } } diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c index 34d19711469f..fd0c9da2e83c 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c @@ -34,15 +34,14 @@ #include "s5p_mfc_buf.h" #include "s5p_mfc_mem.h" -static struct s5p_mfc_fmt *mfc_enc_hwfc_find_format(unsigned int format, unsigned int t) +static struct s5p_mfc_fmt *mfc_enc_hwfc_find_format(unsigned int pixelformat) { unsigned long i; mfc_debug_enter(); for (i = 0; i < NUM_FORMATS; i++) { - if (enc_hwfc_formats[i].fourcc == format && - enc_hwfc_formats[i].type == t) + if (enc_hwfc_formats[i].fourcc == pixelformat) return (struct s5p_mfc_fmt *)&enc_hwfc_formats[i]; } @@ -58,7 +57,7 @@ static int mfc_otf_set_buf_info(struct s5p_mfc_ctx *ctx) mfc_debug_enter(); - ctx->src_fmt = mfc_enc_hwfc_find_format(buf_info->pixel_format, MFC_FMT_RAW); + ctx->src_fmt = mfc_enc_hwfc_find_format(buf_info->pixel_format); if (!ctx->src_fmt) { mfc_err_ctx("OTF: failed to set source format\n"); return -EINVAL; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_qos.c b/drivers/media/platform/exynos/mfc/s5p_mfc_qos.c index df0c2466599f..844efd2944bc 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_qos.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_qos.c @@ -277,7 +277,7 @@ static inline unsigned long mfc_qos_get_weighted_mb(struct s5p_mfc_ctx *ctx, } else { if (ctx->is_10bit) weight = (weight * 100) / MFC_QOS_WEIGHT_10BIT; - else if (ctx->is_422format) + else if (ctx->is_422) weight = (weight * 100) / MFC_QOS_WEIGHT_422_10INTRA; } break; @@ -323,7 +323,7 @@ static inline unsigned long mfc_qos_get_weighted_mb(struct s5p_mfc_ctx *ctx, mfc_debug(3, "QoS weight: %d.%03d, codec: %d, num planes: %d, " "10bit: %d, 422format: %d (mb: %ld)\n", weight / 1000, weight % 1000, ctx->codec_mode, - num_planes, ctx->is_10bit, ctx->is_422format, + num_planes, ctx->is_10bit, ctx->is_422, weighted_mb);