All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH 03/11] [media] mb86a20s: provide CNR stats before FE_HAS_SYNC
Date: Mon, 4 Mar 2013 08:23:13 -0300	[thread overview]
Message-ID: <20130304082313.7acf632e@redhat.com> (raw)
In-Reply-To: <1362326331-17541-4-git-send-email-mchehab@redhat.com>

Em Sun,  3 Mar 2013 12:58:43 -0300
Mauro Carvalho Chehab <mchehab@redhat.com> escreveu:

> State 9 means TS started to be output, and it should be
> associated with FE_HAS_SYNC.
> 
> The mb86a20scan get CNR statistics at state 7, when frame sync
> is obtained.
> 
> As CNR may help to adjust the antenna, provide it earlier.
> 
> A latter patch could eventually start outputing MER measures
> earlier, but that would require a bigger change, and probably
> won't be better than the current way, as the time between
> changing from state 8 to 9 is generally lower than the time
> to get the stats collected.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> ---
>  drivers/media/dvb-frontends/mb86a20s.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
> index daeee81..e222e55 100644
> --- a/drivers/media/dvb-frontends/mb86a20s.c
> +++ b/drivers/media/dvb-frontends/mb86a20s.c
> @@ -312,7 +312,7 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status)
>  	dev_dbg(&state->i2c->dev, "%s: Status = 0x%02x (state = %d)\n",
>  		 __func__, *status, val);
>  
> -	return 0;
> +	return val;
>  }
>  
>  static int mb86a20s_read_signal_strength(struct dvb_frontend *fe)
> @@ -1564,7 +1564,7 @@ static void mb86a20s_stats_not_ready(struct dvb_frontend *fe)
>  	}
>  }
>  
> -static int mb86a20s_get_stats(struct dvb_frontend *fe)
> +static int mb86a20s_get_stats(struct dvb_frontend *fe, int status_nr)
>  {
>  	struct mb86a20s_state *state = fe->demodulator_priv;
>  	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
> @@ -1584,6 +1584,14 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
>  	/* Get per-layer stats */
>  	mb86a20s_get_blk_error_layer_CNR(fe);
>  
> +	/*
> +	 * At state 7, only CNR is available
> +	 * For BER measures, state=9 is required
> +	 * FIXME: we may get MER measures with state=8
> +	 */
> +	if (status_nr < 9)
> +		return 0;
> +
>  	for (i = 0; i < 3; i++) {
>  		if (c->isdbt_layer_enabled & (1 << i)) {
>  			/* Layer is active and has rc segments */
> @@ -1875,7 +1883,7 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
>  {
>  	struct mb86a20s_state *state = fe->demodulator_priv;
>  	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
> -	int rc;
> +	int rc, status_nr;
>  
>  	dev_dbg(&state->i2c->dev, "%s called.\n", __func__);
>  
> @@ -1883,12 +1891,12 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
>  		fe->ops.i2c_gate_ctrl(fe, 0);
>  
>  	/* Get lock */
> -	rc = mb86a20s_read_status(fe, status);
> -	if (!(*status & FE_HAS_LOCK)) {
> +	status_nr = mb86a20s_read_status(fe, status);
> +	if (status_nr < 7) {
>  		mb86a20s_stats_not_ready(fe);
>  		mb86a20s_reset_frontend_cache(fe);
>  	}
> -	if (rc < 0) {
> +	if (state < 0) {

This is obviously wrong ;)

Patch with fixup enclosed.

Cheers,
Mauro

-

[PATCH 03/11v2] [media] mb86a20s: provide CNR stats before FE_HAS_SYNC

State 9 means TS started to be output, and it should be
associated with FE_HAS_SYNC.

The mb86a20scan get CNR statistics at state 7, when frame sync
is obtained.

As CNR may help to adjust the antenna, provide it earlier.

A latter patch could eventually start outputing MER measures
earlier, but that would require a bigger change, and probably
won't be better than the current way, as the time between
changing from state 8 to 9 is generally lower than the time
to get the stats collected.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index daeee81..2720b82 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -312,7 +312,7 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status)
 	dev_dbg(&state->i2c->dev, "%s: Status = 0x%02x (state = %d)\n",
 		 __func__, *status, val);
 
-	return 0;
+	return val;
 }
 
 static int mb86a20s_read_signal_strength(struct dvb_frontend *fe)
@@ -1564,7 +1564,7 @@ static void mb86a20s_stats_not_ready(struct dvb_frontend *fe)
 	}
 }
 
-static int mb86a20s_get_stats(struct dvb_frontend *fe)
+static int mb86a20s_get_stats(struct dvb_frontend *fe, int status_nr)
 {
 	struct mb86a20s_state *state = fe->demodulator_priv;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -1584,6 +1584,14 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
 	/* Get per-layer stats */
 	mb86a20s_get_blk_error_layer_CNR(fe);
 
+	/*
+	 * At state 7, only CNR is available
+	 * For BER measures, state=9 is required
+	 * FIXME: we may get MER measures with state=8
+	 */
+	if (status_nr < 9)
+		return 0;
+
 	for (i = 0; i < 3; i++) {
 		if (c->isdbt_layer_enabled & (1 << i)) {
 			/* Layer is active and has rc segments */
@@ -1875,7 +1883,7 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
 {
 	struct mb86a20s_state *state = fe->demodulator_priv;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-	int rc;
+	int rc, status_nr;
 
 	dev_dbg(&state->i2c->dev, "%s called.\n", __func__);
 
@@ -1883,12 +1891,12 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
 		fe->ops.i2c_gate_ctrl(fe, 0);
 
 	/* Get lock */
-	rc = mb86a20s_read_status(fe, status);
-	if (!(*status & FE_HAS_LOCK)) {
+	status_nr = mb86a20s_read_status(fe, status);
+	if (status_nr < 7) {
 		mb86a20s_stats_not_ready(fe);
 		mb86a20s_reset_frontend_cache(fe);
 	}
-	if (rc < 0) {
+	if (status_nr < 0) {
 		dev_err(&state->i2c->dev,
 			"%s: Can't read frontend lock status\n", __func__);
 		goto error;
@@ -1908,7 +1916,7 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
 	/* Fill signal strength */
 	c->strength.stat[0].uvalue = rc;
 
-	if (*status & FE_HAS_LOCK) {
+	if (status_nr >= 7) {
 		/* Get TMCC info*/
 		rc = mb86a20s_get_frontend(fe);
 		if (rc < 0) {
@@ -1919,7 +1927,7 @@ static int mb86a20s_read_status_and_stats(struct dvb_frontend *fe,
 		}
 
 		/* Get statistics */
-		rc = mb86a20s_get_stats(fe);
+		rc = mb86a20s_get_stats(fe, status_nr);
 		if (rc < 0 && rc != -EBUSY) {
 			dev_err(&state->i2c->dev,
 				"%s: Can't get FE statistics.\n", __func__);



  reply	other threads:[~2013-03-04 11:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03 15:58 [PATCH 00/11] Do some improvements/fixups on mb86a20s, cx231xx and em28xx Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 01/11] [media] mb86a20s: don't pollute dmesg with debug messages Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 02/11] [media] mb86a20s: adjust IF based on what's set on the tuner Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 03/11] [media] mb86a20s: provide CNR stats before FE_HAS_SYNC Mauro Carvalho Chehab
2013-03-04 11:23   ` Mauro Carvalho Chehab [this message]
2013-03-03 15:58 ` [PATCH 04/11] [media] mb86a20s: Fix signal strength calculus Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 05/11] [media] mb86a20s: don't allow updating signal strength too fast Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 06/11] [media] mb86a20s: change AGC tuning parameters Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 07/11] [media] mb86a20s: Always reset the frontend with set_frontend Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 08/11] [media] mb86a20s: Don't reset strength with the other stats Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 09/11] [media] mb86a20s: cleanup the status at set_frontend() Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 10/11] [media] cx231xx: Improve signal reception for PV SBTVD Mauro Carvalho Chehab
2013-03-03 15:58 ` [PATCH 11/11] [media] em28xx-dvb: Don't put device in suspend mode at feed stop Mauro Carvalho Chehab

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=20130304082313.7acf632e@redhat.com \
    --to=mchehab@redhat.com \
    --cc=linux-media@vger.kernel.org \
    /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 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.