summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@collabora.com>2019-04-25 03:12:22 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-05-28 12:07:59 -0400
commitcf760c4b6020cd6e4015465e7b39d69286296cc2 (patch)
tree5b4d8d30311d9061ad58badeb6c0bdeb8895f0cf /drivers
parent4914425e28fb90c39fa986016373845de5453e97 (diff)
media: rockchip/vpu: Use pixel format helpers
Now that we've introduced the pixel format helpers, use them in vpu driver, and get rid of the internal helpers. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c91
1 files changed, 2 insertions, 89 deletions
diff --git a/drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c b/drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c
index dcbfc3cbc9f3..7fe104b75ba0 100644
--- a/drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c
+++ b/drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c
@@ -30,93 +30,6 @@
#include "rockchip_vpu_hw.h"
#include "rockchip_vpu_common.h"
-/**
- * struct v4l2_format_info - information about a V4L2 format
- * @format: 4CC format identifier (V4L2_PIX_FMT_*)
- * @header_size: Size of header, optional and used by compressed formats
- * @num_planes: Number of planes (1 to 3)
- * @cpp: Number of bytes per pixel (per plane)
- * @hsub: Horizontal chroma subsampling factor
- * @vsub: Vertical chroma subsampling factor
- * @is_compressed: Is it a compressed format?
- * @multiplanar: Is it a multiplanar variant format? (e.g. NV12M)
- */
-struct rockchip_vpu_v4l2_format_info {
- u32 format;
- u32 header_size;
- u8 num_planes;
- u8 cpp[3];
- u8 hsub;
- u8 vsub;
- u8 is_compressed;
- u8 multiplanar;
-};
-
-static const struct rockchip_vpu_v4l2_format_info *
-rockchip_vpu_v4l2_format_info(u32 format)
-{
- static const struct rockchip_vpu_v4l2_format_info formats[] = {
- { .format = V4L2_PIX_FMT_YUV420M, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .multiplanar = 1 },
- { .format = V4L2_PIX_FMT_NV12M, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .multiplanar = 1 },
- { .format = V4L2_PIX_FMT_YUYV, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
- { .format = V4L2_PIX_FMT_UYVY, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
- };
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(formats); ++i) {
- if (formats[i].format == format)
- return &formats[i];
- }
-
- vpu_err("Unsupported V4L 4CC format (%08x)\n", format);
- return NULL;
-}
-
-static void
-fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt,
- int pixelformat, int width, int height)
-{
- const struct rockchip_vpu_v4l2_format_info *info;
- struct v4l2_plane_pix_format *plane;
- int i;
-
- info = rockchip_vpu_v4l2_format_info(pixelformat);
- if (!info)
- return;
-
- pixfmt->width = width;
- pixfmt->height = height;
- pixfmt->pixelformat = pixelformat;
-
- if (!info->multiplanar) {
- pixfmt->num_planes = 1;
- plane = &pixfmt->plane_fmt[0];
- plane->bytesperline = info->is_compressed ?
- 0 : width * info->cpp[0];
- plane->sizeimage = info->header_size;
- for (i = 0; i < info->num_planes; i++) {
- unsigned int hsub = (i == 0) ? 1 : info->hsub;
- unsigned int vsub = (i == 0) ? 1 : info->vsub;
-
- plane->sizeimage += info->cpp[i] *
- DIV_ROUND_UP(width, hsub) *
- DIV_ROUND_UP(height, vsub);
- }
- } else {
- pixfmt->num_planes = info->num_planes;
- for (i = 0; i < info->num_planes; i++) {
- unsigned int hsub = (i == 0) ? 1 : info->hsub;
- unsigned int vsub = (i == 0) ? 1 : info->vsub;
-
- plane = &pixfmt->plane_fmt[i];
- plane->bytesperline =
- info->cpp[i] * DIV_ROUND_UP(width, hsub);
- plane->sizeimage =
- plane->bytesperline * DIV_ROUND_UP(height, vsub);
- }
- }
-}
-
static const struct rockchip_vpu_fmt *
rockchip_vpu_find_format(struct rockchip_vpu_ctx *ctx, u32 fourcc)
{
@@ -340,7 +253,7 @@ vidioc_try_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f)
height = round_up(height, JPEG_MB_DIM);
/* Fill remaining fields */
- fill_pixfmt_mp(pix_mp, fmt->fourcc, width, height);
+ v4l2_fill_pixfmt_mp(pix_mp, fmt->fourcc, width, height);
for (i = 0; i < pix_mp->num_planes; i++) {
memset(pix_mp->plane_fmt[i].reserved, 0,
@@ -394,7 +307,7 @@ void rockchip_vpu_enc_reset_src_fmt(struct rockchip_vpu_dev *vpu,
fmt->quantization = V4L2_QUANTIZATION_DEFAULT;
fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
- fill_pixfmt_mp(fmt, ctx->vpu_src_fmt->fourcc, width, height);
+ v4l2_fill_pixfmt_mp(fmt, ctx->vpu_src_fmt->fourcc, width, height);
}
static int