mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 04:34:11 +08:00
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: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
2abb4db289
commit
1c7b5eedb9
@ -841,12 +841,20 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
|
||||
return -EINVAL;
|
||||
|
||||
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) &&
|
||||
vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
|
||||
mtk_v4l2_err("out_q_ctx buffers already requested");
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setting CAPTURE format after CAPTURE buffers are allocated is
|
||||
* invalid.
|
||||
*/
|
||||
if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
|
||||
vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
|
||||
mtk_v4l2_err("cap_q_ctx buffers already requested");
|
||||
@ -865,6 +873,8 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
|
||||
fmt = mtk_vdec_find_format(f);
|
||||
}
|
||||
}
|
||||
if (fmt == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
q_data->fmt = fmt;
|
||||
vidioc_try_fmt(f, q_data->fmt);
|
||||
@ -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_height = pix_mp->height;
|
||||
|
||||
ctx->colorspace = f->fmt.pix_mp.colorspace;
|
||||
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
|
||||
ctx->quantization = f->fmt.pix_mp.quantization;
|
||||
ctx->xfer_func = f->fmt.pix_mp.xfer_func;
|
||||
ctx->colorspace = pix_mp->colorspace;
|
||||
ctx->ycbcr_enc = pix_mp->ycbcr_enc;
|
||||
ctx->quantization = pix_mp->quantization;
|
||||
ctx->xfer_func = pix_mp->xfer_func;
|
||||
|
||||
if (ctx->state == MTK_STATE_FREE) {
|
||||
ret = vdec_if_init(ctx, q_data->fmt->fourcc);
|
||||
|
Loading…
Reference in New Issue
Block a user