Re: SAA716x DVB driver

2018-01-25 Thread Jemma Denson
Hi Tycho,

On 20/01/18 15:49, Tycho Lürsen wrote:
> Right, but we still need a maintainer. Are you capable/willing to
> volunteer for the job?

If no-one else will then yes I can, but I can't claim to know these devices
inside out. It would really depend on what's required of a maintainer, I'm
struggling to find this documented anywhere.

Cards I can't test with would really need someone to be able to add a
tested-by to verify they work.

>>
>>> I think that your proposal to use a stripped version of Luis Alves
>>> repo is a no go, since it contains a couple of demod/tuner drivers
>>> that are not upstreamed yet. That complicates the upstreaming process
>>> too much, I think.
>> Oh, I would have stripped it *right* down and removed every card except
>> my TBS6280. The end result would probably be pretty close to Soeren's at
>> that point anyway, so I was starting to think like what you've done and
>> base it on that instead.
> If you want, I can strip the driver down a lot more and ad back the
> drivers you need. Just tell me what it is you need.

As above, it's really just a case of making it maintainable. If someone
can step forward and ack for them working then they could be included
but if not then I think it's best dropping them until that happens.


Jemma.


Re: SAA716x DVB driver

2018-01-19 Thread Jemma Denson
Hi Tycho,

On 19/01/18 13:59, Tycho Lürsen wrote:
> Hi Jemma,
>
> I'm with you: let's get merged at least something!
>
> Did you find  a maintainer for this driver?
> I can do simple stuff like in my fork of Soeren Moch's repo, but thats
> where it ends. I dont have the knowledge needed to maintain a driver.

Not yet, but I can't really say I've been looking - unfortunately real
life got in the way of anything over christmas. I'm not sure I do
either, but it really depends on what's required. From what I can see
from maintaining another driver then as long as the driver is working
there's not a whole lot to do.

>
> I think that your proposal to use a stripped version of Luis Alves
> repo is a no go, since it contains a couple of demod/tuner drivers
> that are not upstreamed yet. That complicates the upstreaming process
> too much, I think.

Oh, I would have stripped it *right* down and removed every card except
my TBS6280. The end result would probably be pretty close to Soeren's at
that point anyway, so I was starting to think like what you've done and
base it on that instead.

> I used a stripped version of Soeren Moch's repo to prove its stability
> instead, adding the drivers I need so I can test it. You can see what
> I did at :
> https://github.com/bas-t/linux-saa716x/commits/for-media-stripped
>
> This has been tested with linux 4.9.77, 4.14.14 and 4.15-rc8.
> Works like a charm for me.
>

Looks like a good start, I'd be tempted to remove all the other cards
though unless you have them available to test with. Keeps the submission
simpler and less to worry about, they can be added back in later if
someone has an itch to scratch (and hardware to test with!).

