Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9930555ybi; Wed, 24 Jul 2019 12:32:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBSyVUcyrM8ZRc/hmkwbBUkHFhwiZNvPGSqNPyKFeQZT7CSamCjPNdCVCp1xa2vlKe1iBZ X-Received: by 2002:aa7:8a99:: with SMTP id a25mr12980073pfc.127.1563996720478; Wed, 24 Jul 2019 12:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996720; cv=none; d=google.com; s=arc-20160816; b=rfiizRVF+4kRFZRljs18e1NRdPUW5VOW718pVTorT21mV566a2H2nAsgFF0xyps7RS +b1WgUQAoorgqIXLINu75TeBMvNxvLFPYYyhVXuk8JBu/hbnWY9szRN3N9vj3AAky3N/ NvRM0Yo6aCFcyku8C5osjIo50/Toom9TYPveua9gH8vsvaJvvzw2aliZVCr7dy6u2Hio CY+rm6AuYW0k4SCxNHsOHtvmaWMu080nOXyf+D7dR0MDJ7Z+rKXaSNL1/SRij12VE7Is wFSFtljtLkRL/1rezhxerpc6CLJtbMTMLO1qY0bUl2kwtoP/iALrUdolPv0LKZgVGEN6 sRsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N0ZWx7G0CVHHhFp7tprkQQNd+mNACTj3+5L07p0GBw8=; b=I7INXpOLOVTw3r6qfj+g1Gw0pAbr/qrTxxHW9F2sXEgXngvEOFjXJtpr1qngKIvyWt eICKP9pEm7T3QyV+q3d9pwQ26836sXytWzOvehx2UDaapgEP/zcScGhcWpHuqEe+r11D p2v4pq6nkJiugXwwyoIX8DqLs7MWEDfsDAjTEiqAab2KONVYdVq+hkt2IgBmZDSxUT5j 7lU4oivdub/sGMI74E24IW072ZA26ttRIR1Pop+lc5VWGks/DQ2YUyuBC5OwoR1Y9IYO zDl6aStY8teWe+qEa6ZJrAEAIk3esCujk7ickhrMkHRyz2CfAzllNTgR3KTnM5pQ3gSe qS5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wUsh1C4J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cj12si14492327plb.237.2019.07.24.12.31.45; Wed, 24 Jul 2019 12:32:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wUsh1C4J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387718AbfGXT3t (ORCPT + 99 others); Wed, 24 Jul 2019 15:29:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729049AbfGXT3s (ORCPT ); Wed, 24 Jul 2019 15:29:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0F70A20659; Wed, 24 Jul 2019 19:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996587; bh=rwpYAFFP66pvd1T+pqBLTPqnTByuUEyJCshjGZGVTyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wUsh1C4JmvNDkHRLyZK/MRwSGdC7hLz890c6LprFz5nPdPz6K4QZqlGErm7D7+tJu FGwMtEqsfGGKY+ctyHuoaYirqpCkHeUus1AwCGbSYcBDdR92eWGoTpwlI1nfK+27Vd TcbwrMJ/4KsWjWdIKoOoRDhjAONOz8cv2hbiQf1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.2 148/413] media: coda: fix mpeg2 sequence number handling Date: Wed, 24 Jul 2019 21:17:19 +0200 Message-Id: <20190724191745.532716587@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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 976f6aa69f41..1eeed34f300d 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -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)) { -- 2.20.1