Re: [PATCH] cx23885/vb2 regression: please test this patch

2015-01-16 Thread Luis Alves
Hans,

There is another guy having issues with TBS8820 card (uses cx88 and cx24116)

His syslog:
http://paste.ubuntu.com/9284564/

The stackdump makes me believe that the issue also appeared since
[media] cx88: convert to vb2
(still to confirm)

Regards,
Luis


On Fri, Jan 16, 2015 at 4:20 PM, Raimonds Cicans r...@apollo.lv wrote:
 On 16.01.2015 16:54, Hans Verkuil wrote:

 On 01/13/2015 06:55 PM, Raimonds Cicans wrote:

 On 13.01.2015 16:01, Hans Verkuil wrote:

 Can you both test this patch? It should (I hope) solve the problems you
 both had with the cx23885 driver.

 Can you check that the function cx23885_risc_field in
 drivers/media/pci/cx23885/cx23885-core.c uses sg = sg_next(sg);
 instead of sg++;?

 There is no sg++ in whole drivers/media/pci/cx23885/ directory.

 To avoid confusion I would prefer that you test with a 3.18 or higher
 kernel
 and please state which kernel version you use and whether you used the
 media_build system or a specific git repo to build the drivers.

 kernel: Gentoo Hardened kernel 3.18.1 (hardened part turned off)
 media_build: pure original media_build
 media tree: https://github.com/ljalves/linux_media (original linux-media
 plus some
 new out of kernel TBS drivers (from this tree I need TBS6285 driver))

 I'm also interested if you can reproduce it using just command-line tools
 (and let me know what it is you do).

 For tests I use only command line tools: w_scan  dvb-fe-tool

 Tests:
 1) w_scan on first front end then after 5-10 seconds w_scan on other
 2) w_scan on second front end then after 5-10 seconds w_scan on first
 3) dvb-fe-tool -d DVBS on first front end then after 5-10 seconds w_scan
 on second front end then after 5-10 seconds w_scan on first
 4) dvb-fe-tool -d DVBS on second front end then after 5-10 seconds w_scan
 on first front end then after 5-10 seconds w_scan on second

 w_scan run on both front ends simultaneously.


 Use only one DVB adapter, not both.

 Do you mean one card or one front end?



 Raimonds Cicans

 --
 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
--
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] si2168: Add ts_mode config.

2014-07-23 Thread Luis Alves
Hi Antti,
Yes, I know. I already had asked Mauro to reject it (on irc).

I'll send a fixed one soon.

Regards,
Luis


On Wed, Jul 23, 2014 at 10:04 AM, Antti Palosaari cr...@iki.fi wrote:
 Moikka
 This cannot work. You refer config struct that is coming outside of driver.
 That means, caller must keep stuct, but it does not, and I really don't even
 like idea to leave it responsibility of caller. Due to that you will need
 copy all config values to driver state before return from probe().

 regards
 Antti



 On 07/22/2014 06:54 PM, Luis Alves wrote:

 This patch adds the TS mode as a config option:
 - ts_mode added to config struct.
 - Possible (interesting) values are
 * Parallel mode = 0x06
 * Serial mode = 0x03

 Currently the modules using this demod only use parallel mode.

 Regards,
 Luis

 Signed-off-by: Luis Alves lja...@gmail.com
 ---
   drivers/media/dvb-frontends/si2168.c  | 17 ++---
   drivers/media/dvb-frontends/si2168.h  |  6 ++
   drivers/media/usb/dvb-usb/cxusb.c |  1 +
   drivers/media/usb/em28xx/em28xx-dvb.c |  1 +
   4 files changed, 18 insertions(+), 7 deletions(-)

 diff --git a/drivers/media/dvb-frontends/si2168.c
 b/drivers/media/dvb-frontends/si2168.c
 index 41bdbc4..d45a1c6 100644
 --- a/drivers/media/dvb-frontends/si2168.c
 +++ b/drivers/media/dvb-frontends/si2168.c
 @@ -297,13 +297,6 @@ static int si2168_set_frontend(struct dvb_frontend
 *fe)
 if (ret)
 goto err;

 -   memcpy(cmd.args, \x14\x00\x01\x10\x16\x00, 6);
 -   cmd.wlen = 6;
 -   cmd.rlen = 4;
 -   ret = si2168_cmd_execute(s, cmd);
 -   if (ret)
 -   goto err;
 -
 memcpy(cmd.args, \x14\x00\x09\x10\xe3\x18, 6);
 cmd.wlen = 6;
 cmd.rlen = 4;
 @@ -350,6 +343,7 @@ err:
   static int si2168_init(struct dvb_frontend *fe)
   {
 struct si2168 *s = fe-demodulator_priv;
 +   struct si2168_config *config = s-client-dev.platform_data;
 int ret, len, remaining;
 const struct firmware *fw = NULL;
 u8 *fw_file;
 @@ -479,6 +473,15 @@ static int si2168_init(struct dvb_frontend *fe)
 dev_info(s-client-dev, %s: found a '%s' in warm state\n,
 KBUILD_MODNAME, si2168_ops.info.name);

 +   /* Set TSMODE */
 +   memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
 +   cmd.args[4] |= config-ts_mode;
 +   cmd.wlen = 6;
 +   cmd.rlen = 4;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 s-active = true;

 return 0;
 diff --git a/drivers/media/dvb-frontends/si2168.h
 b/drivers/media/dvb-frontends/si2168.h
 index 3c5b5ab..ebbf309 100644
 --- a/drivers/media/dvb-frontends/si2168.h
 +++ b/drivers/media/dvb-frontends/si2168.h
 @@ -34,6 +34,12 @@ struct si2168_config {
  * returned by driver
  */
 struct i2c_adapter **i2c_adapter;
 +
 +   /* TS mode */
 +   u8 ts_mode;
   };

 +#define SI2168_TSMODE_PARALLEL 0x06
 +#define SI2168_TSMODE_SERIAL   0x03
 +
   #endif
 diff --git a/drivers/media/usb/dvb-usb/cxusb.c
 b/drivers/media/usb/dvb-usb/cxusb.c
 index b7461ac..18a2720 100644
 --- a/drivers/media/usb/dvb-usb/cxusb.c
 +++ b/drivers/media/usb/dvb-usb/cxusb.c
 @@ -1369,6 +1369,7 @@ static int cxusb_tt_ct2_4400_attach(struct
 dvb_usb_adapter *adap)
 /* attach frontend */
 si2168_config.i2c_adapter = adapter;
 si2168_config.fe = adap-fe_adap[0].fe;
 +   si2168_config.ts_mode = SI2168_TSMODE_PARALLEL;
 memset(info, 0, sizeof(struct i2c_board_info));
 strlcpy(info.type, si2168, I2C_NAME_SIZE);
 info.addr = 0x64;
 diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c
 b/drivers/media/usb/em28xx/em28xx-dvb.c
 index 96a0bdb..27d5d84 100644
 --- a/drivers/media/usb/em28xx/em28xx-dvb.c
 +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
 @@ -1525,6 +1525,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
 /* attach demod */
 si2168_config.i2c_adapter = adapter;
 si2168_config.fe = dvb-fe[0];
 +   si2168_config.ts_mode = SI2168_TSMODE_PARALLEL;
 memset(info, 0, sizeof(struct i2c_board_info));
 strlcpy(info.type, si2168, I2C_NAME_SIZE);
 info.addr = 0x64;


 --
 http://palosaari.fi/
--
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] si2157: Fix DVB-C bandwidth.

2014-07-22 Thread Luis Alves
This patch fixes DVB-C reception.
Without setting the bandwidth to 8MHz the received stream gets corrupted.

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/tuners/si2157.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 6c53edb..e2de428 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -245,6 +245,7 @@ static int si2157_set_params(struct dvb_frontend *fe)
break;
case SYS_DVBC_ANNEX_A:
delivery_system = 0x30;
+   bandwidth = 0x08;
break;
default:
ret = -EINVAL;
-- 
1.9.1

--
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] si2168: Add ts_mode config.

2014-07-22 Thread Luis Alves
This patch adds the TS mode as a config option:
- ts_mode added to config struct.
- Possible (interesting) values are
   * Parallel mode = 0x06
   * Serial mode = 0x03

Currently the modules using this demod only use parallel mode.

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c  | 17 ++---
 drivers/media/dvb-frontends/si2168.h  |  6 ++
 drivers/media/usb/dvb-usb/cxusb.c |  1 +
 drivers/media/usb/em28xx/em28xx-dvb.c |  1 +
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 41bdbc4..d45a1c6 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -297,13 +297,6 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   memcpy(cmd.args, \x14\x00\x01\x10\x16\x00, 6);
-   cmd.wlen = 6;
-   cmd.rlen = 4;
-   ret = si2168_cmd_execute(s, cmd);
-   if (ret)
-   goto err;
-
memcpy(cmd.args, \x14\x00\x09\x10\xe3\x18, 6);
cmd.wlen = 6;
cmd.rlen = 4;
@@ -350,6 +343,7 @@ err:
 static int si2168_init(struct dvb_frontend *fe)
 {
struct si2168 *s = fe-demodulator_priv;
+   struct si2168_config *config = s-client-dev.platform_data;
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file;
@@ -479,6 +473,15 @@ static int si2168_init(struct dvb_frontend *fe)
dev_info(s-client-dev, %s: found a '%s' in warm state\n,
KBUILD_MODNAME, si2168_ops.info.name);
 
+   /* Set TSMODE */
+   memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
+   cmd.args[4] |= config-ts_mode;
+   cmd.wlen = 6;
+   cmd.rlen = 4;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
s-active = true;
 
return 0;
diff --git a/drivers/media/dvb-frontends/si2168.h 
b/drivers/media/dvb-frontends/si2168.h
index 3c5b5ab..ebbf309 100644
--- a/drivers/media/dvb-frontends/si2168.h
+++ b/drivers/media/dvb-frontends/si2168.h
@@ -34,6 +34,12 @@ struct si2168_config {
 * returned by driver
 */
struct i2c_adapter **i2c_adapter;
+
+   /* TS mode */
+   u8 ts_mode;
 };
 
+#define SI2168_TSMODE_PARALLEL 0x06
+#define SI2168_TSMODE_SERIAL   0x03
+
 #endif
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index b7461ac..18a2720 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1369,6 +1369,7 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
/* attach frontend */
si2168_config.i2c_adapter = adapter;
si2168_config.fe = adap-fe_adap[0].fe;
+   si2168_config.ts_mode = SI2168_TSMODE_PARALLEL;
memset(info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, si2168, I2C_NAME_SIZE);
info.addr = 0x64;
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index 96a0bdb..27d5d84 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1525,6 +1525,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
/* attach demod */
si2168_config.i2c_adapter = adapter;
si2168_config.fe = dvb-fe[0];
+   si2168_config.ts_mode = SI2168_TSMODE_PARALLEL;
memset(info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, si2168, I2C_NAME_SIZE);
info.addr = 0x64;
-- 
1.9.1

--
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] si2157: Fix DVB-C bandwidth.

2014-07-22 Thread Luis Alves
That's right,
A few days ago I also checked that with Antti. I've also had made some
debugging and DVB core is in fact passing the correct bandwidth to the
driver.

But the true is that it doesn't work...
The sample I have is a dvb-c mux using QAM128 @ 6 Mbaud (which results
in 7MHz bw) using 7MHz filter value will make the TS stream
unwatchable (lots of continuity errors).

Can this be a hardware fault?
All closed source drivers I've seen are hardcoding this value to 8MHz
when working in dvb-c (easily seen on i2c sniffs).


On Tue, Jul 22, 2014 at 5:10 PM, Mauro Carvalho Chehab
m.che...@samsung.com wrote:
 Em Tue, 22 Jul 2014 12:09:48 +0100
 Luis Alves lja...@gmail.com escreveu:

 This patch fixes DVB-C reception.
 Without setting the bandwidth to 8MHz the received stream gets corrupted.

 Regards,
 Luis

 Signed-off-by: Luis Alves lja...@gmail.com
 ---
  drivers/media/tuners/si2157.c | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
 index 6c53edb..e2de428 100644
 --- a/drivers/media/tuners/si2157.c
 +++ b/drivers/media/tuners/si2157.c
 @@ -245,6 +245,7 @@ static int si2157_set_params(struct dvb_frontend *fe)
   break;
   case SYS_DVBC_ANNEX_A:
   delivery_system = 0x30;
 + bandwidth = 0x08;

 Hmm... this patch looks wrong, as it will break DVB-C support where
 the bandwidth is lower than 6MHz.

 The DVB core sets c-bandwidth_hz for DVB-C based on the rolloff and
 the symbol rate. If this is not working for you, then something else
 is likely wrong.

 I suggest you to add a printk() there to show what's the value set
 at c-bandwidth_hz and what's the symbol rate that you're using.

 On DVB-C, the rolloff is fixed (1.15 for annex A and 1.13 for Annex C).
 Not sure if DVB-C2 allows selecting a different rolloff factor, nor
 if si2157 works with DVB-C2.

   break;
   default:
   ret = -EINVAL;