I do have a few other tbs 716x cards available here at work so might be
able to test some others out, but we're a bit busy at the moment so
would have to be on my own time and there's not much of that available
at the moment either :(


Jemma.


Re: [GIT PULL] SAA716x DVB driver

2017-12-03 Thread Jemma Denson

On 03/12/17 14:11, Soeren Moch wrote:

On 03.12.2017 11:57, Jemma Denson wrote:

On 02/12/17 23:59, Soeren Moch wrote:

All the entries in the TODO file are not specific for saa716x_ff.

Ah, it's been a few months since I looked at that. I think some of the
things listed I had already identified as problems - checkpatch
especially,

Finding checkpatch problems is easy...


Indeed they are. They still take some time to go though.


Hence my comment about finding a maintainer - I had assumed if the
immediate result didn't support your card you probably wouldn't be
willing
to do that.

What I'm trying to do here is get *something* merged, and then once
that work is done any interested parties can add to it. Or at the very
least if some patches are left OOT the constant workload required to
keep that up to date should be reduced significantly because they'll be
far less to look after.


Why not merge the driver as-is? The community would get support for
several cards, easy access to the code without the need for separate git
repositories or dkms packages, and a maintainer that understands the
hardware and driver code.

The whole purpose of driver development is bringing support for existing
hardware to available user applications, preferably with existing APIs.
And exactly that is in this pull request.
In the whole discussion I cannot find a single reason, how merging this
driver would violate the linux development principles.


That's not really one for me to answer, but Mauro has raised objections
so it can't be merged as is. I'm just trying to find a way forward that
avoids this getting stuck for another few years.


One of the problems though is choosing which fork to use. I *think* there
are 2 - the one you've got which is the original powARman branch and the
one I would be using is the CrazyCat / Luis /  TBS line. There are
going to be
some differences but hopefully that's all frontend support based and
one cut
down to a single frontend would end up a good base to add the rest back
in.


I think my repository represents the main development branch, just
maintained by different people (adding Manu, Andreas, Oliver, in case
they want to object). The CrazyCat repo is not a fork (including
history), it is just a snapshot of the driver plus several patches.



Well I know of several patches I've made to that repo that haven't
made it back to the "main" branch, so whilst maybe not a fork in
the traditional sense it certainly is functioning like one.

As I said, I'm just trying to get *something* merged.  I can base a
ff-stripped patch on the powarman branch instead but it does represent
more work for me as I need to work out what else might be missing to
support the only card I have for testing this with. It might end up being
easy but I don't know that yet.

Let's get something happening here rather than just trying to argue
with the maintainers. There's absolutely nothing stopping further patches
being sent in later on once the chipset driver is merged.


Jemma.


Re: [GIT PULL] SAA716x DVB driver

2017-12-03 Thread Jemma Denson

On 02/12/17 23:59, Soeren Moch wrote:

On 02.12.2017 20:49, Mauro Carvalho Chehab wrote:

Em Sat, 2 Dec 2017 18:51:16 +
Jemma Denson <jden...@gmail.com> escreveu:

Would I be correct in thinking the main blocker to this is the *_ff features
used by the S2-6400 card? There's plenty of other cards using this chipset
that don't need that part.

Would a solution for now to be a driver with the ff components stripped out,
and then the ff API work can be done later when / if there's any interest?

Works for me. In such case (and provided that the driver without *_ff are
in good shape), we could merge it under drivers/media (instead of merging
it on staging).

All the entries in the TODO file are not specific for saa716x_ff.


Ah, it's been a few months since I looked at that. I think some of the
things listed I had already identified as problems - checkpatch especially,
and the irq code probably needs a bit more auto-detection.
I'm not sure I've seen how the other issues manifest themselves so I
might need some explanation of that (off list if you prefer)


I guess a problem would be finding a maintainer, I'm happy to put together
a stripped down driver just supporting the TBS card I use (I already have
one I use with dkms), but I'm not sure I have the time or knowledge of this
chipset to be a maintainer.

There is chipset specific stuff to fix, especially irq handling.


Is this the module parameter kludges or something else?


As we're talking more about touching at uAPI, probably it doesn't require
chipsed knowledge. Only time and interest on doing it.

Please sync with Soeren. Perhaps if you both could help on it, it would
make the task easier.

As I already wrote to different people off-list: I'm happy to support
more cards with the saa7160 bridge and maintain these in this driver. As
hobbyist programmer this of course makes no sense to me, if the hardware
I own (S2-6400) is not supported.



Hence my comment about finding a maintainer - I had assumed if the
immediate result didn't support your card you probably wouldn't be willing
to do that.

What I'm trying to do here is get *something* merged, and then once
that work is done any interested parties can add to it. Or at the very
least if some patches are left OOT the constant workload required to
keep that up to date should be reduced significantly because they'll be
far less to look after.

One of the problems though is choosing which fork to use. I *think* there
are 2 - the one you've got which is the original powARman branch and the
one I would be using is the CrazyCat / Luis /  TBS line. There are going 
to be

some differences but hopefully that's all frontend support based and one cut
down to a single frontend would end up a good base to add the rest back
in.

I'm looking at maybe finding time over christmas break.


Jemma


Re: [GIT PULL] SAA716x DVB driver

2017-12-02 Thread Jemma Denson

Hi Mauro,

On 27/11/17 11:24, Mauro Carvalho Chehab wrote:

Em Fri, 24 Nov 2017 17:28:37 +0100
Tycho Lürsen  escreveu:


Hi Mauro,

afaik the last communication about submission of this driver was about
two months ago.

This driver is important to me, because I own several TurboSight cards
that are saa716x based. I want to submit a patch that supports my cards.
Of course I can only do so when you accept this driver in the first place.

Any chance you and Sören agree about how to proceed about this driver
anytime soon?

If we can reach an agreement about what should be done for the driver
to be promoted from staging some day, I'll merge it. Otherwise,
it can be kept maintained out of tree. This driver has been maintained
OOT for a very long time, and it seems that people were happy with
that, as only at the second half of this year someone is requesting
to merge it.

So, while I agree that the best is to merge it upstream and
address the issues that made it OOT for a long time, we shouldn't
rush it with the risk of doing more harm than good.

Thanks,
Mauro


Would I be correct in thinking the main blocker to this is the *_ff features
used by the S2-6400 card? There's plenty of other cards using this chipset
that don't need that part.

Would a solution for now to be a driver with the ff components stripped out,
and then the ff API work can be done later when / if there's any interest?

I guess a problem would be finding a maintainer, I'm happy to put together
a stripped down driver just supporting the TBS card I use (I already have
one I use with dkms), but I'm not sure I have the time or knowledge of this
chipset to be a maintainer. Unfortunately my workplace is phasing out
these cards otherwise I'd try and get them to sponsor me rather than do it
on my own time!


Jemma.



Re: [PATCH v2] media: isl6421: add checks for current overflow

2017-08-19 Thread Jemma Denson

On 17/08/17 20:50, Jemma Denson wrote:


On 16/08/17 10:42, Mauro Carvalho Chehab wrote:

I've just tested both your v2 patch and changes I'm suggesting above; both work
fine on my setup. Do you want me to send a v3?

Yeah, sure! I'm currently in travel, returning only on Friday, and I don't
have the hardware to test. So, if you can send it, I'd appreciate :-)
Cheers,
Mauro

Ok, just sent. The if statements ended up being a bit complicated, but I added 
checking
if the DCL bit was being overridden (it is by several cards under cx88), only 
pausing
for a second if DCL was in use as the datasheet suggested that's only done in 
that mode,
and also skipped checking overflow if the device was set to off.
The latter should cover overflow somehow being picked up during attach and 
causing the
attach to fail. Unlikely to happen but we shouldn't fail on what could be a 
transient
issue.


Sorry, time for a v4! I wasn't happy with adding a permanent 200ms pause so 
I've reverted
that back to how you had it before. The pause before re-enabling dcl is only 
really needed
if it needs time to settle down and so reverting back to always doing a 1000ms 
on overload
should cover it.

Jemma.



[PATCH v4] media: isl6421: add checks for current overflow

2017-08-19 Thread Jemma Denson
This Kaffeine's BZ:
https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different 
approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking 
an
special flag.

Add support for it.

Tested on Skystar S2. Changes respect override_or option so should still work 
fine
on cx88 based cards which disable dynamic current limit.

Changes since v1:
v2 - fixed incorrect checking of i2c return values
v3 - fix if logic to check if dcl needs re-enabling
   - respect override_or values which aim to disable dcl
   - only do long sleep on overload if dcl enabled
   - add short sleep before re-enabling dcl
   - only check overload and potentially return EINVAL if device is on
v4 - revert v3 sleep logic changes to remove tuning delays

Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 drivers/media/dvb-frontends/isl6421.c | 76 +--
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/isl6421.c 
b/drivers/media/dvb-frontends/isl6421.c
index 838b42771a05..3f3487887672 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -38,35 +38,101 @@ struct isl6421 {
u8  override_and;
struct i2c_adapter  *i2c;
u8  i2c_addr;
+   boolis_off;
 };
 
 static int isl6421_set_voltage(struct dvb_frontend *fe,
   enum fe_sec_voltage voltage)
 {
+   int ret;
+   u8 buf;
+   bool is_off;
struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
-   struct i2c_msg msg = {  .addr = isl6421->i2c_addr, .flags = 0,
-   .buf = >config,
-   .len = sizeof(isl6421->config) };
+   struct i2c_msg msg[2] = {
+   {
+ .addr = isl6421->i2c_addr,
+ .flags = 0,
+ .buf = >config,
+ .len = 1,
+   }, {
+ .addr = isl6421->i2c_addr,
+ .flags = I2C_M_RD,
+ .buf = ,
+ .len = 1,
+   }
+
+   };
 
isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
 
switch(voltage) {
case SEC_VOLTAGE_OFF:
+   is_off = true;
break;
case SEC_VOLTAGE_13:
+   is_off = false;
isl6421->config |= ISL6421_EN1;
break;
case SEC_VOLTAGE_18:
+   is_off = false;
isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
break;
default:
return -EINVAL;
}
 
+   /*
+* If LNBf were not powered on, disable dynamic current limit, as,
+* according with datasheet, highly capacitive load on the output may
+* cause a difficult start-up.
+*/
+   if (isl6421->is_off && !is_off)
+   isl6421->config |= ISL6421_DCL;
+
isl6421->config |= isl6421->override_or;
isl6421->config &= isl6421->override_and;
 
-   return (i2c_transfer(isl6421->i2c, , 1) == 1) ? 0 : -EIO;
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+
+   /* Store off status now incase future commands fail */
+   isl6421->is_off = is_off;
+
+   /* On overflow, the device will try again after 900 ms (typically) */
+   if (!is_off && (buf & ISL6421_OLF1))
+   msleep(1000);
+
+   /* Re-enable dynamic current limit */
+   if ((isl6421->config & ISL6421_DCL) &&
+   !(isl6421->override_or & ISL6421_DCL)) {
+   isl6421->config &= ~ISL6421_DCL;
+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+   }
+
+   /* Check if overload flag is active. If so, disable power */
+   if (!is_off && (buf & ISL6421_OLF1)) {
+   isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
+   ret = i2c_transfer(isl6421->i2c, msg, 1);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;
+   isl6421->is_off = true;
+
+   dev_warn(>i

Re: [PATCH v2] media: isl6421: add checks for current overflow

2017-08-17 Thread Jemma Denson

On 16/08/17 10:42, Mauro Carvalho Chehab wrote:


I've just tested both your v2 patch and changes I'm suggesting above; both work
fine on my setup. Do you want me to send a v3?

Yeah, sure! I'm currently in travel, returning only on Friday, and I don't
have the hardware to test. So, if you can send it, I'd appreciate :-)

Cheers,
Mauro


Ok, just sent. The if statements ended up being a bit complicated, but I added 
checking
if the DCL bit was being overridden (it is by several cards under cx88), only 
pausing
for a second if DCL was in use as the datasheet suggested that's only done in 
that mode,
and also skipped checking overflow if the device was set to off.

The latter should cover overflow somehow being picked up during attach and 
causing the
attach to fail. Unlikely to happen but we shouldn't fail on what could be a 
transient
issue.

Jemma.



[PATCH v3] media: isl6421: add checks for current overflow

2017-08-17 Thread Jemma Denson
This Kaffeine's BZ:
https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different 
approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking 
an
special flag.

Add support for it.

Tested on Skystar S2. Changes respect override_or option so should still work 
fine
on cx88 based cards which disable dynamic current limit.

Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 drivers/media/dvb-frontends/isl6421.c | 77 +--
 1 file changed, 73 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/isl6421.c 
b/drivers/media/dvb-frontends/isl6421.c
index 838b42771a05..f58590fe71f5 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -38,35 +38,102 @@ struct isl6421 {
u8  override_and;
struct i2c_adapter  *i2c;
u8  i2c_addr;
+   boolis_off;
 };
 
 static int isl6421_set_voltage(struct dvb_frontend *fe,
   enum fe_sec_voltage voltage)
 {
+   int ret;
+   u8 buf;
+   bool is_off;
struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
-   struct i2c_msg msg = {  .addr = isl6421->i2c_addr, .flags = 0,
-   .buf = >config,
-   .len = sizeof(isl6421->config) };
+   struct i2c_msg msg[2] = {
+   {
+ .addr = isl6421->i2c_addr,
+ .flags = 0,
+ .buf = >config,
+ .len = 1,
+   }, {
+ .addr = isl6421->i2c_addr,
+ .flags = I2C_M_RD,
+ .buf = ,
+ .len = 1,
+   }
+
+   };
 
isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
 
switch(voltage) {
case SEC_VOLTAGE_OFF:
+   is_off = true;
break;
case SEC_VOLTAGE_13:
+   is_off = false;
isl6421->config |= ISL6421_EN1;
break;
case SEC_VOLTAGE_18:
+   is_off = false;
isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
break;
default:
return -EINVAL;
}
 
+   /*
+* If LNBf were not powered on, disable dynamic current limit, as,
+* according with datasheet, highly capacitive load on the output may
+* cause a difficult start-up.
+*/
+   if (isl6421->is_off && !is_off)
+   isl6421->config |= ISL6421_DCL;
+
isl6421->config |= isl6421->override_or;
isl6421->config &= isl6421->override_and;
 
-   return (i2c_transfer(isl6421->i2c, , 1) == 1) ? 0 : -EIO;
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+
+   /* Store off status now incase future commands fail */
+   isl6421->is_off = is_off;
+
+   /* On overflow, the device will try again after 900 ms (typically) */
+   if (!(isl6421->config & ISL6421_DCL) && (buf & ISL6421_OLF1))
+   msleep(1000);
+
+   /* Re-enable dynamic current limit after a certain amount of time */
+   if ((isl6421->config & ISL6421_DCL) &&
+   !(isl6421->override_or & ISL6421_DCL)) {
+   msleep(200);
+   isl6421->config &= ~ISL6421_DCL;
+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+   }
+
+   /* Check if overload flag is active. If so, disable power */
+   if (!is_off && (buf & ISL6421_OLF1)) {
+   isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
+   ret = i2c_transfer(isl6421->i2c, msg, 1);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;
+   isl6421->is_off = true;
+
+   dev_warn(>i2c->dev,
+"Overload current detected. disabling LNBf power\n");
+   return -EINVAL;
+   }
+
+   return 0;
 }
 
 static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
@@ -148,6 +215,8 @@ struct dvb_frontend *isl6421_attach(struct dvb_fronten

Re: [PATCH v2] media: isl6421: add checks for current overflow

2017-08-15 Thread Jemma Denson

Hi Mauro,

On 13/08/17 20:35, Mauro Carvalho Chehab wrote:


This Kaffeine's BZ:
https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different 
approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking 
an
special flag.

Add support for it.

Compile-tested only.

Signed-off-by: Mauro Carvalho Chehab 
---
  drivers/media/dvb-frontends/isl6421.c | 72 +--
  1 file changed, 68 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/isl6421.c 
b/drivers/media/dvb-frontends/isl6421.c
index 838b42771a05..b04d56ad4ce8 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -38,25 +38,43 @@ struct isl6421 {
u8  override_and;
struct i2c_adapter  *i2c;
u8  i2c_addr;
+   boolis_off;
  };
  
  static int isl6421_set_voltage(struct dvb_frontend *fe,

   enum fe_sec_voltage voltage)
  {
+   int ret;
+   u8 buf;
+   bool is_off;
struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
-   struct i2c_msg msg = {  .addr = isl6421->i2c_addr, .flags = 0,
-   .buf = >config,
-   .len = sizeof(isl6421->config) };
+   struct i2c_msg msg[2] = {
+   {
+ .addr = isl6421->i2c_addr,
+ .flags = 0,
+ .buf = >config,
+ .len = 1,
+   }, {
+ .addr = isl6421->i2c_addr,
+ .flags = I2C_M_RD,
+ .buf = ,
+ .len = 1,
+   }
+
+   };
  
  	isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
  
  	switch(voltage) {

case SEC_VOLTAGE_OFF:
+   is_off = true;
break;
case SEC_VOLTAGE_13:
+   is_off = false;
isl6421->config |= ISL6421_EN1;
break;
case SEC_VOLTAGE_18:
+   is_off = false;
isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
break;
default:
@@ -66,7 +84,51 @@ static int isl6421_set_voltage(struct dvb_frontend *fe,
isl6421->config |= isl6421->override_or;
isl6421->config &= isl6421->override_and;
  
-	return (i2c_transfer(isl6421->i2c, , 1) == 1) ? 0 : -EIO;

+   /*
+* If LNBf were not powered on, disable dynamic current limit, as,
+* according with datasheet, highly capacitive load on the output may
+* cause a difficult start-up.
+*/
+   if (isl6421->is_off && !is_off)
+   isl6421->config |= ISL6421_EN1;


Checking the datasheet I think we need to be setting DCL high instead. EN1 is
already set anyway.


+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+
+   isl6421->is_off = is_off;


Is this in the right place?


+
+   /* On overflow, the device will try again after 900 ms (typically) */
+   if (isl6421->is_off && (buf & ISL6421_OLF1))
+   msleep(1000);


1000ms does only cover one cycle of OFF then ON - the device will keep cycling
900ms off then 20ms on until overflow is cleared so it might take longer but
adding the code to support longer is  probably not worth it. Waiting one cycle
is better than the current none anyway.


+
+   if (isl6421->is_off && !is_off) {
+   isl6421->config &= ~ISL6421_EN1;
+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 2)
+   return -EIO;
+   }


Does this if statement ever match? isl6421->is_off and is_off are the same value
at this point. I presume this is supposed to be re-enabling DCL so would again
also need that bit instead of EN1. We might also need a little delay before
turning it on - the datasheet mentions a "chosen amount of time". I've no idea
what's appropriate here, 200ms?

A simpler if statement might be just (isl6421->config & ISL6421_DCL), we just
need to check DCL was set high above.


+
+   /* Check if overload flag is active. If so, disable power */
+   if (buf & ISL6421_OLF1) {
+   isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
+   ret = i2c_transfer(isl6421->i2c, msg, 1);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;
+   

Re: [PATCH RFC] media: isl6421: add checks for current overflow

2017-08-13 Thread Jemma Denson

Hi Mauro,

Just tried this on my card - unfortunately the patch as is doesn't work.

On 13/08/17 13:10, Mauro Carvalho Chehab wrote:

This Kaffeine's BZ:
https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different 
approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking 
an
special flag.

Add support for it.

Compile-tested only.

Signed-off-by: Mauro Carvalho Chehab 
---
  drivers/media/dvb-frontends/isl6421.c | 72 +--
  1 file changed, 68 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/isl6421.c 
b/drivers/media/dvb-frontends/isl6421.c
index 838b42771a05..47a7e559cef2 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -38,25 +38,43 @@ struct isl6421 {
u8  override_and;
struct i2c_adapter  *i2c;
u8  i2c_addr;
+   boolis_off;
  };
  
  static int isl6421_set_voltage(struct dvb_frontend *fe,

   enum fe_sec_voltage voltage)
  {
+   int ret;
+   u8 buf;
+   bool is_off;
struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
-   struct i2c_msg msg = {  .addr = isl6421->i2c_addr, .flags = 0,
-   .buf = >config,
-   .len = sizeof(isl6421->config) };
+   struct i2c_msg msg[2] = {
+   {
+ .addr = isl6421->i2c_addr,
+ .flags = 0,
+ .buf = >config,
+ .len = 1,
+   }, {
+ .addr = isl6421->i2c_addr,
+ .flags = I2C_M_RD,
+ .buf = ,
+ .len = 1,
+   }
+
+   };
  
  	isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
  
  	switch(voltage) {

case SEC_VOLTAGE_OFF:
+   is_off = true;
break;
case SEC_VOLTAGE_13:
+   is_off = false;
isl6421->config |= ISL6421_EN1;
break;
case SEC_VOLTAGE_18:
+   is_off = false;
isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
break;
default:
@@ -66,7 +84,51 @@ static int isl6421_set_voltage(struct dvb_frontend *fe,
isl6421->config |= isl6421->override_or;
isl6421->config &= isl6421->override_and;
  
-	return (i2c_transfer(isl6421->i2c, , 1) == 1) ? 0 : -EIO;

+   /*
+* If LNBf were not powered on, disable dynamic current limit, as,
+* according with datasheet, highly capacitive load on the output may
+* cause a difficult start-up.
+*/
+   if (isl6421->is_off && !is_off)
+   isl6421->config |= ISL6421_EN1;
+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;


This needs to check ret != 2


+
+   isl6421->is_off = is_off;
+
+   /* On overflow, the device will try again after 900 ms (typically) */
+   if (isl6421->is_off && (buf & ISL6421_OLF1))
+   msleep(1000);
+
+   if (isl6421->is_off && !is_off) {
+   isl6421->config &= ~ISL6421_EN1;
+
+   ret = i2c_transfer(isl6421->i2c, msg, 2);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;
+   }


Same again


+
+   /* Check if overload flag is active. If so, disable power */
+   if (buf & ISL6421_OLF1) {
+   isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
+   ret = i2c_transfer(isl6421->i2c, msg, 1);
+   if (ret < 0)
+   return ret;
+   if (ret != 1)
+   return -EIO;
+   isl6421->is_off = true;
+
+   dev_warn(>i2c->dev,
+"Overload current detected. disabling LNBf power\n");
+   return -EINVAL;
+   }
+   return 0;
  }
  
  static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)

@@ -148,6 +210,8 @@ struct dvb_frontend *isl6421_attach(struct dvb_frontend 
*fe, struct i2c_adapter
return NULL;
}
  
+	isl6421->is_off = true;

+
/* install release callback */
fe->ops.release_sec = isl6421_release;
  



Once I changed these it worked fine - I can still tune in with this 
patch even switching from H to V. I've no idea if this fixes the bug 
logged in kaffeine though as I haven't seen it.



Jemma.



Re: [PATCH] [media] cx24120: do not allow an invalid delivery system types

2016-09-05 Thread Jemma Denson

On 03/09/16 18:04, Colin King wrote:

From: Colin Ian King <colin.k...@canonical.com>

cx24120_set_frontend currently allows invalid delivery system types
other than SYS_DVBS2 and SYS_DVBS.  Fix this by returning -EINVAL
for invalid values.

Signed-off-by: Colin Ian King <colin.k...@canonical.com>
---
  drivers/media/dvb-frontends/cx24120.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)


Yes, that's needed, thanks!

Acked-by: Jemma Denson <jden...@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: EIT off-air tables for HD in UK

2016-06-15 Thread Jemma Denson

On 14/06/16 19:31, Nick Whitehead wrote:
I've just started to use this to recover EIT information from the 
transmitted stream (UK, freeview).


I've managed to get the tables OK, but the EIT name / description for 
all HD channels is scrambled. Some research indicates these are 
huffman encoded for an unclear reason.


Given the right tables, it should be possible therefore to decode them 
when they appear in the linked list of descriptors in each event. 
However, it appears that dvb_parse_string() called all the way down 
from dvb_read_sections() converts the character sets name / 
description strings so that they can no longer be decoded. If huffman 
encoded, I think the first character of each is a 0x1f, followed by a 
0x01 or 0x02 which probably indicates the table to use.


It seems to me therefore that the 0x1f needs to be picked up in the 
switch (*src) {} at line 395 in parse_string.c, and huffman decode 
done there. After the return from dvb_parse_string(), and certainly 
when they appear in the EIT table, it's too late.


I am not sure if I'm right about all this as I know very little about 
DVB. However it looks like that to me. Have I got this right or is 
already successfully handled somewhere I haven't realised?





FYI mythtv decodes the EIT successfully so is probably a good place to 
start looking. The original patch to add it in is here: 
https://svn.mythtv.org/trac/attachment/ticket/5365/freesat_epg.diff

AFAIK Freeview HD is done the same way as Freesat.

Jemma.


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Driver Technisat Skystar S2 and Compro VideoMate S350

2016-03-10 Thread Jemma Denson

Hi Neil,

Sorry, I can't help with the Compro, but maybe with the Technisat :)


On 10/03/16 13:53, Neil Cordwell wrote:

Technisat Skystar S2

When I first installed this card I couldn't find the firmware
dvb-fe-cx24120-1.20.58.2.fw. Downloaded this from github and now there are
no errors in dmesg, but I cannot get the card to tune in MythTV. I wondered
if the  in the output of lspci is anything?

3:05.0 Multimedia controller [0480]: Philips Semiconductors
SAA7131/SAA7133/SAA7135 Video Broadcast Decoder [1131:7133] (rev d1)
 Subsystem: Compro Technology, Inc. VideoMate T750 [185b:c900]
 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR+ FastB2B- DisINTx-
 Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort-
SERR- 
 Kernel driver in use: saa7134


The above is for the Compro and not the Skystar, but  is 
likely to just be that it needs root.





I tried to use dvbv5-scan with a simple channel file and get an error. Scan
does nothing

neil@Sonata-Linux:~/Documents$ dvbv5-scan --input-format=CHANNEL Astra-28.2E
ERROR Doesn't know how to handle delimiter '[CHANNEL]' while parsing line 2
of Astra-28.2E


[CHANNEL]
 DELIVERY_SYSTEM = DVBS2
 FREQUENCY = 11719500
 POLARIZATION = HORIZONTAL
 SYMBOL_RATE = 2950
 INNER_FEC = 3/4
 MODULATION = QPSK
 INVERSION = AUTO


A few problems here - that's dvbv5 format and not channel so best to 
just skip the input-format, also 11719500 doesn't exist on 28.2E 
anymore, you probably want to be running this as root, and you should be 
specifying the lnb type.


This is how I ran it on mine quite recently whilst fixing a bug in the 
driver (you might need to change the adapter number on -a):

# dvbv5-scan -a 0 -l EXTENDED /usr/share/dvbv5/dvb-s/Astra-28.2E

That bug was patched only a few weeks ago so the above will probably 
fail on some of the transponders. MythTV wasn't affected though so that 
should scan fine, aslong as all the other things with myth are setup ok 
- it's quite fiddly!



Jemma.


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v4l-utils PATCH 1/1] dvbv5-zap.c: fix setting signal handlers

2015-12-18 Thread Jemma Denson
Signal handlers are currently out of order - SIGALRM is always set, and
SIGINT only set when timeout is set. These should be the other way round.

Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index e19d7c2..e927383 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -959,10 +959,10 @@ int main(int argc, char **argv)
goto err;
}
 
-   signal(SIGALRM, do_timeout);
signal(SIGTERM, do_timeout);
+   signal(SIGINT, do_timeout);
if (args.timeout > 0) {
-   signal(SIGINT, do_timeout);
+   signal(SIGALRM, do_timeout);
alarm(args.timeout);
}
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v4l-utils PATCH-v2 1/4] dvbv5-zap.c: fix setting signal handlers

2015-12-18 Thread Jemma Denson
Signal handlers are currently out of order - SIGALRM is always set, and
SIGINT only set when timeout is set. These should be the other way round.

Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index e19d7c2..e927383 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -959,10 +959,10 @@ int main(int argc, char **argv)
goto err;
}
 
-   signal(SIGALRM, do_timeout);
signal(SIGTERM, do_timeout);
+   signal(SIGINT, do_timeout);
if (args.timeout > 0) {
-   signal(SIGINT, do_timeout);
+   signal(SIGALRM, do_timeout);
alarm(args.timeout);
}
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v4l-utils PATCH-v2 2/4] dvbv5-zap.c: allow timeout with -x

2015-12-18 Thread Jemma Denson
Timeout handlers aren't set when running with -x (exit after tuning).
This patch adds handlers so -t can be used with -x.

Without a timeout dvbv5-zap will run forever if there's no signal,
preventing it's use by scripts to obtain signal stats.

Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index e927383..2d19d45 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -855,6 +855,13 @@ int main(int argc, char **argv)
goto err;
 
if (args.exit_after_tuning) {
+   signal(SIGTERM, do_timeout);
+   signal(SIGINT, do_timeout);
+   if (args.timeout > 0) {
+   signal(SIGALRM, do_timeout);
+   alarm(args.timeout);
+   }
+
err = 0;
check_frontend(, parms);
goto err;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v4l-utils PATCH-v2 4/4] dvbv5-zap.c: Move common signals code into function

2015-12-18 Thread Jemma Denson
Code repeated 3 times; move to common function.

Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 33 +
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 2d71307..ef17be9 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -737,6 +737,16 @@ int do_traffic_monitor(struct arguments *args,
return 0;
 }
 
+static void set_signals(struct arguments *args)
+{
+   signal(SIGTERM, do_timeout);
+   signal(SIGINT, do_timeout);
+   if (args->timeout > 0) {
+   signal(SIGALRM, do_timeout);
+   alarm(args->timeout);
+   }
+}
+
 int main(int argc, char **argv)
 {
struct arguments args;
@@ -855,26 +865,14 @@ int main(int argc, char **argv)
goto err;
 
if (args.exit_after_tuning) {
-   signal(SIGTERM, do_timeout);
-   signal(SIGINT, do_timeout);
-   if (args.timeout > 0) {
-   signal(SIGALRM, do_timeout);
-   alarm(args.timeout);
-   }
-
+   set_signals();
err = 0;
check_frontend(, parms);
goto err;
}
 
if (args.traffic_monitor) {
-   signal(SIGTERM, do_timeout);
-   signal(SIGINT, do_timeout);
-   if (args.timeout > 0) {
-   signal(SIGALRM, do_timeout);
-   alarm(args.timeout);
-   }
-
+   set_signals();
err = do_traffic_monitor(, parms);
goto err;
}
@@ -966,12 +964,7 @@ int main(int argc, char **argv)
goto err;
}
 
-   signal(SIGTERM, do_timeout);
-   signal(SIGINT, do_timeout);
-   if (args.timeout > 0) {
-   signal(SIGALRM, do_timeout);
-   alarm(args.timeout);
-   }
+   set_signals();
 
if (!check_frontend(, parms)) {
err = 1;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Patches to dvbv5-zap

2015-12-18 Thread Jemma Denson
This patch series replaces the single patch sent earlier today. Essentially
it's to allow -t to be used at the same time as -x. We have a requirement
to show signal stats in a web interface and a lack of timeout would cause
issues when there's no signal.

The other patches are fixing bugs I noticed in adding this and then
simplifying the code slightly.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v4l-utils PATCH-v2 3/4] dvbv5-zap.c: fix wrong signal

2015-12-18 Thread Jemma Denson
Signal here should be SIGALRM and not SIGINT in order to call do_timeout().

Signed-off-by: Jemma Denson <jden...@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 2d19d45..2d71307 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -871,7 +871,7 @@ int main(int argc, char **argv)
signal(SIGTERM, do_timeout);
signal(SIGINT, do_timeout);
if (args.timeout > 0) {
-   signal(SIGINT, do_timeout);
+   signal(SIGALRM, do_timeout);
alarm(args.timeout);
}
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: AverMedia HD Duet (White Box) A188WB drivers

2015-12-07 Thread Jemma Denson

Hi Manu,

On 08/10/15 17:28, Manu Abraham wrote:

Hi,

I just got back at work again. Will set things up this weekend/next week.


Have you had a chance to make any more progress on this?

As you're probably aware there are quite a few drivers waiting for 
saa716x to be integrated into the tree; if you need some help here is 
the work remaining to be done something that can be picked up by other 
people?


Regards,

Jemma.



--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] TechniSat SkyStar S2 - problem tuning DVB-S2 channels

2015-11-19 Thread Jemma Denson

Hi Robert,

On 18/11/15 19:08, Robert wrote:

Normally i'm using kaffeine, but i have tried dvbv5-scan now.
Unfortunately it segfaults. I have attached the full output including
the backtrace [1]



I can't help with the segfault I'm afraid, but looking at that log it is 
definitely not managing to lock to any of the DVB-S2 transponders. The 
driver does work fine on S2 for me, but I am only able to test on 28.2E. 
Patrick did some testing on 19.2E so I'm going to cc him into this to 
confirm it does work there on S2.


In the meantime it might be worth checking that it is being tuned with 
the right parameters - I included some dynamic debug output to see what 
it was being asked to do when tuning:


echo 'file cx24120.c func cx24120_set_frontend +pf' > 
/sys/kernel/debug/dynamic_debug/control


This should output something like this in dmesg:

[2995692.044792] cx24120_set_frontend: i2c i2c-9: DVB-S2
[2995692.044799] cx24120_set_frontend: i2c i2c-9: delsys  = 6
[2995692.044802] cx24120_set_frontend: i2c i2c-9: modulation  = 9
[2995692.044805] cx24120_set_frontend: i2c i2c-9: frequency   = 1097000
[2995692.044808] cx24120_set_frontend: i2c i2c-9: pilot   = 0 (val = 
0x40)
[2995692.044811] cx24120_set_frontend: i2c i2c-9: symbol_rate = 2300 
(clkdiv/ratediv = 0x03/0x06)
[2995692.044814] cx24120_set_frontend: i2c i2c-9: FEC = 2 
(mask/val = 0x00/0x0d)
[2995692.044817] cx24120_set_frontend: i2c i2c-9: Inversion   = 2 (val = 
0x0c)


Hopefully from there it should be possible to see if it's being sent the 
correct parameters.


Regards,

Jemma.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] TechniSat SkyStar S2 - problem tuning DVB-S2 channels

2015-11-18 Thread Jemma Denson

Hi Robert,

On 18/11/15 15:03, Robert wrote:

Hello,

I am using a "TechniSat SkyStar S2" DVB-S2 card. Drivers for this card
are included in the kernel tree since 4.2. Unfortunately, i can't tune
to ANY DVB-S2 channels with this new in-tree driver. DVB-S channels are
working fine. Id[1] of the commit which introduced support for this card.

Before 4.2 arrived i have used this[2] patch with which DVB-S2 channels
where tuneable without any problems. This patch works even with 4.3
after i have converted the fe_ structs to enums.

If you need anything to debug this behaviour, i will be at your disposal.




What program are you using to try and tune? Is it trying to tune in 
using DVB-S2? The "other" driver was done quite some while ago, and 
included some clunky code to fallback to S2 if DVB-S tuning failed as it 
was developed before the DVB API had support for supplying DVB-S2 as a 
delivery system and this was the only way of supporting S2 back then.
This was removed in the in-tree driver as it isn't needed anymore, but 
this does mean that the tuning program needs to supply the correct 
delivery system.


Have you tried it with dvbv5-scan & dvbv5-zap?

Regards,

Jemma
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] cx24120: Take control of b2c2 receive stream

