From patchwork Tue Jul 2 11:56:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 2812671 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7DA719F3C3 for ; Tue, 2 Jul 2013 11:57:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60EA12016A for ; Tue, 2 Jul 2013 11:57:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3429B2012E for ; Tue, 2 Jul 2013 11:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446Ab3GBL4v (ORCPT ); Tue, 2 Jul 2013 07:56:51 -0400 Received: from shell.v3.sk ([195.168.3.45]:59944 "EHLO norkia.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828Ab3GBL4t (ORCPT ); Tue, 2 Jul 2013 07:56:49 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by norkia.v3.sk (Postfix) with ESMTP id 50B9B12A0E2; Tue, 2 Jul 2013 13:56:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at v3.sk Received: from norkia.v3.sk ([127.0.0.1]) by localhost (norkia.v3.sk [127.0.0.1]) (amavisd-new, port 10024) with SMTP id XpiNt-DQifci; Tue, 2 Jul 2013 13:56:42 +0200 (CEST) Received: from localhost.localdomain (unknown [158.193.130.168]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lkundrak@v3.sk) by norkia.v3.sk (Postfix) with ESMTP id BBA0C12A0E1; Tue, 2 Jul 2013 13:56:42 +0200 (CEST) From: Lubomir Rintel To: linux-media@vger.kernel.org Cc: Lubomir Rintel , Hans Verkuil , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [media] usbtv: Throw corrupted frames away Date: Tue, 2 Jul 2013 13:56:39 +0200 Message-Id: <1372766199-28771-2-git-send-email-lkundrak@v3.sk> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1372766199-28771-1-git-send-email-lkundrak@v3.sk> References: <1372766199-28771-1-git-send-email-lkundrak@v3.sk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Ignore out of order data and mark incomplete buffers as errored. This gets rid of annoying flicker due to occassional garbage from hardware. Signed-off-by: Lubomir Rintel Cc: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: linux-kernel@vger.kernel.org Cc: linux-media@vger.kernel.org --- drivers/media/usb/usbtv/usbtv.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c index bdb87d7..acd649c 100644 --- a/drivers/media/usb/usbtv/usbtv.c +++ b/drivers/media/usb/usbtv/usbtv.c @@ -89,6 +89,7 @@ struct usbtv { /* Number of currently processed frame, useful find * out when a new one begins. */ u32 frame_id; + int chunks_done; int iso_size; unsigned int sequence; @@ -242,8 +243,13 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk) return; /* Beginning of a frame. */ - if (chunk_no == 0) + if (chunk_no == 0) { usbtv->frame_id = frame_id; + usbtv->chunks_done = 0; + } + + if (usbtv->frame_id != frame_id) + return; spin_lock_irqsave(&usbtv->buflock, flags); if (list_empty(&usbtv->bufs)) { @@ -258,16 +264,21 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk) /* Copy the chunk data. */ usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd); + usbtv->chunks_done++; /* Last chunk in a frame, signalling an end */ if (odd && chunk_no == USBTV_CHUNKS-1) { int size = vb2_plane_size(&buf->vb, 0); + enum vb2_buffer_state state = usbtv->chunks_done == + USBTV_CHUNKS ? + VB2_BUF_STATE_DONE : + VB2_BUF_STATE_ERROR; buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; buf->vb.v4l2_buf.sequence = usbtv->sequence++; v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); vb2_set_plane_payload(&buf->vb, 0, size); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); + vb2_buffer_done(&buf->vb, state); list_del(&buf->list); }