From patchwork Sun Feb 25 12:31:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10240859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BF3B603B4 for ; Sun, 25 Feb 2018 12:32:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EE1629CBE for ; Sun, 25 Feb 2018 12:32:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13A8B29CE4; Sun, 25 Feb 2018 12:32:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B208329CBE for ; Sun, 25 Feb 2018 12:32:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751722AbeBYMcE (ORCPT ); Sun, 25 Feb 2018 07:32:04 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35977 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbeBYMbz (ORCPT ); Sun, 25 Feb 2018 07:31:55 -0500 Received: by mail-wm0-f67.google.com with SMTP id 188so11764215wme.1 for ; Sun, 25 Feb 2018 04:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=sRhgYTCl9OI7uLOfH7i4APieND86np04L6y4C+FtDF4=; b=oXxSoTFzqh+PZpawcsdsz2ETcQqkTAiqetCvn/TNOADP5iJL6gDz6TzsMcRHicoPLW nShnbBDtu9rcldZ7xSgSEctAn3aqTf/z+B9vn25NdgOXQgqkG5cAUlnZR6Ub3DW696wS pA2sBaR+EMNGuGLJcDEeTfkGFheERC922FxYcZ34UGIfaatLRgMWpYpjxFVHPzVQx8vK SIpfVCQnYvJHHuNmZ5Gwt52wbUZoS+/6EPsIwMjTYJQTb1zIZ6J46+KFVppr2TVZoU2Z 8+cj/w3m0O2X5/p9g+FB379guCPOlf0hk/KAS/RiYfw667cjGLF06Shx74la/gGgVb+W RIDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=sRhgYTCl9OI7uLOfH7i4APieND86np04L6y4C+FtDF4=; b=XZ3Fw4am2sdSlxx78sEk2XcUzVrW5HdbfgJUxSq8VFOPAkQCDNGsA9xFNPlTEoaAB7 yLjeEs3YLfzlKL6bM4QC/Vgz1wQR7EsGwMaPHqarm7VBdBQc+7vv5I3bHYaE9n0nwc3f 9qtzT8DQsLZugXRJUPJuHQLbOJhK3569KvqkDILl0f7EostZ7h6wUdxTJGBe+t7EdNYJ AujgYqV4PIi1yQmm7VJy+BxMarm2PnfsgkRBx979EkrRNrA/o+OMmxuRf1Ou19/FQhsy 1UV4yxp5O4wx9lSTNobFfAefV8aUC5DkFGFWZ2j6VgUjDfZ+VeT1BbW4gIGGcbiv3YP9 Fs0Q== X-Gm-Message-State: APf1xPBBTjpCRMqFdOgAPbl2OIS2hpfmt44DUgVsTc+n5afP6F377Jx3 Qh4Bkkoif/dB23BOTyMTN2VLng== X-Google-Smtp-Source: AG47ELssqVsci8wwIdiuZt/7yXa+O46RWvxQjenvEGpMJyEeJ/bfH4gFQySTm8PF0UxNPJcPuz7NXw== X-Received: by 10.28.43.199 with SMTP id r190mr6287305wmr.58.1519561914104; Sun, 25 Feb 2018 04:31:54 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id y34sm15304779wry.19.2018.02.25.04.31.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Feb 2018 04:31:53 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH v2 11/12] [media] ngene: move the tsin_exchange() stripcopy block into a function Date: Sun, 25 Feb 2018 13:31:39 +0100 Message-Id: <20180225123140.19486-12-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180225123140.19486-1-d.scheller.oss@gmail.com> References: <20180225123140.19486-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Move the copy logic that will skip previously inserted TS NULL frames when moving data to the DVB ring buffers into an own function. This is done to not duplicate code all over the place with the following TS offset shift fixup patch. Signed-off-by: Daniel Scheller --- drivers/media/pci/ngene/ngene-dvb.c | 48 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/media/pci/ngene/ngene-dvb.c b/drivers/media/pci/ngene/ngene-dvb.c index f71fd41c762c..6d72b9f69418 100644 --- a/drivers/media/pci/ngene/ngene-dvb.c +++ b/drivers/media/pci/ngene/ngene-dvb.c @@ -123,6 +123,32 @@ static u32 overflow; static u32 stripped; #endif +static inline void tsin_copy_stripped(struct ngene *dev, void *buf) +{ + if (memcmp(buf, fill_ts, sizeof(fill_ts)) != 0) { + if (dvb_ringbuffer_free(&dev->tsin_rbuf) >= 188) { + dvb_ringbuffer_write(&dev->tsin_rbuf, buf, 188); + wake_up(&dev->tsin_rbuf.queue); +#ifdef DEBUG_CI_XFER + ok++; +#endif + } +#ifdef DEBUG_CI_XFER + else + overflow++; +#endif + } +#ifdef DEBUG_CI_XFER + else + stripped++; + + if (ok % 100 == 0 && overflow) + dev_warn(&dev->pci_dev->dev, + "%s: ok %u overflow %u dropped %u\n", + __func__, ok, overflow, stripped); +#endif +} + void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags) { struct ngene_channel *chan = priv; @@ -134,28 +160,8 @@ void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags) if (dev->ci.en && chan->number == 2) { while (len >= 188) { - if (memcmp(buf, fill_ts, sizeof fill_ts) != 0) { - if (dvb_ringbuffer_free(&dev->tsin_rbuf) >= 188) { - dvb_ringbuffer_write(&dev->tsin_rbuf, buf, 188); - wake_up(&dev->tsin_rbuf.queue); -#ifdef DEBUG_CI_XFER - ok++; -#endif - } -#ifdef DEBUG_CI_XFER - else - overflow++; -#endif - } -#ifdef DEBUG_CI_XFER - else - stripped++; + tsin_copy_stripped(dev, buf); - if (ok % 100 == 0 && overflow) - dev_warn(&dev->pci_dev->dev, - "%s: ok %u overflow %u dropped %u\n", - __func__, ok, overflow, stripped); -#endif buf += 188; len -= 188; }