linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Daniel Scheller <d.scheller.oss@gmail.com>
Cc: linux-media@vger.kernel.org, mchehab@s-opensource.com
Subject: Re: [PATCH v2 11/12] [media] ngene: move the tsin_exchange() stripcopy block into a function
Date: Tue, 6 Mar 2018 13:18:23 -0300	[thread overview]
Message-ID: <20180306131823.4b6280ba@vento.lan> (raw)
In-Reply-To: <20180225123140.19486-12-d.scheller.oss@gmail.com>

Em Sun, 25 Feb 2018 13:31:39 +0100
Daniel Scheller <d.scheller.oss@gmail.com> escreveu:

> From: Daniel Scheller <d.scheller@gmx.net>
> 
> 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 <d.scheller@gmx.net>
> ---
>  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

Those blocks are ugly. Also, there's no Kconfig way to enable those
debug messages.

If they're meant only for your own consumption, just keep it
outside of upstream.

Otherwise, please change the logic in a way that it would
make the code harder to read/enable.

> +}
> +
>  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;
>  		}



Thanks,
Mauro

  reply	other threads:[~2018-03-06 16:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-25 12:31 [PATCH v2 00/12] ngene-updates: Hardware support, TS buffer shift fix Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 01/12] [media] ngene: add two additional PCI IDs Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 02/12] [media] ngene: convert kernellog printing from printk() to dev_*() macros Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 03/12] [media] ngene: use defines to identify the demod_type Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 04/12] [media] ngene: support STV0367 DVB-C/T DuoFlex addons Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 05/12] [media] ngene: add XO2 module support Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 06/12] [media] ngene: add support for Sony CXD28xx-based DuoFlex modules Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 07/12] [media] ngene: add support for DuoFlex S2 V4 addon modules Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 08/12] [media] ngene: deduplicate I2C adapter evaluation Daniel Scheller
2018-03-06 16:06   ` Mauro Carvalho Chehab
2018-03-06 16:14     ` Mauro Carvalho Chehab
2018-02-25 12:31 ` [PATCH v2 09/12] [media] ngene: check for CXD2099AR presence before attaching Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 10/12] [media] ngene: don't treat non-existing demods as error Daniel Scheller
2018-02-25 12:31 ` [PATCH v2 11/12] [media] ngene: move the tsin_exchange() stripcopy block into a function Daniel Scheller
2018-03-06 16:18   ` Mauro Carvalho Chehab [this message]
2018-02-25 12:31 ` [PATCH v2 12/12] [media] ngene: compensate for TS buffer offset shifts Daniel Scheller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306131823.4b6280ba@vento.lan \
    --to=mchehab@kernel.org \
    --cc=d.scheller.oss@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@s-opensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).