All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic
@ 2016-06-30  3:34 Mauro Carvalho Chehab
  2016-06-30  5:39 ` kbuild test robot
  2016-07-01  1:46 ` Abylay Ospan
  0 siblings, 2 replies; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2016-06-30  3:34 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Sergey Kozlov,
	Abylay Ospan

It is a good idea to measure the signal strength while
tuning, as this helps to identify if the antenna is ok.
Also, such measure helps to identify the quality of the
signal.

Do some changes to enable it before signal lock. While
here, optimize the code to only initialize the stats
length once, and make sure that, just after set_frontend,
any reading for the stats that depends on lock to return
FE_SCALE_NOT_AVAILABLE.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/dvb-frontends/cxd2841er.c | 45 ++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
index d369a7567d18..3d39ae954fe2 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -2936,31 +2936,25 @@ static int cxd2841er_get_frontend(struct dvb_frontend *fe,
 	else if (priv->state == STATE_ACTIVE_TC)
 		cxd2841er_read_status_tc(fe, &status);
 
+	cxd2841er_read_signal_strength(fe, &strength);
+	p->strength.stat[0].scale = FE_SCALE_RELATIVE;
+	p->strength.stat[0].uvalue = strength;
+
 	if (status & FE_HAS_LOCK) {
-		cxd2841er_read_signal_strength(fe, &strength);
-		p->strength.len = 1;
-		p->strength.stat[0].scale = FE_SCALE_RELATIVE;
-		p->strength.stat[0].uvalue = strength;
 		cxd2841er_read_snr(fe, &snr);
-		p->cnr.len = 1;
 		p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
 		p->cnr.stat[0].svalue = snr;
+
 		cxd2841er_read_ucblocks(fe, &errors);
-		p->block_error.len = 1;
 		p->block_error.stat[0].scale = FE_SCALE_COUNTER;
 		p->block_error.stat[0].uvalue = errors;
+
 		cxd2841er_read_ber(fe, &ber);
-		p->post_bit_error.len = 1;
 		p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
 		p->post_bit_error.stat[0].uvalue = ber;
 	} else {
-		p->strength.len = 1;
-		p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
-		p->cnr.len = 1;
 		p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
-		p->block_error.len = 1;
 		p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
-		p->post_bit_error.len = 1;
 		p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
 	}
 	return 0;
@@ -3021,6 +3015,12 @@ static int cxd2841er_set_frontend_s(struct dvb_frontend *fe)
 			__func__, carr_offset);
 	}
 done:
+	/* Reset stats */
+	p->strength.stat[0].scale = FE_SCALE_RELATIVE;
+	p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+	p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+	p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+
 	return ret;
 }
 
@@ -3382,6 +3382,21 @@ static enum dvbfe_algo cxd2841er_get_algo(struct dvb_frontend *fe)
 	return DVBFE_ALGO_HW;
 }
 
+static int cxd2841er_init_stats(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+
+	p->strength.len = 1;
+	p->strength.stat[0].scale = FE_SCALE_RELATIVE;
+	p->cnr.len = 1;
+	p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+	p->block_error.len = 1;
+	p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+	p->post_bit_error.len = 1;
+	p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+}
+
+
 static int cxd2841er_init_s(struct dvb_frontend *fe)
 {
 	struct cxd2841er_priv *priv = fe->demodulator_priv;
@@ -3403,6 +3418,9 @@ static int cxd2841er_init_s(struct dvb_frontend *fe)
 	/* SONY_DEMOD_CONFIG_SAT_IFAGCNEG set to 1 */
 	cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
 	cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xb9, 0x01, 0x01);
+
+	cxd2841er_init_stats(fe);
+
 	return 0;
 }
 
@@ -3422,6 +3440,9 @@ static int cxd2841er_init_tc(struct dvb_frontend *fe)
 	/* SONY_DEMOD_CONFIG_PARALLEL_SEL = 1 */
 	cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
 	cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xc4, 0x00, 0x80);
