Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10376731ybi; Wed, 24 Jul 2019 22:04:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaUBxBJhjVAhSGCOWb4At/8Jfvv3KPoOy3qUIYgv2qVfXNaHoURpUv7cBOWfQ1/R8D5mCb X-Received: by 2002:a63:8f55:: with SMTP id r21mr83465082pgn.318.1564031062230; Wed, 24 Jul 2019 22:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564031062; cv=none; d=google.com; s=arc-20160816; b=JY6pqf2U1PDHl6qe1hzB+OkM7Qk1dDXOuDesipDXxdkpw/iUJLDMeq9DTlqbT01kbZ 2zA1ysD/P8IIWvusEl+yGZcaUTeIxFL6wyZV4Dz2dPPI+WukZLlU/KwAXN05eSePQhtb tpuLuw821CMEun4RHsVj42rp4VhCkvVTiTXVbwQj3FR42tcDw+TS/O/izW9DO7KuqiCq mJ+4BhA8JgcUuGTQP+Ur4XkbETv7k5oe8ctIG21x1lUyw1lHZhLCHWuFGp4WhAxqJzga 6/q6G/UU4tlJAuaWuXVWzCrLj5gVOjjucx77rxrqKXs5qhowQpq1hpXnh+ApBLWbf2yo jzTA== 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=TjrtOHInI3TI6gxCnKLEaKPu862vEhRdjyDCAoK+rYo=; b=CKgaCtHibxUHWvHT1h7QzPfOF6yjlkG1Jt0nckictwblrXVibZLNCuDgI4gzpiXRPX d3i06bBzejm1rD7dLA5m+mZxksCOvuAhGhYU4v8OrUuM9xlUWLOgg1a4e/BC07fwLFpa tm52RJn90QY9aheK+dioOQyPVH2a5qnM+lcVym8pVtU440bXKTrphIWKsJcKhjog4dre Fky3SgEGIJ8ycgbiMuMXfZo4rTsotKS6g9DQd8AMkOYm9RE/HmYTlmqfz1gd6yrZDUZW hpBp23DFQiN92IEXsZr/HVPnKXu85Vff4dPfv1NGUdvjRnGHqsuDLAtNdeR42D1L+p9B YkeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fTvLdFeh; 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 p20si17533428pgk.158.2019.07.24.22.04.07; Wed, 24 Jul 2019 22:04:22 -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=fTvLdFeh; 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 S2391190AbfGXTtd (ORCPT + 99 others); Wed, 24 Jul 2019 15:49:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:57474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391503AbfGXTtW (ORCPT ); Wed, 24 Jul 2019 15:49:22 -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 449F520659; Wed, 24 Jul 2019 19:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997761; bh=Kkvq8HF2PdQJOysh0E/srbZf1ptLqlyUIzHkyNKcgBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTvLdFehdm6TY5ELhI2sRIgskV9TyN8RFc//1ql1oQgWZqKNFVCdLWh6M+pZ89PTd armyCwvhbPF5ERMpjKlY+rUNjFSq4I08aCo6khEdBh6//dTEwCbC+GURsU2rzqZt9B C8lTeVF8I16qeAPyMWVVqa4z9g+4L5XUXH9FMh3Y= 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.1 135/371] media: coda: fix mpeg2 sequence number handling Date: Wed, 24 Jul 2019 21:18:07 +0200 Message-Id: <20190724191735.070786550@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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 eaa86737fa04..5eb93ac060d5 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -1743,6 +1743,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 */ @@ -2155,7 +2156,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