* [PATCH 1/1] mn88473: implement lock for all delivery systems
@ 2015-03-18 21:37 Benjamin Larsson
2015-03-19 14:44 ` Antti Palosaari
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Larsson @ 2015-03-18 21:37 UTC (permalink / raw)
To: crope; +Cc: Linux Media Mailing List
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:
--
2.1.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-18 21:37 [PATCH 1/1] mn88473: implement lock for all delivery systems Benjamin Larsson
@ 2015-03-19 14:44 ` Antti Palosaari
2015-03-20 23:13 ` Benjamin Larsson
0 siblings, 1 reply; 8+ messages in thread
From: Antti Palosaari @ 2015-03-19 14:44 UTC (permalink / raw)
To: Benjamin Larsson; +Cc: Linux Media Mailing List
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:
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-19 14:44 ` Antti Palosaari
@ 2015-03-20 23:13 ` Benjamin Larsson
2015-03-20 23:25 ` Antti Palosaari
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Larsson @ 2015-03-20 23:13 UTC (permalink / raw)
To: Antti Palosaari; +Cc: Linux Media Mailing List
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-20 23:13 ` Benjamin Larsson
@ 2015-03-20 23:25 ` Antti Palosaari
2015-03-21 10:18 ` Benjamin Larsson
0 siblings, 1 reply; 8+ messages in thread
From: Antti Palosaari @ 2015-03-20 23:25 UTC (permalink / raw)
To: Benjamin Larsson; +Cc: Linux Media Mailing List
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
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-20 23:25 ` Antti Palosaari
@ 2015-03-21 10:18 ` Benjamin Larsson
2015-03-22 11:30 ` Antti Palosaari
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Larsson @ 2015-03-21 10:18 UTC (permalink / raw)
To: Antti Palosaari; +Cc: Linux Media Mailing List
[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]
On 03/21/2015 12:25 AM, Antti Palosaari wrote:
> 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.
Ok, will try that later.
Anyway, I tried the attached patch and I was able to get a lock after a
reboot from windows with the windows driver initializing the stick. If I
replugged the stick I get no signal and if I try the rtl2832 demod it
reports the same. So I think that my signal is just to weak for the
kernel r820t driver. So it would be nice if you could test this patch
and see if it works.
>
> regards
> Antti
>
MvH
Benjamin Larsson
[-- Attachment #2: 0001-mn88473-implement-lock-for-all-delivery-systems.patch --]
[-- Type: text/x-patch, Size: 2308 bytes --]
>From 603398bf07ef5eccca4d632b9ef61ccf0e6b46d0 Mon Sep 17 00:00:00 2001
From: Benjamin Larsson <benjamin@southpole.se>
Date: Sun, 15 Mar 2015 23:43:07 +0100
Subject: [PATCH 1/1] mn88473: implement lock for all delivery systems
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
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..a4ff299 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:
--
2.1.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-21 10:18 ` Benjamin Larsson
@ 2015-03-22 11:30 ` Antti Palosaari
2015-03-22 16:02 ` Benjamin Larsson
0 siblings, 1 reply; 8+ messages in thread
From: Antti Palosaari @ 2015-03-22 11:30 UTC (permalink / raw)
To: Benjamin Larsson; +Cc: Linux Media Mailing List
On 03/21/2015 12:18 PM, Benjamin Larsson wrote:
> On 03/21/2015 12:25 AM, Antti Palosaari wrote:
>> 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.
>
> Ok, will try that later.
>
> Anyway, I tried the attached patch and I was able to get a lock after a
> reboot from windows with the windows driver initializing the stick. If I
> replugged the stick I get no signal and if I try the rtl2832 demod it
> reports the same. So I think that my signal is just to weak for the
> kernel r820t driver. So it would be nice if you could test this patch
> and see if it works.
Now it works. Next time I really expect you will test your patches
somehow before sending. Now I tested 3 different patch versions, find 2
first to be broken and last one working. It took around 2 hours of my time.
Patch applied.
Antti
>
>
>>
>> regards
>> Antti
>>
>
> MvH
> Benjamin Larsson
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-22 11:30 ` Antti Palosaari
@ 2015-03-22 16:02 ` Benjamin Larsson
2015-03-22 19:53 ` Antti Palosaari
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Larsson @ 2015-03-22 16:02 UTC (permalink / raw)
To: Antti Palosaari; +Cc: Linux Media Mailing List
> Now it works. Next time I really expect you will test your patches
> somehow before sending. Now I tested 3 different patch versions, find 2
> first to be broken and last one working. It took around 2 hours of my time.
>
> Patch applied.
>
> Antti
>
Yeah, my bad. Next I want to move the driver out of staging. What do I
need to fix to make it suitable for the main tree ?
There is locking code for both 88472 and 88473.
There is a workaround for the I2C errors.
The r820t is now able to receive dvb-c at frequencies around 300MHz.
So I think all TODO's are taken care of. Is it inly the missing register
I/O checks left ?
MvH
Benjamin Larsson
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mn88473: implement lock for all delivery systems
2015-03-22 16:02 ` Benjamin Larsson
@ 2015-03-22 19:53 ` Antti Palosaari
0 siblings, 0 replies; 8+ messages in thread
From: Antti Palosaari @ 2015-03-22 19:53 UTC (permalink / raw)
To: Benjamin Larsson; +Cc: Linux Media Mailing List
On 03/22/2015 06:02 PM, Benjamin Larsson wrote:
>> Now it works. Next time I really expect you will test your patches
>> somehow before sending. Now I tested 3 different patch versions, find 2
>> first to be broken and last one working. It took around 2 hours of my
>> time.
>>
>> Patch applied.
>>
>> Antti
>>
>
> Yeah, my bad. Next I want to move the driver out of staging. What do I
> need to fix to make it suitable for the main tree ?
>
> There is locking code for both 88472 and 88473.
> There is a workaround for the I2C errors.
> The r820t is now able to receive dvb-c at frequencies around 300MHz.
>
> So I think all TODO's are taken care of. Is it inly the missing register
> I/O checks left ?
I think technically it is in a condition that it could be moved out from
stating.
There is surely a lot of things that could be done better or improve,
but all the must be fixed things are fixed.
regards
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-03-22 19:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 21:37 [PATCH 1/1] mn88473: implement lock for all delivery systems Benjamin Larsson
2015-03-19 14:44 ` Antti Palosaari
2015-03-20 23:13 ` Benjamin Larsson
2015-03-20 23:25 ` Antti Palosaari
2015-03-21 10:18 ` Benjamin Larsson
2015-03-22 11:30 ` Antti Palosaari
2015-03-22 16:02 ` Benjamin Larsson
2015-03-22 19:53 ` Antti Palosaari
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.