Commit 1c7b5eed authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Mauro Carvalho Chehab

media: mtk-vcodec: vdec: clean up vidioc_vdec_s_fmt a bit

Check for a potentially NULL pointer that was overlooked and use shorter
accessors to the same data. While we are at it, sprinkle a few comments.
Signed-off-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 2abb4db2
...@@ -841,12 +841,20 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, ...@@ -841,12 +841,20 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
return -EINVAL; return -EINVAL;
pix_mp = &f->fmt.pix_mp; pix_mp = &f->fmt.pix_mp;
/*
* Setting OUTPUT format after OUTPUT buffers are allocated is invalid
* if using the stateful API.
*/
if ((f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) && if ((f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) &&
vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) { vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
mtk_v4l2_err("out_q_ctx buffers already requested"); mtk_v4l2_err("out_q_ctx buffers already requested");
ret = -EBUSY; ret = -EBUSY;
} }
/*
* Setting CAPTURE format after CAPTURE buffers are allocated is
* invalid.
*/
if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) && if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) { vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
mtk_v4l2_err("cap_q_ctx buffers already requested"); mtk_v4l2_err("cap_q_ctx buffers already requested");
...@@ -865,6 +873,8 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, ...@@ -865,6 +873,8 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
fmt = mtk_vdec_find_format(f); fmt = mtk_vdec_find_format(f);
} }
} }
if (fmt == NULL)
return -EINVAL;
q_data->fmt = fmt; q_data->fmt = fmt;
vidioc_try_fmt(f, q_data->fmt); vidioc_try_fmt(f, q_data->fmt);
...@@ -873,10 +883,10 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, ...@@ -873,10 +883,10 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
q_data->coded_width = pix_mp->width; q_data->coded_width = pix_mp->width;
q_data->coded_height = pix_mp->height; q_data->coded_height = pix_mp->height;
ctx->colorspace = f->fmt.pix_mp.colorspace; ctx->colorspace = pix_mp->colorspace;
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc; ctx->ycbcr_enc = pix_mp->ycbcr_enc;
ctx->quantization = f->fmt.pix_mp.quantization; ctx->quantization = pix_mp->quantization;
ctx->xfer_func = f->fmt.pix_mp.xfer_func; ctx->xfer_func = pix_mp->xfer_func;
if (ctx->state == MTK_STATE_FREE) { if (ctx->state == MTK_STATE_FREE) {
ret = vdec_if_init(ctx, q_data->fmt->fourcc); ret = vdec_if_init(ctx, q_data->fmt->fourcc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment