From d6c9f3ac7c982043725cbd20ace607a8dfdfd32c Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Mon, 27 Apr 2015 15:36:25 +0900 Subject: [PATCH] CHROMIUM: [media] rk3288-vpu: Make find_format() use fourcc directly 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 Reviewed-on: https://chromium-review.googlesource.com/269866 Reviewed-by: Pawel Osciak Trybot-Ready: Pawel Osciak Change-Id: Ifa9c4e3e378fbeafb6453a01b9e4f7c11606025b Signed-off-by: Jeffy Chen Signed-off-by: Yakir Yang --- .../platform/rk3288-vpu/rk3288_vpu_dec.c | 20 ++++++++----------- .../platform/rk3288-vpu/rk3288_vpu_enc.c | 19 ++++++++---------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c index bb28e55c56c1..f7c3725ec0c8 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c @@ -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; diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c index d288e04511cb..00e6cacc0043 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c @@ -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); -- 2.34.1