]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: coda: fix mpeg2 sequence number handling
authorPhilipp Zabel <p.zabel@pengutronix.de>
Tue, 18 Jun 2019 16:45:10 +0000 (12:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:10:33 +0000 (09:10 +0200)
[ Upstream commit 56d159a4ec6d8da7313aac6fcbb95d8fffe689ba ]

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: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/coda/coda-bit.c

index 976f6aa69f41e6fc644fb0cf1aa6acc99c5d03d3..1eeed34f300d7c7574ddd291fb180148e037b986 100644 (file)
@@ -1739,6 +1739,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
                v4l2_err(&dev->v4l2_dev, "CODA_COMMAND_SEQ_INIT timeout\n");
                return ret;
        }
+       ctx->sequence_offset = ~0U;
        ctx->initialized = 1;
 
        /* Update kfifo out pointer from coda bitstream read pointer */
@@ -2151,7 +2152,9 @@ static void coda_finish_decode(struct coda_ctx *ctx)
                v4l2_err(&dev->v4l2_dev,
                         "decoded frame index out of range: %d\n", decoded_idx);
        } 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;
                spin_lock(&ctx->buffer_meta_lock);
                if (!list_empty(&ctx->buffer_meta_list)) {