Commit 53dc2d9d authored by Philipp Zabel's avatar Philipp Zabel Committed by Stefan Bader

media: coda: fix mpeg2 sequence number handling

BugLink: https://bugs.launchpad.net/bugs/1840081

[ Upstream commit 56d159a4 ]

Sequence number handling assumed that the BIT processor frame number
starts counting at 1, but this is not true for the MPEG-2 decoder,
which starts at 0. Fix the sequence counter offset detection to handle
this.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent ae85372a
...@@ -1581,6 +1581,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) ...@@ -1581,6 +1581,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM); coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
ctx->sequence_offset = ~0U;
ctx->initialized = 1; ctx->initialized = 1;
/* Update kfifo out pointer from coda bitstream read pointer */ /* Update kfifo out pointer from coda bitstream read pointer */
...@@ -1971,7 +1972,9 @@ static void coda_finish_decode(struct coda_ctx *ctx) ...@@ -1971,7 +1972,9 @@ static void coda_finish_decode(struct coda_ctx *ctx)
v4l2_err(&dev->v4l2_dev, v4l2_err(&dev->v4l2_dev,
"decoded frame index out of range: %d\n", decoded_idx); "decoded frame index out of range: %d\n", decoded_idx);
} else { } else {
val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM) - 1; val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM);
if (ctx->sequence_offset == -1)
ctx->sequence_offset = val;
val -= ctx->sequence_offset; val -= ctx->sequence_offset;
spin_lock_irqsave(&ctx->buffer_meta_lock, flags); spin_lock_irqsave(&ctx->buffer_meta_lock, flags);
if (!list_empty(&ctx->buffer_meta_list)) { if (!list_empty(&ctx->buffer_meta_list)) {
......
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