2015-06-10 Thread Jemma Denson

Hi Mauro,

On 10/06/15 00:56, Mauro Carvalho Chehab wrote:
Hmm... if patch 1 is enough to fix the issue, and patch 4 may break 
things, I'll apply only patch 1/4 for now. If Patrick agrees, and you 
find a way to avoid breakages, please resubmit for me to apply the 
other ones. Regards, Mauro 


I already posted a v2 of this patch series which does the stream control 
in a much better way - that v2 version has been running on my mythtv 
recording box for a few weeks now without issue.


Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/4] b2c2: Add option to skip the first 6 pid filters

2015-06-01 Thread Jemma Denson

Hi Antti,

On 01/06/15 07:14, Antti Palosaari wrote:

On 05/30/2015 09:10 PM, Jemma Denson wrote:

The flexcop bridge chip has two banks of hardware pid filters -
an initial 6, and on some chip revisions an additional bank of 32.

A bug is present on the initial 6 - when changing transponders
one of two PAT packets from the old transponder would be included
in the initial packets from the new transponder. This usually
transpired with userspace programs complaining about services
missing, because they are seeing a PAT that they would not be
expecting. Running in full TS mode does not exhibit this problem,
neither does using just the additional 32.

This patch adds in an option to not use the inital 6 and solely use
just the additional 32, and enables this option for the SkystarS2
card. Other cards can be added as required if they also have
this bug.


