CHROMIUM: [media] rk3288-vpu: Make find_format() use fourcc directly
authorTomasz Figa <tfiga@chromium.org>
Mon, 27 Apr 2015 06:36:25 +0000 (15:36 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:54:45 +0000 (19:54 +0800)
As a prerequisite for using find_format() helpers from contexts in which
a v4l2_format struct is not available, this patch makes it take u32 fourcc
as its argument instead, since it was the only member of that struct it
actually used anyway.

BUG=chromium:485409
TEST=vda/veatests, Chrome with crrev.com/1097913002.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/269866
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Trybot-Ready: Pawel Osciak <posciak@chromium.org>

Change-Id: Ifa9c4e3e378fbeafb6453a01b9e4f7c11606025b
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c
drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c

index bb28e55c56c13b5bfb95468ac7e1517865249e16..f7c3725ec0c821b89bc212f542c6565e709e467d 100644 (file)
@@ -67,14 +67,14 @@ static struct rk3288_vpu_fmt formats[] = {
        },
 };
 
-static struct rk3288_vpu_fmt *find_format(struct v4l2_format *f, bool bitstream)
+static struct rk3288_vpu_fmt *find_format(u32 fourcc, bool bitstream)
 {
        unsigned int i;
 
        vpu_debug_enter();
 
        for (i = 0; i < ARRAY_SIZE(formats); i++) {
-               if (formats[i].fourcc == f->fmt.pix_mp.pixelformat &&
+               if (formats[i].fourcc == fourcc &&
                    !!bitstream == (formats[i].codec_mode != RK_VPU_CODEC_NONE))
                        return &formats[i];
        }
@@ -265,7 +265,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
                vpu_debug(4, "%s\n", fmt2str(f->fmt.pix_mp.pixelformat, str));
 
-               fmt = find_format(f, true);
+               fmt = find_format(pix_fmt_mp->pixelformat, true);
                if (!fmt) {
                        vpu_err("failed to try output format\n");
                        return -EINVAL;
@@ -282,7 +282,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
                vpu_debug(4, "%s\n", fmt2str(f->fmt.pix_mp.pixelformat, str));
 
-               fmt = find_format(f, false);
+               fmt = find_format(pix_fmt_mp->pixelformat, false);
                if (!fmt) {
                        vpu_err("failed to try capture format\n");
                        return -EINVAL;
@@ -347,7 +347,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                if (ret)
                        goto out;
 
-               ctx->vpu_src_fmt = find_format(f, true);
+               ctx->vpu_src_fmt = find_format(pix_fmt_mp->pixelformat, true);
                ctx->src_fmt = *pix_fmt_mp;
                break;
 
@@ -376,7 +376,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                if (ret)
                        goto out;
 
-               fmt = find_format(f, false);
+               fmt = find_format(pix_fmt_mp->pixelformat, false);
                ctx->vpu_dst_fmt = fmt;
 
                mb_width = MB_WIDTH(pix_fmt_mp->width);
@@ -1105,12 +1105,8 @@ static const struct rk3288_vpu_run_ops rk3288_vpu_dec_run_ops = {
 
 int rk3288_vpu_dec_init(struct rk3288_vpu_ctx *ctx)
 {
-       struct v4l2_format f;
-
-       f.fmt.pix_mp.pixelformat = DEF_SRC_FMT_DEC;
-       ctx->vpu_src_fmt = find_format(&f, false);
-       f.fmt.pix_mp.pixelformat = DEF_DST_FMT_DEC;
-       ctx->vpu_dst_fmt = find_format(&f, true);
+       ctx->vpu_src_fmt = find_format(DEF_SRC_FMT_DEC, false);
+       ctx->vpu_dst_fmt = find_format(DEF_DST_FMT_DEC, true);
 
        ctx->run_ops = &rk3288_vpu_dec_run_ops;
 
index d288e04511cba5c92c5fe199f190431c8e609ccb..00e6cacc00436f40764f77d1fa1b4e0b0307663f 100644 (file)
@@ -97,14 +97,14 @@ static struct rk3288_vpu_fmt formats[] = {
        },
 };
 
-static struct rk3288_vpu_fmt *find_format(struct v4l2_format *f, bool bitstream)
+static struct rk3288_vpu_fmt *find_format(u32 fourcc, bool bitstream)
 {
        unsigned int i;
 
        vpu_debug_enter();
 
        for (i = 0; i < ARRAY_SIZE(formats); i++) {
-               if (formats[i].fourcc != f->fmt.pix_mp.pixelformat)
+               if (formats[i].fourcc != fourcc)
                        continue;
                if (bitstream && formats[i].codec_mode != RK_VPU_CODEC_NONE)
                        return &formats[i];
@@ -457,7 +457,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
                vpu_debug(4, "%s\n", fmt2str(f->fmt.pix_mp.pixelformat, str));
 
-               fmt = find_format(f, true);
+               fmt = find_format(pix_fmt_mp->pixelformat, true);
                if (!fmt) {
                        vpu_err("failed to try capture format\n");
                        return -EINVAL;
@@ -474,7 +474,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
        case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
                vpu_debug(4, "%s\n", fmt2str(f->fmt.pix_mp.pixelformat, str));
 
-               fmt = find_format(f, false);
+               fmt = find_format(pix_fmt_mp->pixelformat, false);
                if (!fmt) {
                        vpu_err("failed to try output format\n");
                        return -EINVAL;
@@ -538,7 +538,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                if (ret)
                        goto out;
 
-               ctx->vpu_dst_fmt = find_format(f, true);
+               ctx->vpu_dst_fmt = find_format(pix_fmt_mp->pixelformat, true);
                ctx->dst_fmt = *pix_fmt_mp;
                break;
 
@@ -557,7 +557,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                if (ret)
                        goto out;
 
-               fmt = find_format(f, false);
+               fmt = find_format(pix_fmt_mp->pixelformat, false);
                ctx->vpu_src_fmt = fmt;
 
                mb_width = MB_WIDTH(pix_fmt_mp->width);
@@ -1304,13 +1304,10 @@ static const struct rk3288_vpu_run_ops rk3288_vpu_enc_run_ops = {
 int rk3288_vpu_enc_init(struct rk3288_vpu_ctx *ctx)
 {
        struct rk3288_vpu_dev *vpu = ctx->dev;
-       struct v4l2_format f;
        int ret;
 
-       f.fmt.pix_mp.pixelformat = DEF_SRC_FMT_ENC;
-       ctx->vpu_src_fmt = find_format(&f, false);
-       f.fmt.pix_mp.pixelformat = DEF_DST_FMT_ENC;
-       ctx->vpu_dst_fmt = find_format(&f, true);
+       ctx->vpu_src_fmt = find_format(DEF_SRC_FMT_ENC, false);
+       ctx->vpu_dst_fmt = find_format(DEF_DST_FMT_ENC, true);
 
        ret = rk3288_vpu_aux_buf_alloc(vpu, &ctx->run.priv_src,
                                        RK3288_HW_PARAMS_SIZE);