diff options
author | Sungwon Jo <doriya@nexell.co.kr> | 2017-07-12 11:47:58 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2020-07-08 19:32:59 +0900 |
commit | 048525047499c9c711e2cf378bcf5b05bc0170c2 (patch) | |
tree | 9dd67bc37fe931addfc244ace27c54cc00da86d5 | |
parent | c52de721864b8f0999373e7f2ef462d72c829380 (diff) | |
download | linux-artik7-048525047499c9c711e2cf378bcf5b05bc0170c2.tar.gz linux-artik7-048525047499c9c711e2cf378bcf5b05bc0170c2.tar.bz2 linux-artik7-048525047499c9c711e2cf378bcf5b05bc0170c2.zip |
media: nxp-vpu: support various output format.
This patch support various output format.
Supported format is as follows:
- Continuous planes( V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_YVU420 )
- Non-continuous planes( V4L2_PIX_FMT_YUV420M, V4L2_PIX_FMT_YVU420M )
Change-Id: I3ba28a58a147e6c8cc577c34c0ad0a38692be3c6
Signed-off-by: Sungwon Jo <doriya@nexell.co.kr>
-rw-r--r-- | drivers/media/platform/nxp-vpu/nx_vpu_dec_v4l2.c | 64 | ||||
-rw-r--r-- | drivers/media/platform/nxp-vpu/nx_vpu_v4l2.c | 46 |
2 files changed, 41 insertions, 69 deletions
diff --git a/drivers/media/platform/nxp-vpu/nx_vpu_dec_v4l2.c b/drivers/media/platform/nxp-vpu/nx_vpu_dec_v4l2.c index 45d14be88caa..d8738c99555f 100644 --- a/drivers/media/platform/nxp-vpu/nx_vpu_dec_v4l2.c +++ b/drivers/media/platform/nxp-vpu/nx_vpu_dec_v4l2.c @@ -245,6 +245,7 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv, ctx->img_fmt.fourcc = img_fmt->fourcc; ctx->img_fmt.num_planes = f->fmt.pix_mp.num_planes; + ctx->imgFourCC = img_fmt->fourcc; ctx->chromaInterleave = (pix_fmt_mp->num_planes != 2) ? (0) : (1); /* set memory align */ @@ -590,18 +591,40 @@ static void nx_vpu_dec_buf_queue(struct vb2_buffer *vb) buf->planes.raw.y = nx_vpu_mem_plane_addr(ctx, vb, 0); dec_ctx->frame_buf[idx].phyAddr[0] = buf->planes.raw.y; - if (ctx->img_fmt.num_planes > 1) { - buf->planes.raw.cb = - dec_ctx->frame_buf[idx].phyAddr[1] = - nx_vpu_mem_plane_addr(ctx, vb, 1) + - ctx->luma_size + ctx->chroma_size; + if (ctx->imgFourCC == V4L2_PIX_FMT_YUV420 || + ctx->imgFourCC == V4L2_PIX_FMT_YVU420 ) { + if (ctx->img_fmt.num_planes > 1) { + buf->planes.raw.cb = + dec_ctx->frame_buf[idx].phyAddr[1] = + (ctx->imgFourCC == V4L2_PIX_FMT_YUV420) ? + buf->planes.raw.y + ctx->luma_size : + buf->planes.raw.y + ctx->luma_size + ctx->chroma_size; + } + + if (ctx->img_fmt.num_planes > 2) { + buf->planes.raw.cr = + dec_ctx->frame_buf[idx].phyAddr[2] = + (ctx->imgFourCC == V4L2_PIX_FMT_YUV420) ? + buf->planes.raw.y + ctx->luma_size + ctx->chroma_size : + buf->planes.raw.y + ctx->luma_size; + } } + else { + if (ctx->img_fmt.num_planes > 1) { + buf->planes.raw.cb = + dec_ctx->frame_buf[idx].phyAddr[1] = + (ctx->imgFourCC == V4L2_PIX_FMT_YUV420M) ? + nx_vpu_mem_plane_addr(ctx, vb, 1) : + nx_vpu_mem_plane_addr(ctx, vb, 2); + } - if (ctx->img_fmt.num_planes > 2) { - buf->planes.raw.cr = - dec_ctx->frame_buf[idx].phyAddr[2] = - nx_vpu_mem_plane_addr(ctx, vb, 2) + - ctx->luma_size; + if (ctx->img_fmt.num_planes > 2) { + buf->planes.raw.cr = + dec_ctx->frame_buf[idx].phyAddr[2] = + (ctx->imgFourCC == V4L2_PIX_FMT_YUV420M) ? + nx_vpu_mem_plane_addr(ctx, vb, 2) : + nx_vpu_mem_plane_addr(ctx, vb, 1); + } } list_add_tail(&buf->list, &ctx->codec.dec.dpb_queue); @@ -885,27 +908,6 @@ int vpu_dec_parse_vid_cfg(struct nx_vpu_ctx *ctx) (V4L2_FIELD_NONE) : (V4L2_FIELD_INTERLACED); dec_ctx->frame_buf_delay = seqArg.frameBufDelay; - switch (seqArg.imgFormat) { - case IMG_FORMAT_420: - ctx->imgFourCC = V4L2_PIX_FMT_YUV420M; - break; - case IMG_FORMAT_422: - ctx->imgFourCC = V4L2_PIX_FMT_YUV422M; - break; - /* case IMG_FORMAT_224: - ctx->imgFourCC = ; - break; */ - case IMG_FORMAT_444: - ctx->imgFourCC = V4L2_PIX_FMT_YUV444M; - break; - case IMG_FORMAT_400: - ctx->imgFourCC = V4L2_PIX_FMT_GREY; - break; - default: - NX_ErrMsg(("Image format is not supported!!\n")); - return -EINVAL; - } - dec_ctx->start_Addr = 0; dec_ctx->end_Addr = seqArg.strmReadPos; ctx->strm_size = dec_ctx->end_Addr - dec_ctx->start_Addr; diff --git a/drivers/media/platform/nxp-vpu/nx_vpu_v4l2.c b/drivers/media/platform/nxp-vpu/nx_vpu_v4l2.c index cabefc2eba3d..4aacb6ba6cb3 100644 --- a/drivers/media/platform/nxp-vpu/nx_vpu_v4l2.c +++ b/drivers/media/platform/nxp-vpu/nx_vpu_v4l2.c @@ -217,53 +217,23 @@ int nx_vpu_try_run(struct nx_vpu_ctx *ctx) static struct nx_vpu_fmt formats[] = { { .name = "YUV 4:2:0 3 Planes", - .fourcc = V4L2_PIX_FMT_YUV420M, + .fourcc = V4L2_PIX_FMT_YUV420, .num_planes = 3, }, { - .name = "YUV 4:2:2 3 Planes", - .fourcc = V4L2_PIX_FMT_YUV422M, + .name = "YUV 4:2:0 None Contiguous 3 Planes", + .fourcc = V4L2_PIX_FMT_YUV420M, .num_planes = 3, }, { - .name = "YUV 4:4:4 3 Planes", - .fourcc = V4L2_PIX_FMT_YUV444M, + .name = "YVU 4:2:0 3 Planes", + .fourcc = V4L2_PIX_FMT_YVU420, .num_planes = 3, }, { - .name = "Grey 1 Planes", - .fourcc = V4L2_PIX_FMT_GREY, - .num_planes = 1, - }, - { - .name = "YUV 4:2:0 2 Planes Y/CbCr", - .fourcc = V4L2_PIX_FMT_NV12M, - .num_planes = 2, - }, - { - .name = "YUV 4:2:0 2 Planes Y/CrCb", - .fourcc = V4L2_PIX_FMT_NV21M, - .num_planes = 2, - }, - { - .name = "YUV 4:2:2 2 Planes Y/CbCr", - .fourcc = V4L2_PIX_FMT_NV16M, - .num_planes = 2, - }, - { - .name = "YUV 4:2:2 2 Planes Y/CrCb", - .fourcc = V4L2_PIX_FMT_NV61M, - .num_planes = 2, - }, - { - .name = "YUV 4:4:4 2 Planes Y/CbCr", - .fourcc = V4L2_PIX_FMT_NV24M, - .num_planes = 2, - }, - { - .name = "YUV 4:4:4 2 Planes Y/CrCb", - .fourcc = V4L2_PIX_FMT_NV42M, - .num_planes = 2, + .name = "YVU 4:2:0 None Contiguous 3 Planes", + .fourcc = V4L2_PIX_FMT_YVU420M, + .num_planes = 3, }, { .name = "MPEG2 Stream", |