+
+	cxd2841er_init_stats(fe);
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic
  2016-06-30  3:34 [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic Mauro Carvalho Chehab
@ 2016-06-30  5:39 ` kbuild test robot
  2016-07-01  1:46 ` Abylay Ospan
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-06-30  5:39 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: kbuild-all, Linux Media Mailing List, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sergey Kozlov, Abylay Ospan

[-- Attachment #1: Type: text/plain, Size: 1924 bytes --]

Hi,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.7-rc5 next-20160629]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/cxd2841er-Do-some-changes-at-the-dvbv5-stats-logic/20160630-120109
base:   git://linuxtv.org/media_tree.git master
config: x86_64-acpi-redef (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/media/dvb-frontends/cxd2841er.c: In function 'cxd2841er_init_stats':
>> drivers/media/dvb-frontends/cxd2841er.c:3397:1: warning: no return statement in function returning non-void [-Wreturn-type]
    }
    ^

vim +3397 drivers/media/dvb-frontends/cxd2841er.c

  3381		dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
  3382		return DVBFE_ALGO_HW;
  3383	}
  3384	
  3385	static int cxd2841er_init_stats(struct dvb_frontend *fe)
  3386	{
  3387		struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  3388	
  3389		p->strength.len = 1;
  3390		p->strength.stat[0].scale = FE_SCALE_RELATIVE;
  3391		p->cnr.len = 1;
  3392		p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
  3393		p->block_error.len = 1;
  3394		p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
  3395		p->post_bit_error.len = 1;
  3396		p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> 3397	}
  3398	
  3399	
  3400	static int cxd2841er_init_s(struct dvb_frontend *fe)
  3401	{
  3402		struct cxd2841er_priv *priv = fe->demodulator_priv;
  3403	
  3404		/* sanity. force demod to SHUTDOWN state */
  3405		if (priv->state == STATE_SLEEP_S) {

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 28308 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic
  2016-06-30  3:34 [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic Mauro Carvalho Chehab
  2016-06-30  5:39 ` kbuild test robot
@ 2016-07-01  1:46 ` Abylay Ospan
  1 sibling, 0 replies; 3+ messages in thread
From: Abylay Ospan @ 2016-07-01  1:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Sergey Kozlov

Acked-by: Abylay Ospan <aospan@netup.ru>

2016-06-29 23:34 GMT-04:00 Mauro Carvalho Chehab <mchehab@s-opensource.com>:
> It is a good idea to measure the signal strength while
> tuning, as this helps to identify if the antenna is ok.
> Also, such measure helps to identify the quality of the
> signal.
>
> Do some changes to enable it before signal lock. While
> here, optimize the code to only initialize the stats
> length once, and make sure that, just after set_frontend,
> any reading for the stats that depends on lock to return
> FE_SCALE_NOT_AVAILABLE.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/dvb-frontends/cxd2841er.c | 45 ++++++++++++++++++++++++---------
>  1 file changed, 33 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
> index d369a7567d18..3d39ae954fe2 100644
> --- a/drivers/media/dvb-frontends/cxd2841er.c
> +++ b/drivers/media/dvb-frontends/cxd2841er.c
> @@ -2936,31 +2936,25 @@ static int cxd2841er_get_frontend(struct dvb_frontend *fe,
>         else if (priv->state == STATE_ACTIVE_TC)
>                 cxd2841er_read_status_tc(fe, &status);
>
> +       cxd2841er_read_signal_strength(fe, &strength);
> +       p->strength.stat[0].scale = FE_SCALE_RELATIVE;
> +       p->strength.stat[0].uvalue = strength;
> +
>         if (status & FE_HAS_LOCK) {
> -               cxd2841er_read_signal_strength(fe, &strength);
> -               p->strength.len = 1;
> -               p->strength.stat[0].scale = FE_SCALE_RELATIVE;
> -               p->strength.stat[0].uvalue = strength;
>                 cxd2841er_read_snr(fe, &snr);
> -               p->cnr.len = 1;
>                 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
>                 p->cnr.stat[0].svalue = snr;
> +
>                 cxd2841er_read_ucblocks(fe, &errors);
> -               p->block_error.len = 1;
>                 p->block_error.stat[0].scale = FE_SCALE_COUNTER;
>                 p->block_error.stat[0].uvalue = errors;
> +
>                 cxd2841er_read_ber(fe, &ber);
> -               p->post_bit_error.len = 1;
>                 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
>                 p->post_bit_error.stat[0].uvalue = ber;
>         } else {
> -               p->strength.len = 1;
> -               p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> -               p->cnr.len = 1;
>                 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> -               p->block_error.len = 1;
>                 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> -               p->post_bit_error.len = 1;
>                 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
>         }
>         return 0;
> @@ -3021,6 +3015,12 @@ static int cxd2841er_set_frontend_s(struct dvb_frontend *fe)
>                         __func__, carr_offset);
>         }
>  done:
> +       /* Reset stats */
> +       p->strength.stat[0].scale = FE_SCALE_RELATIVE;
> +       p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +       p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +       p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +
>         return ret;
>  }
>
> @@ -3382,6 +3382,21 @@ static enum dvbfe_algo cxd2841er_get_algo(struct dvb_frontend *fe)
>         return DVBFE_ALGO_HW;
>  }
>
> +static int cxd2841er_init_stats(struct dvb_frontend *fe)
> +{
> +       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
> +
> +       p->strength.len = 1;
> +       p->strength.stat[0].scale = FE_SCALE_RELATIVE;
> +       p->cnr.len = 1;
> +       p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +       p->block_error.len = 1;
> +       p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +       p->post_bit_error.len = 1;
> +       p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
> +}
> +
> +
>  static int cxd2841er_init_s(struct dvb_frontend *fe)
>  {
>         struct cxd2841er_priv *priv = fe->demodulator_priv;
> @@ -3403,6 +3418,9 @@ static int cxd2841er_init_s(struct dvb_frontend *fe)
>         /* SONY_DEMOD_CONFIG_SAT_IFAGCNEG set to 1 */
>         cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
>         cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xb9, 0x01, 0x01);
> +
> +       cxd2841er_init_stats(fe);
> +
>         return 0;
>  }
>
> @@ -3422,6 +3440,9 @@ static int cxd2841er_init_tc(struct dvb_frontend *fe)
>         /* SONY_DEMOD_CONFIG_PARALLEL_SEL = 1 */
>         cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
>         cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xc4, 0x00, 0x80);
> +
> +       cxd2841er_init_stats(fe);
> +
>         return 0;
>  }
>
> --
> 2.7.4
>



-- 
Abylay Ospan,
NetUP Inc.
http://www.netup.tv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-01  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-30  3:34 [PATCH] cxd2841er: Do some changes at the dvbv5 stats logic Mauro Carvalho Chehab
2016-06-30  5:39 ` kbuild test robot
2016-07-01  1:46 ` Abylay Ospan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.