--
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] si2157: Use name si2157_ops instead of si2157_tuner_ops (harmonize with si2168)

2014-07-18 Thread Luis Alves
This actually fixes a bug.
The struct prototype is defined at the beginning of the code as
si2157_ops but the real struct is called si2157_tuner_ops.

This is causing the name to be empty on this info msg: si2157 16-0060:
si2157: found a '' in cold state

Luis


On Fri, Jul 18, 2014 at 6:41 AM, Olli Salonen olli.salo...@iki.fi wrote:
 Signed-off-by: Olli Salonen olli.salo...@iki.fi
 ---
  drivers/media/tuners/si2157.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
 index 329004f..4730f69 100644
 --- a/drivers/media/tuners/si2157.c
 +++ b/drivers/media/tuners/si2157.c
 @@ -277,7 +277,7 @@ err:
 return ret;
  }

 -static const struct dvb_tuner_ops si2157_tuner_ops = {
 +static const struct dvb_tuner_ops si2157_ops = {
 .info = {
 .name   = Silicon Labs Si2157/Si2158,
 .frequency_min  = 11000,
 @@ -317,7 +317,7 @@ static int si2157_probe(struct i2c_client *client,
 goto err;

 fe-tuner_priv = s;
 -   memcpy(fe-ops.tuner_ops, si2157_tuner_ops,
 +   memcpy(fe-ops.tuner_ops, si2157_ops,
 sizeof(struct dvb_tuner_ops));

 i2c_set_clientdata(client, s);
 --
 1.9.1

 --
 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
--
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/1] si2168: Set symbol_rate in set_frontend for DVB-C delivery system.

2014-07-17 Thread Luis Alves
This patch adds symbol rate setting to the driver.

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 0422925..7980741 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -278,6 +278,18 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   /* set DVB-C symbol rate */
+   if (c-delivery_system == SYS_DVBC_ANNEX_A) {
+   memcpy(cmd.args, \x14\x00\x02\x11, 4);
+   cmd.args[4] = (c-symbol_rate / 1000)  0xff;
+   cmd.args[5] = ((c-symbol_rate / 1000)  8)  0xff;
+   cmd.wlen = 6;
+   cmd.rlen = 4;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+   }
+
memcpy(cmd.args, \x14\x00\x0f\x10\x10\x00, 6);
cmd.wlen = 6;
cmd.rlen = 4;
-- 
1.9.1

--
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] si2168: improve scanning performance by setting property 0301 with a value from Windows driver.

2014-07-17 Thread Luis Alves
This would be best done during init and not every time on set_frontend.

Regards,
Luis

On Thu, Jul 17, 2014 at 7:43 PM, Olli Salonen olli.salo...@iki.fi wrote:
 Signed-off-by: Olli Salonen olli.salo...@iki.fi
 ---
  drivers/media/dvb-frontends/si2168.c | 7 +++
  1 file changed, 7 insertions(+)

 diff --git a/drivers/media/dvb-frontends/si2168.c 
 b/drivers/media/dvb-frontends/si2168.c
 index 0422925..56811e1 100644
 --- a/drivers/media/dvb-frontends/si2168.c
 +++ b/drivers/media/dvb-frontends/si2168.c
 @@ -313,6 +313,13 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
 if (ret)
 goto err;

 +   memcpy(cmd.args, \x14\x00\x01\x03\x0c\x00, 6);
 +   cmd.wlen = 6;
 +   cmd.rlen = 4;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 memcpy(cmd.args, \x85, 1);
 cmd.wlen = 1;
 cmd.rlen = 1;
 --
 1.9.1

 --
 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
--
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/1] si2168: Fix i2c_add_mux_adapter return value in probe function. In case it failed the return value was always 0.

2014-07-17 Thread Luis Alves
Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 7980741..3fed522 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -619,8 +619,10 @@ static int si2168_probe(struct i2c_client *client,
/* create mux i2c adapter for tuner */
s-adapter = i2c_add_mux_adapter(client-adapter, client-dev, s,
0, 0, 0, si2168_select, si2168_deselect);
-   if (s-adapter == NULL)
+   if (s-adapter == NULL) {
+   ret = -ENODEV;
goto err;
+   }
 
/* create dvb_frontend */
memcpy(s-fe.ops, si2168_ops, sizeof(struct dvb_frontend_ops));
-- 
1.9.1

--
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/1] si2168: Remove testing for demod presence on probe. If the demod is in sleep mode it will fail.

2014-07-17 Thread Luis Alves
Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 3fed522..7e45eeab 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -595,7 +595,6 @@ static int si2168_probe(struct i2c_client *client,
struct si2168_config *config = client-dev.platform_data;
struct si2168 *s;
int ret;
-   struct si2168_cmd cmd;
 
dev_dbg(client-dev, %s:\n, __func__);
 
@@ -609,13 +608,6 @@ static int si2168_probe(struct i2c_client *client,
s-client = client;
mutex_init(s-i2c_mutex);
 
-   /* check if the demod is there */
-   cmd.wlen = 0;
-   cmd.rlen = 1;
-   ret = si2168_cmd_execute(s, cmd);
-   if (ret)
-   goto err;
-
/* create mux i2c adapter for tuner */
s-adapter = i2c_add_mux_adapter(client-adapter, client-dev, s,
0, 0, 0, si2168_select, si2168_deselect);
-- 
1.9.1

--
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/1] si2168: Support Si2168-A20 firmware downloading.

2014-07-17 Thread Luis Alves
This adds support for the Si2168-A20 firmware download.
Extracting the firmware:

wget 
http://www.tbsdtv.com/download/document/tbs6281/tbs6281-t2-t-driver_v1.0.0.6.zip
unzip tbs6281-t2-t-driver_v1.0.0.6.zip
dd if=tbs-6281_x64/tbs6281_64.sys of=dvb-demod-si2168-a20-01.fw count=28656 
bs=1 skip=1625088

md5sum:
32e06713b33915f674bfb2c209beaea5 /lib/firmware/dvb-demod-si2168-a20-01.fw

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c  | 4 
 drivers/media/dvb-frontends/si2168_priv.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 7e45eeab..ad38c17 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -377,10 +377,14 @@ static int si2168_init(struct dvb_frontend *fe)
chip_id = cmd.args[1]  24 | cmd.args[2]  16 | cmd.args[3]  8 |
cmd.args[4]  0;
 
+   #define SI2168_A20 ('A'  24 | 68  16 | '2'  8 | '0'  0)
#define SI2168_A30 ('A'  24 | 68  16 | '3'  8 | '0'  0)
#define SI2168_B40 ('B'  24 | 68  16 | '4'  8 | '0'  0)
 
switch (chip_id) {
+   case SI2168_A20:
+   fw_file = SI2168_A20_FIRMWARE;
+   break;
case SI2168_A30:
fw_file = SI2168_A30_FIRMWARE;
break;
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index bebb68a..ebbf502 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -22,6 +22,7 @@
 #include linux/firmware.h
 #include linux/i2c-mux.h
 
+#define SI2168_A20_FIRMWARE dvb-demod-si2168-a20-01.fw
 #define SI2168_A30_FIRMWARE dvb-demod-si2168-a30-01.fw
 #define SI2168_B40_FIRMWARE dvb-demod-si2168-b40-01.fw
 #define SI2168_B40_FIRMWARE_FALLBACK dvb-demod-si2168-02.fw
-- 
1.9.1

--
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/1 v2] si2168: Support Si2168-A20 firmware downloading.

2014-07-17 Thread Luis Alves
(ignore the previous one, it was incomplete)

This adds support for the Si2168-A20 firmware download.
Extracting the firmware:

wget 
http://www.tbsdtv.com/download/document/tbs6281/tbs6281-t2-t-driver_v1.0.0.6.zip
unzip tbs6281-t2-t-driver_v1.0.0.6.zip
dd if=tbs-6281_x64/tbs6281_64.sys of=dvb-demod-si2168-a20-01.fw count=28656 
bs=1 skip=1625088

md5sum:
32e06713b33915f674bfb2c209beaea5 /lib/firmware/dvb-demod-si2168-a20-01.fw

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/si2168.c  | 5 +
 drivers/media/dvb-frontends/si2168_priv.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 7e45eeab..50c4a91 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -377,10 +377,14 @@ static int si2168_init(struct dvb_frontend *fe)
chip_id = cmd.args[1]  24 | cmd.args[2]  16 | cmd.args[3]  8 |
cmd.args[4]  0;
 
+   #define SI2168_A20 ('A'  24 | 68  16 | '2'  8 | '0'  0)
#define SI2168_A30 ('A'  24 | 68  16 | '3'  8 | '0'  0)
#define SI2168_B40 ('B'  24 | 68  16 | '4'  8 | '0'  0)
 
switch (chip_id) {
+   case SI2168_A20:
+   fw_file = SI2168_A20_FIRMWARE;
+   break;
case SI2168_A30:
fw_file = SI2168_A30_FIRMWARE;
break;
@@ -672,5 +676,6 @@ module_i2c_driver(si2168_driver);
 MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
 MODULE_DESCRIPTION(Silicon Labs Si2168 DVB-T/T2/C demodulator driver);
 MODULE_LICENSE(GPL);
+MODULE_FIRMWARE(SI2168_A20_FIRMWARE);
 MODULE_FIRMWARE(SI2168_A30_FIRMWARE);
 MODULE_FIRMWARE(SI2168_B40_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index bebb68a..ebbf502 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -22,6 +22,7 @@
 #include linux/firmware.h
 #include linux/i2c-mux.h
 
+#define SI2168_A20_FIRMWARE dvb-demod-si2168-a20-01.fw
 #define SI2168_A30_FIRMWARE dvb-demod-si2168-a30-01.fw
 #define SI2168_B40_FIRMWARE dvb-demod-si2168-b40-01.fw
 #define SI2168_B40_FIRMWARE_FALLBACK dvb-demod-si2168-02.fw
-- 
1.9.1

--
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/1 v2] si2168: Support Si2168-A20 firmware downloading.

2014-07-17 Thread Luis Alves
I think so... at least the known ones.

On Thu, Jul 17, 2014 at 11:56 PM, Antti Palosaari cr...@iki.fi wrote:
 Thank for the patch! I will apply that sure too.
 Driver supports now all Si2168 versions?

 regards
 Antti


 On 07/18/2014 01:43 AM, Luis Alves wrote:

 (ignore the previous one, it was incomplete)

 This adds support for the Si2168-A20 firmware download.
 Extracting the firmware:

 wget
 http://www.tbsdtv.com/download/document/tbs6281/tbs6281-t2-t-driver_v1.0.0.6.zip
 unzip tbs6281-t2-t-driver_v1.0.0.6.zip
 dd if=tbs-6281_x64/tbs6281_64.sys of=dvb-demod-si2168-a20-01.fw
 count=28656 bs=1 skip=1625088

 md5sum:
 32e06713b33915f674bfb2c209beaea5 /lib/firmware/dvb-demod-si2168-a20-01.fw

 Regards,
 Luis


 Signed-off-by: Luis Alves lja...@gmail.com
 ---
   drivers/media/dvb-frontends/si2168.c  | 5 +
   drivers/media/dvb-frontends/si2168_priv.h | 1 +
   2 files changed, 6 insertions(+)

 diff --git a/drivers/media/dvb-frontends/si2168.c
 b/drivers/media/dvb-frontends/si2168.c
 index 7e45eeab..50c4a91 100644
 --- a/drivers/media/dvb-frontends/si2168.c
 +++ b/drivers/media/dvb-frontends/si2168.c
 @@ -377,10 +377,14 @@ static int si2168_init(struct dvb_frontend *fe)
 chip_id = cmd.args[1]  24 | cmd.args[2]  16 | cmd.args[3]  8
 |
 cmd.args[4]  0;

 +   #define SI2168_A20 ('A'  24 | 68  16 | '2'  8 | '0'  0)
 #define SI2168_A30 ('A'  24 | 68  16 | '3'  8 | '0'  0)
 #define SI2168_B40 ('B'  24 | 68  16 | '4'  8 | '0'  0)

 switch (chip_id) {
 +   case SI2168_A20:
 +   fw_file = SI2168_A20_FIRMWARE;
 +   break;
 case SI2168_A30:
 fw_file = SI2168_A30_FIRMWARE;
 break;
 @@ -672,5 +676,6 @@ module_i2c_driver(si2168_driver);
   MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
   MODULE_DESCRIPTION(Silicon Labs Si2168 DVB-T/T2/C demodulator driver);
   MODULE_LICENSE(GPL);
 +MODULE_FIRMWARE(SI2168_A20_FIRMWARE);
   MODULE_FIRMWARE(SI2168_A30_FIRMWARE);
   MODULE_FIRMWARE(SI2168_B40_FIRMWARE);
 diff --git a/drivers/media/dvb-frontends/si2168_priv.h
 b/drivers/media/dvb-frontends/si2168_priv.h
 index bebb68a..ebbf502 100644
 --- a/drivers/media/dvb-frontends/si2168_priv.h
 +++ b/drivers/media/dvb-frontends/si2168_priv.h
 @@ -22,6 +22,7 @@
   #include linux/firmware.h
   #include linux/i2c-mux.h

 +#define SI2168_A20_FIRMWARE dvb-demod-si2168-a20-01.fw
   #define SI2168_A30_FIRMWARE dvb-demod-si2168-a30-01.fw
   #define SI2168_B40_FIRMWARE dvb-demod-si2168-b40-01.fw
   #define SI2168_B40_FIRMWARE_FALLBACK dvb-demod-si2168-02.fw


 --
 http://palosaari.fi/
--
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: Upstreaming SAA716x driver to the media_tree

2014-02-25 Thread Luis Alves
Hi Manu,

How's the progress going?
Looking forward to finally see this driver in the tree :D

Regards,
Luis

On Tue, Feb 11, 2014 at 7:47 PM, Manu Abraham abraham.m...@gmail.com wrote:
 On Tue, Feb 11, 2014 at 7:14 PM, Luis Alves lja...@gmail.com wrote:
 Hi,

 Any update on this?

 I need to address the issues Mauro pointed out, prior to the merge.
 Will address the issues during the next week. Have been a bit busy
 restoring the system at my end after a crash.

 Regards,

 Manu
--
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: Upstreaming SAA716x driver to the media_tree

2014-02-11 Thread Luis Alves
Hi,

Any update on this?

Thanks,
Luis

On Wed, Jan 22, 2014 at 3:26 PM, Manu Abraham abraham.m...@gmail.com wrote:
 On Wed, Jan 22, 2014 at 3:29 AM, Steven Toth st...@kernellabs.com wrote:
 On Mon, Jan 13, 2014 at 10:35 PM, Manu Abraham abraham.m...@gmail.com 
 wrote:
 On Tue, Jan 14, 2014 at 12:20 AM, Steven Toth st...@kernellabs.com wrote:
 Manu, do you see any inconvenience in sending your driver to the
 linux_media tree?
 I'm available to place some effort on this task.


 I can push the 716x driver and whatever additional changes that I have
 later on this weekend, if that's okay with you.

 I never saw a push.

 Spliiting and cleaning up the patches took up more time than expected.
 Please wait a few days.

 Any news on this?


 I just pushed out a large chunk of the changes. There are a few
 dependencies that need to be resolved with the rebased tree.
--
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/8] rtl2832: Fix deadlock on i2c mux select function.

2014-02-08 Thread Luis Alves
From: Luis Alves lja...@gmail.com

Signed-off-by: Luis Alves lja...@gmail.com
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c
b/drivers/media/dvb-frontends/rtl2832.c
index c0366a8..cfc5438 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -917,7 +917,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void
*mux_priv, u32 chan_id)
buf[0] = 0x00;
buf[1] = 0x01;
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
@@ -930,7 +930,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void
*mux_priv, u32 chan_id)
else
buf[1] = 0x10; /* close */
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
-- 
1.8.5.3


--
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


Upstreaming SAA716x driver to the media_tree

2014-01-07 Thread Luis Alves
Hi,

I'm finishing a new frontend driver for one of my dvb cards, but the
pcie bridge uses the (cursed) saa716x.
As far as I know the progress to upstream Manu's driver to the
media_tree has stalled.

In CC I've placed some of the people that I found working on it
lately, supporting a few dvb cards.

It would be good if we could gather everything in one place and send a
few patchs to get this upstreamed for once...

Manu, do you see any inconvenience in sending your driver to the
linux_media tree?
I'm available to place some effort on this task.

Regards,
Luis Alves
--
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: Upstreaming SAA716x driver to the media_tree

2014-01-07 Thread Luis Alves
Hi Manu,

That would be great.
Let me know if you need a hand!

Regards,
Luis


On Tue, Jan 7, 2014 at 1:10 PM, Manu Abraham abraham.m...@gmail.com wrote:
 Hi Luis,


 On Tue, Jan 7, 2014 at 5:28 PM, Luis Alves lja...@gmail.com wrote:
 Hi,

 I'm finishing a new frontend driver for one of my dvb cards, but the
 pcie bridge uses the (cursed) saa716x.
 As far as I know the progress to upstream Manu's driver to the
 media_tree has stalled.

 In CC I've placed some of the people that I found working on it
 lately, supporting a few dvb cards.

 It would be good if we could gather everything in one place and send a
 few patchs to get this upstreamed for once...

 Manu, do you see any inconvenience in sending your driver to the
 linux_media tree?
 I'm available to place some effort on this task.


 I can push the 716x driver and whatever additional changes that I have
 later on this weekend, if that's okay with you.


 Regards,

 Manu
--
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: Upstreaming SAA716x driver to the media_tree

2014-01-07 Thread Luis Alves
HI Andreas,

My initial commit is based on:
http://powarman.dyndns.org/hgwebdir.cgi/v4l-dvb-saa716x/
(I think it's your repo with some commits from Soeren Moch)

The difference to my working area is that I have the driver placed in
drivers/media/pci/saa716x (instead of
drivers/media/common/saa716x) and everything is rebased on the
latest media_tree.
On top of that I just have 2 commits: one to be able to build FF cards
and another to fix some i2c issues.

You can check my repo here:
https://github.com/ljalves/linux_media/commits/saa716x

Regards,
Luis


On Tue, Jan 7, 2014 at 4:12 PM, Andreas Regel andreas.re...@gmx.de wrote:
 Hi Luis,

 Am 07.01.2014 12:58, schrieb Luis Alves:
 Hi,

 I'm finishing a new frontend driver for one of my dvb cards, but the
 pcie bridge uses the (cursed) saa716x.
 As far as I know the progress to upstream Manu's driver to the
 media_tree has stalled.

 In CC I've placed some of the people that I found working on it
 lately, supporting a few dvb cards.

 It would be good if we could gather everything in one place and send a
 few patchs to get this upstreamed for once...

 Manu, do you see any inconvenience in sending your driver to the
 linux_media tree?
 I'm available to place some effort on this task.

 which repository of the saa761x is your work based on?

 Regards,
 Andreas

--
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: Upstreaming SAA716x driver to the media_tree

2014-01-07 Thread Luis Alves
Hi Konstantin,
(here we go again...)

What the hell are you talking about? I didn't submit any I2C patch.
This email is just about Manu sending his SAA716x driver to the media_tree.

And where do you see any saa716x_input.[c|h] in my repo?

Anyway, since you asked I took some pics:
https://plus.google.com/photos/105602732859464871628/albums/5966247612074668305?authkey=CN3jl9mWhrDhQg
(SDA_HOLD setting in the comment)

For SDA_HOLD = 0x19 the next clock rising edge is really close to the
data line release.
Even 0x14 is too close, so I will use a smaller value so maybe 0x10 is
fine for the 400kHZ clk speed.

And I do have a TBS card that doesn't work with Manu default setting (0x19).


Your email besides being offending, is empty.
If someone's actions hurt the community are your own.

Not going to enter in personal discussions in here nor going to waist
time answering to anymore of your offending emails.
If you want to exchange some thoughts, mail me personally.

Regards,
Luis







On Tue, Jan 7, 2014 at 5:31 PM, Konstantin Dimitrov
kosio.dimit...@gmail.com wrote:
 Luis,

 can you explain to us all here how exactly you came up to those
 particular I2C fixes:

 https://github.com/ljalves/linux_media/commit/be7cd1ff82cc20578b805ad508d089f818ae726d

 because essentially they are the same as what i did years ago -
 included as source code in drivers i made for some TBS cards (source
 code is available all over online) or we just have the exact same case
 with you as before:

 http://www.spinics.net/lists/linux-media/msg65888.html

 http://www.spinics.net/lists/linux-media/msg65889.html

 and you're continue to taking credit for patches i made or basically
 stealing them.

 if they were some trivial patches i won't mind, but even they are
 small, they are nothing like trivial.

 so, i believe you will have really hard time to explain your I2C
 fixes, because for example the SDA hold time value of 0x14 is needed
 for only one particular SAA716x-based card (other such cards can work
 with wide range of SDA hold time settings) and i'm sure you don't know
 that card and cannot cite its model or any technical details why
 that's needed, because you don't have it, as well it takes quite an
 effort and good knowledge of I2C signaling with oscilloscope to figure
 out that value, as well that exactly that value needs changing.

 why you didn't use for example 0x16 or 0x13 for SDA hold time in
 your I2C patch?!

 so, one time, like the previous time, excuse that you just didn't know
 who the author of that work is may fly, but second time, especially
 considering that the SAA716x code base from which i'm sure you took
 (not to use stole) those settings contains my name as copyright,
 because i actually added to that code base new code i developed from
 scratch like for example saa716x_input.[c|h], is another thing you
 cannot explain.

 so, i was waiting Manu to upstream his SAA716x driver code some day
 and then submit the improvements i made to it. yet again you're trying
 to take that from me and again, conveniently you included many people
 on CC, but not me.

 in my opinion what you're doing is not right, because that patch is
 not clean-room reverse-engineering, you just took those changes from
 another open-source base and if nothing else it's at least common
 courtesy in open-source community when you didn't make them to not
 submit them as your patches.

 i also think with your actions you're actually hurting the community,
 because people like me, that do actually have the technical
 understanding and can help and contribute further improvements are
 driven away from the community, because
 effectively the community accepting behavior like yours is encouraging
 code stealing!!

 --konstantin

 On Tue, Jan 7, 2014 at 6:33 PM, Luis Alves lja...@gmail.com wrote:
 HI Andreas,

 My initial commit is based on:
 http://powarman.dyndns.org/hgwebdir.cgi/v4l-dvb-saa716x/
 (I think it's your repo with some commits from Soeren Moch)

 The difference to my working area is that I have the driver placed in
 drivers/media/pci/saa716x (instead of
 drivers/media/common/saa716x) and everything is rebased on the
 latest media_tree.
 On top of that I just have 2 commits: one to be able to build FF cards
 and another to fix some i2c issues.

 You can check my repo here:
 https://github.com/ljalves/linux_media/commits/saa716x

 Regards,
 Luis


 On Tue, Jan 7, 2014 at 4:12 PM, Andreas Regel andreas.re...@gmx.de wrote:
 Hi Luis,

 Am 07.01.2014 12:58, schrieb Luis Alves:
 Hi,

 I'm finishing a new frontend driver for one of my dvb cards, but the
 pcie bridge uses the (cursed) saa716x.
 As far as I know the progress to upstream Manu's driver to the
 media_tree has stalled.

 In CC I've placed some of the people that I found working on it
 lately, supporting a few dvb cards.

 It would be good if we could gather everything in one place and send a
 few patchs to get this upstreamed for once...

 Manu, do you see any inconvenience

[PATCH 1/2] cx24117: Add complete demod command list.

2013-11-12 Thread Luis Alves
Hi,

This patch adds the complete list of all the commands known for the cx24117 
demod.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/cx24117.c | 98 +--
 1 file changed, 58 insertions(+), 40 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
index 476b422..a6fe1af 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -135,15 +135,33 @@
 
 
 enum cmds {
-   CMD_SET_VCO = 0x10,
-   CMD_TUNEREQUEST = 0x11,
-   CMD_MPEGCONFIG  = 0x13,
-   CMD_TUNERINIT   = 0x14,
-   CMD_LNBSEND = 0x21, /* Formerly CMD_SEND_DISEQC */
-   CMD_LNBDCLEVEL  = 0x22,
-   CMD_SET_TONE= 0x23,
-   CMD_UPDFWVERS   = 0x35,
-   CMD_TUNERSLEEP  = 0x36,
+   CMD_SET_VCOFREQ= 0x10,
+   CMD_TUNEREQUEST= 0x11,
+   CMD_GLOBAL_MPEGCFG = 0x13,
+   CMD_MPEGCFG= 0x14,
+   CMD_TUNERINIT  = 0x15,
+   CMD_GET_SRATE  = 0x18,
+   CMD_SET_GOLDCODE   = 0x19,
+   CMD_GET_AGCACC = 0x1a,
+   CMD_DEMODINIT  = 0x1b,
+   CMD_GETCTLACC  = 0x1c,
+
+   CMD_LNBCONFIG  = 0x20,
+   CMD_LNBSEND= 0x21,
+   CMD_LNBDCLEVEL = 0x22,
+   CMD_LNBPCBCONFIG   = 0x23,
+   CMD_LNBSENDTONEBST = 0x24,
+   CMD_LNBUPDREPLY= 0x25,
+
+   CMD_SET_GPIOMODE   = 0x30,
+   CMD_SET_GPIOEN = 0x31,
+   CMD_SET_GPIODIR= 0x32,
+   CMD_SET_GPIOOUT= 0x33,
+   CMD_ENABLERSCORR   = 0x34,
+   CMD_FWVERSION  = 0x35,
+   CMD_SET_SLEEPMODE  = 0x36,
+   CMD_BERCTRL= 0x3c,
+   CMD_EVENTCTRL  = 0x3d,
 };
 
 static LIST_HEAD(hybrid_tuner_instance_list);
@@ -619,8 +637,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
cx24117_writereg(state, 0xf7, 0x0c);
cx24117_writereg(state, 0xe0, 0x00);
 
-   /* CMD 1B */
-   cmd.args[0] = 0x1b;
+   /* Init demodulator */
+   cmd.args[0] = CMD_DEMODINIT;
cmd.args[1] = 0x00;
cmd.args[2] = 0x01;
cmd.args[3] = 0x00;
@@ -629,8 +647,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
if (ret != 0)
goto error;
 
-   /* CMD 10 */
-   cmd.args[0] = CMD_SET_VCO;
+   /* Set VCO frequency */
+   cmd.args[0] = CMD_SET_VCOFREQ;
cmd.args[1] = 0x06;
cmd.args[2] = 0x2b;
cmd.args[3] = 0xd8;
@@ -648,8 +666,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
if (ret != 0)
goto error;
 
-   /* CMD 15 */
-   cmd.args[0] = 0x15;
+   /* Tuner init */
+   cmd.args[0] = CMD_TUNERINIT;
cmd.args[1] = 0x00;
cmd.args[2] = 0x01;
cmd.args[3] = 0x00;
@@ -667,8 +685,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
if (ret != 0)
goto error;
 
-   /* CMD 13 */
-   cmd.args[0] = CMD_MPEGCONFIG;
+   /* Global MPEG config */
+   cmd.args[0] = CMD_GLOBAL_MPEGCFG;
cmd.args[1] = 0x00;
cmd.args[2] = 0x00;
cmd.args[3] = 0x00;
@@ -679,9 +697,9 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
if (ret != 0)
goto error;
 
-   /* CMD 14 */
+   /* MPEG config for each demod */
for (i = 0; i  2; i++) {
-   cmd.args[0] = CMD_TUNERINIT;
+   cmd.args[0] = CMD_MPEGCFG;
cmd.args[1] = (u8) i;
cmd.args[2] = 0x00;
cmd.args[3] = 0x05;
@@ -699,8 +717,8 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
cx24117_writereg(state, 0xcf, 0x00);
cx24117_writereg(state, 0xe5, 0x04);
 
-   /* Firmware CMD 35: Get firmware version */
-   cmd.args[0] = CMD_UPDFWVERS;
+   /* Get firmware version */
+   cmd.args[0] = CMD_FWVERSION;
cmd.len = 2;
for (i = 0; i  4; i++) {
cmd.args[1] = i;
@@ -779,8 +797,8 @@ static int cx24117_read_signal_strength(struct dvb_frontend 
*fe,
u8 reg = (state-demod == 0) ?
CX24117_REG_SSTATUS0 : CX24117_REG_SSTATUS1;
 
-   /* Firmware CMD 1A */
-   cmd.args[0] = 0x1a;
+   /* Read AGC accumulator register */
+   cmd.args[0] = CMD_GET_AGCACC;
cmd.args[1] = (u8) state-demod;
cmd.len = 2;
ret = cx24117_cmd_execute(fe, cmd);
@@ -899,8 +917,8 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
voltage == SEC_VOLTAGE_18 ? SEC_VOLTAGE_18 :
SEC_VOLTAGE_OFF);
 
-   /* CMD 32 */
-   cmd.args[0] = 0x32;
+   /* Set GPIO direction */
+   cmd.args[0] = CMD_SET_GPIODIR;
cmd.args[1] = reg;
cmd.args[2] = reg;
cmd.len = 3;
@@ -910,8 +928,8 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
 
if ((voltage == SEC_VOLTAGE_13) ||
(voltage == SEC_VOLTAGE_18)) {
-   /* CMD

[PATCH 2/2] cx24117: Fix LNB set_voltage function.

2013-11-12 Thread Luis Alves
Hi,
This patch should fix/enhance the set_voltage function for the cx24117 demod.

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/cx24117.c | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
index a6fe1af..68f768a 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -917,22 +917,15 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
voltage == SEC_VOLTAGE_18 ? SEC_VOLTAGE_18 :
SEC_VOLTAGE_OFF);
 
-   /* Set GPIO direction */
-   cmd.args[0] = CMD_SET_GPIODIR;
-   cmd.args[1] = reg;
-   cmd.args[2] = reg;
+   /* Prepare a set GPIO logic level CMD */
+   cmd.args[0] = CMD_SET_GPIOOUT;
+   cmd.args[2] = reg; /* mask */
cmd.len = 3;
-   ret = cx24117_cmd_execute(fe, cmd);
-   if (ret)
-   return ret;
 
if ((voltage == SEC_VOLTAGE_13) ||
(voltage == SEC_VOLTAGE_18)) {
-   /* Set GPIO logic level */
-   cmd.args[0] = CMD_SET_GPIOOUT;
+   /* power on LNB */
cmd.args[1] = reg;
-   cmd.args[2] = reg;
-   cmd.len = 3;
ret = cx24117_cmd_execute(fe, cmd);
if (ret != 0)
return ret;
@@ -949,17 +942,17 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
cmd.args[1] = state-demod ? 0 : 1;
cmd.args[2] = (voltage == SEC_VOLTAGE_18 ? 0x01 : 0x00);
cmd.len = 3;
+   ret = cx24117_cmd_execute(fe, cmd);
 
/* Min delay time before DiSEqC send */
msleep(20);
} else {
-   cmd.args[0] = CMD_SET_GPIOOUT;
+   /* power off LNB */
cmd.args[1] = 0x00;
-   cmd.args[2] = reg;
-   cmd.len = 3;
+   ret = cx24117_cmd_execute(fe, cmd);
}
 
-   return cx24117_cmd_execute(fe, cmd);
+   return ret;
 }
 
 static int cx24117_set_tone(struct dvb_frontend *fe,
@@ -1277,6 +1270,16 @@ static int cx24117_initfe(struct dvb_frontend *fe)
cmd.args[2] = CX24117_OCC;
cmd.len = 3;
ret = cx24117_cmd_execute_nolock(fe, cmd);
+   if (ret != 0)
+   goto exit;
+
+   /* Set GPIO direction */
+   /* Set as output - controls LNB power on/off */
+   cmd.args[0] = CMD_SET_GPIODIR;
+   cmd.args[1] = 0x30;
+   cmd.args[2] = 0x30;
+   cmd.len = 3;
+   ret = cx24117_cmd_execute_nolock(fe, cmd);
 
 exit:
mutex_unlock(state-priv-fe_lock);
-- 
1.8.3.2

--
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] cx24117: Fix/enhance set_voltage function.

2013-10-12 Thread Luis Alves
Hi,

On this patch:
Added a few defines to describe what every constant in the set_voltage function.
Added the description to the CX24117 GPIO control commands.
Moved the GPIODIR setup to the initfe function.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/cx24117.c |   60 +
 1 file changed, 38 insertions(+), 22 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
index 476b422..3c7523b 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -129,6 +129,14 @@
 #define CX24117_DISEQC_MINI_A (0)
 #define CX24117_DISEQC_MINI_B (1)
 
+/* LNB voltage enable GPIO pins */
+#define CX24117_DEMOD0_LNBDCPIN (1  4)
+#define CX24117_DEMOD1_LNBDCPIN (1  5)
+
+/* Demod to LNB mapping */
+#define CX24117_DEMOD0_LNB (1)
+#define CX24117_DEMOD1_LNB (0)
+
 
 #define CX24117_PNE(0) /* 0 disabled / 2 enabled */
 #define CX24117_OCC(1) /* 0 disabled / 1 enabled */
@@ -142,6 +150,8 @@ enum cmds {
CMD_LNBSEND = 0x21, /* Formerly CMD_SEND_DISEQC */
CMD_LNBDCLEVEL  = 0x22,
CMD_SET_TONE= 0x23,
+   CMD_GPIODIR = 0x32,
+   CMD_GPIOOUT = 0x33,
CMD_UPDFWVERS   = 0x35,
CMD_TUNERSLEEP  = 0x36,
 };
@@ -891,7 +901,8 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
struct cx24117_state *state = fe-demodulator_priv;
struct cx24117_cmd cmd;
int ret;
-   u8 reg = (state-demod == 0) ? 0x10 : 0x20;
+   u8 pin = (state-demod == 0) ?
+   CX24117_DEMOD0_LNBDCPIN : CX24117_DEMOD1_LNBDCPIN;
 
dev_dbg(state-priv-i2c-dev, %s() demod%d %s\n,
__func__, state-demod,
@@ -899,26 +910,18 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
voltage == SEC_VOLTAGE_18 ? SEC_VOLTAGE_18 :
SEC_VOLTAGE_OFF);
 
-   /* CMD 32 */
-   cmd.args[0] = 0x32;
-   cmd.args[1] = reg;
-   cmd.args[2] = reg;
-   cmd.len = 3;
-   ret = cx24117_cmd_execute(fe, cmd);
-   if (ret)
-   return ret;
-
if ((voltage == SEC_VOLTAGE_13) ||
(voltage == SEC_VOLTAGE_18)) {
-   /* CMD 33 */
-   cmd.args[0] = 0x33;
-   cmd.args[1] = reg;
-   cmd.args[2] = reg;
+   /* Turn on LNB DC voltage */
+   cmd.args[0] = CMD_GPIOOUT;
+   cmd.args[1] = pin;  /* level */
+   cmd.args[2] = pin;  /* mask */
cmd.len = 3;
ret = cx24117_cmd_execute(fe, cmd);
if (ret != 0)
return ret;
 
+   /* Wait for any pending diseqc TX */
ret = cx24117_wait_for_lnb(fe);
if (ret != 0)
return ret;
@@ -926,22 +929,25 @@ static int cx24117_set_voltage(struct dvb_frontend *fe,
/* Wait for voltage/min repeat delay */
msleep(100);
 
-   /* CMD 22 - CMD_LNBDCLEVEL */
+   /* Set DC level (0=13V 1=18V) */
cmd.args[0] = CMD_LNBDCLEVEL;
-   cmd.args[1] = state-demod ? 0 : 1;
-   cmd.args[2] = (voltage == SEC_VOLTAGE_18 ? 0x01 : 0x00);
+   cmd.args[1] = (state-demod == 0) ?
+   CX24117_DEMOD0_LNB : CX24117_DEMOD1_LNB;
+   cmd.args[2] = (voltage == SEC_VOLTAGE_18 ? 1 : 0);
cmd.len = 3;
+   ret = cx24117_cmd_execute(fe, cmd);
 
/* Min delay time before DiSEqC send */
msleep(20);
} else {
-   cmd.args[0] = 0x33;
-   cmd.args[1] = 0x00;
-   cmd.args[2] = reg;
+   /* Turn off LNB DC voltage */
+   cmd.args[0] = CMD_GPIOOUT;
+   cmd.args[1] = 0;/* level */
+   cmd.args[2] = pin;  /* mask */
cmd.len = 3;
+   ret = cx24117_cmd_execute(fe, cmd);
}
-
-   return cx24117_cmd_execute(fe, cmd);
+   return ret;
 }
 
 static int cx24117_set_tone(struct dvb_frontend *fe,
@@ -1260,6 +1266,16 @@ static int cx24117_initfe(struct dvb_frontend *fe)
cmd.args[2] = CX24117_OCC;
cmd.len = 3;
ret = cx24117_cmd_execute_nolock(fe, cmd);
+   if (ret != 0)
+   goto exit;
+
+   /* Setup cx24117 GPIO direction */
+   /* These pins turn on/off LNB DC voltage */
+   cmd.args[0] = CMD_GPIODIR;
+   cmd.args[1] = CX24117_DEMOD0_LNBDCPIN | CX24117_DEMOD1_LNBDCPIN;
+   cmd.args[2] = CX24117_DEMOD0_LNBDCPIN | CX24117_DEMOD1_LNBDCPIN;
+   cmd.len = 3;
+   ret = cx24117_cmd_execute_nolock(fe, cmd);
 
 exit:
mutex_unlock(state-priv-fe_lock);
-- 
1.7.9.5

--
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

[PATCH] cx24117: Prevent mutex to be stuck on locked state if FE init fails.

2013-10-04 Thread Luis Alves
Hi,
This patch will fix the situation where the mutex was left in a locked state if 
for some reason the FE init failed.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/cx24117.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
index 9087309..476b422 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -1238,11 +1238,11 @@ static int cx24117_initfe(struct dvb_frontend *fe)
cmd.len = 3;
ret = cx24117_cmd_execute_nolock(fe, cmd);
if (ret != 0)
-   return ret;
+   goto exit;
 
ret = cx24117_diseqc_init(fe);
if (ret != 0)
-   return ret;
+   goto exit;
 
/* CMD 3C */
cmd.args[0] = 0x3c;
@@ -1252,7 +1252,7 @@ static int cx24117_initfe(struct dvb_frontend *fe)
cmd.len = 4;
ret = cx24117_cmd_execute_nolock(fe, cmd);
if (ret != 0)
-   return ret;
+   goto exit;
 
/* CMD 34 */
cmd.args[0] = 0x34;
@@ -1260,9 +1260,8 @@ static int cx24117_initfe(struct dvb_frontend *fe)
cmd.args[2] = CX24117_OCC;
cmd.len = 3;
ret = cx24117_cmd_execute_nolock(fe, cmd);
-   if (ret != 0)
-   return ret;
 
+exit:
mutex_unlock(state-priv-fe_lock);
 
return ret;
-- 
1.7.9.5

--
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/2] cx24117: Removed from cx23885 the no longer needed frontend pointer from the dvb_attach function.

2013-10-02 Thread Luis Alves
cx23885 changes: to be used against mkrufky/cx24117 branch

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-dvb.c |   11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 34120db..0549205 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1058,20 +1058,13 @@ static int dvb_register(struct cx23885_tsport *port)
case 1:
fe0-dvb.frontend = dvb_attach(cx24117_attach,
tbs_cx24117_config,
-   i2c_bus-i2c_adap, NULL);
+   i2c_bus-i2c_adap);
break;
/* PORT C */
case 2:
-   /* use fe1 pointer as temporary holder */
-   /* for the first frontend */
-   fe1 = videobuf_dvb_get_frontend(
-   port-dev-ts1.frontends, 1);
-
fe0-dvb.frontend = dvb_attach(cx24117_attach,
tbs_cx24117_config,
-   i2c_bus-i2c_adap, fe1-dvb.frontend);
-   /* we're done, so clear fe1 pointer */
-   fe1 = NULL;
+   i2c_bus-i2c_adap);
break;
}
break;
-- 
1.7.9.5

--
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/2] cx24117: Changed the way common data struct was being passed to the demod.

2013-10-02 Thread Luis Alves
Hi Mike,

It's done (also tested and apparently working good)!

I didn't know if two separated patches were needed (one for the cx24117 and the 
other for the cx23885) but I've splited it.
As you pointed out, this series of patches are to be used against your cx24117 
branch.

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/cx24117.c |   72 +++--
 drivers/media/dvb-frontends/cx24117.h |4 +-
 2 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
index 3b63913..9087309 100644
--- a/drivers/media/dvb-frontends/cx24117.c
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -31,6 +31,7 @@
 #include linux/init.h
 #include linux/firmware.h
 
+#include tuner-i2c.h
 #include dvb_frontend.h
 #include cx24117.h
 
@@ -145,6 +146,9 @@ enum cmds {
CMD_TUNERSLEEP  = 0x36,
 };
 
+static LIST_HEAD(hybrid_tuner_instance_list);
+static DEFINE_MUTEX(cx24117_list_mutex);
+
 /* The Demod/Tuner can't easily provide these, we cache them */
 struct cx24117_tuning {
u32 frequency;
@@ -176,9 +180,11 @@ struct cx24117_priv {
u8 demod_address;
struct i2c_adapter *i2c;
u8 skip_fw_load;
-
struct mutex fe_lock;
-   atomic_t fe_nr;
+
+   /* Used for sharing this struct between demods */
+   struct tuner_i2c_props i2c_props;
+   struct list_head hybrid_tuner_instance_list;
 };
 
 /* one per each fe */
@@ -536,7 +542,7 @@ static int cx24117_load_firmware(struct dvb_frontend *fe,
dev_dbg(state-priv-i2c-dev,
%s() demod%d FW is %zu bytes (%02x %02x .. %02x %02x)\n,
__func__, state-demod, fw-size, fw-data[0], fw-data[1],
-   fw-data[fw-size-2], fw-data[fw-size-1]);
+   fw-data[fw-size - 2], fw-data[fw-size - 1]);
 
cx24117_writereg(state, 0xea, 0x00);
cx24117_writereg(state, 0xea, 0x01);
@@ -1116,37 +1122,64 @@ static int cx24117_diseqc_send_burst(struct 
dvb_frontend *fe,
return 0;
 }
 
+static int cx24117_get_priv(struct cx24117_priv **priv,
+   struct i2c_adapter *i2c, u8 client_address)
+{
+   int ret;
+
+   mutex_lock(cx24117_list_mutex);
+   ret = hybrid_tuner_request_state(struct cx24117_priv, (*priv),
+   hybrid_tuner_instance_list, i2c, client_address, cx24117);
+   mutex_unlock(cx24117_list_mutex);
+
+   return ret;
+}
+
+static void cx24117_release_priv(struct cx24117_priv *priv)
+{
+   mutex_lock(cx24117_list_mutex);
+   if (priv != NULL)
+   hybrid_tuner_release_state(priv);
+   mutex_unlock(cx24117_list_mutex);
+}
+
 static void cx24117_release(struct dvb_frontend *fe)
 {
struct cx24117_state *state = fe-demodulator_priv;
dev_dbg(state-priv-i2c-dev, %s demod%d\n,
__func__, state-demod);
-   if (!atomic_dec_and_test(state-priv-fe_nr))
-   kfree(state-priv);
+   cx24117_release_priv(state-priv);
kfree(state);
 }
 
 static struct dvb_frontend_ops cx24117_ops;
 
 struct dvb_frontend *cx24117_attach(const struct cx24117_config *config,
-   struct i2c_adapter *i2c, struct dvb_frontend *fe)
+   struct i2c_adapter *i2c)
 {
struct cx24117_state *state = NULL;
struct cx24117_priv *priv = NULL;
int demod = 0;
 
-   /* first frontend attaching */
-   /* allocate shared priv struct */
-   if (fe == NULL) {
-   priv = kzalloc(sizeof(struct cx24117_priv), GFP_KERNEL);
-   if (priv == NULL)
-   goto error1;
+   /* get the common data struct for both demods */
+   demod = cx24117_get_priv(priv, i2c, config-demod_address);
+
+   switch (demod) {
+   case 0:
+   dev_err(state-priv-i2c-dev,
+   %s: Error attaching frontend %d\n,
+   KBUILD_MODNAME, demod);
+   goto error1;
+   break;
+   case 1:
+   /* new priv instance */
priv-i2c = i2c;
priv-demod_address = config-demod_address;
mutex_init(priv-fe_lock);
-   } else {
-   demod = 1;
-   priv = ((struct cx24117_state *) fe-demodulator_priv)-priv;
+   break;
+   default:
+   /* existing priv instance */
+   break;
}
 
/* allocate memory for the internal state */
@@ -1154,7 +1187,7 @@ struct dvb_frontend *cx24117_attach(const struct 
cx24117_config *config,
if (state == NULL)
goto error2;
 
-   state-demod = demod;
+   state-demod = demod - 1;
state-priv = priv;
 
/* test i2c bus for ack */
@@ -1163,12 +1196,9 @@ struct dvb_frontend *cx24117_attach(const struct 
cx24117_config *config,
goto error3;
}
 
-   /* nr of frontends using the module */
-   atomic_inc(priv-fe_nr

Re: [PATCH 1/2] cx24117: Changed the way common data struct was being passed to the demod.

2013-10-02 Thread Luis Alves
I Antti,

I think it's safe to use because the hybrid_tuner_request_state will
make sure that the i2c_adapter_id is the same for both demods.

On the other hand, I think I need to re-send this changes as one single file.

Regards,
Luis


2013/10/2 Antti Palosaari cr...@iki.fi:
 On 03.10.2013 01:09, Luis Alves wrote:

 Hi Mike,

 It's done (also tested and apparently working good)!

 I didn't know if two separated patches were needed (one for the cx24117
 and the other for the cx23885) but I've splited it.
 As you pointed out, this series of patches are to be used against your
 cx24117 branch.

 Regards,
 Luis

 Signed-off-by: Luis Alves lja...@gmail.com


 I am not very familiar how that hybrid tuner request works, but it seems to
 be based of driver global list.

 I wonder if that works as it should. What happens when you have two cx24117
 demods equipped, having total of 4 frontends? Does it block access only for
 one demod at the time (as it should block only one per chip)?

 regards
 Antti



 ---
   drivers/media/dvb-frontends/cx24117.c |   72
 +++--
   drivers/media/dvb-frontends/cx24117.h |4 +-
   2 files changed, 53 insertions(+), 23 deletions(-)

 diff --git a/drivers/media/dvb-frontends/cx24117.c
 b/drivers/media/dvb-frontends/cx24117.c
 index 3b63913..9087309 100644
 --- a/drivers/media/dvb-frontends/cx24117.c
 +++ b/drivers/media/dvb-frontends/cx24117.c
 @@ -31,6 +31,7 @@
   #include linux/init.h
   #include linux/firmware.h

 +#include tuner-i2c.h
   #include dvb_frontend.h
   #include cx24117.h

 @@ -145,6 +146,9 @@ enum cmds {
 CMD_TUNERSLEEP  = 0x36,
   };

 +static LIST_HEAD(hybrid_tuner_instance_list);
 +static DEFINE_MUTEX(cx24117_list_mutex);
 +
   /* The Demod/Tuner can't easily provide these, we cache them */
   struct cx24117_tuning {
 u32 frequency;
 @@ -176,9 +180,11 @@ struct cx24117_priv {
 u8 demod_address;
 struct i2c_adapter *i2c;
 u8 skip_fw_load;
 -
 struct mutex fe_lock;
 -   atomic_t fe_nr;
 +
 +   /* Used for sharing this struct between demods */
 +   struct tuner_i2c_props i2c_props;
 +   struct list_head hybrid_tuner_instance_list;
   };

   /* one per each fe */
 @@ -536,7 +542,7 @@ static int cx24117_load_firmware(struct dvb_frontend
 *fe,
 dev_dbg(state-priv-i2c-dev,
 %s() demod%d FW is %zu bytes (%02x %02x .. %02x %02x)\n,
 __func__, state-demod, fw-size, fw-data[0],
 fw-data[1],
 -   fw-data[fw-size-2], fw-data[fw-size-1]);
 +   fw-data[fw-size - 2], fw-data[fw-size - 1]);

 cx24117_writereg(state, 0xea, 0x00);
 cx24117_writereg(state, 0xea, 0x01);
 @@ -1116,37 +1122,64 @@ static int cx24117_diseqc_send_burst(struct
 dvb_frontend *fe,
 return 0;
   }

 +static int cx24117_get_priv(struct cx24117_priv **priv,
 +   struct i2c_adapter *i2c, u8 client_address)
 +{
 +   int ret;
 +
 +   mutex_lock(cx24117_list_mutex);
 +   ret = hybrid_tuner_request_state(struct cx24117_priv, (*priv),
 +   hybrid_tuner_instance_list, i2c, client_address,
 cx24117);
 +   mutex_unlock(cx24117_list_mutex);
 +
 +   return ret;
 +}
 +
 +static void cx24117_release_priv(struct cx24117_priv *priv)
 +{
 +   mutex_lock(cx24117_list_mutex);
 +   if (priv != NULL)
 +   hybrid_tuner_release_state(priv);
 +   mutex_unlock(cx24117_list_mutex);
 +}
 +
   static void cx24117_release(struct dvb_frontend *fe)
   {
 struct cx24117_state *state = fe-demodulator_priv;
 dev_dbg(state-priv-i2c-dev, %s demod%d\n,
 __func__, state-demod);
 -   if (!atomic_dec_and_test(state-priv-fe_nr))
 -   kfree(state-priv);
 +   cx24117_release_priv(state-priv);
 kfree(state);
   }

   static struct dvb_frontend_ops cx24117_ops;

   struct dvb_frontend *cx24117_attach(const struct cx24117_config *config,
 -   struct i2c_adapter *i2c, struct dvb_frontend *fe)
 +   struct i2c_adapter *i2c)
   {
 struct cx24117_state *state = NULL;
 struct cx24117_priv *priv = NULL;
 int demod = 0;

 -   /* first frontend attaching */
 -   /* allocate shared priv struct */
 -   if (fe == NULL) {
 -   priv = kzalloc(sizeof(struct cx24117_priv), GFP_KERNEL);
 -   if (priv == NULL)
 -   goto error1;
 +   /* get the common data struct for both demods */
 +   demod = cx24117_get_priv(priv, i2c, config-demod_address);
 +
 +   switch (demod) {
 +   case 0:
 +   dev_err(state-priv-i2c-dev,
 +   %s: Error attaching frontend %d\n,
 +   KBUILD_MODNAME, demod);
 +   goto error1;
 +   break;
 +   case 1:
 +   /* new priv instance */
 priv-i2c = i2c;
 priv-demod_address = config-demod_address;
 mutex_init(priv-fe_lock

[PATCH] cx23885[v3]: Fix interrupt storm when enabling IR receiver.

2013-07-24 Thread Luis Alves
Hi,

New patch for this issue. Changes:
 - Added flatiron readreg and writereg functions prototypes (new header file).
 - Modified the av work handler to preserve all other register bits when dealing
   with the interrupt flag.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-av.c|   13 +
 drivers/media/pci/cx23885/cx23885-video.c |4 ++--
 drivers/media/pci/cx23885/cx23885-video.h |   28 
 3 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/pci/cx23885/cx23885-video.h

diff --git a/drivers/media/pci/cx23885/cx23885-av.c 
b/drivers/media/pci/cx23885/cx23885-av.c
index e958a01..c443b7a 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -23,6 +23,7 @@
 
 #include cx23885.h
 #include cx23885-av.h
+#include cx23885-video.h
 
 void cx23885_av_work_handler(struct work_struct *work)
 {
@@ -32,5 +33,17 @@ void cx23885_av_work_handler(struct work_struct *work)
 
v4l2_subdev_call(dev-sd_cx25840, core, interrupt_service_routine,
 PCI_MSK_AV_CORE, handled);
+
+   /* Getting here with the interrupt not handled
+  then probbaly flatiron does have pending interrupts.
+   */
+   if (!handled) {
+   /* clear left and right adc channel interrupt request flag */
+   cx23885_flatiron_write(dev, 0x1f,
+   cx23885_flatiron_read(dev, 0x1f) | 0x80);
+   cx23885_flatiron_write(dev, 0x23,
+   cx23885_flatiron_read(dev, 0x23) | 0x80);
+   }
+
cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index e33d1a7..f4e7cef 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -417,7 +417,7 @@ static void res_free(struct cx23885_dev *dev, struct 
cx23885_fh *fh,
mutex_unlock(dev-lock);
 }
 
-static int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
+int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
 {
/* 8 bit registers, 8 bit values */
u8 buf[] = { reg, data };
@@ -428,7 +428,7 @@ static int cx23885_flatiron_write(struct cx23885_dev *dev, 
u8 reg, u8 data)
return i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
 }
 
-static u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
+u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
 {
/* 8 bit registers, 8 bit values */
int ret;
diff --git a/drivers/media/pci/cx23885/cx23885-video.h 
b/drivers/media/pci/cx23885/cx23885-video.h
new file mode 100644
index 000..6e88214
--- /dev/null
+++ b/drivers/media/pci/cx23885/cx23885-video.h
@@ -0,0 +1,28 @@
+/*
+ *  Driver for the Conexant CX23885/7/8 PCIe bridge
+ *
+ *  AV device support routines - non-input, non-vl42_subdev routines
+ *
+ *  Copyright (C) 2010  Andy Walls awa...@md.metrocast.net
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+#ifndef _CX23885_VIDEO_H_
+#define _CX23885_VIDEO_H_
+int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data);
+u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg);
+#endif
-- 
1.7.9.5

--
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] cx23885[v4]: Fix interrupt storm when enabling IR receiver.

2013-07-24 Thread Luis Alves
Hi,
Removed wrong description in the header file. Sorry about that...

New patch for this issue. Changes:
 - Added flatiron readreg and writereg functions prototypes (new header file).
 - Modified the av work handler to preserve all other register bits when dealing
   with the interrupt flag.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-av.c|   13 +
 drivers/media/pci/cx23885/cx23885-video.c |4 ++--
 drivers/media/pci/cx23885/cx23885-video.h |   26 ++
 3 files changed, 41 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/pci/cx23885/cx23885-video.h

diff --git a/drivers/media/pci/cx23885/cx23885-av.c 
b/drivers/media/pci/cx23885/cx23885-av.c
index e958a01..c443b7a 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -23,6 +23,7 @@
 
 #include cx23885.h
 #include cx23885-av.h
+#include cx23885-video.h
 
 void cx23885_av_work_handler(struct work_struct *work)
 {
@@ -32,5 +33,17 @@ void cx23885_av_work_handler(struct work_struct *work)
 
v4l2_subdev_call(dev-sd_cx25840, core, interrupt_service_routine,
 PCI_MSK_AV_CORE, handled);
+
+   /* Getting here with the interrupt not handled
+  then probbaly flatiron does have pending interrupts.
+   */
+   if (!handled) {
+   /* clear left and right adc channel interrupt request flag */
+   cx23885_flatiron_write(dev, 0x1f,
+   cx23885_flatiron_read(dev, 0x1f) | 0x80);
+   cx23885_flatiron_write(dev, 0x23,
+   cx23885_flatiron_read(dev, 0x23) | 0x80);
+   }
+
cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index e33d1a7..f4e7cef 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -417,7 +417,7 @@ static void res_free(struct cx23885_dev *dev, struct 
cx23885_fh *fh,
mutex_unlock(dev-lock);
 }
 
-static int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
+int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
 {
/* 8 bit registers, 8 bit values */
u8 buf[] = { reg, data };
@@ -428,7 +428,7 @@ static int cx23885_flatiron_write(struct cx23885_dev *dev, 
u8 reg, u8 data)
return i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
 }
 
-static u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
+u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
 {
/* 8 bit registers, 8 bit values */
int ret;
diff --git a/drivers/media/pci/cx23885/cx23885-video.h 
b/drivers/media/pci/cx23885/cx23885-video.h
new file mode 100644
index 000..c961a2b
--- /dev/null
+++ b/drivers/media/pci/cx23885/cx23885-video.h
@@ -0,0 +1,26 @@
+/*
+ *  Driver for the Conexant CX23885/7/8 PCIe bridge
+ *
+ *  Copyright (C) 2010  Andy Walls awa...@md.metrocast.net
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+#ifndef _CX23885_VIDEO_H_
+#define _CX23885_VIDEO_H_
+int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data);
+u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg);
+#endif
-- 
1.7.9.5

--
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/2] cx24117[v4]: Add new dvb-frontend.

2013-07-24 Thread Luis Alves
v4:
Patch order fixed.
Changed some msleep's to clear checkpatch warning.


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/Kconfig   |7 +
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/cx24117.c | 1621 +
 drivers/media/dvb-frontends/cx24117.h |   47 +
 4 files changed, 1676 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cx24117.c
 create mode 100644 drivers/media/dvb-frontends/cx24117.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 0e2ec6f..bddbab4 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -200,6 +200,13 @@ config DVB_CX24116
help
  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_CX24117
+   tristate Conexant CX24117 based
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ A Dual DVB-S/S2 tuner module. Say Y when you want to support this 
frontend.
+
 config DVB_SI21XX
tristate Silicon Labs SI21XX based
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index cebc0fa..f9cb43d 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_DVB_ATBM8830) += atbm8830.o
 obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o
 obj-$(CONFIG_DVB_AF9013) += af9013.o
 obj-$(CONFIG_DVB_CX24116) += cx24116.o
+obj-$(CONFIG_DVB_CX24117) += cx24117.o
 obj-$(CONFIG_DVB_SI21XX) += si21xx.o
 obj-$(CONFIG_DVB_STV0288) += stv0288.o
 obj-$(CONFIG_DVB_STB6000) += stb6000.o
diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
new file mode 100644
index 000..3b63913
--- /dev/null
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -0,0 +1,1621 @@
+/*
+Conexant cx24117/cx24132 - Dual DVBS/S2 Satellite demod/tuner driver
+
+Copyright (C) 2013 Luis Alves lja...@gmail.com
+   July, 6th 2013
+   First release based on cx24116 driver by:
+   Steven Toth and Georg Acher, Darron Broad, Igor Liplianin
+   Cards currently supported:
+   TBS6980 - Dual DVBS/S2 PCIe card
+   TBS6981 - Dual DVBS/S2 PCIe card
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include linux/slab.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/firmware.h
+
+#include dvb_frontend.h
+#include cx24117.h
+
+
+#define CX24117_DEFAULT_FIRMWARE dvb-fe-cx24117.fw
+#define CX24117_SEARCH_RANGE_KHZ 5000
+
+/* known registers */
+#define CX24117_REG_COMMAND  (0x00)  /* command buffer */
+#define CX24117_REG_EXECUTE  (0x1f)  /* execute command */
+
+#define CX24117_REG_FREQ3_0  (0x34)  /* frequency */
+#define CX24117_REG_FREQ2_0  (0x35)
+#define CX24117_REG_FREQ1_0  (0x36)
+#define CX24117_REG_STATE0   (0x39)
+#define CX24117_REG_SSTATUS0 (0x3a)  /* demod0 signal high / status */
+#define CX24117_REG_SIGNAL0  (0x3b)
+#define CX24117_REG_FREQ5_0  (0x3c)  /* +-freq */
+#define CX24117_REG_FREQ6_0  (0x3d)
+#define CX24117_REG_SRATE2_0 (0x3e)  /* +- 1000 * srate */
+#define CX24117_REG_SRATE1_0 (0x3f)
+#define CX24117_REG_QUALITY2_0   (0x40)
+#define CX24117_REG_QUALITY1_0   (0x41)
+
+#define CX24117_REG_BER4_0   (0x47)
+#define CX24117_REG_BER3_0   (0x48)
+#define CX24117_REG_BER2_0   (0x49)
+#define CX24117_REG_BER1_0   (0x4a)
+#define CX24117_REG_DVBS_UCB2_0  (0x4b)
+#define CX24117_REG_DVBS_UCB1_0  (0x4c)
+#define CX24117_REG_DVBS2_UCB2_0 (0x50)
+#define CX24117_REG_DVBS2_UCB1_0 (0x51)
+#define CX24117_REG_QSTATUS0 (0x93)
+#define CX24117_REG_CLKDIV0  (0xe6)
+#define CX24117_REG_RATEDIV0 (0xf0)
+
+
+#define CX24117_REG_FREQ3_1  (0x55)  /* frequency */
+#define CX24117_REG_FREQ2_1  (0x56)
+#define CX24117_REG_FREQ1_1  (0x57)
+#define CX24117_REG_STATE1   (0x5a)
+#define CX24117_REG_SSTATUS1 (0x5b)  /* demod1 signal high / status */
+#define CX24117_REG_SIGNAL1  (0x5c)
+#define CX24117_REG_FREQ5_1  (0x5d)  /* +- freq */
+#define CX24117_REG_FREQ4_1  (0x5e

[PATCH 2/2] cx24117[v4]: Add new dvb-frontend: add supported cards to cx23885. Currently tested with TBS6980 and TBS6981.

2013-07-24 Thread Luis Alves
v4:
Patch order fixed.
Changed some msleep's to clear checkpatch warnings.


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/Kconfig |1 +
 drivers/media/pci/cx23885/cx23885-cards.c |   67 +
 drivers/media/pci/cx23885/cx23885-dvb.c   |   31 +
 drivers/media/pci/cx23885/cx23885-input.c |   12 ++
 drivers/media/pci/cx23885/cx23885.h   |2 +
 5 files changed, 113 insertions(+)

diff --git a/drivers/media/pci/cx23885/Kconfig 
b/drivers/media/pci/cx23885/Kconfig
index b3688aa..91b2ed7 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -23,6 +23,7 @@ config VIDEO_CX23885
select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT
select DVB_CX24116 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_CX24117 if MEDIA_SUBDRV_AUTOSELECT
select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT
select DVB_DS3000 if MEDIA_SUBDRV_AUTOSELECT
select DVB_TS2020 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 7e923f8..7ecd3fb 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -259,6 +259,16 @@ struct cx23885_board cx23885_boards[] = {
.name   = TurboSight TBS 6920,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_TBS_6980] = {
+   .name   = TurboSight TBS 6980,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_TBS_6981] = {
+   .name   = TurboSight TBS 6981,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
[CX23885_BOARD_TEVII_S470] = {
.name   = TeVii S470,
.portb  = CX23885_MPEG_DVB,
@@ -698,6 +708,14 @@ struct cx23885_subid cx23885_subids[] = {
.subdevice = 0x,
.card  = CX23885_BOARD_TBS_6920,
}, {
+   .subvendor = 0x6980,
+   .subdevice = 0x,
+   .card  = CX23885_BOARD_TBS_6980,
+   }, {
+   .subvendor = 0x6981,
+   .subdevice = 0x,
+   .card  = CX23885_BOARD_TBS_6981,
+   }, {
.subvendor = 0xd470,
.subdevice = 0x9022,
.card  = CX23885_BOARD_TEVII_S470,
@@ -1022,6 +1040,35 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 
*eeprom_data)
dev-name, tv.model);
 }
 
+/* Some TBS cards require initing a chip using a bitbanged SPI attached
+   to the cx23885 gpio's. If this chip doesn't get init'ed the demod
+   doesn't respond to any command. */
+static void tbs_card_init(struct cx23885_dev *dev)
+{
+   int i;
+   const u8 buf[] = {
+   0xe0, 0x06, 0x66, 0x33, 0x65,
+   0x01, 0x17, 0x06, 0xde};
+
+   switch (dev-board) {
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
+   cx_set(GP0_IO, 0x00070007);
+   usleep_range(1000, 1);
+   cx_clear(GP0_IO, 2);
+   usleep_range(1000, 1);
+   for (i = 0; i  9 * 8; i++) {
+   cx_clear(GP0_IO, 7);
+   usleep_range(1000, 1);
+   cx_set(GP0_IO,
+   ((buf[i  3]  (7 - (i  7)))  1) | 4);
+   usleep_range(1000, 1);
+   }
+   cx_set(GP0_IO, 7);
+   break;
+   }
+}
+
 int cx23885_tuner_callback(void *priv, int component, int command, int arg)
 {
struct cx23885_tsport *port = priv;
@@ -1224,6 +1271,8 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x00040004);
break;
case CX23885_BOARD_TBS_6920:
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_PROF_8000:
cx_write(MC417_CTL, 0x0036);
cx_write(MC417_OEN, 0x1000);
@@ -1472,6 +1521,8 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
case CX23885_BOARD_TEVII_S470:
case CX23885_BOARD_MYGICA_X8507:
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1515,6 +1566,8 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_TEVII_S470:
case CX23885_BOARD_HAUPPAUGE_HVR1250:
case CX23885_BOARD_MYGICA_X8507:
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981

Re: [PATCH] cx23885[v2]: Fix IR interrupt storm.

2013-07-19 Thread Luis Alves
Hi Max,

Should have thought on that! I'll change it to preserve all other bits.

Thanks,
Luis


On Fri, Jul 19, 2013 at 4:37 AM, nibble.max nibble@gmail.com wrote:
 Hello Luis,
 The internel interrupts are rounted as follow:
 flatiron(include ADC)---HammerHead(include IR inside)---Pecos(PCIe)
 The flatiron interrupt is enabled when chip power up.
 When HammerHead interrupt is enalbe in Pecos, the most of interrupts are 
 coming from flatiron.
 The more accurate code is that reading back these left and right 
 registers(0x1f, 0x23), set its bit-7 to 1 , then write back.
 So that it does not touch other bits.
 BR,
 Max

Hi all,
This path is meant to be up-streamed.

Andy has a nice explanation for the interrupt storm when
enabling the IR interrupt:

The flatiron core (the audio adc) signals the end of its self-test
with an interrupt. Since the flatiron irq seems OR-wired
with the IR irq the result is this interrupt storm.
This i2c tranfers will clear the flatiron interrupts - the left
and right channels self-tests.

Also as suggested by Andy I moved the i2c transfers to the
cx23885 av core interrupt handling worker. If any spurious
interrupt happens we silence them.

The flatiron has some dedicated register read/write functions but are
not exported so Antti just suggested to call the i2c_transfer directly.

Tested in the TBS6981 Dual DVB-S2 card.

PS: I've found this i2c_transfers in TBS media tree, more precisely
in the cx23885-i2c.c file.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-av.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-av.c 
b/drivers/media/pci/cx23885/cx23885-av.c
index e958a01..d33570f 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -29,8 +29,25 @@ void cx23885_av_work_handler(struct work_struct *work)
   struct cx23885_dev *dev =
  container_of(work, struct cx23885_dev, 
 cx25840_work);
   bool handled;
+  char buffer[2];
+  struct i2c_msg msg = {
+  .addr = 0x98  1,
+  .flags = 0,
+  .len = 2,
+  .buf = buffer,
+  };

   v4l2_subdev_call(dev-sd_cx25840, core, interrupt_service_routine,
PCI_MSK_AV_CORE, handled);
+
+  if (!handled) {
+  /* clear any pending flatiron interrupts */
+  buffer[0] = 0x1f;
+  buffer[1] = 0x80;
+  i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+  buffer[0] = 0x23;
+  i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+  }
+
   cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
 }
--
1.7.9.5

--
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

--
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] cx23885: Fix interrupt storm that happens in some cards when IR is enabled.

2013-07-18 Thread Luis Alves
Sorry if I wasn't clear, but this patch is not intended to be merged
in the main tree (as it is).
I've sent it so that people facing this interrupt storm when IR is
enabled can test it in their cards (I only have the TBS6981 to test
and it works).
Probably I should have just sent a mail with a code sample...

About what it does, I don't have a clue! I just know that it does
silence the interrupt spam.
My best guess is that the IR interrupt line is shared with the ADC
interrupt line and maybe the ADC is generating an end-of-conversion
interrupt by default.
And touching this register can be disabling the ADC interrupts - or
powering down the ADC - or just disabling the ADC clock.

It would be valuable for other people that have this issues in their
cards to test and then make a proper patch to the cx23885.

If this doesn't work with other cards, then I'll just add those two
lines to be specific to my card init code.

Thanks and Regards,
Luis
--
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] cx23885: Fix interrupt storm that happens in some cards when IR is enabled.

2013-07-18 Thread Luis Alves
Hi Konstantin,

It was not my intention to send this piece of code as a patch to be
upstreamed. My apologies for that misunderstanding.
My intention was just to send something for people to try and see if
it solves the interrupt spam in their cards.
I should have sent it just as a normal email to the list.

You are right that I don't fully understand what those registers
control because unfortunately there is no public documentation
available (even for end of life products). But Andy Walls seem to have
a very good explanation.

I just disagree about knowing the author of this code... I had no clue
it was you, all I knew is that it came from tbs under GPL.
But if you say you are, I believe you and give you all the credit...

To be honest I just want my tbs card to work as it should.

Regards,
Luis
--
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] cx23885[v2]: Fix IR interrupt storm.

2013-07-18 Thread Luis Alves
Hi all,
This path is meant to be up-streamed.

Andy has a nice explanation for the interrupt storm when
enabling the IR interrupt:

The flatiron core (the audio adc) signals the end of its self-test
with an interrupt. Since the flatiron irq seems OR-wired
with the IR irq the result is this interrupt storm.
This i2c tranfers will clear the flatiron interrupts - the left
and right channels self-tests.

Also as suggested by Andy I moved the i2c transfers to the
cx23885 av core interrupt handling worker. If any spurious
interrupt happens we silence them.

The flatiron has some dedicated register read/write functions but are
not exported so Antti just suggested to call the i2c_transfer directly.

Tested in the TBS6981 Dual DVB-S2 card.

PS: I've found this i2c_transfers in TBS media tree, more precisely
in the cx23885-i2c.c file.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-av.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-av.c 
b/drivers/media/pci/cx23885/cx23885-av.c
index e958a01..d33570f 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -29,8 +29,25 @@ void cx23885_av_work_handler(struct work_struct *work)
struct cx23885_dev *dev =
   container_of(work, struct cx23885_dev, cx25840_work);
bool handled;
+   char buffer[2];
+   struct i2c_msg msg = {
+   .addr = 0x98  1,
+   .flags = 0,
+   .len = 2,
+   .buf = buffer,
+   };
 
v4l2_subdev_call(dev-sd_cx25840, core, interrupt_service_routine,
 PCI_MSK_AV_CORE, handled);
+
+   if (!handled) {
+   /* clear any pending flatiron interrupts */
+   buffer[0] = 0x1f;
+   buffer[1] = 0x80;
+   i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+   buffer[0] = 0x23;
+   i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+   }
+
cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
 }
-- 
1.7.9.5

--
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] cx24117[v2]: Add new dvb-frontend driver (tested cards: TBS6980 and TBS6981 Dual tuner DVB-S/S2)

2013-07-17 Thread Luis Alves
[v2] Fixed/changed according to first review.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/Kconfig   |7 +
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/cx24117.c | 1645 +
 drivers/media/dvb-frontends/cx24117.h |   47 +
 drivers/media/pci/cx23885/Kconfig |1 +
 drivers/media/pci/cx23885/cx23885-cards.c |   65 ++
 drivers/media/pci/cx23885/cx23885-dvb.c   |   31 +
 drivers/media/pci/cx23885/cx23885-input.c |   12 +
 drivers/media/pci/cx23885/cx23885.h   |2 +
 9 files changed, 1811 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cx24117.c
 create mode 100644 drivers/media/dvb-frontends/cx24117.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 0e2ec6f..bddbab4 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -200,6 +200,13 @@ config DVB_CX24116
help
  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_CX24117
+   tristate Conexant CX24117 based
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ A Dual DVB-S/S2 tuner module. Say Y when you want to support this 
frontend.
+
 config DVB_SI21XX
tristate Silicon Labs SI21XX based
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index cebc0fa..f9cb43d 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_DVB_ATBM8830) += atbm8830.o
 obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o
 obj-$(CONFIG_DVB_AF9013) += af9013.o
 obj-$(CONFIG_DVB_CX24116) += cx24116.o
+obj-$(CONFIG_DVB_CX24117) += cx24117.o
 obj-$(CONFIG_DVB_SI21XX) += si21xx.o
 obj-$(CONFIG_DVB_STV0288) += stv0288.o
 obj-$(CONFIG_DVB_STB6000) += stb6000.o
diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
new file mode 100644
index 000..f55f8a2
--- /dev/null
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -0,0 +1,1645 @@
+/*
+Conexant cx24117/cx24132 - Dual DVBS/S2 Satellite demod/tuner driver
+
+Copyright (C) 2013 Luis Alves lja...@gmail.com
+   July, 6th 2013
+   First release based on cx24116 driver by:
+   Steven Toth and Georg Acher, Darron Broad, Igor Liplianin
+Cards currently supported:
+   TBS6980 - Dual DVBS/S2 PCIe card
+   TBS6981 - Dual DVBS/S2 PCIe card
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include linux/slab.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/firmware.h
+
+#include dvb_frontend.h
+#include cx24117.h
+
+
+#define CX24117_DEFAULT_FIRMWARE dvb-fe-cx24117.fw
+#define CX24117_SEARCH_RANGE_KHZ 5000
+
+/* known registers */
+#define CX24117_REG_COMMAND  (0x00)  /* command buffer */
+#define CX24117_REG_EXECUTE  (0x1f)  /* execute command */
+
+#define CX24117_REG_FREQ3_0  (0x34)  /* frequency */
+#define CX24117_REG_FREQ2_0  (0x35)
+#define CX24117_REG_FREQ1_0  (0x36)
+#define CX24117_REG_STATE0   (0x39)
+#define CX24117_REG_SSTATUS0 (0x3a)  /* demod0 signal high / status */
+#define CX24117_REG_SIGNAL0  (0x3b)
+#define CX24117_REG_FREQ5_0  (0x3c)  /* +-freq */
+#define CX24117_REG_FREQ6_0  (0x3d)
+#define CX24117_REG_SRATE2_0 (0x3e)  /* +- 1000 * srate */
+#define CX24117_REG_SRATE1_0 (0x3f)
+#define CX24117_REG_QUALITY2_0   (0x40)
+#define CX24117_REG_QUALITY1_0   (0x41)
+
+#define CX24117_REG_BER4_0   (0x47)
+#define CX24117_REG_BER3_0   (0x48)
+#define CX24117_REG_BER2_0   (0x49)
+#define CX24117_REG_BER1_0   (0x4a)
+#define CX24117_REG_DVBS_UCB2_0  (0x4b)
+#define CX24117_REG_DVBS_UCB1_0  (0x4c)
+#define CX24117_REG_DVBS2_UCB2_0 (0x50)
+#define CX24117_REG_DVBS2_UCB1_0 (0x51)
+#define CX24117_REG_QSTATUS0 (0x93)
+#define CX24117_REG_CLKDIV0  (0xe6)
+#define CX24117_REG_RATEDIV0 (0xf0)
+
+
+#define CX24117_REG_FREQ3_1  (0x55)  /* frequency */
+#define CX24117_REG_FREQ2_1  (0x56)
+#define CX24117_REG_FREQ1_1  (0x57

[PATCH 1/2] cx24117[v3]: Add new dvb-frontend driver (cx23885 changes)

2013-07-17 Thread Luis Alves
v3:
Fixed issues reported by checkpatch script (thanks Antti).
Changed/fixed some stuff as sugested by Mauro Chehab.
Splited cx23885 changes to a separated patch.

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/Kconfig |1 +
 drivers/media/pci/cx23885/cx23885-cards.c |   68 +
 drivers/media/pci/cx23885/cx23885-dvb.c   |   31 +
 drivers/media/pci/cx23885/cx23885-input.c |   12 +
 drivers/media/pci/cx23885/cx23885.h   |2 +
 5 files changed, 114 insertions(+)

diff --git a/drivers/media/pci/cx23885/Kconfig 
b/drivers/media/pci/cx23885/Kconfig
index b3688aa..91b2ed7 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -23,6 +23,7 @@ config VIDEO_CX23885
select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT
select DVB_CX24116 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_CX24117 if MEDIA_SUBDRV_AUTOSELECT
select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT
select DVB_DS3000 if MEDIA_SUBDRV_AUTOSELECT
select DVB_TS2020 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 7e923f8..d7800ac 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -259,6 +259,16 @@ struct cx23885_board cx23885_boards[] = {
.name   = TurboSight TBS 6920,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_TBS_6980] = {
+   .name   = TurboSight TBS 6980,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_TBS_6981] = {
+   .name   = TurboSight TBS 6981,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
[CX23885_BOARD_TEVII_S470] = {
.name   = TeVii S470,
.portb  = CX23885_MPEG_DVB,
@@ -698,6 +708,14 @@ struct cx23885_subid cx23885_subids[] = {
.subdevice = 0x,
.card  = CX23885_BOARD_TBS_6920,
}, {
+   .subvendor = 0x6980,
+   .subdevice = 0x,
+   .card  = CX23885_BOARD_TBS_6980,
+   }, {
+   .subvendor = 0x6981,
+   .subdevice = 0x,
+   .card  = CX23885_BOARD_TBS_6981,
+   }, {
.subvendor = 0xd470,
.subdevice = 0x9022,
.card  = CX23885_BOARD_TEVII_S470,
@@ -1022,6 +1040,36 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 
*eeprom_data)
dev-name, tv.model);
 }
 
+/* some TBS cards require init */
+static void tbs_card_init(struct cx23885_dev *dev)
+{
+   int i;
+   const u8 buf[] = {
+   0xe0, 0x06, 0x66, 0x33, 0x65,
+   0x01, 0x17, 0x06, 0xde};
+
+   switch (dev-board) {
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
+   cx_set(GP0_IO, 0x00070007);
+   msleep(1);
+   cx_clear(GP0_IO, 2);
+   msleep(1);
+   /* send init bitstream */
+   /* the bitstream is sent in a bitbanged spi */
+   /* attached to cx23995 GPIO port */
+   for (i = 0; i  9 * 8; i++) {
+   cx_clear(GP0_IO, 7);
+   msleep(1);
+   cx_set(GP0_IO,
+   ((buf[i  3]  (7 - (i  7)))  1) | 4);
+   msleep(1);
+   }
+   cx_set(GP0_IO, 7);
+   break;
+   }
+}
+
 int cx23885_tuner_callback(void *priv, int component, int command, int arg)
 {
struct cx23885_tsport *port = priv;
@@ -1224,6 +1272,8 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x00040004);
break;
case CX23885_BOARD_TBS_6920:
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_PROF_8000:
cx_write(MC417_CTL, 0x0036);
cx_write(MC417_OEN, 0x1000);
@@ -1472,6 +1522,8 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
case CX23885_BOARD_TEVII_S470:
case CX23885_BOARD_MYGICA_X8507:
+   case CX23885_BOARD_TBS_6980:
+   case CX23885_BOARD_TBS_6981:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1515,6 +1567,8 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_TEVII_S470:
case CX23885_BOARD_HAUPPAUGE_HVR1250:
case CX23885_BOARD_MYGICA_X8507:
+   case CX23885_BOARD_TBS_6980:
+   case

[PATCH 2/2] cx24117[v3]: Add new dvb-frontend driver (tested cards: TBS6980 and TBS6981 Dual tuner DVB-S/S2)

2013-07-17 Thread Luis Alves
v3:
Fixed issues reported by checkpatch script (thanks Antti).
Changed/fixed some stuff as sugested by Mauro Chehab.
Splited cx23885 changes to a separated patch.

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/Kconfig   |7 +
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/cx24117.c | 1621 +
 drivers/media/dvb-frontends/cx24117.h |   47 +
 4 files changed, 1676 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cx24117.c
 create mode 100644 drivers/media/dvb-frontends/cx24117.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 0e2ec6f..bddbab4 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -200,6 +200,13 @@ config DVB_CX24116
help
  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_CX24117
+   tristate Conexant CX24117 based
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ A Dual DVB-S/S2 tuner module. Say Y when you want to support this 
frontend.
+
 config DVB_SI21XX
tristate Silicon Labs SI21XX based
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index cebc0fa..f9cb43d 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_DVB_ATBM8830) += atbm8830.o
 obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o
 obj-$(CONFIG_DVB_AF9013) += af9013.o
 obj-$(CONFIG_DVB_CX24116) += cx24116.o
+obj-$(CONFIG_DVB_CX24117) += cx24117.o
 obj-$(CONFIG_DVB_SI21XX) += si21xx.o
 obj-$(CONFIG_DVB_STV0288) += stv0288.o
 obj-$(CONFIG_DVB_STB6000) += stb6000.o
diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
new file mode 100644
index 000..19ea43e
--- /dev/null
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -0,0 +1,1621 @@
+/*
+Conexant cx24117/cx24132 - Dual DVBS/S2 Satellite demod/tuner driver
+
+Copyright (C) 2013 Luis Alves lja...@gmail.com
+   July, 6th 2013
+   First release based on cx24116 driver by:
+   Steven Toth and Georg Acher, Darron Broad, Igor Liplianin
+   Cards currently supported:
+   TBS6980 - Dual DVBS/S2 PCIe card
+   TBS6981 - Dual DVBS/S2 PCIe card
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include linux/slab.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/firmware.h
+
+#include dvb_frontend.h
+#include cx24117.h
+
+
+#define CX24117_DEFAULT_FIRMWARE dvb-fe-cx24117.fw
+#define CX24117_SEARCH_RANGE_KHZ 5000
+
+/* known registers */
+#define CX24117_REG_COMMAND  (0x00)  /* command buffer */
+#define CX24117_REG_EXECUTE  (0x1f)  /* execute command */
+
+#define CX24117_REG_FREQ3_0  (0x34)  /* frequency */
+#define CX24117_REG_FREQ2_0  (0x35)
+#define CX24117_REG_FREQ1_0  (0x36)
+#define CX24117_REG_STATE0   (0x39)
+#define CX24117_REG_SSTATUS0 (0x3a)  /* demod0 signal high / status */
+#define CX24117_REG_SIGNAL0  (0x3b)
+#define CX24117_REG_FREQ5_0  (0x3c)  /* +-freq */
+#define CX24117_REG_FREQ6_0  (0x3d)
+#define CX24117_REG_SRATE2_0 (0x3e)  /* +- 1000 * srate */
+#define CX24117_REG_SRATE1_0 (0x3f)
+#define CX24117_REG_QUALITY2_0   (0x40)
+#define CX24117_REG_QUALITY1_0   (0x41)
+
+#define CX24117_REG_BER4_0   (0x47)
+#define CX24117_REG_BER3_0   (0x48)
+#define CX24117_REG_BER2_0   (0x49)
+#define CX24117_REG_BER1_0   (0x4a)
+#define CX24117_REG_DVBS_UCB2_0  (0x4b)
+#define CX24117_REG_DVBS_UCB1_0  (0x4c)
+#define CX24117_REG_DVBS2_UCB2_0 (0x50)
+#define CX24117_REG_DVBS2_UCB1_0 (0x51)
+#define CX24117_REG_QSTATUS0 (0x93)
+#define CX24117_REG_CLKDIV0  (0xe6)
+#define CX24117_REG_RATEDIV0 (0xf0)
+
+
+#define CX24117_REG_FREQ3_1  (0x55)  /* frequency */
+#define CX24117_REG_FREQ2_1  (0x56)
+#define CX24117_REG_FREQ1_1  (0x57)
+#define CX24117_REG_STATE1   (0x5a)
+#define CX24117_REG_SSTATUS1 (0x5b)  /* demod1 signal high / status */
+#define CX24117_REG_SIGNAL1  (0x5c)
+#define

[PATCH] cx23885: Fix interrupt storm that happens in some cards when IR is enabled.

2013-07-17 Thread Luis Alves
Hi,

This i2c init should stop the interrupt storm that happens in some cards when 
the IR receiver in enabled.
It works perfectly in my TBS6981.

It would be good to test in other problematic cards.

In this patch I've added the IR init to the TeVii S470/S471 (and some others 
that fall in the same case statment).
Other cards but these that suffer the same issue should also be tested.

Give feedback!

Regards,
Luis



Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-cards.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 7e923f8..89ce132 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1081,6 +1081,27 @@ int cx23885_tuner_callback(void *priv, int component, 
int command, int arg)
return 0;
 }
 
+void cx23885_ir_setup(struct cx23885_dev *dev)
+{
+   struct i2c_msg msg;
+   char buffer[2];
+
+   /* this should stop the IR interrupt
+  storm that happens in some cards */
+   msg.addr = 0x4c;
+   msg.flags = 0;
+   msg.len = 2;
+   msg.buf = buffer;
+
+   buffer[0] = 0x1f;
+   buffer[1] = 0x80;
+   i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+
+   buffer[0] = 0x23;
+   buffer[1] = 0x80;
+   i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+}
+
 void cx23885_gpio_setup(struct cx23885_dev *dev)
 {
switch (dev-board) {
@@ -1664,6 +1685,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
ts1-gen_ctrl_val  = 0x5; /* Parallel */
ts1-ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   cx23885_ir_setup(dev);
break;
case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
-- 
1.7.9.5

--
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] cx24117: Add new dvb-frontend driver (tested cards: TBS6980 and TBS6981 Dual tuner DVB-S/S2)

2013-07-15 Thread Luis Alves
Hi all,

This patch adds support for the following CX24117 demod based cards:
TBS6980, TBS6981 (Dual tuner DVB-S/S2).
(tested with both cards)

Regards,
Luis

Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/dvb-frontends/Kconfig   |7 +
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/cx24117.c | 1666 +
 drivers/media/dvb-frontends/cx24117.h |   47 +
 drivers/media/pci/cx23885/Kconfig |1 +
 drivers/media/pci/cx23885/cx23885-cards.c |   65 ++
 drivers/media/pci/cx23885/cx23885-dvb.c   |   31 +
 drivers/media/pci/cx23885/cx23885-input.c |   12 +
 drivers/media/pci/cx23885/cx23885.h   |2 +
 9 files changed, 1832 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cx24117.c
 create mode 100644 drivers/media/dvb-frontends/cx24117.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 0e2ec6f..bddbab4 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -200,6 +200,13 @@ config DVB_CX24116
help
  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_CX24117
+   tristate Conexant CX24117 based
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ A Dual DVB-S/S2 tuner module. Say Y when you want to support this 
frontend.
+
 config DVB_SI21XX
tristate Silicon Labs SI21XX based
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index cebc0fa..f9cb43d 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_DVB_ATBM8830) += atbm8830.o
 obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o
 obj-$(CONFIG_DVB_AF9013) += af9013.o
 obj-$(CONFIG_DVB_CX24116) += cx24116.o
+obj-$(CONFIG_DVB_CX24117) += cx24117.o
 obj-$(CONFIG_DVB_SI21XX) += si21xx.o
 obj-$(CONFIG_DVB_STV0288) += stv0288.o
 obj-$(CONFIG_DVB_STB6000) += stb6000.o
diff --git a/drivers/media/dvb-frontends/cx24117.c 
b/drivers/media/dvb-frontends/cx24117.c
new file mode 100644
index 000..691ab5c
--- /dev/null
+++ b/drivers/media/dvb-frontends/cx24117.c
@@ -0,0 +1,1666 @@
+/*
+Conexant cx24117/cx24132 - Dual DVBS/S2 Satellite demod/tuner driver
+
+Copyright (C) 2013 Luis Alves lja...@gmail.com
+   July, 6th 2013
+   First release based on cx24116 driver by:
+   Steven Toth and Georg Acher, Darron Broad, Igor Liplianin
+Cards currently supported:
+   TBS6980 - Dual DVBS/S2 PCIe card
+   TBS6981 - Dual DVBS/S2 PCIe card
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include linux/slab.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/firmware.h
+
+#include dvb_frontend.h
+#include cx24117.h
+
+/* SNR measurements */
+static int esno_snr;
+module_param(esno_snr, int, 0644);
+MODULE_PARM_DESC(esno_snr, SNR return units, 0=ESNO(db * 10), \
+   1=PERCENTAGE 0-100 (default:0));
+
+
+#define CX24117_DEFAULT_FIRMWARE dvb-fe-cx24117.fw
+#define CX24117_SEARCH_RANGE_KHZ 5000
+
+/* known registers */
+#define CX24117_REG_COMMAND  (0x00)  /* command buffer */
+#define CX24117_REG_EXECUTE  (0x1f)  /* execute command */
+
+#define CX24117_REG_FREQ3_0  (0x34)  /* frequency */
+#define CX24117_REG_FREQ2_0  (0x35)
+#define CX24117_REG_FREQ1_0  (0x36)
+#define CX24117_REG_STATE0   (0x39)
+#define CX24117_REG_SSTATUS0 (0x3a)  /* demod0 signal high / status */
+#define CX24117_REG_SIGNAL0  (0x3b)
+#define CX24117_REG_FREQ5_0  (0x3c)  /* +-freq */
+#define CX24117_REG_FREQ6_0  (0x3d)
+#define CX24117_REG_SRATE2_0 (0x3e)  /* +- 1000 * srate */
+#define CX24117_REG_SRATE1_0 (0x3f)
+#define CX24117_REG_QUALITY2_0   (0x40)
+#define CX24117_REG_QUALITY1_0   (0x41)
+
+#define CX24117_REG_BER4_0   (0x47)
+#define CX24117_REG_BER3_0   (0x48)
+#define CX24117_REG_BER2_0   (0x49)
+#define CX24117_REG_BER1_0   (0x4a)
+#define CX24117_REG_DVBS_UCB2_0  (0x4b)
+#define CX24117_REG_DVBS_UCB1_0  (0x4c)
+#define CX24117_REG_DVBS2_UCB2_0 (0x50)
+#define

[PATCH] Fixed misleading error when handling IR interrupts.

2013-07-11 Thread Luis Alves
Hi,
Handling the AV Core/IR interrupts schedules its workqueue but
the schedule_work function returns false if @work was already on the
kernel-global workqueue and true otherwise.

Printing an error message if @work wasn't in the queue is wrong.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-core.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-core.c 
b/drivers/media/pci/cx23885/cx23885-core.c
index 268654a..9f63d93 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -1941,10 +1941,7 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id)
 
if ((pci_status  pci_mask)  PCI_MSK_AV_CORE) {
cx23885_irq_disable(dev, PCI_MSK_AV_CORE);
-   if (!schedule_work(dev-cx25840_work))
-   printk(KERN_ERR %s: failed to set up deferred work for
-   AV Core/IR interrupt. Interrupt is disabled
-   and won't be re-enabled\n, dev-name);
+   schedule_work(dev-cx25840_work);
handled++;
}
 
-- 
1.7.9.5

--
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