diff mbox

[1/1] mn88473: implement lock for all delivery systems

Message ID 1426714629-15640-1-git-send-email-benjamin@southpole.se (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Larsson March 18, 2015, 9:37 p.m. UTC
Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88473/mn88473.c | 50 +++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

Comments

Antti Palosaari March 19, 2015, 2:44 p.m. UTC | #1
Bad news. It does lock for DVB-C now, but DVB-T nor DVB-T2 does not lock.

regards
Antti

On 03/18/2015 11:37 PM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
> ---
>   drivers/staging/media/mn88473/mn88473.c | 50 +++++++++++++++++++++++++++++++--
>   1 file changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
> index a23e59e..196fcd6 100644
> --- a/drivers/staging/media/mn88473/mn88473.c
> +++ b/drivers/staging/media/mn88473/mn88473.c
> @@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
>   {
>   	struct i2c_client *client = fe->demodulator_priv;
>   	struct mn88473_dev *dev = i2c_get_clientdata(client);
> +	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>   	int ret;
> +	unsigned int utmp;
> +	int lock = 0;
>
>   	*status = 0;
>
> @@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
>   		goto err;
>   	}
>
> -	*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
> -			FE_HAS_SYNC | FE_HAS_LOCK;
> +	switch (c->delivery_system) {
> +	case SYS_DVBT:
> +		ret = regmap_read(dev->regmap[0], 0x62, &utmp);
> +		if (ret)
> +			goto err;
> +		if (utmp & 0xA0) {
> +			if ((utmp & 0xF) >= 0x03)
> +				*status |= FE_HAS_SIGNAL;
> +			if ((utmp & 0xF) >= 0x09)
> +				lock = 1;
> +		}
> +		break;
> +	case SYS_DVBT2:
> +		ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
> +		if (ret)
> +			goto err;
> +		if (utmp & 0x40) {
> +			if ((utmp & 0xF) >= 0x07)
> +				*status |= FE_HAS_SIGNAL;
> +			if ((utmp & 0xF) >= 0x0a)
> +				*status |= FE_HAS_CARRIER;
> +			if ((utmp & 0xF) >= 0x0d)
> +				*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
> +		}
> +		break;
> +	case SYS_DVBC_ANNEX_A:
> +		ret = regmap_read(dev->regmap[1], 0x85, &utmp);
> +		if (ret)
> +			goto err;
> +		if (!(utmp & 0x40)) {
> +			ret = regmap_read(dev->regmap[1], 0x89, &utmp);
> +			if (ret)
> +				goto err;
> +			if (utmp & 0x01)
> +				lock = 1;
> +		}
> +		break;
> +	default:
> +		ret = -EINVAL;
> +		goto err;
> +	}
> +
> +	if (lock)
> +		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
> +				FE_HAS_SYNC | FE_HAS_LOCK;
>
>   	return 0;
>   err:
>
Benjamin Larsson March 20, 2015, 11:13 p.m. UTC | #2
On 03/19/2015 03:44 PM, Antti Palosaari wrote:
> Bad news. It does lock for DVB-C now, but DVB-T nor DVB-T2 does not lock.
>
> regards
> Antti

I'm getting tired :/. Had the time to test now and the checks is 
supposed to be negated.

if (utmp & 0xA0) { -> if (!(utmp & 0xA0))

But as stock dvbv5-scan crashes on ubuntu 14.04 and I can't unload the 
mn88473 module I will confirm this when I have an actual working version 
of dvbv5-scan and Ubuntu.

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Antti Palosaari March 20, 2015, 11:25 p.m. UTC | #3
On 03/21/2015 01:13 AM, Benjamin Larsson wrote:
> On 03/19/2015 03:44 PM, Antti Palosaari wrote:
>> Bad news. It does lock for DVB-C now, but DVB-T nor DVB-T2 does not lock.
>>
>> regards
>> Antti
>
> I'm getting tired :/. Had the time to test now and the checks is
> supposed to be negated.
>
> if (utmp & 0xA0) { -> if (!(utmp & 0xA0))
>
> But as stock dvbv5-scan crashes on ubuntu 14.04 and I can't unload the
> mn88473 module I will confirm this when I have an actual working version
> of dvbv5-scan and Ubuntu.

You could also use w_scan. Or install latest dvbv5-scan from git - it 
works even without install by running from compile directory.

regards
Antti
diff mbox

Patch

diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c
index a23e59e..196fcd6 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -167,7 +167,10 @@  static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
 	struct i2c_client *client = fe->demodulator_priv;
 	struct mn88473_dev *dev = i2c_get_clientdata(client);
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int ret;
+	unsigned int utmp;
+	int lock = 0;
 
 	*status = 0;
 
@@ -176,8 +179,51 @@  static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status)
 		goto err;
 	}
 
-	*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
-			FE_HAS_SYNC | FE_HAS_LOCK;
+	switch (c->delivery_system) {
+	case SYS_DVBT:
+		ret = regmap_read(dev->regmap[0], 0x62, &utmp);
+		if (ret)
+			goto err;
+		if (utmp & 0xA0) {
+			if ((utmp & 0xF) >= 0x03)
+				*status |= FE_HAS_SIGNAL;
+			if ((utmp & 0xF) >= 0x09)
+				lock = 1;
+		}
+		break;
+	case SYS_DVBT2:
+		ret = regmap_read(dev->regmap[2], 0x8B, &utmp);
+		if (ret)
+			goto err;
+		if (utmp & 0x40) {
+			if ((utmp & 0xF) >= 0x07)
+				*status |= FE_HAS_SIGNAL;
+			if ((utmp & 0xF) >= 0x0a)
+				*status |= FE_HAS_CARRIER;
+			if ((utmp & 0xF) >= 0x0d)
+				*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+		}
+		break;
+	case SYS_DVBC_ANNEX_A:
+		ret = regmap_read(dev->regmap[1], 0x85, &utmp);
+		if (ret)
+			goto err;
+		if (!(utmp & 0x40)) {
+			ret = regmap_read(dev->regmap[1], 0x89, &utmp);
+			if (ret)
+				goto err;
+			if (utmp & 0x01)
+				lock = 1;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+		goto err;
+	}
+
+	if (lock)
+		*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
+				FE_HAS_SYNC | FE_HAS_LOCK;
 
 	return 0;
 err: