linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 066/105] media: coda: fix mpeg2 sequence number handling
Date: Mon, 15 Jul 2019 10:28:00 -0400	[thread overview]
Message-ID: <20190715142839.9896-66-sashal@kernel.org> (raw)
In-Reply-To: <20190715142839.9896-1-sashal@kernel.org>

From: Philipp Zabel <p.zabel@pengutronix.de>

[ 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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 6eee55430d46..43eb5d51cf23 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1679,6 +1679,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 */
@@ -2095,7 +2096,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_irqsave(&ctx->buffer_meta_lock, flags);
 		if (!list_empty(&ctx->buffer_meta_list)) {
-- 
2.20.1


  parent reply	other threads:[~2019-07-15 14:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190715142839.9896-1-sashal@kernel.org>
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 008/105] media: dvb: usb: fix use after free in dvb_usb_device_exit Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 009/105] media: spi: IR LED: add missing of table registration Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 011/105] media: marvell-ccic: fix DMA s/g desc number calculation Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 012/105] media: vpss: fix a potential NULL pointer dereference Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 013/105] media: media_device_enum_links32: clean a reserved field Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 024/105] media: mc-device.c: don't memset __user pointer contents Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 025/105] media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 029/105] tua6100: Avoid build warnings Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 031/105] media: wl128x: Fix some error handling in fm_v4l2_init_video_device() Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 042/105] media: fdp1: Support M3N and E3 platforms Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 061/105] media: s5p-mfc: Make additional clocks optional Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 062/105] media: i2c: fix warning same module names Sasha Levin
2019-07-15 14:28 ` Sasha Levin [this message]
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 067/105] media: coda: fix last buffer handling in V4L2_ENC_CMD_STOP Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 068/105] media: coda: increment sequence offset for the last returned frame Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 069/105] media: vimc: cap: check v4l2_fill_pixfmt return value Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 070/105] media: hdpvr: fix locking and a missing msleep Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190715142839.9896-66-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).