Why not to use strategy where 32 pid filter is used as a priority and 
that buggy 6 pid filter is used only when 32 pid filter is not 
available (or it is already 100% in use)?




Yes, that might work, I hadn't though of just swapping them around - 
thanks. It would however assume that the 0x PAT feed is requested 
early on enough that it always sits within the bank of 32 and nothing 
else is too bothered by the odd out of order packet.


The only concern I have got is if there is any other oddness in the 
first 6 - this card is the only flexcop based card with dvb-s2 and there 
is a lack of stream with high bitrate transponders (approx. 45Mbps), 
which we think might due to the hardware pid filter. The card apparently 
works fine under the windows driver so it's a case of trying to work out 
what that might be doing differently. It's quite speculative at the 
moment but I'm hoping this patch might help with that and I'm waiting 
for some feedback on that - I'm stuck with 28.2E which doesn't hold 
anything interesting.


At the moment it doesn't really matter too much having only 32 filters 
rather than the full 38 - it does switch to full-TS once it runs out of 
hardware filters, and the only issue with full-TS is that the flexcop 
can't pass a TS with more than 45Mbps (but they aren't working at the 
moment anyway)



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/4] b2c2: Add external stream control

2015-05-30 Thread Jemma Denson
Some demods are aware that their stream has stopped, such as whilst
tuning. Allow them to control the flexcop receive and output
streams.

This avoids flexcop_pci_irq_check_work from triggering and resetting
the stream unneccesarily due to a lack of data.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-common.h|  3 +++
 drivers/media/common/b2c2/flexcop-hw-filter.c | 38 ---
 drivers/media/pci/b2c2/flexcop-pci.c  |  5 +++-
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-common.h 
b/drivers/media/common/b2c2/flexcop-common.h
index 184adda..fa606ec 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -91,6 +91,8 @@ struct flexcop_device {
int feedcount;
int pid_filtering;
int fullts_streaming_state;
+   int use_external_stream_control;
+   int external_stream_started;
int skip_6_hw_pid_filter;
 
/* bus specific callbacks */
@@ -178,6 +180,7 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff);
 void flexcop_hw_filter_init(struct flexcop_device *fc);
 void flexcop_stream_reset(struct flexcop_device *fc);
+void flexcop_external_stream_control(struct flexcop_device *fc, int onoff);
 
 void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
 
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index da000ba..8fdeaa2 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -171,6 +171,8 @@ static int flexcop_toggle_fullts_streaming(struct 
flexcop_device *fc, int onoff)
return 0;
 }
 
+static void flexcop_stream_control(struct flexcop_device *fc, int onoff);
+
 int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff)
 {
@@ -206,15 +208,9 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
 
/* if it was the first or last feed request change the stream-status */
if (fc-feedcount == onoff) {
-   flexcop_rcv_data_ctrl(fc, onoff);
-   if (fc-stream_control) /* device specific stream control */
-   fc-stream_control(fc, onoff);
-
-   /* feeding stopped - reset the flexcop filter*/
-   if (onoff == 0) {
-   flexcop_reset_block_300(fc);
-   flexcop_hw_filter_init(fc);
-   }
+   if (!fc-use_external_stream_control ||
+   fc-external_stream_started)
+   flexcop_stream_control(fc, onoff);
}
return 0;
 }
@@ -257,3 +253,27 @@ void flexcop_stream_reset(struct flexcop_device *fc)
spin_unlock_irq(fc-demux.lock);
 }
 EXPORT_SYMBOL(flexcop_stream_reset);
