From patchwork Fri Jun 13 16:08:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 4350631 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D0A91BEEAA for ; Fri, 13 Jun 2014 16:09:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F39FD20268 for ; Fri, 13 Jun 2014 16:09:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EBFC2022A for ; Fri, 13 Jun 2014 16:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753468AbaFMQJk (ORCPT ); Fri, 13 Jun 2014 12:09:40 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:44514 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbaFMQJM (ORCPT ); Fri, 13 Jun 2014 12:09:12 -0400 Received: from client-120-static.hi.pengutronix.de ([10.1.0.120] helo=paszta.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1WvU2J-0006dC-Da; Fri, 13 Jun 2014 18:09:03 +0200 From: Philipp Zabel To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Kamil Debski , Fabio Estevam , kernel@pengutronix.de, Philipp Zabel Subject: [PATCH 23/30] [media] coda: add sequence counter offset Date: Fri, 13 Jun 2014 18:08:49 +0200 Message-Id: <1402675736-15379-24-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <1402675736-15379-1-git-send-email-p.zabel@pengutronix.de> References: <1402675736-15379-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.120 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The coda h.264 decoder also counts PIC_RUNs where no frame was decoded but a frame was rotated out / marked as ready to be displayed. This causes an offset between the incoming encoded frame's sequence number and the decode sequence number returned by the coda. This patch introduces a sequence counter offset variable to keep track of the difference. Signed-off-by: Philipp Zabel --- drivers/media/platform/coda.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 93836c8..4641667dbc 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -222,6 +222,7 @@ struct coda_ctx { u32 isequence; u32 qsequence; u32 osequence; + u32 sequence_offset; struct coda_q_data q_data[2]; enum coda_inst_type inst_type; struct coda_codec *codec; @@ -2674,6 +2675,7 @@ static void coda_stop_streaming(struct vb2_queue *q) ctx->streamon_cap = 0; ctx->osequence = 0; + ctx->sequence_offset = 0; } if (!ctx->streamon_out && !ctx->streamon_cap) { @@ -3179,7 +3181,9 @@ static void coda_finish_decode(struct coda_ctx *ctx) if (decoded_idx == -1) { /* no frame was decoded, but we might have a display frame */ - if (display_idx < 0 && ctx->display_idx < 0) + if (display_idx >= 0 && display_idx < ctx->num_internal_frames) + ctx->sequence_offset++; + else if (ctx->display_idx < 0) ctx->prescan_failed = true; } else if (decoded_idx == -2) { /* no frame was decoded, we still return the remaining buffers */ @@ -3191,10 +3195,11 @@ static void coda_finish_decode(struct coda_ctx *ctx) struct coda_timestamp, list); list_del(&ts->list); val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM) - 1; + val -= ctx->sequence_offset; if (val != ts->sequence) { v4l2_err(&dev->v4l2_dev, - "sequence number mismatch (%d != %d)\n", - val, ts->sequence); + "sequence number mismatch (%d(%d) != %d)\n", + val, ctx->sequence_offset, ts->sequence); } ctx->frame_timestamps[decoded_idx] = *ts; kfree(ts);