+
+void flexcop_stream_control(struct flexcop_device *fc, int onoff)
+{
+   flexcop_rcv_data_ctrl(fc, onoff);
+
+   /* device specific stream control */
+   if (fc-stream_control)
+   fc-stream_control(fc, onoff);
+
+   /* feeding stopped - reset the flexcop filter*/
+   if (onoff == 0) {
+   flexcop_reset_block_300(fc);
+   flexcop_hw_filter_init(fc);
+   }
+}
+
+void flexcop_external_stream_control(struct flexcop_device *fc, int onoff)
+{
+   fc-external_stream_started = onoff;
+
+   /* only change stream if feed already requested */
+   if (fc-feedcount)
+   flexcop_stream_control(fc, onoff);
+}
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c 
b/drivers/media/pci/b2c2/flexcop-pci.c
index eb3b31f..cd49790 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -62,6 +62,7 @@ struct flexcop_pci {
int count;
int count_prev;
int stream_problem;
+   int stream_started;
 
spinlock_t irq_lock;
unsigned long last_irq;
@@ -107,7 +108,7 @@ static void flexcop_pci_irq_check_work(struct work_struct 
*work)
container_of(work, struct flexcop_pci, irq_check_work.work);
struct flexcop_device *fc = fc_pci-fc_dev;
 
-   if (fc-feedcount) {
+   if (fc_pci-stream_started) {
 
if (fc_pci-count == fc_pci-count_prev) {
deb_chk(no IRQ since the last check\n);
@@ -232,6 +233,7 @@ static int flexcop_pci_stream_control(struct flexcop_device 
*fc, int onoff)
flexcop_dma_control_timer_irq(fc, FC_DMA_1, 1);
deb_irq(IRQ enabled\n);
fc_pci-count_prev = fc_pci-count;
+   fc_pci-stream_started = 1;
} else {
flexcop_dma_control_timer_irq(fc, FC_DMA_1, 0);
deb_irq(IRQ disabled\n);
@@ -239,6 +241,7 @@ static int flexcop_pci_stream_control(struct flexcop_device 
*fc, int onoff

[PATCH v2 0/4] SkystarS2 pid filtering fix and stream control

2015-05-30 Thread Jemma Denson
This patch series finishes off the addition of the SkyStarS2 card -
the patches here aren't strictly required for running the card so
haven't previously been included.

The first patch fixes a bug present in the current flexcop driver -
I've seen it with this card, and it has also been noticed in some
other cards. Those cards will need identifying and patches created to
use this fix as it is not enabled by default.

The other three patches add in a feature that was half complete in the
original binary blob for this card, and allows the demod chip to
control the streams on the b2c2 when it turns off it's output during
tuning. This helps to avoid a situation where the hardware filter is
constantly reset by a software watchdog in flexcop-pci because it
can't see any data coming in.

Changes since v1:
* Move the stream reset code from flexcop_pci to flexcop_hw_filter so
  the fact it might interfere with hw_filter code isn't missed.
* Control both streams - so output stream aswell as receive.
* Track the external stream state so we don't leave the stream turned
  off in a reset.
* Don't let the external control start the stream until a feed is
  actually requested.

Jemma Denson (4):
  b2c2: Add option to skip the first 6 pid filters
  b2c2: Move stream reset code from flexcop-pci to flexcop
  b2c2: Add external stream control
  cx24120: Take control of b2c2 streams

 drivers/media/common/b2c2/flexcop-common.h|  5 ++
 drivers/media/common/b2c2/flexcop-fe-tuner.c  | 13 +
 drivers/media/common/b2c2/flexcop-hw-filter.c | 71 ++-
 drivers/media/dvb-frontends/cx24120.c | 29 +++
 drivers/media/dvb-frontends/cx24120.h |  1 +
 drivers/media/pci/b2c2/flexcop-pci.c  | 19 ++-
 6 files changed, 103 insertions(+), 35 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/4] cx24120: Take control of b2c2 streams

2015-05-30 Thread Jemma Denson
Now that b2c2 has an option to allow us to do so, turn off the
flexcop streams when we turn off mpeg output whilst tuning.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-fe-tuner.c | 10 ++
 drivers/media/dvb-frontends/cx24120.c| 29 +++-
 drivers/media/dvb-frontends/cx24120.h|  1 +
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 31ebf1e..706ff26 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -625,11 +625,20 @@ fail:
 
 /* SkyStar S2 PCI DVB-S/S2 card based on Conexant cx24120/cx24118 */
 #if FE_SUPPORTED(CX24120)  FE_SUPPORTED(ISL6421)
+static int skystarS2_rev33_stream_control(struct dvb_frontend *fe, int onoff)
+{
+   struct flexcop_device *fc = fe-dvb-priv;
+
+   flexcop_external_stream_control(fc, onoff);
+   return 0;
+}
+
 static const struct cx24120_config skystar2_rev3_3_cx24120_config = {
.i2c_addr = 0x55,
.xtal_khz = 10111,
.initial_mpeg_config = { 0xa1, 0x76, 0x07 },
.request_firmware = flexcop_fe_request_firmware,
+   .stream_control = skystarS2_rev33_stream_control,
.i2c_wr_max = 4,
 };
 
@@ -651,6 +660,7 @@ static int skystarS2_rev33_attach(struct flexcop_device *fc,
}
info(ISL6421 successfully attached.);
 
+   fc-use_external_stream_control = 1;
if (fc-has_32_hw_pid_filter)
fc-skip_6_hw_pid_filter = 1;
 
diff --git a/drivers/media/dvb-frontends/cx24120.c 
b/drivers/media/dvb-frontends/cx24120.c
index a14d0f1..d625c1c 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -371,6 +371,8 @@ static void cx24120_check_cmd(struct cx24120_state *state, 
u8 id)
case CMD_DISEQC_BURST:
cx24120_msg_mpeg_output_global_config(state, 0);
/* Old driver would do a msleep(100) here */
+   state-config-stream_control(state-frontend, 0);
+   state-mpeg_enabled = 0;
default:
return;
}
@@ -382,10 +384,9 @@ static int cx24120_message_send(struct cx24120_state 
*state,
 {
int ficus;
 
-   if (state-mpeg_enabled) {
-   /* Disable mpeg out on certain commands */
+   /* If controlling stream, turn if off whilst tuning */
+   if (state-config-stream_control  state-mpeg_enabled)
cx24120_check_cmd(state, cmd-id);
-   }
 
cx24120_writereg(state, CX24120_REG_CMD_START, cmd-id);
cx24120_writeregs(state, CX24120_REG_CMD_ARGS, cmd-arg[0],
@@ -464,7 +465,6 @@ static int cx24120_msg_mpeg_output_global_config(struct 
cx24120_state *state,
return ret;
}
 
-   state-mpeg_enabled = enable;
dev_dbg(state-i2c-dev, MPEG output %s\n,
enable ? enabled : disabled);
 
@@ -743,11 +743,13 @@ static int cx24120_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
/* Set clock ratios */
cx24120_set_clock_ratios(fe);
 
-   /* Old driver would do a msleep(200) here */
-
/* Renable mpeg output */
-   if (!state-mpeg_enabled)
+   if (state-config-stream_control  !state-mpeg_enabled) {
+   /* Old driver would do a msleep(200) here */
cx24120_msg_mpeg_output_global_config(state, 1);
+   state-config-stream_control(fe, 1);
+   state-mpeg_enabled = 1;
+   }
 
state-need_clock_set = 0;
}
@@ -1418,8 +1420,17 @@ static int cx24120_init(struct dvb_frontend *fe)
 
/* Initialise mpeg outputs */
cx24120_writereg(state, 0xeb, 0x0a);
-   if (cx24120_msg_mpeg_output_global_config(state, 0) ||
-   cx24120_msg_mpeg_output_config(state, 0) ||
+
+   /* Enable global output now if we're not doing stream control */
+   if (!state-config-stream_control)
+   ret = cx24120_msg_mpeg_output_global_config(state, 1);
+   else
+   ret = cx24120_msg_mpeg_output_global_config(state, 0);
+
+   if (ret != 0)
+   return ret;
+
+   if (cx24120_msg_mpeg_output_config(state, 0) ||
cx24120_msg_mpeg_output_config(state, 1) ||
cx24120_msg_mpeg_output_config(state, 2)) {
err(Error initialising mpeg output. :(\n);
diff --git a/drivers/media/dvb-frontends/cx24120.h 
b/drivers/media/dvb-frontends/cx24120.h
index f097042..313518c 100644
--- a/drivers/media/dvb-frontends/cx24120.h
+++ b/drivers/media/dvb-frontends/cx24120.h
@@ -37,6 +37,7 @@ struct cx24120_config {
 
int (*request_firmware)(struct dvb_frontend *fe,
const struct firmware **fw, char *name);
+   int (*stream_control)(struct dvb_frontend

[PATCH v2 2/4] b2c2: Move stream reset code from flexcop-pci to flexcop

2015-05-30 Thread Jemma Denson
As this bit of code is resetting the flexcop stream and the hardware
filter a better place for it is in flexcop-hw-filter.c

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-common.h|  1 +
 drivers/media/common/b2c2/flexcop-hw-filter.c | 17 -
 drivers/media/pci/b2c2/flexcop-pci.c  | 14 +-
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-common.h 
b/drivers/media/common/b2c2/flexcop-common.h
index 2b2460e..184adda 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -177,6 +177,7 @@ void flexcop_dump_reg(struct flexcop_device *fc,
 int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff);
 void flexcop_hw_filter_init(struct flexcop_device *fc);
+void flexcop_stream_reset(struct flexcop_device *fc);
 
 void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
 
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index 8220257..da000ba 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -218,7 +218,6 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
}
return 0;
 }
-EXPORT_SYMBOL(flexcop_pid_feed_control);
 
 void flexcop_hw_filter_init(struct flexcop_device *fc)
 {
@@ -242,3 +241,19 @@ void flexcop_hw_filter_init(struct flexcop_device *fc)
 
flexcop_null_filter_ctrl(fc, 1);
 }
+
+void flexcop_stream_reset(struct flexcop_device *fc)
+{
+   struct dvb_demux_feed *feed;
+
+   spin_lock_irq(fc-demux.lock);
+   list_for_each_entry(feed, fc-demux.feed_list, list_head) {
+   flexcop_pid_feed_control(fc, feed, 0);
+   }
+
+   list_for_each_entry(feed, fc-demux.feed_list, list_head) {
+   flexcop_pid_feed_control(fc, feed, 1);
+   }
+   spin_unlock_irq(fc-demux.lock);
+}
+EXPORT_SYMBOL(flexcop_stream_reset);
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c 
b/drivers/media/pci/b2c2/flexcop-pci.c
index 8b5e0b3..eb3b31f 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -112,21 +112,9 @@ static void flexcop_pci_irq_check_work(struct work_struct 
*work)
if (fc_pci-count == fc_pci-count_prev) {
deb_chk(no IRQ since the last check\n);
if (fc_pci-stream_problem++ == 3) {
-   struct dvb_demux_feed *feed;
deb_info(flexcop-pci: stream problem, 
resetting pid filter\n);
 
-   spin_lock_irq(fc-demux.lock);
-   list_for_each_entry(feed, fc-demux.feed_list,
-   list_head) {
-   flexcop_pid_feed_control(fc, feed, 0);
-   }
-
-   list_for_each_entry(feed, fc-demux.feed_list,
-   list_head) {
-   flexcop_pid_feed_control(fc, feed, 1);
-   }
-   spin_unlock_irq(fc-demux.lock);
-
+   flexcop_stream_reset(fc);
fc_pci-stream_problem = 0;
}
} else {
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/4] b2c2: Add option to skip the first 6 pid filters

2015-05-30 Thread Jemma Denson
The flexcop bridge chip has two banks of hardware pid filters -
an initial 6, and on some chip revisions an additional bank of 32.

A bug is present on the initial 6 - when changing transponders
one of two PAT packets from the old transponder would be included
in the initial packets from the new transponder. This usually
transpired with userspace programs complaining about services
missing, because they are seeing a PAT that they would not be
expecting. Running in full TS mode does not exhibit this problem,
neither does using just the additional 32.

This patch adds in an option to not use the inital 6 and solely use
just the additional 32, and enables this option for the SkystarS2
card. Other cards can be added as required if they also have
this bug.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-common.h|  1 +
 drivers/media/common/b2c2/flexcop-fe-tuner.c  |  3 +++
 drivers/media/common/b2c2/flexcop-hw-filter.c | 16 ++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-common.h 
b/drivers/media/common/b2c2/flexcop-common.h
index 437912e..2b2460e 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -91,6 +91,7 @@ struct flexcop_device {
int feedcount;
int pid_filtering;
int fullts_streaming_state;
+   int skip_6_hw_pid_filter;
 
/* bus specific callbacks */
flexcop_ibi_value(*read_ibi_reg) (struct flexcop_device *,
diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 2426062..31ebf1e 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -651,6 +651,9 @@ static int skystarS2_rev33_attach(struct flexcop_device *fc,
}
info(ISL6421 successfully attached.);
 
+   if (fc-has_32_hw_pid_filter)
+   fc-skip_6_hw_pid_filter = 1;
+
return 1;
 }
 #else
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index 77e4547..8220257 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -117,6 +117,10 @@ static void flexcop_pid_control(struct flexcop_device *fc,
deb_ts(setting pid: %5d %04x at index %d '%s'\n,
pid, pid, index, onoff ? on : off);
 
+   /* First 6 can be buggy - skip over them if option set */
+   if (fc-skip_6_hw_pid_filter)
+   index += 6;
+
/* We could use bit magic here to reduce source code size.
 * I decided against it, but to use the real register names */
switch (index) {
@@ -170,7 +174,10 @@ static int flexcop_toggle_fullts_streaming(struct 
flexcop_device *fc, int onoff)
 int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff)
 {
-   int max_pid_filter = 6 + fc-has_32_hw_pid_filter*32;
+   int max_pid_filter = 6;
+
+   max_pid_filter -= 6 * fc-skip_6_hw_pid_filter;
+   max_pid_filter += 32 * fc-has_32_hw_pid_filter;
 
fc-feedcount += onoff ? 1 : -1; /* the number of PIDs/Feed currently 
requested */
if (dvbdmxfeed-index = max_pid_filter)
@@ -217,7 +224,12 @@ void flexcop_hw_filter_init(struct flexcop_device *fc)
 {
int i;
flexcop_ibi_value v;
-   for (i = 0; i  6 + 32*fc-has_32_hw_pid_filter; i++)
+   int max_pid_filter = 6;
+
+   max_pid_filter -= 6 * fc-skip_6_hw_pid_filter;
+   max_pid_filter += 32 * fc-has_32_hw_pid_filter;
+
+   for (i = 0; i  max_pid_filter; i++)
flexcop_pid_control(fc, i, 0x1fff, 0);
 
flexcop_pid_group_filter(fc, 0, 0x1fe0);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] cx24120: Take control of b2c2 receive stream

2015-05-26 Thread Jemma Denson

Hi Patrick,

On 26/05/15 10:05, Patrick Boettcher wrote:

Now that b2c2 has an option to allow us to do so, turn off the
flexcop receive stream when we turn off mpeg output whilst tuning.

Does this not fix (and your '[PATCH 2/4]') the problem of receiving
PAT from the previously tuned transport-stream?

Then patch 1 and 4 should not be necessary, should they?!


Only patch 1 fixes that problem, so out of the 4 here that one is the 
most necessary. Controlling the flexcop receive stream and/or stopping 
the cx24120 from sending doesn't actually appear to do much of anything 
- it doesn't seem any better or worse doing one or the other, both or 
even neither! (Apart from Patch 4 breaking things, as mentioned).


I'm including it though because I presume the reference driver advised 
it was done, and it does tidy up the cx24120 codebase considerably by 
being able to disable the whole turn off sending the stream whilst 
tuning feature - I'm envisioning that in the future someone might want 
to take on the task of merging cx24117  cx24120 as they're quite 
similar, and allowing what seems to just be a flexcop oddity to be 
turned off would make this possible.



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DVB-T2 PCIe vs DVB-S2

2015-05-26 Thread Jemma Denson

On 26/05/15 08:53, Ian Campbell wrote:

Hello,

I'm looking to get a DVB-T2 tuner card to add UK Freeview HD to my
mythtv box.

Looking at http://linuxtv.org/wiki/index.php/DVB-T2_PCIe_Cards is seems
that many (the majority even) of the cards there are actually DVB-S2.

Is this a mistake or is there something I don't know (like maybe S2 is
compatible with T2)?

Thanks,
Ian.


That's a mistake - I don't recall that table looking like that when I 
was looking for one, and S2 is quite definitely not compatible with T2!


I can confirm that the 290e works out of the box with myth with very few 
problems, however it's well out of production now and you might not be 
after a USB device. I'm not sure anything else would work without some 
hacking because last I heard myth doesn't do T2 the proper way using 
DVBv5 yet, and afaik only the 290e driver has a fudge to allow T2 on v3.
(http://lists.mythtv.org/pipermail/mythtv-users/2014-November/374441.html and 
https://code.mythtv.org/trac/ticket/12342)



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] b2c2: Always turn off receive stream

2015-05-24 Thread Jemma Denson

On 22/05/15 21:28, Jemma Denson wrote:

When letting an external device control the receive stream, it won't
know when there's demand for any feeds, so won't be turning off our
receive stream. This patch bring back control of turning it off in
this sitation.

The demod can still delay turning it on until it has data to send,
and still turn it off temporarily whilst it knows there's no
stream, such as whilst tuning.

Signed-off-by: Jemma Denson jden...@gmail.com
---
  drivers/media/common/b2c2/flexcop-hw-filter.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index eceb9c5..8926c82 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -206,7 +206,7 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
  
  	/* if it was the first or last feed request change the stream-status */

if (fc-feedcount == onoff) {
-   if (!fc-external_stream_control)
+   if (!fc-external_stream_control || onoff == 0)
flexcop_rcv_data_ctrl(fc, onoff);
  
  		if (fc-stream_control) /* device specific stream control */


Hmm, OK. I've done some further testing and this last patch needs either 
ignoring or a rethink. It interferes with flexcop_pci_irq_check_work() 
in pci/b2c2/flexcop-pci.c. That function will try and reset all the hw 
filters with calls to flexcop_pid_feed_control() by turning them all off 
and then back on again.
Including this patch causes the receive stream to be turned off and it 
then doesn't get enabled again.



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] SkystarS2 pid filtering fix and stream control.

2015-05-22 Thread Jemma Denson
This patch series finishes off the addition of the SkyStarS2 card -
the patches here aren't strictly required for running the card so
haven't previously been included.

The first patch fixes a bug present in the current flexcop driver -
I've seen it with this card, and it has also been noticed in some
other cards. Those cards will need identifying and patches created to
use this fix as it is not enabled by default.

The other three patches add in a feature that was half complete in the
original binary blob for this card, and allows the demod chip to
control the receive stream on the b2c2 when it turns off it's output
during tuning. I'm not sure it actually needs to turn it's output
stream off, and the patches also make it easy to disable this.

Jemma Denson (4):
  b2c2: Add option to skip the first 6 pid filters
  b2c2: Allow external stream control
  cx24120: Take control of b2c2 receive stream
  b2c2: Always turn off receive stream

 drivers/media/common/b2c2/flexcop-common.h|  3 +++
 drivers/media/common/b2c2/flexcop-fe-tuner.c  | 13 
 drivers/media/common/b2c2/flexcop-hw-filter.c | 22 
 drivers/media/dvb-frontends/cx24120.c | 29 ++-
 drivers/media/dvb-frontends/cx24120.h |  1 +
 5 files changed, 55 insertions(+), 13 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] b2c2: Add option to skip the first 6 pid filters

2015-05-22 Thread Jemma Denson
The flexcop bridge chip has two banks of hardware pid filters -
an initial 6, and on some chip revisions an additional bank of 32.

A bug is present on the initial 6 - when changing transponders
one of two PAT packets from the old transponder would be included
in the initial packets from the new transponder. This usually
transpired with userspace programs complaining about services
missing, because they are seeing a PAT that they would not be
expecting. Running in full TS mode does not exhibit this problem,
neither does using just the additional 32.

This patch adds in an option to not use the inital 6 and solely use
just the additional 32, and enables this option for the SkystarS2
card. Other cards can be added as required if they also have
this bug.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-common.h|  1 +
 drivers/media/common/b2c2/flexcop-fe-tuner.c  |  3 +++
 drivers/media/common/b2c2/flexcop-hw-filter.c | 16 ++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-common.h 
b/drivers/media/common/b2c2/flexcop-common.h
index 437912e..2b2460e 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -91,6 +91,7 @@ struct flexcop_device {
int feedcount;
int pid_filtering;
int fullts_streaming_state;
+   int skip_6_hw_pid_filter;
 
/* bus specific callbacks */
flexcop_ibi_value(*read_ibi_reg) (struct flexcop_device *,
diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 2426062..31ebf1e 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -651,6 +651,9 @@ static int skystarS2_rev33_attach(struct flexcop_device *fc,
}
info(ISL6421 successfully attached.);
 
+   if (fc-has_32_hw_pid_filter)
+   fc-skip_6_hw_pid_filter = 1;
+
return 1;
 }
 #else
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index 77e4547..8220257 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -117,6 +117,10 @@ static void flexcop_pid_control(struct flexcop_device *fc,
deb_ts(setting pid: %5d %04x at index %d '%s'\n,
pid, pid, index, onoff ? on : off);
 
+   /* First 6 can be buggy - skip over them if option set */
+   if (fc-skip_6_hw_pid_filter)
+   index += 6;
+
/* We could use bit magic here to reduce source code size.
 * I decided against it, but to use the real register names */
switch (index) {
@@ -170,7 +174,10 @@ static int flexcop_toggle_fullts_streaming(struct 
flexcop_device *fc, int onoff)
 int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff)
 {
-   int max_pid_filter = 6 + fc-has_32_hw_pid_filter*32;
+   int max_pid_filter = 6;
+
+   max_pid_filter -= 6 * fc-skip_6_hw_pid_filter;
+   max_pid_filter += 32 * fc-has_32_hw_pid_filter;
 
fc-feedcount += onoff ? 1 : -1; /* the number of PIDs/Feed currently 
requested */
if (dvbdmxfeed-index = max_pid_filter)
@@ -217,7 +224,12 @@ void flexcop_hw_filter_init(struct flexcop_device *fc)
 {
int i;
flexcop_ibi_value v;
-   for (i = 0; i  6 + 32*fc-has_32_hw_pid_filter; i++)
+   int max_pid_filter = 6;
+
+   max_pid_filter -= 6 * fc-skip_6_hw_pid_filter;
+   max_pid_filter += 32 * fc-has_32_hw_pid_filter;
+
+   for (i = 0; i  max_pid_filter; i++)
flexcop_pid_control(fc, i, 0x1fff, 0);
 
flexcop_pid_group_filter(fc, 0, 0x1fe0);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] b2c2: Allow external stream control

2015-05-22 Thread Jemma Denson
This patch brings in a feature present in the gpl patch portion of
the SkystarS2 driver available for download from Technisat. The
patch is identical save for renaming the configuration variable,
and also directly exposing the flexcop_rcv_data_ctrl() instead of
wrapping it around a separate function.

The feature added is to allow passing control of the flexcop
receive stream to another device, such as the demod chip.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-common.h| 2 ++
 drivers/media/common/b2c2/flexcop-hw-filter.c | 6 --
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-common.h 
b/drivers/media/common/b2c2/flexcop-common.h
index 2b2460e..7075043 100644
--- a/drivers/media/common/b2c2/flexcop-common.h
+++ b/drivers/media/common/b2c2/flexcop-common.h
@@ -91,6 +91,7 @@ struct flexcop_device {
int feedcount;
int pid_filtering;
int fullts_streaming_state;
+   int external_stream_control;
int skip_6_hw_pid_filter;
 
/* bus specific callbacks */
@@ -174,6 +175,7 @@ void flexcop_dump_reg(struct flexcop_device *fc,
flexcop_ibi_register reg, int num);
 
 /* from flexcop-hw-filter.c */
+void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff);
 int flexcop_pid_feed_control(struct flexcop_device *fc,
struct dvb_demux_feed *dvbdmxfeed, int onoff);
 void flexcop_hw_filter_init(struct flexcop_device *fc);
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index 8220257..eceb9c5 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -5,7 +5,7 @@
  */
 #include flexcop.h
 
-static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
+void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
 {
flexcop_set_ibi_value(ctrl_208, Rcv_Data_sig, onoff);
deb_ts(rcv_data is now: '%s'\n, onoff ? on : off);
@@ -206,7 +206,9 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
 
/* if it was the first or last feed request change the stream-status */
if (fc-feedcount == onoff) {
-   flexcop_rcv_data_ctrl(fc, onoff);
+   if (!fc-external_stream_control)
+   flexcop_rcv_data_ctrl(fc, onoff);
+
if (fc-stream_control) /* device specific stream control */
fc-stream_control(fc, onoff);
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] b2c2: Always turn off receive stream

2015-05-22 Thread Jemma Denson
When letting an external device control the receive stream, it won't
know when there's demand for any feeds, so won't be turning off our
receive stream. This patch bring back control of turning it off in
this sitation.

The demod can still delay turning it on until it has data to send,
and still turn it off temporarily whilst it knows there's no
stream, such as whilst tuning.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-hw-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c 
b/drivers/media/common/b2c2/flexcop-hw-filter.c
index eceb9c5..8926c82 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -206,7 +206,7 @@ int flexcop_pid_feed_control(struct flexcop_device *fc,
 
/* if it was the first or last feed request change the stream-status */
if (fc-feedcount == onoff) {
-   if (!fc-external_stream_control)
+   if (!fc-external_stream_control || onoff == 0)
flexcop_rcv_data_ctrl(fc, onoff);
 
if (fc-stream_control) /* device specific stream control */
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] cx24120: Take control of b2c2 receive stream

2015-05-22 Thread Jemma Denson
Now that b2c2 has an option to allow us to do so, turn off the
flexcop receive stream when we turn off mpeg output whilst tuning.

This turning off whilst tuning feature is a bit unusual, and can
now also be easily disabled by leaving stream_control unset in the
config struct.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-fe-tuner.c | 10 ++
 drivers/media/dvb-frontends/cx24120.c| 29 +++-
 drivers/media/dvb-frontends/cx24120.h|  1 +
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 31ebf1e..fdd3a18 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -625,11 +625,20 @@ fail:
 
 /* SkyStar S2 PCI DVB-S/S2 card based on Conexant cx24120/cx24118 */
 #if FE_SUPPORTED(CX24120)  FE_SUPPORTED(ISL6421)
+static int skystarS2_stream_control(struct dvb_frontend *fe, int onoff)
+{
+   struct flexcop_device *fc = fe-dvb-priv;
+
+   flexcop_rcv_data_ctrl(fc, onoff);
+   return 0;
+}
+
 static const struct cx24120_config skystar2_rev3_3_cx24120_config = {
.i2c_addr = 0x55,
.xtal_khz = 10111,
.initial_mpeg_config = { 0xa1, 0x76, 0x07 },
.request_firmware = flexcop_fe_request_firmware,
+   .stream_control = skystarS2_stream_control,
.i2c_wr_max = 4,
 };
 
@@ -651,6 +660,7 @@ static int skystarS2_rev33_attach(struct flexcop_device *fc,
}
info(ISL6421 successfully attached.);
 
+   fc-external_stream_control = 1;
if (fc-has_32_hw_pid_filter)
fc-skip_6_hw_pid_filter = 1;
 
diff --git a/drivers/media/dvb-frontends/cx24120.c 
b/drivers/media/dvb-frontends/cx24120.c
index a14d0f1..d625c1c 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -371,6 +371,8 @@ static void cx24120_check_cmd(struct cx24120_state *state, 
u8 id)
case CMD_DISEQC_BURST:
cx24120_msg_mpeg_output_global_config(state, 0);
/* Old driver would do a msleep(100) here */
+   state-config-stream_control(state-frontend, 0);
+   state-mpeg_enabled = 0;
default:
return;
}
@@ -382,10 +384,9 @@ static int cx24120_message_send(struct cx24120_state 
*state,
 {
int ficus;
 
-   if (state-mpeg_enabled) {
-   /* Disable mpeg out on certain commands */
+   /* If controlling stream, turn if off whilst tuning */
+   if (state-config-stream_control  state-mpeg_enabled)
cx24120_check_cmd(state, cmd-id);
-   }
 
cx24120_writereg(state, CX24120_REG_CMD_START, cmd-id);
cx24120_writeregs(state, CX24120_REG_CMD_ARGS, cmd-arg[0],
@@ -464,7 +465,6 @@ static int cx24120_msg_mpeg_output_global_config(struct 
cx24120_state *state,
return ret;
}
 
-   state-mpeg_enabled = enable;
dev_dbg(state-i2c-dev, MPEG output %s\n,
enable ? enabled : disabled);
 
@@ -743,11 +743,13 @@ static int cx24120_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
/* Set clock ratios */
cx24120_set_clock_ratios(fe);
 
-   /* Old driver would do a msleep(200) here */
-
/* Renable mpeg output */
-   if (!state-mpeg_enabled)
+   if (state-config-stream_control  !state-mpeg_enabled) {
+   /* Old driver would do a msleep(200) here */
cx24120_msg_mpeg_output_global_config(state, 1);
+   state-config-stream_control(fe, 1);
+   state-mpeg_enabled = 1;
+   }
 
state-need_clock_set = 0;
}
@@ -1418,8 +1420,17 @@ static int cx24120_init(struct dvb_frontend *fe)
 
/* Initialise mpeg outputs */
cx24120_writereg(state, 0xeb, 0x0a);
-   if (cx24120_msg_mpeg_output_global_config(state, 0) ||
-   cx24120_msg_mpeg_output_config(state, 0) ||
+
+   /* Enable global output now if we're not doing stream control */
+   if (!state-config-stream_control)
+   ret = cx24120_msg_mpeg_output_global_config(state, 1);
+   else
+   ret = cx24120_msg_mpeg_output_global_config(state, 0);
+
+   if (ret != 0)
+   return ret;
+
+   if (cx24120_msg_mpeg_output_config(state, 0) ||
cx24120_msg_mpeg_output_config(state, 1) ||
cx24120_msg_mpeg_output_config(state, 2)) {
err(Error initialising mpeg output. :(\n);
diff --git a/drivers/media/dvb-frontends/cx24120.h 
b/drivers/media/dvb-frontends/cx24120.h
index f097042..313518c 100644
--- a/drivers/media/dvb-frontends/cx24120.h
+++ b/drivers/media/dvb-frontends/cx24120.h
@@ -37,6 +37,7 @@ struct cx24120_config {
 
int (*request_firmware)(struct dvb_frontend

[PATCH] b2c2: Mismatch in config ifdefs for SkystarS2

2015-05-21 Thread Jemma Denson
Compilation warning issued by kbuild test robot:
 drivers/media/common/b2c2/flexcop-fe-tuner.c:31:12: warning: 
 'flexcop_fe_request_firmware' defined but not used [-Wunused-function]
static int flexcop_fe_request_firmware(struct dvb_frontend *fe,

This patch fixes a mismatch in Kconfig define checks. One had a
check for just CX24120, the other is checking for both CX24120
and ISL6421.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/flexcop-fe-tuner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 2426062..a8d562f 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -27,7 +27,7 @@
 #define FE_SUPPORTED(fe) (defined(CONFIG_DVB_##fe) || \
(defined(CONFIG_DVB_##fe##_MODULE)  defined(MODULE)))
 
-#if FE_SUPPORTED(BCM3510) || FE_SUPPORTED(CX24120)
+#if FE_SUPPORTED(BCM3510) || (FE_SUPPORTED(CX24120)  FE_SUPPORTED(ISL6421))
 static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
const struct firmware **fw, char *name)
 {
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL v3] for 4.2: add support for cx24120/Technisat SkyStar S2

2015-05-20 Thread Jemma Denson

On 20/05/15 09:05, Patrick Boettcher wrote:

Hi Mauro,

This is an updated version (v3) of the pull-request for integrating the
cx24120-driver.

Jemma (and partially me) addressed all strict-conding-style-issues and
fixed several things regarding signal-stats and demod-issues + some code
cleaning in general.

Yesterday night Jemma implemented everything related to the UNC and
BER-stuff. I also integrated your smatch-patches on my branch.

In this mail you'll also find the complete patch, please feel free to
review it.




Mauro, I have realised I might have made a mistake in how UCB is 
calculated - I have a patch for this already, should I just send this 
through to the list on it's own?



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cx24120: Assume ucb registers is a counter

2015-05-20 Thread Jemma Denson
The ucblocks register is probably a counter and not a rate; assume
it is so and change the calculations as required.

Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/dvb-frontends/cx24120.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24120.c 
b/drivers/media/dvb-frontends/cx24120.c
index a14d0f1..10a948e 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -154,7 +154,7 @@ struct cx24120_state {
u32 bitrate;
u32 berw_usecs;
u32 ber_prev;
-   u32 per_prev;
+   u32 ucb_offset;
unsigned long ber_jiffies_stats;
unsigned long per_jiffies_stats;
 };
@@ -698,8 +698,12 @@ static void cx24120_get_stats(struct cx24120_state *state)
ucb |= cx24120_readreg(state, CX24120_REG_UCB_L);
dev_dbg(state-i2c-dev, ucblocks = %d\n, ucb);
 
+   /* handle reset */
+   if (ucb  state-ucb_offset)
+   state-ucb_offset = c-block_error.stat[0].uvalue;
+
c-block_error.stat[0].scale = FE_SCALE_COUNTER;
-   c-block_error.stat[0].uvalue += ucb;
+   c-block_error.stat[0].uvalue = ucb + state-ucb_offset;
 
c-block_count.stat[0].scale = FE_SCALE_COUNTER;
c-block_count.stat[0].uvalue += state-bitrate / 8 / 208;
@@ -1541,8 +1545,7 @@ static int cx24120_read_ucblocks(struct dvb_frontend *fe, 
u32 *ucblocks)
return 0;
}
 
-   *ucblocks = c-block_error.stat[0].uvalue - state-per_prev;
-   state-per_prev = c-block_error.stat[0].uvalue;
+   *ucblocks = c-block_error.stat[0].uvalue - state-ucb_offset;
 
return 0;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] For 4.2 (or even 4.1?) add support for cx24120/Technisat SkyStar S2

2015-05-19 Thread Jemma Denson

On 19/05/15 11:57, Mauro Carvalho Chehab wrote:



The only thing left now is moving UCB  BER over to DVBv5 stats - we
haven't got anything close to any specs for this demod so I'm struggling
to work out how to handle the counter increment.
It's not helped by my signal not being marginal enough to see any errors
anyway!

What's the best course of action here - either leave those two out
entirely or fudge something to get the numbers to about the right
magnitude and worry about making it more accurate at a later date?

I prefer to have something, even not 100% acurate, reported via DVBv5.

Regards,
Mauro


I think I've managed to work it out now :) It's set to use a 16 bit BER 
window and what I did manage to see suggests that the window is based on 
packets. So it's just a case of calculating things from there.


I implemented something for BER lastnight but it does need a little 
tidying. UCB should be much more straightforward. I should be able to 
find time during the week, or if not this weekend. I'll send the patches 
through to Patrick to add to his tree and then we can have a v3 pull 
request.



Jemma.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/8] m88ds3103: do not return error from get_frontend() when not ready

2015-05-18 Thread Jemma Denson

Hi Antti,

On 18/05/15 06:08, Antti Palosaari wrote:

Do not return error from get_frontend() when status is queried, but
device is not ready. dvbv5-zap has habit to call that IOCTL before
device is tuned and it also refuses to use DVBv5 statistic after
that...


In the driver I'm working on I noticed that in dvb5-zap too. I also saw 
a timing issue if holding fe_status in the priv struct - fe_status will 
remain at FE_HAS_LOCK until read_status() spins around again and this 
can cause get_frontend to proceed when it probably shouldn't. The end 
result is this early call to get_frontend() overwrites the property 
cache before zap has sent it through to set_frontend() and tuning then 
fails.


Do we need to be fixing these issues at a driver level?


Jemma.




Signed-off-by: Antti Palosaari cr...@iki.fi
---
  drivers/media/dvb-frontends/m88ds3103.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index d3d928e..03dceb5 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -742,7 +742,7 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe)
dev_dbg(priv-i2c-dev, %s:\n, __func__);
  
  	if (!priv-warm || !(priv-fe_status  FE_HAS_LOCK)) {

-   ret = -EAGAIN;
+   ret = 0;
goto err;
}
  


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] For 4.2 (or even 4.1?) add support for cx24120/Technisat SkyStar S2

2015-05-15 Thread Jemma Denson

Hi Mauro,

On 15/05/15 15:24, Mauro Carvalho Chehab wrote:

Of course. Jemma and me (mainly Jemma) are progressing and might be
able to resubmit everything this weekend.

Good! Thanks for the good work!

Mauro



The only thing left now is moving UCB  BER over to DVBv5 stats - we 
haven't got anything close to any specs for this demod so I'm struggling 
to work out how to handle the counter increment.
It's not helped by my signal not being marginal enough to see any errors 
anyway!


What's the best course of action here - either leave those two out 
entirely or fudge something to get the numbers to about the right 
magnitude and worry about making it more accurate at a later date?



Jemma.

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


DVBv5 qos/stats driver implementation

2015-05-05 Thread Jemma Denson

Mauro/Antti,

Myself and Patrick are currently in the process of bringing an old out 
of tree frontend driver into shape for inclusion, and one of the issues 
raised by Mauro was the requirement for the new DVBv5 stats method. I've 
noticed there seems to be two different ways of going around this - one 
is to run through the collection and cache filling process during the 
calls to read_status (as in dib7000p/dib8000p), and the other is to poll 
independently every couple of seconds via schedule_delayed_work (as in 
af9033, rtl2830/2832).


Is there any reason for the two different ways - is it just a coding 
preference or is there some specifics to how these frontends need to be 
implemented?


Thanks,

Jemma.


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] For 4.2 (or even 4.1?) add support for cx24120/Technisat SkyStar S2

2015-04-27 Thread Jemma Denson

(Resending to fix reply-all)

Hi Mauro,

Thanks for taking the time to look into this. I'll let Patrick respond 
to the first part regards the pull request - I'll just respond to the 
points you've made about the driver itself.


On 27/04/15 21:16, Mauro Carvalho Chehab wrote:
 +
 +
 +/* Write multiple registers */
 +static int cx24120_writeregN(struct cx24120_state *state,
 +u8 reg, const u8 *values, u16 len, u8 incr)
 +{
 +int ret;
 +u8 buf[5]; /* maximum 4 data bytes at once - flexcop limitation
 +(very limited i2c-interface this one) */
 Hmm... if the limit is at flexcop, then the best is to not be add such
 restriction here, but at the flexcop code, and passing the max limit that
 used for the I2C transfer as a parameter at the attach structure, just
 like other frontend and tuner drivers do.
I had considered doing that - the cx24116 driver does have i2c_wr_max as 
part of it's config struct. The only reason I didn't however was that I 
did consider that it's now quite unlikely this demod would be used in 
anything else so it could probably safely stay fixed for a while yet.


As you say though it would be nicer as a config item, and it shouldn't 
be too much to add in so I'll look into doing it that way.


 Also, this limit is hardcoded here. Please use a define instead.
So, if I do have this as a config item then this and the following 
hardcoded values should all disappear...


 +
 +struct i2c_msg msg = {
 +.addr = state-config-i2c_addr,
 +.flags = 0,
 +.buf = buf,
 +.len = len };
 +
 +while (len) {
 +buf[0] = reg;
 +msg.len = len  4 ? 4 : len;
 Again, don't hardcode the max buf size here.


 +
 +/* Wait for tuning */
 +while (delay_cnt = 0) {
 +cx24120_read_status(fe, status);
 +if (status  FE_HAS_LOCK)
 +goto tuned;
 +msleep(20);
 +delay_cnt -= 20;
 +}
 I don't see any need for waiting for tune here. This is generally done in
 userspace and at the kthread inside dvb_frontend.c.

 Any reason why this has to be done here?

Some point after tuning the cx24120_set_clock_ratios function needs to 
be called and the firmware command CMD_CLOCK_SET sent. The ratios sent 
to this command depend on delivery system, fec  pilot - the latter two 
only available to read after tuning. If this isn't done then the mpeg 
stream doesn't appear.


Is there a better point to set the ratios? Or for another way of asking 
that, is there some other function that will always get hit after tuning?


 +
 +/* Calculate vco from config */
 +static u64 cx24120_calculate_vco(struct cx24120_state *state)
 +{
 +u32 vco;
 +u64 inv_vco, res, xxyyzz;
 +u32 xtal_khz = state-config-xtal_khz;
 +
 +xxyyzz = 0x4ULL;
 xxyyzz? Weird name for a var.
Yes... one of the oddities left from the dissasembled driver I hadn't 
ironed out yet! I'll look into what it's supposed to be doing and rename 
that to something far more sensible.



As time allows I'll get this fixed up as required - would it be best if 
I send patches to here made against Patrick's tree? I presume also one 
patch for each of the coding styles, and then one patch for each of the 
other issues?



Jemma.


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add support for TechniSat Skystar S2

2015-04-17 Thread Jemma Denson

On 17/04/15 10:06, Patrick Boettcher wrote:

I have my Skystar S2 pointed to 19.2E.
That would be great if you could test on that, 28.2E can be a bit 
conservative. The parts that I consider need testing are FEC and Pilot 
on DVBS2 - I didn't have that much variety in FEC values, and as far as 
I could tell everything is Pilot=ON on 28.2.


If it's not obvious from the code and comments, the values used for 
tuning are in the modfec_table, and the pattern *seems* to match with 
the modfec_lookup_table - for DVBS2, anyway. With DVBS the values for 
setting and getting are different, and not just a straight +=0x2d 
unfortunately.
I did have a plan to merge these two tables together, and it would need 
a seperate u8 val for setting and getting due to DVBS being odd.


Pilot was admittedly a bit of guesswork - it seems to be able to do the 
same thing as the cx24117 driver, in that ON is |= 0x40 and AUTO is 
|=0x80. To work out the fec values needed I had some code that looped 
through from 0x01 to 0xff and found that, for example, 8PSK 2/3 worked 
on 0x4d, 0x8d and 0xcd and failed to tune on 0x0d which made me realise 
that the top two bits were infact pilot.
It really does need testing with a S2 transponder which needs pilot off 
- to check firstly that the tuning mask is correct, and also that 
get_fec is doing the right thing with retrieving the value. I'm not 100% 
sure that bit 8 signifies pilot in that register, but it seems to fit in 
that that clock ratios needed are different which would be due to the 
data rate being slightly lower when pilot is in use.



To prepare an integration into 4.2 (or at least 4.3) I suggest using my
media_tree on linuxtv.org .

http://git.linuxtv.org/cgit.cgi/pb/media_tree.git/ cx24120-v2

I added a checkpatch-patch on top of it. If you can, please base any
future work of yours on this tree until is has been integrated.
Will do! If I can work out the SNR scale I have got plans to have this 
work in the new way of doing this. Did you ever manage to obtain a 
datasheet for this demod? I have tried contacting NXP but haven't 
received anything back.



Please also tell me, whether you are OK with the comment I added around
your commit or not.

Yes, that's OK.

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add support for TechniSat Skystar S2

2015-04-13 Thread Jemma Denson

Oh, I was doing this the wrong way then. I did have some preamble to
this but it seems to have been stripped.

Anyway, this patch adds support for the Technisat Skystar S2 - this
has been tried before but the cx24120 driver was a bit out of shape
and it didn't got any further:
https://patchwork.linuxtv.org/patch/10575/

It is an old card, but currently being sold off for next to nothing,
so it's proving quite popular of late.
Noticing it's quite similar to the cx24116 and cx24117 I've rewritten
the driver in a similar way. There were a few registers and commands
from those drivers missing from this one I've tested out and found
they do something so they've been added in to speed up tuning and to
make get_frontend return something useful.

I've only got access to 28.2E, but everything I've tried seems to work
OK, on both the v3 and v5 APIs. Assuming I've read the APIs and some
of the modern drivers OK it should be doing things in the reasonably
modern way, but if anything else needs doing let me know.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Add support for TechniSat Skystar S2

2015-04-12 Thread Jemma Denson
Signed-off-by: Jemma Denson jden...@gmail.com
---
 drivers/media/common/b2c2/Kconfig|1 +
 drivers/media/common/b2c2/flexcop-fe-tuner.c |   51 +-
 drivers/media/common/b2c2/flexcop-misc.c |1 +
 drivers/media/common/b2c2/flexcop-reg.h  |1 +
 drivers/media/dvb-frontends/Kconfig  |7 +
 drivers/media/dvb-frontends/Makefile |1 +
 drivers/media/dvb-frontends/cx24120.c| 1577 ++
 drivers/media/dvb-frontends/cx24120.h|   56 +
 8 files changed, 1688 insertions(+), 7 deletions(-)
 create mode 100644 drivers/media/dvb-frontends/cx24120.c
 create mode 100644 drivers/media/dvb-frontends/cx24120.h

diff --git a/drivers/media/common/b2c2/Kconfig 
b/drivers/media/common/b2c2/Kconfig
index a8c6cdf..e593638 100644
--- a/drivers/media/common/b2c2/Kconfig
+++ b/drivers/media/common/b2c2/Kconfig
@@ -14,6 +14,7 @@ config DVB_B2C2_FLEXCOP
select DVB_S5H1420 if MEDIA_SUBDRV_AUTOSELECT
select DVB_TUNER_ITD1000 if MEDIA_SUBDRV_AUTOSELECT
select DVB_ISL6421 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_CX24120 if MEDIA_SUBDRV_AUTOSELECT
select DVB_CX24123 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT
select DVB_TUNER_CX24113 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c 
b/drivers/media/common/b2c2/flexcop-fe-tuner.c
index 7e14e90..66f6910 100644
--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c
@@ -12,6 +12,7 @@
 #include cx24113.h
 #include cx24123.h
 #include isl6421.h
+#include cx24120.h
 #include mt352.h
 #include bcm3510.h
 #include nxt200x.h
@@ -26,6 +27,16 @@
 #define FE_SUPPORTED(fe) (defined(CONFIG_DVB_##fe) || \
(defined(CONFIG_DVB_##fe##_MODULE)  defined(MODULE)))
 
+#if FE_SUPPORTED(BCM3510) || FE_SUPPORTED(CX24120)
+static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
+   const struct firmware **fw, char *name)
+{
+   struct flexcop_device *fc = fe-dvb-priv;
+
+   return request_firmware(fw, name, fc-dev);
+}
+#endif
+
 /* lnb control */
 #if FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)
 static int flexcop_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t 
voltage)
@@ -445,13 +456,6 @@ static int airstar_dvbt_attach(struct flexcop_device *fc,
 
 /* AirStar ATSC 1st generation */
 #if FE_SUPPORTED(BCM3510)
-static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
-   const struct firmware **fw, char* name)
-{
-   struct flexcop_device *fc = fe-dvb-priv;
-   return request_firmware(fw, name, fc-dev);
-}
-
 static struct bcm3510_config air2pc_atsc_first_gen_config = {
.demod_address= 0x0f,
.request_firmware = flexcop_fe_request_firmware,
@@ -619,6 +623,38 @@ fail:
 #define cablestar2_attach NULL
 #endif
 
+/* SkyStar S2 PCI DVB-S/S2 card based on Conexant cx24120/cx24118 */
+#if FE_SUPPORTED(CX24120)  FE_SUPPORTED(ISL6421)
+static const struct cx24120_config skystar2_rev3_3_cx24120_config = {
+   .i2c_addr = 0x55,
+   .xtal_khz = 10111,
+   .initial_mpeg_config = { 0xa1, 0x76, 0x07 },
+   .request_firmware = flexcop_fe_request_firmware,
+};
+
+static int skystarS2_rev33_attach(struct flexcop_device *fc,
+   struct i2c_adapter *i2c)
+{
+   fc-fe = dvb_attach(cx24120_attach,
+   skystar2_rev3_3_cx24120_config, i2c);
+   if (fc-fe == NULL)
+   return 0;
+
+   fc-dev_type = FC_SKYS2_REV33;
+   fc-fc_i2c_adap[2].no_base_addr = 1;
+   if ((dvb_attach(isl6421_attach, fc-fe,
+   fc-fc_i2c_adap[2].i2c_adap, 0x08, 0, 0, false) == NULL)) {
+   err(ISL6421 could NOT be attached!);
+   return 0;
+   }
+   info(ISL6421 successfully attached.);
+
+   return 1;
+}
+#else
+#define skystarS2_rev33_attach NULL
+#endif
+
 static struct {
flexcop_device_type_t type;
int (*attach)(struct flexcop_device *, struct i2c_adapter *);
@@ -632,6 +668,7 @@ static struct {
{ FC_AIR_ATSC1, airstar_atsc1_attach },
{ FC_CABLE, cablestar2_attach },
{ FC_SKY_REV23, skystar2_rev23_attach },
+   { FC_SKYS2_REV33, skystarS2_rev33_attach },
 };
 
 /* try to figure out the frontend */
diff --git a/drivers/media/common/b2c2/flexcop-misc.c 
b/drivers/media/common/b2c2/flexcop-misc.c
index f06f3a9..b8eff23 100644
--- a/drivers/media/common/b2c2/flexcop-misc.c
+++ b/drivers/media/common/b2c2/flexcop-misc.c
@@ -56,6 +56,7 @@ static const char *flexcop_device_names[] = {
[FC_SKY_REV26]  = Sky2PC/SkyStar 2 DVB-S rev 2.6,
[FC_SKY_REV27]  = Sky2PC/SkyStar 2 DVB-S rev 2.7a/u,
[FC_SKY_REV28]  = Sky2PC/SkyStar 2 DVB-S rev 2.8,
+   [FC_SKYS2_REV33] = Sky2PC/SkyStar S2 DVB-S/S2 rev 3.3,
 };
 
 static const char *flexcop_bus_names[] = {
diff --git a/drivers/media/common/b2c2/flexcop-reg.h 
b/drivers/media/common/b2c2/flexcop-reg.h
index dc4528d..835c54d 100644