Re: Upstreaming SAA716x driver to the media_tree

2014-01-07 Thread Andreas Regel
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


Not receiving any messages since 2012-11-04

2012-12-01 Thread Andreas Regel
Hi,

am I the only one that is receiveing no mails from linux-media since Nov 04, 
2012?

Best 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: [PATCH 1/3] stv090x: Fix typo in register macros

2012-05-24 Thread Andreas Regel
Am 15.05.2012 14:43, schrieb Manu Abraham:
 Hi Andreas,
 
 Sorry about the late reply.
 
 Which datasheet revision are you using ? I looked at RevG and found that the
 register ERRCNT22 @ 0xF59D, 0xF39D do have bitfields by name Px_ERR_CNT2
 on Page 227.
 
 Did you overlook that by some chance ?
 
 Best Regards,
 Manu

Hi Manu,

I checked the datasheet. You are right, the actual bitfield of register 
Px_ERRCNT22 is named there Px_ERR_CNT2 but the same name is also used for the 
bitfields of registers Px_ERRCNT21 and Px_ERRCNT20. I think naming it CNT22 
better reflects its actual meaning of being the only a part of the counter 
value. It also would match the naming of ERRCNT12.

Best 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: [PATCH 1/3] stv090x: Fix typo in register macros

2012-03-11 Thread Andreas Regel
Hi Mauro,

it should be OK now.

---
 drivers/media/dvb/frontends/stv090x.c |2 +-
 drivers/media/dvb/frontends/stv090x_reg.h |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c
index 4aef187..6c3c095 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -3526,7 +3526,7 @@ static int stv090x_read_per(struct dvb_frontend *fe, u32 
*per)
} else {
/* Counter 2 */
reg = STV090x_READ_DEMOD(state, ERRCNT22);
-   h = STV090x_GETFIELD_Px(reg, ERR_CNT2_FIELD);
+   h = STV090x_GETFIELD_Px(reg, ERR_CNT22_FIELD);
 
reg = STV090x_READ_DEMOD(state, ERRCNT21);
m = STV090x_GETFIELD_Px(reg, ERR_CNT21_FIELD);
diff --git a/drivers/media/dvb/frontends/stv090x_reg.h 
b/drivers/media/dvb/frontends/stv090x_reg.h
index 93741ee..26c8885 100644
--- a/drivers/media/dvb/frontends/stv090x_reg.h
+++ b/drivers/media/dvb/frontends/stv090x_reg.h
@@ -2232,8 +2232,8 @@
 #define STV090x_P2_ERRCNT22STV090x_Px_ERRCNT22(2)
 #define STV090x_OFFST_Px_ERRCNT2_OLDVALUE_FIELD7
 #define STV090x_WIDTH_Px_ERRCNT2_OLDVALUE_FIELD1
-#define STV090x_OFFST_Px_ERR_CNT2_FIELD0
-#define STV090x_WIDTH_Px_ERR_CNT2_FIELD7
+#define STV090x_OFFST_Px_ERR_CNT22_FIELD   0
+#define STV090x_WIDTH_Px_ERR_CNT22_FIELD   7
 
 #define STV090x_Px_ERRCNT21(__x)   (0xF59E - (__x - 1) * 
0x200)
 #define STV090x_P1_ERRCNT21STV090x_Px_ERRCNT21(1)
-- 
1.7.2.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


Re: [PATCH 2/3] stv090x: use error counter 1 for BER estimation

2012-03-11 Thread Andreas Regel
---
 drivers/media/dvb/frontends/stv090x.c |   30 +-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c
index 6c3c095..afbd50c 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -3512,6 +3512,33 @@ static int stv090x_read_status(struct dvb_frontend *fe, 
enum fe_status *status)
return 0;
 }
 
+static int stv090x_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+   struct stv090x_state *state = fe-demodulator_priv;
+
+   u32 reg, h, m, l;
+   enum fe_status status;
+
+   stv090x_read_status(fe, status);
+   if (!(status  FE_HAS_LOCK)) {
+   *ber = 1  23; /* Max BER */
+   } else {
+   /* Counter 1 */
+   reg = STV090x_READ_DEMOD(state, ERRCNT12);
+   h = STV090x_GETFIELD_Px(reg, ERR_CNT12_FIELD);
+
+   reg = STV090x_READ_DEMOD(state, ERRCNT11);
+   m = STV090x_GETFIELD_Px(reg, ERR_CNT11_FIELD);
+
+   reg = STV090x_READ_DEMOD(state, ERRCNT10);
+   l = STV090x_GETFIELD_Px(reg, ERR_CNT10_FIELD);
+
+   *ber = ((h  16) | (m  8) | l);
+   }
+   return 0;
+}
+
+#if 0
 static int stv090x_read_per(struct dvb_frontend *fe, u32 *per)
 {
struct stv090x_state *state = fe-demodulator_priv;
@@ -3562,6 +3589,7 @@ err:
dprintk(FE_ERROR, 1, I/O error);
return -1;
 }
+#endif
 
 static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int 
val)
 {
@@ -4740,7 +4768,7 @@ static struct dvb_frontend_ops stv090x_ops = {
 
.search = stv090x_search,
.read_status= stv090x_read_status,
-   .read_ber   = stv090x_read_per,
+   .read_ber   = stv090x_read_ber,
.read_signal_strength   = stv090x_read_signal_strength,
.read_snr   = stv090x_read_cnr,
 };
-- 
1.7.2.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


Re: [PATCH 3/3] stv090x: On STV0903 do not set registers of the second path.

2012-03-11 Thread Andreas Regel
resend w/o line-wrapps.

---
 drivers/media/dvb/frontends/stv090x.c |  141 ++--
 1 files changed, 132 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c
index afbd50c..ce064a3 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -4268,7 +4268,7 @@ err:
return -1;
 }
 
-static int stv090x_set_tspath(struct stv090x_state *state)
+static int stv0900_set_tspath(struct stv090x_state *state)
 {
u32 reg;
 
@@ -4539,6 +4539,121 @@ err:
return -1;
 }
 
+static int stv0903_set_tspath(struct stv090x_state *state)
+{
+   u32 reg;
+
+   if (state-internal-dev_ver = 0x20) {
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   stv090x_write_reg(state, STV090x_TSGENERAL, 0x00);
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   default:
+   stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c);
+   break;
+   }
+   } else {
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x10);
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   default:
+   stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x14);
+   break;
+   }
+   }
+
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_DVBCI:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   default:
+   break;
+   }
+
+   if (state-config-ts1_clk  0) {
+   u32 speed;
+
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   default:
+   speed = state-internal-mclk /
+   (state-config-ts1_clk / 4);
+   if (speed  0x08)
+   speed = 0x08;
+   if (speed  0xFF)
+   speed = 0xFF;
+   break;
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   speed = state-internal-mclk /
+   (state-config-ts1_clk / 32);
+   if (speed  0x20)
+   speed = 0x20;
+   if (speed  0xFF)
+   speed = 0xFF;
+   break;
+   }
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGM);
+   STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 3);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGM, reg)  0)
+   goto err;
+   if (stv090x_write_reg(state, STV090x_P1_TSSPEED, speed)  0)
+   goto err;
+   }
+
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x01);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   

[PATCH 1/2] stb0899: set FE_HAS_SIGNAL flag in read_status

2012-02-28 Thread Andreas Regel

In stb0899_read_status the FE_HAS_SIGNAL flag was not set in case of a
successful carrier lock. This change fixes that.

Signed-off-by: Andreas Regel andreas.re...@gmx.de
---
 drivers/media/dvb/frontends/stb0899_drv.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/frontends/stb0899_drv.c 
b/drivers/media/dvb/frontends/stb0899_drv.c

index 38565be..4a58afc 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -1071,7 +1071,7 @@ static int stb0899_read_status(struct dvb_frontend 
*fe, enum fe_status *status)

reg  = stb0899_read_reg(state, STB0899_VSTATUS);
if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) {
 dprintk(state-verbose, FE_DEBUG, 1,  FE_HAS_CARRIER | 
FE_HAS_LOCK);

-   *status |= FE_HAS_CARRIER | FE_HAS_LOCK;
+   *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | 
FE_HAS_LOCK;
reg = stb0899_read_reg(state, STB0899_PLPARM);
if (STB0899_GETFIELD(VITCURPUN, reg)) {
@@ -1088,7 +1088,7 @@ static int stb0899_read_status(struct dvb_frontend 
*fe, enum fe_status *status)

if (internal-lock) {
reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2);
 			if (STB0899_GETFIELD(UWP_LOCK, reg)  STB0899_GETFIELD(CSM_LOCK, 
reg)) {

-   *status |= FE_HAS_CARRIER;
+   *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER;
dprintk(state-verbose, FE_DEBUG, 1,
UWP  CSM Lock ! --- DVB-S2 
FE_HAS_CARRIER);
 -- 1.7.2.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] stb0899: fixed reading of IF_AGC_GAIN register

2012-02-28 Thread Andreas Regel

When reading IF_AGC_GAIN register a wrong value for the base address
register was used (STB0899_DEMOD instead of STB0899_S2DEMOD). That
lead to a wrong signal strength value on DVB-S2 transponders.

Signed-off-by: Andreas Regel andreas.re...@gmx.de
---
 drivers/media/dvb/frontends/stb0899_drv.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/frontends/stb0899_drv.c 
b/drivers/media/dvb/frontends/stb0899_drv.c

index 4a58afc..a2e9eba 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -983,7 +983,7 @@ static int stb0899_read_signal_strength(struct 
dvb_frontend *fe, u16 *strength)

break;
case SYS_DVBS2:
if (internal-lock) {
-   reg = STB0899_READ_S2REG(STB0899_DEMOD, IF_AGC_GAIN);
+   reg = STB0899_READ_S2REG(STB0899_S2DEMOD, IF_AGC_GAIN);
val = STB0899_GETFIELD(IF_AGC_GAIN, reg);
  			*strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, 
ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val);

--
1.7.2.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/3] stv090x: Fix typo in register macros

2012-02-27 Thread Andreas Regel

Fix typo in register macros of ERRCNT2.

Signed-off-by: Andreas Regel andreas.re...@gmx.de
---
 drivers/media/dvb/frontends/stv090x.c |2 +-
 drivers/media/dvb/frontends/stv090x_reg.h |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c

index 4aef187..6c3c095 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -3526,7 +3526,7 @@ static int stv090x_read_per(struct dvb_frontend 
*fe, u32 *per)

} else {
/* Counter 2 */
reg = STV090x_READ_DEMOD(state, ERRCNT22);
-   h = STV090x_GETFIELD_Px(reg, ERR_CNT2_FIELD);
+   h = STV090x_GETFIELD_Px(reg, ERR_CNT22_FIELD);
reg = STV090x_READ_DEMOD(state, ERRCNT21);
m = STV090x_GETFIELD_Px(reg, ERR_CNT21_FIELD);
diff --git a/drivers/media/dvb/frontends/stv090x_reg.h 
b/drivers/media/dvb/frontends/stv090x_reg.h

index 93741ee..26c8885 100644
--- a/drivers/media/dvb/frontends/stv090x_reg.h
+++ b/drivers/media/dvb/frontends/stv090x_reg.h
@@ -2232,8 +2232,8 @@
 #define STV090x_P2_ERRCNT22STV090x_Px_ERRCNT22(2)
 #define STV090x_OFFST_Px_ERRCNT2_OLDVALUE_FIELD7
 #define STV090x_WIDTH_Px_ERRCNT2_OLDVALUE_FIELD1
-#define STV090x_OFFST_Px_ERR_CNT2_FIELD0
-#define STV090x_WIDTH_Px_ERR_CNT2_FIELD7
+#define STV090x_OFFST_Px_ERR_CNT22_FIELD   0
+#define STV090x_WIDTH_Px_ERR_CNT22_FIELD   7
  #define STV090x_Px_ERRCNT21(__x)  (0xF59E - (__x - 1) * 
0x200)
 #define STV090x_P1_ERRCNT21STV090x_Px_ERRCNT21(1)
--
1.7.2.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/3] stv090x: use error counter 1 for BER estimation

2012-02-27 Thread Andreas Regel

Use error counter 1 of the STV090x to get a correct bit error rate value.

Signed-off-by: Andreas Regel andreas.re...@gmx.de
---
 drivers/media/dvb/frontends/stv090x.c |   30 
+-

 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c

index 6c3c095..afbd50c 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -3512,6 +3512,33 @@ static int stv090x_read_status(struct 
dvb_frontend *fe, enum fe_status *status)

return 0;
 }
 +static int stv090x_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+   struct stv090x_state *state = fe-demodulator_priv;
+
+   u32 reg, h, m, l;
+   enum fe_status status;
+
+   stv090x_read_status(fe, status);
+   if (!(status  FE_HAS_LOCK)) {
+   *ber = 1  23; /* Max BER */
+   } else {
+   /* Counter 1 */
+   reg = STV090x_READ_DEMOD(state, ERRCNT12);
+   h = STV090x_GETFIELD_Px(reg, ERR_CNT12_FIELD);
+
+   reg = STV090x_READ_DEMOD(state, ERRCNT11);
+   m = STV090x_GETFIELD_Px(reg, ERR_CNT11_FIELD);
+
+   reg = STV090x_READ_DEMOD(state, ERRCNT10);
+   l = STV090x_GETFIELD_Px(reg, ERR_CNT10_FIELD);
+
+   *ber = ((h  16) | (m  8) | l);
+   }
+   return 0;
+}
+
+#if 0
 static int stv090x_read_per(struct dvb_frontend *fe, u32 *per)
 {
struct stv090x_state *state = fe-demodulator_priv;
@@ -3562,6 +3589,7 @@ err:
dprintk(FE_ERROR, 1, I/O error);
return -1;
 }
+#endif
  static int stv090x_table_lookup(const struct stv090x_tab *tab, int 
max, int val)

 {
@@ -4740,7 +4768,7 @@ static struct dvb_frontend_ops stv090x_ops = {
.search = stv090x_search,
.read_status= stv090x_read_status,
-   .read_ber   = stv090x_read_per,
+   .read_ber   = stv090x_read_ber,
.read_signal_strength   = stv090x_read_signal_strength,
.read_snr   = stv090x_read_cnr,
 };
--
1.7.2.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 3/3] stv090x: On STV0903 do not set registers of the second path.

2012-02-27 Thread Andreas Regel
Sometimes there is a problem when trying to access the non-existing 
registers of the second demodulator path on the STV0903.

This change removes the calls in case the driver is used on a STV0903.

Signed-off-by: Andreas Regel andreas.re...@gmx.de
---
 drivers/media/dvb/frontends/stv090x.c |  141 
++--

 1 files changed, 132 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb/frontends/stv090x.c 
b/drivers/media/dvb/frontends/stv090x.c

index afbd50c..ce064a3 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -4268,7 +4268,7 @@ err:
return -1;
 }
 -static int stv090x_set_tspath(struct stv090x_state *state)
+static int stv0900_set_tspath(struct stv090x_state *state)
 {
u32 reg;
 @@ -4539,6 +4539,121 @@ err:
return -1;
 }
 +static int stv0903_set_tspath(struct stv090x_state *state)
+{
+   u32 reg;
+
+   if (state-internal-dev_ver = 0x20) {
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   stv090x_write_reg(state, STV090x_TSGENERAL, 0x00);
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   default:
+   stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c);
+   break;
+   }
+   } else {
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x10);
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   default:
+   stv090x_write_reg(state, STV090x_TSGENERAL1X, 0x14);
+   break;
+   }
+   }
+
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_DVBCI:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
+   STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
+   STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg)  0)
+   goto err;
+   break;
+
+   default:
+   break;
+   }
+
+   if (state-config-ts1_clk  0) {
+   u32 speed;
+
+   switch (state-config-ts1_mode) {
+   case STV090x_TSMODE_PARALLEL_PUNCTURED:
+   case STV090x_TSMODE_DVBCI:
+   default:
+   speed = state-internal-mclk /
+   (state-config-ts1_clk / 4);
+   if (speed  0x08)
+   speed = 0x08;
+   if (speed  0xFF)
+   speed = 0xFF;
+   break;
+   case STV090x_TSMODE_SERIAL_PUNCTURED:
+   case STV090x_TSMODE_SERIAL_CONTINUOUS:
+   speed = state-internal-mclk /
+   (state-config-ts1_clk / 32);
+   if (speed  0x20)
+   speed = 0x20;
+   if (speed  0xFF)
+   speed = 0xFF;
+   break;
+   }
+   reg = stv090x_read_reg(state, STV090x_P1_TSCFGM);
+   STV090x_SETFIELD_Px(reg, TSFIFO_MANSPEED_FIELD, 3);
+   if (stv090x_write_reg(state, STV090x_P1_TSCFGM, reg)  0)
+   goto err;
+   if (stv090x_write_reg(state, STV090x_P1_TSSPEED, speed)  0)
+   goto err

Re: stv0903bab i2c-repeater question

2010-03-31 Thread Andreas Regel

Hi Sergey,

Am 31.03.2010 12:14, schrieb Sergey Mironov:
 Hello maillist!
 I am integrating frontend with dvb-demux driver of one device
 called mdemux.

 The frontend includes following parts:
 - stv0903bab demodulator
 - stv6110a tuner
 - lnbp21 power supply controller

 stv6110a is connected to i2c bus via stv0903's repeater.

 My question is about setting up i2c repeater frequency divider (I2CRPT
 register).  stv0903 datasheet says that the speed of the i2c repeater
 obtained by
 dividing the internal chip frequency (that is, 135 MHz)

 budget.c driver uses value STV090x_RPTLEVEL_16 for this divider. But
 135*10^6/16 is still too high to be valid i2c freq.

 Please explain where I'm wrong. Does the base frequency really equals 
to 135

 Mhz? Thanks.


The frequency divider in I2CRPT controls the speed of the I2C repeater 
HW unit inside the STV0903. The I2C clock itself has the same speed as 
the one that is used to access the STV0903. The repeater basically just 
routes the signals from one bus to the other and needs a higher internal 
frequency to do that properly. That is the frequency you set up with I2CRPT.


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: PULL http://jusst.de/hg/stv090x

2010-01-23 Thread Andreas Regel

Hi Manu,

Am 22.01.2010 21:22, schrieb Manu Abraham:

On Fri, Jan 22, 2010 at 11:40 PM, Devin Heitmueller
dheitmuel...@kernellabs.com  wrote:

Also, the dvb_frontend.c makes calls to i2c_gate_ctrl() at various
points, so you would need to ensure that none of those occur before
calling into your driver as there could potentially be a deadlock
there too.


Ok, thanks for the pointer. The gate control is never called
externally in reality. I will wait a little while for this patch to be
applied.  It removes the exported function and thereby an unnecessary
dereference.

http://jusst.de/hg/stv090x/rev/b3d28f5b2b53


There is one call to the gate control function from stv6110x_attach. 
This is needed to set up the clock output divider to the correct value 
before the demodulators clock is configured.


This could be solved by calling tuner_init before setting up the master 
clock in stv090x_init but that only helps on single tuner devices. On 
dual tuner devices you can only open the adapter that works with the 
second tuner. Then you will have the case that the master clock is set 
without having the clock output divider of first tuner initialized to 
the correct value.


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: PULL http://jusst.de/hg/stv090x

2010-01-23 Thread Andreas Regel

Hi Manu,

Am 23.01.2010 19:32, schrieb Manu Abraham:

On Sat, Jan 23, 2010 at 10:07 PM, Manu Abrahamabraham.m...@gmail.com  wrote:

Hi Andreas,

On Sat, Jan 23, 2010 at 9:50 PM, Andreas Regelandreas.re...@gmx.de  wrote:

Hi Manu,

Am 22.01.2010 21:22, schrieb Manu Abraham:


On Fri, Jan 22, 2010 at 11:40 PM, Devin Heitmueller
dheitmuel...@kernellabs.comwrote:


Also, the dvb_frontend.c makes calls to i2c_gate_ctrl() at various
points, so you would need to ensure that none of those occur before
calling into your driver as there could potentially be a deadlock
there too.


Ok, thanks for the pointer. The gate control is never called
externally in reality. I will wait a little while for this patch to be
applied.  It removes the exported function and thereby an unnecessary
dereference.

http://jusst.de/hg/stv090x/rev/b3d28f5b2b53


There is one call to the gate control function from stv6110x_attach. This is
needed to set up the clock output divider to the correct value before the
demodulators clock is configured.

This could be solved by calling tuner_init before setting up the master
clock in stv090x_init but that only helps on single tuner devices. On dual
tuner devices you can only open the adapter that works with the second
tuner. Then you will have the case that the master clock is set without
having the clock output divider of first tuner initialized to the correct
value.


Thinking of which, maybe it would be better to attach the tuner_attach
within the stv090x_attach(). That could solve the issue, AFAICT. What
do you say ?


OR

Another option will be to attach the tuner prior to the demodulator,
without the clock configuration in the tuner attach (clk configuartion
would be another function ptr), attach the demodulator, run clock
configuration...

I think this might be a bit more cleaner than attaching the tuner
within the demodulator_attach() ... ?


as there already is a function pointer interface for tuner control, I 
would prefer the second approach.


Shall I prepare a patch for it or do you want to?

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: PULL http://jusst.de/hg/stv090x

2010-01-10 Thread Andreas Regel

Hi Mauro,

Am 10.01.2010 13:52, schrieb Mauro Carvalho Chehab:

Manu Abraham wrote:

Mauro,

Please pull http://jusst.de/hg/stv090x changesets: from 13880 - 13891
inclusive of both.


The third changeset has some locking troubles:

# Node ID 4dd17a6a5ecc320eab58590a8567e5ba03b9d53a
[STV090x] Added mutex protection around tuner I2C access.

After the patch, the code will look like:

static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{
 struct stv090x_state *state = fe-demodulator_priv;
 u32 reg;

 if (enable)
 mutex_lock(state-internal-tuner_lock);

 reg = STV090x_READ_DEMOD(state, I2CRPT);
 if (enable) {
 dprintk(FE_DEBUG, 1, Enable Gate);
 STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 1);
 if (STV090x_WRITE_DEMOD(state, I2CRPT, reg)  0)
 goto err;

 } else {

 dprintk(FE_DEBUG, 1, Disable Gate);
 STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 0);
 if ((STV090x_WRITE_DEMOD(state, I2CRPT, reg))  0)
 goto err;
 }

 if (!enable)
 mutex_unlock(state-internal-tuner_lock);

 return 0;
err:
 dprintk(FE_ERROR, 1, I/O error);
 mutex_unlock(state-internal-tuner_lock);
 return -1;
}

As the err: is called on both enable and disable conditions, the error
code will try to unlock an already unlocked mutex, if !enable.

Also, it doesn't make sense to lock only if the gate is enabled,
since it seems that the lock is meant to protect the i2c gate bus and
both conditions will call STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, enable ? 1 : 
0);

The better would be simply to remove the if (enable)/if (!enable) tests
on the above code.


The lock shall protect the access to the tuners and not to the registers 
itself, so it is locked when enable is set and unlocked when enable isn't.


The code between a call to stv090x_i2c_gate_ctrl(..., 1)
and stv090x_i2c_gate_ctrl(..., 0) shall be exclusive in case both tuners 
have the same I2C address.


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: PULL http://jusst.de/hg/stv090x

2010-01-10 Thread Andreas Regel

Hi Mauro,

Am 10.01.2010 15:15, schrieb Mauro Carvalho Chehab:

Andreas Regel wrote:

Hi Mauro,

Am 10.01.2010 13:52, schrieb Mauro Carvalho Chehab:

Manu Abraham wrote:

Mauro,

Please pull http://jusst.de/hg/stv090x changesets: from 13880 - 13891
inclusive of both.


The third changeset has some locking troubles:

# Node ID 4dd17a6a5ecc320eab58590a8567e5ba03b9d53a
[STV090x] Added mutex protection around tuner I2C access.

After the patch, the code will look like:

static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{
  struct stv090x_state *state = fe-demodulator_priv;
  u32 reg;

  if (enable)
  mutex_lock(state-internal-tuner_lock);

  reg = STV090x_READ_DEMOD(state, I2CRPT);
  if (enable) {
  dprintk(FE_DEBUG, 1, Enable Gate);
  STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 1);
  if (STV090x_WRITE_DEMOD(state, I2CRPT, reg)   0)
  goto err;

  } else {

  dprintk(FE_DEBUG, 1, Disable Gate);
  STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD, 0);
  if ((STV090x_WRITE_DEMOD(state, I2CRPT, reg))   0)
  goto err;
  }

  if (!enable)
  mutex_unlock(state-internal-tuner_lock);

  return 0;
err:
  dprintk(FE_ERROR, 1, I/O error);
  mutex_unlock(state-internal-tuner_lock);
  return -1;
}

As the err: is called on both enable and disable conditions, the error
code will try to unlock an already unlocked mutex, if !enable.

Also, it doesn't make sense to lock only if the gate is enabled,
since it seems that the lock is meant to protect the i2c gate bus and
both conditions will call STV090x_SETFIELD_Px(reg, I2CT_ON_FIELD,
enable ? 1 : 0);

The better would be simply to remove the if (enable)/if (!enable) tests
on the above code.


The lock shall protect the access to the tuners and not to the registers
itself, so it is locked when enable is set and unlocked when enable isn't


Ok.


The code between a call to stv090x_i2c_gate_ctrl(..., 1)
and stv090x_i2c_gate_ctrl(..., 0) shall be exclusive in case both tuners
have the same I2C address.


By just looking at the i2c_gate_ctrl, it is not clear how do you expect that
the locking will work. You should add a comment better explaining it.

Also, as I pointed, if STV090x_WRITE_DEMOD fails, the unlock code will be called
even if the gate is not enabled.



you don't have to look at stv090x_i2c_gate_ctrl alone. stv090x driver 
contains code like this:


if (stv090x_i2c_gate_ctrl(fe, 1)  0)
goto err;

tuner access

if (stv090x_i2c_gate_ctrl(fe, 0)  0)
goto err;

Intention of the patch is to make the tuner access exclusive. Thats the 
reason why the mutex is locked when gate is opened and unlocked when the 
gate is closed.


In case the opening fails the close call is not made und thus mutex is 
not unlocked twice.


There one problem pending with: when there is an error during tuner 
access the gate will not be closed and thus the mutex will not be 
unlocked. For this case a patch from Oliver Endriss is attached.


Regards,
Andreas
# HG changeset patch
# User Oliver Endriss o.endr...@gmx.de
# Date 1263097942 -3600
# Node ID fefb0eb3c442f8ab1e446c6f275c914a99495312
# Parent  b1e950fefc1ac04f3ef67d274d6a72859afd734f
stv090x: Disable I2C gate on error

From: Oliver Endriss o.endr...@gmx.de

The I2C gate must also be disabled, if a tuner command failed.
Otherwise the tuner mutex would be locked forever.

Priority: normal

Signed-off-by: Oliver Endriss o.endr...@gmx.de

diff -r b1e950fefc1a -r fefb0eb3c442 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Wed Jan 06 02:24:56 
2010 +0400
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Sun Jan 10 05:32:22 
2010 +0100
@@ -2514,12 +2514,12 @@ static u32 stv090x_srate_srch_coarse(str
 
if (state-config-tuner_set_frequency) {
if (state-config-tuner_set_frequency(fe, 
freq)  0)
-   goto err;
+   goto err_gateoff;
}
 
if (state-config-tuner_set_bandwidth) {
if (state-config-tuner_set_bandwidth(fe, 
state-tuner_bw)  0)
-   goto err;
+   goto err_gateoff;
}
 
if (stv090x_i2c_gate_ctrl(fe, 0)  0)
@@ -2532,7 +2532,7 @@ static u32 stv090x_srate_srch_coarse(str
 
if (state-config-tuner_get_status) {
if (state-config-tuner_get_status(fe, reg)  
0)
-   goto err;
+   goto err_gateoff

Re: TT S2-1600 and NOVA-HD-S2 tuning problems on some transponders

2009-11-04 Thread Andreas Regel
Hi Magnus,

Magnus Hörlin schrieb:
 The S2-1600's are more inconsistent. They have problems tuning to 11421,
 12130, 12226 and 12341 MHz. Sometimes they do and once locked, they run
 forever with perfect reception. I don't understand why there's a problem
 with these transponders since they tune just fine to transponders with the
 same SR, polarisation and nearby frequencies. Very greateful for any input.

The stv090x driver as it is in current hg repository has some known issues with 
locking reliability.

Please try the patches that I sent two days ago to the list.

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


[PATCH] stv6110x: fix r divider calculation

2009-11-02 Thread Andreas Regel

This patch fixed the calculation of the r divider in stv6110x_set_frequency. It 
had always the value 3 no matter what frequency was given.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 43878f8dbfb0 linux/drivers/media/dvb/frontends/stv6110x.c
--- a/linux/drivers/media/dvb/frontends/stv6110x.c  Sun Nov 01 07:17:46 
2009 -0200
+++ b/linux/drivers/media/dvb/frontends/stv6110x.c  Mon Nov 02 21:02:22 
2009 +0100
@@ -95,7 +95,7 @@
{
struct stv6110x_state *stv6110x = fe-tuner_priv;
u32 rDiv, divider;
-   s32 pVal, pCalc, rDivOpt = 0;
+   s32 pVal, pCalc, rDivOpt = 0, pCalcOpt = 1000;
u8 i;

STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz 
- 16));
@@ -121,8 +121,10 @@
for (rDiv = 0; rDiv = 3; rDiv++) {
pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv);

-   if ((abs((s32)(pCalc - pVal)))  (abs((s32)(1000 - pVal
+   if ((abs((s32)(pCalc - pVal)))  (abs((s32)(pCalcOpt - pVal
rDivOpt = rDiv;
+
+   pCalcOpt = (REFCLOCK_kHz / 100) / R_DIV(rDivOpt);
}

divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz;
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] stv090x improvements and fixes

2009-11-02 Thread Andreas Regel

Hi,

the following patches fix several issues with the stv090x driver and make 
locking more reliable.

They were available since more than two months and tested successfully using TT 
S2-1600 card by me and other people from vdrportal.de.

Regards,
Andreas Regel
--
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/9] stv090x: increase search range based on symbol rate

2009-11-02 Thread Andreas Regel

This patch increases search range based on symbol rate.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 69d4b117a9e5 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 21:38:25 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 21:43:27 
2009 +0100
@@ -4108,7 +4108,13 @@
state-search_mode = STV090x_SEARCH_AUTO;
state-algo = STV090x_COLD_SEARCH;
state-fec = STV090x_PRERR;
-   state-search_range = 200;
+   if (state-srate  1000) {
+   dprintk(FE_DEBUG, 1, Search range: 10 MHz);
+   state-search_range = 1000;
+   } else {
+   dprintk(FE_DEBUG, 1, Search range: 5 MHz);
+   state-search_range = 500;
+   }

if (stv090x_algo(state) == STV090x_RANGEOK) {
dprintk(FE_DEBUG, 1, Search success!);
--
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/9] stv090x: fixes in stv090x register definitions

2009-11-02 Thread Andreas Regel

This patch fixes errors and typos in stv090x register definitions.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 4e2c22a2b45e linux/drivers/media/dvb/frontends/stv090x_reg.h
--- a/linux/drivers/media/dvb/frontends/stv090x_reg.h   Mon Nov 02 21:44:35 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x_reg.h   Mon Nov 02 22:08:03 
2009 +0100
@@ -44,7 +44,7 @@
#define STV090x_OFFST_OUTSERRS2_HZ_FIELD5
#define STV090x_WIDTH_OUTSERRS2_HZ_FIELD1
#define STV090x_OFFST_OUTSERRS3_HZ_FIELD4
-#define STV090x_WIDTH_OUTPARRS3_HZ_FIELD   1
+#define STV090x_WIDTH_OUTSERRS3_HZ_FIELD   1
#define STV090x_OFFST_OUTPARRS3_HZ_FIELD3
#define STV090x_WIDTH_OUTPARRS3_HZ_FIELD1

@@ -113,24 +113,24 @@
#define STV090x_IRQMASK30xf124
#define STV090x_OFFST_MPLL_LOCK_FIELD   5
#define STV090x_WIDTH_MPLL_LOCK_FIELD   1
-#define STV090x_OFFST_MSTREAM_LCK_3_FIELD  2
-#define STV090x_WIDTH_MSTREAM_LCK_3_FIELD  3
-#define STV090x_OFFST_MSTREAM_LCK_2_FIELD  2
-#define STV090x_WIDTH_MSTREAM_LCK_2_FIELD  3
+#define STV090x_OFFST_MSTREAM_LCK_3_FIELD  4
+#define STV090x_WIDTH_MSTREAM_LCK_3_FIELD  1
+#define STV090x_OFFST_MSTREAM_LCK_2_FIELD  3
+#define STV090x_WIDTH_MSTREAM_LCK_2_FIELD  1
#define STV090x_OFFST_MSTREAM_LCK_1_FIELD   2
-#define STV090x_WIDTH_MSTREAM_LCK_1_FIELD  3
+#define STV090x_WIDTH_MSTREAM_LCK_1_FIELD  1
#define STV090x_OFFST_MDVBS1_PRF_2_FIELD1
#define STV090x_WIDTH_MDVBS1_PRF_2_FIELD1
#define STV090x_OFFST_MDVBS1_PRF_1_FIELD0
#define STV090x_WIDTH_MDVBS1_PRF_1_FIELD1

#define STV090x_IRQMASK20xf125
-#define STV090x_OFFST_MSPY_ENDSIM_3_FIELD  5
-#define STV090x_WIDTH_MSPY_ENDSIM_3_FIELD  3
-#define STV090x_OFFST_MSPY_ENDSIM_2_FIELD  5
-#define STV090x_WIDTH_MSPY_ENDSIM_2_FIELD  3
+#define STV090x_OFFST_MSPY_ENDSIM_3_FIELD  7
+#define STV090x_WIDTH_MSPY_ENDSIM_3_FIELD  1
+#define STV090x_OFFST_MSPY_ENDSIM_2_FIELD  6
+#define STV090x_WIDTH_MSPY_ENDSIM_2_FIELD  1
#define STV090x_OFFST_MSPY_ENDSIM_1_FIELD   5
-#define STV090x_WIDTH_MSPY_ENDSIM_1_FIELD  3
+#define STV090x_WIDTH_MSPY_ENDSIM_1_FIELD  1
#define STV090x_OFFST_MPKTDEL_ERROR_2_FIELD 4
#define STV090x_WIDTH_MPKTDEL_ERROR_2_FIELD 1
#define STV090x_OFFST_MPKTDEL_LOCKB_2_FIELD 3
@@ -370,7 +370,7 @@
#define STV090x_OFFST_SELX1RATIO_FIELD  5
#define STV090x_WIDTH_SELX1RATIO_FIELD  1
#define STV090x_OFFST_STOP_PLL_FIELD3
-#define STV090x_WIDTH_SELX1RATIO_FIELD 1
+#define STV090x_WIDTH_STOP_PLL_FIELD   1
#define STV090x_OFFST_BYPASSPLLFSK_FIELD2
#define STV090x_WIDTH_BYPASSPLLFSK_FIELD1
#define STV090x_OFFST_SELOSCI_FIELD 1
@@ -616,7 +616,7 @@
#define STV090x_OFFST_Px_CONT_TONE_FIELD4
#define STV090x_WIDTH_Px_CONT_TONE_FIELD1
#define STV090x_OFFST_Px_FIFO_4BREADY_FIELD 3
-#define STV090x_WIDTH_Px_FIFO_4BREADY_FIELD2
+#define STV090x_WIDTH_Px_FIFO_4BREADY_FIELD1
#define STV090x_OFFST_Px_FIFO_EMPTY_FIELD   2
#define STV090x_WIDTH_Px_FIFO_EMPTY_FIELD   1
#define STV090x_OFFST_Px_ABORT_DISRX_FIELD  0
@@ -847,12 +847,10 @@
#define STV090x_WIDTH_Px_DVBS2_ENABLE_FIELD 1
#define STV090x_OFFST_Px_DVBS1_ENABLE_FIELD 6
#define STV090x_WIDTH_Px_DVBS1_ENABLE_FIELD 1
-#define STV090x_OFFST_Px_CFR_AUTOSCAN_FIELD5 /* check */
+#define STV090x_OFFST_Px_SCAN_ENABLE_FIELD 4
+#define STV090x_WIDTH_Px_SCAN_ENABLE_FIELD 1
+#define STV090x_OFFST_Px_CFR_AUTOSCAN_FIELD3
#define STV090x_WIDTH_Px_CFR_AUTOSCAN_FIELD 1
-#define STV090x_OFFST_Px_SCAN_ENABLE_FIELD 4 /* check */
-#define STV090x_WIDTH_Px_SCAN_ENABLE_FIELD 1
-#define STV090x_OFFST_Px_TUN_AUTOSCAN_FIELD3
-#define STV090x_WIDTH_Px_TUN_AUTOSCAN_FIELD1
#define STV090x_OFFST_Px_NOFORCE_RELOCK_FIELD   2
#define STV090x_WIDTH_Px_NOFORCE_RELOCK_FIELD   1
#define STV090x_OFFST_Px_TUN_RNG_FIELD  0
@@ -885,7 +883,7 @@
#define STV090x_P2_DMDFLYW  STV090x_Px_DMDFLYW(2)
#define STV090x_OFFST_Px_I2C_IRQVAL_FIELD   4
#define STV090x_WIDTH_Px_I2C_IRQVAL_FIELD   4
-#define STV090x_OFFST_Px_FLYWHEEL_CPT_FIELD0 /* check */
+#define STV090x_OFFST_Px_FLYWHEEL_CPT_FIELD0
#define STV090x_WIDTH_Px_FLYWHEEL_CPT_FIELD 4

#define STV090x_Px_DSTATUS3(__x)(0xF41D - (__x - 1) * 0x200)
@@ -1048,12 +1046,12 @@
#define STV090x_P1_CFRINC1  STV090x_Px_CFRINC1(1)
#define STV090x_P2_CFRINC1  STV090x_Px_CFRINC1(2)
#define STV090x_OFFST_Px_CFR_INC1_FIELD 0
-#define STV090x_WIDTH_Px_CFR_INC1_FIELD7
+#define STV090x_WIDTH_Px_CFR_INC1_FIELD7 /* check */

#define STV090x_Px_CFRINC0(__x) (0xF44B - (__x - 1) * 0x200)
#define STV090x_P1_CFRINC0  STV090x_Px_CFRINC0(1)
#define

[PATCH 3/9] stv090x: fix STR and SNR calculation

2009-11-02 Thread Andreas Regel

This patch fixes STR and SNR calculation and normalizes the value into the 
0..0x range.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 24f72ae37236 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:06:31 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:24:07 
2009 +0100
@@ -4230,14 +4230,12 @@
int res = 0;
int min = 0, med;

-   if (val  tab[min].read)
-   res = tab[min].real;
-   else if (val = tab[max].read)
-   res = tab[max].real;
-   else {
+   if ((val = tab[min].read  val  tab[max].read) ||
+   (val = tab[max].read  val  tab[min].read)) {
while ((max - min)  1) {
med = (max + min) / 2;
-   if (val = tab[min].read  val  tab[med].read)
+   if ((val = tab[min].read  val  tab[med].read) ||
+   (val = tab[med].read  val  tab[min].read))
max = med;
else
min = med;
@@ -4246,6 +4244,18 @@
   (tab[max].real - tab[min].real) /
   (tab[max].read - tab[min].read)) +
tab[min].real;
+   } else {
+   if (tab[min].read  tab[max].read) {
+   if (val  tab[min].read)
+   res = tab[min].real;
+   else if (val = tab[max].read)
+   res = tab[max].real;
+   } else {
+   if (val = tab[min].read)
+   res = tab[min].real;
+   else if (val  tab[max].read)
+   res = tab[max].real;
+   }
}

return res;
@@ -4255,16 +4265,22 @@
{
struct stv090x_state *state = fe-demodulator_priv;
u32 reg;
-   s32 agc;
+   s32 agc_0, agc_1, agc;
+   s32 str;

reg = STV090x_READ_DEMOD(state, AGCIQIN1);
-   agc = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);
-
-   *strength = stv090x_table_lookup(stv090x_rf_tab, 
ARRAY_SIZE(stv090x_rf_tab) - 1, agc);
+   agc_1 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);
+   reg = STV090x_READ_DEMOD(state, AGCIQIN0);
+   agc_0 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);
+   agc = MAKEWORD16(agc_1, agc_0);
+
+   str = stv090x_table_lookup(stv090x_rf_tab,
+   ARRAY_SIZE(stv090x_rf_tab) - 1, agc);
if (agc  stv090x_rf_tab[0].read)
-   *strength = 5;
+   str = 0;
else if (agc  stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read)
-   *strength = -100;
+   str = -100;
+   *strength = (str + 100) * 0x / 100;

return 0;
}
@@ -4275,6 +4291,8 @@
u32 reg_0, reg_1, reg, i;
s32 val_0, val_1, val = 0;
u8 lock_f;
+   s32 div;
+   u32 last;

switch (state-delsys) {
case STV090x_DVBS2:
@@ -4286,14 +4304,15 @@
reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1);
val_1 = STV090x_GETFIELD_Px(reg_1, 
NOSPLHT_NORMED_FIELD);
reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0);
-   val_0 = STV090x_GETFIELD_Px(reg_1, 
NOSPLHT_NORMED_FIELD);
+   val_0 = STV090x_GETFIELD_Px(reg_0, 
NOSPLHT_NORMED_FIELD);
val  += MAKEWORD16(val_1, val_0);
msleep(1);
}
val /= 16;
-   *cnr = stv090x_table_lookup(stv090x_s2cn_tab, 
ARRAY_SIZE(stv090x_s2cn_tab) - 1, val);
-   if (val  stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) 
- 1].read)
-   *cnr = 1000;
+   last = ARRAY_SIZE(stv090x_s2cn_tab) - 1;
+   div = stv090x_s2cn_tab[0].read -
+ stv090x_s2cn_tab[last].read;
+   *cnr = 0x - ((val * 0x) / div);
}
break;

@@ -4307,14 +4326,15 @@
reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1);
val_1 = STV090x_GETFIELD_Px(reg_1, 
NOSDATAT_UNNORMED_FIELD);
reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0);
-   val_0 = STV090x_GETFIELD_Px(reg_1, 
NOSDATAT_UNNORMED_FIELD);
+   val_0 = STV090x_GETFIELD_Px(reg_0, 
NOSDATAT_UNNORMED_FIELD);
val  += MAKEWORD16(val_1, val_0);
msleep(1);
}
val /= 16;
-   *cnr = stv090x_table_lookup(stv090x_s1cn_tab, 
ARRAY_SIZE(stv090x_s1cn_tab) - 1, val

[PATCH 4/9] stv090x: fix some typos

2009-11-02 Thread Andreas Regel

This patch fixes some typos like wrong register or variable names.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 817da160d9e8 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:25:01 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:32:06 
2009 +0100
@@ -1556,7 +1556,7 @@
sym /= (state-mclk  7);
}

-   if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym  8)  0xff))  0) /* 
MSB */
+   if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym  8)  0x7f))  0) /* 
MSB */
goto err;
if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym  0xff))  0) /* LSB */
goto err;
@@ -2048,7 +2048,7 @@
goto err;
if (STV090x_WRITE_DEMOD(state, CFRUP1, 0x0f)  0)
goto err;
-   if (STV090x_WRITE_DEMOD(state, CFRUP1, 0xff)  0)
+   if (STV090x_WRITE_DEMOD(state, CFRUP0, 0xff)  0)
goto err;
if (STV090x_WRITE_DEMOD(state, CFRLOW1, 0xf0)  0)
goto err;
@@ -2102,7 +2102,7 @@

if (STV090x_WRITE_DEMOD(state, CFRUP1, MSB(freq))  0)
goto err;
-   if (STV090x_WRITE_DEMOD(state, CFRUP1, LSB(freq))  0)
+   if (STV090x_WRITE_DEMOD(state, CFRUP0, LSB(freq))  0)
goto err;

freq *= -1;
@@ -2256,7 +2256,7 @@
else
freq_init = freq_init - (freq_step * i);

-   dir = -1;
+   dir *= -1;

if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c)  0) /* Demod 
RESET */
goto err;
@@ -3156,7 +3156,7 @@

derot = (int_1 * int_2) +
((int_1 * tmp_2)  12) +
-   ((int_1 * tmp_1)  12);
+   ((int_2 * tmp_1)  12);

return derot;
}
@@ -3463,7 +3463,7 @@
switch (state-delsys) {
case STV090x_DVBS1:
case STV090x_DSS:
-   if (state-algo == STV090x_SEARCH_AUTO) {
+   if (state-search_mode == STV090x_SEARCH_AUTO) {
reg = STV090x_READ_DEMOD(state, DMDCFGMD);
STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1);
STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0);
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] stv090x: fix calculation of AGC2

2009-11-02 Thread Andreas Regel

This patch fixes calculation of AGC2 and uses a different AGC2 threshold for 
cut 3 chips.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 6e8847485f78 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:33:03 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:42:33 
2009 +0100
@@ -2216,7 +2216,7 @@

static int stv090x_get_agc2_min_level(struct stv090x_state *state)
{
-   u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg;
+   u32 agc2_min = 0x, agc2 = 0, freq_init, freq_step, reg;
s32 i, j, steps, dir;

if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38)  0)
@@ -2267,13 +2267,14 @@
if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58)  0) /* Demod 
RESET */
goto err;
msleep(10);
+
+   agc2 = 0;
for (j = 0; j  10; j++) {
-   agc2 += STV090x_READ_DEMOD(state, AGC2I1)  8;
-   agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+   agc2 += (STV090x_READ_DEMOD(state, AGC2I1)  8) |
+   STV090x_READ_DEMOD(state, AGC2I0);
}
agc2 /= 10;
-   agc2_min = 0x;
-   if (agc2  0x)
+   if (agc2  agc2_min)
agc2_min = agc2;
}

@@ -2315,6 +2316,12 @@
int tmg_lock = 0, i;
s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq;
u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg;
+   u32 agc2th;
+
+   if (state-dev_ver = 0x30)
+   agc2th = 0x2e00;
+   else
+   agc2th = 0x1f00;

reg = STV090x_READ_DEMOD(state, DMDISTATE);
STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */
@@ -2342,7 +2349,7 @@
goto err;
if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00)  0)
goto err;
-   if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60)  0)
+   if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x50)  0)
goto err;

if (state-dev_ver = 0x30) {
@@ -2392,14 +2399,15 @@
reg = STV090x_READ_DEMOD(state, DSTATUS);
if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) = 
2)
tmg_cpt++;
-   agc2 += STV090x_READ_DEMOD(state, AGC2I1)  8;
-   agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
+   agc2 += (STV090x_READ_DEMOD(state, AGC2I1)  8) |
+   STV090x_READ_DEMOD(state, AGC2I0);
}
agc2 /= 10;
srate_coarse = stv090x_get_srate(state, state-mclk);
cur_step++;
dir *= -1;
-   if ((tmg_cpt = 5)  (agc2  0x1f00)  (srate_coarse  5500) 
 (srate_coarse  85))
+   if ((tmg_cpt = 5)  (agc2  agc2th) 
+   (srate_coarse  5000)  (srate_coarse  85))
tmg_lock = 1;
else if (cur_step  steps) {
if (dir  0)
@@ -2480,6 +2488,9 @@
reg = STV090x_READ_DEMOD(state, DMDCFGMD);
STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0x00);
if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg)  0)
+   goto err;
+
+   if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38)  0)
goto err;

if (state-dev_ver = 0x30) {
@@ -2639,8 +2650,8 @@
cpt_fail = 0;
agc2_ovflw = 0;
for (i = 0; i  10; i++) {
-   agc2  = STV090x_READ_DEMOD(state, AGC2I1) 
 8;
-   agc2 |= STV090x_READ_DEMOD(state, 
AGC2I0);
+   agc2 += (STV090x_READ_DEMOD(state, AGC2I1) 
 8) |
+   STV090x_READ_DEMOD(state, 
AGC2I0);
if (agc2 = 0xff00)
agc2_ovflw++;
reg = STV090x_READ_DEMOD(state, 
DSTATUS2);
diff -r 6e8847485f78 linux/drivers/media/dvb/frontends/stv090x_priv.h
--- a/linux/drivers/media/dvb/frontends/stv090x_priv.h  Mon Nov 02 22:33:03 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x_priv.h  Mon Nov 02 22:42:33 
2009 +0100
@@ -83,7 +83,7 @@

#define STV090x_IQPOWER_THRESHOLD 30
#define STV090x_SEARCH_AGC2_TH_CUT20 700
-#define STV090x_SEARCH_AGC2_TH_CUT30   1200
+#define STV090x_SEARCH_AGC2_TH_CUT30   1400

#define STV090x_SEARCH_AGC2_TH(__ver)   \
((__ver = 0x20) ?   \
--
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

[PATCH 6/9] stv090x: several small fixes

2009-11-02 Thread Andreas Regel

This patch contains several fixes for the stv090x driver:
- added missing else
- use calculated timeout instead of fixed one
- use correct frequency when doing zigzag scan
- added missing read of GENCFG register

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r e87448c29625 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 22:43:25 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:02:34 
2009 +0100
@@ -2167,9 +2167,7 @@
}
if (STV090x_WRITE_DEMOD(state, CARHDR, 0x40)  0)
goto err;
-   }
-
-   if (state-srate  1000) {
+   } else if (state-srate  1000) {
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c)  0)
goto err;
} else {
@@ -2420,7 +2418,7 @@
goto err;

if (state-config-tuner_set_frequency) {
-   if (state-config-tuner_set_frequency(fe, 
state-frequency)  0)
+   if (state-config-tuner_set_frequency(fe, freq) 
 0)
goto err;
}

@@ -2598,7 +2596,7 @@
static int stv090x_blind_search(struct stv090x_state *state)
{
u32 agc2, reg, srate_coarse;
-   s32 timeout_dmd = 500, cpt_fail, agc2_ovflw, i;
+   s32 cpt_fail, agc2_ovflw, i;
u8 k_ref, k_max, k_min;
int coarse_fail, lock;

@@ -2642,7 +2640,8 @@
srate_coarse = stv090x_srate_srch_fine(state);
if (srate_coarse != 0) {
stv090x_get_lock_tmg(state);
-   lock = stv090x_get_dmdlock(state, 
timeout_dmd);
+   lock = stv090x_get_dmdlock(state,
+   state-DemodTimeout);
} else {
lock = 0;
}
@@ -2804,7 +2803,7 @@
goto err;

if (state-config-tuner_set_frequency) 
{
-   if 
(state-config-tuner_set_frequency(fe, state-frequency)  0)
+   if 
(state-config-tuner_set_frequency(fe, freq)  0)
goto err;
}

@@ -3865,7 +3864,7 @@
struct dvb_frontend *fe = state-frontend;
enum stv090x_signal_state signal_state = STV090x_NOCARRIER;
u32 reg;
-   s32 timeout_dmd = 500, timeout_fec = 50, agc1_power, power_iq = 0, i;
+   s32 agc1_power, power_iq = 0, i;
int lock = 0, low_sr = 0, no_signal = 0;

reg = STV090x_READ_DEMOD(state, TSCFGH);
@@ -4030,10 +4029,10 @@
lock = stv090x_blind_search(state);

else if (state-algo == STV090x_COLD_SEARCH)
-   lock = stv090x_get_coldlock(state, timeout_dmd);
+   lock = stv090x_get_coldlock(state, state-DemodTimeout);

else if (state-algo == STV090x_WARM_SEARCH)
-   lock = stv090x_get_dmdlock(state, timeout_dmd);
+   lock = stv090x_get_dmdlock(state, state-DemodTimeout);

if ((!lock)  (state-algo == STV090x_COLD_SEARCH)) {
if (!low_sr) {
@@ -4068,8 +4067,9 @@
goto err;
}

-   if (stv090x_get_lock(state, timeout_fec, timeout_fec)) {
-   lock = 1;
+   lock = stv090x_get_lock(state, state-FecTimeout,
+   state-FecTimeout);
+   if (lock) {
if (state-delsys == STV090x_DVBS2) {
stv090x_set_s2rolloff(state);

@@ -4096,7 +4096,6 @@
if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1)  0)
goto err;
} else {
-   lock = 0;
signal_state = STV090x_NODATA;
no_signal = stv090x_chk_signal(state);
}
@@ -4580,6 +4579,8 @@
static int stv090x_ldpc_mode(struct stv090x_state *state, enum stv090x_mode 
ldpc_mode)
{
u32 reg = 0;
+
+   reg = stv090x_read_reg(state, STV090x_GENCFG);

switch (ldpc_mode) {
case STV090x_DUAL:
--
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 7/9] stv090x: additional check for signal presence based on AGC1

2009-11-02 Thread Andreas Regel

This patch adds an additional check for signal presence based on AGC1.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r c6b33af45211 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:03:44 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:08:29 
2009 +0100
@@ -3997,7 +3997,7 @@
if ((agc1_power == 0)  (power_iq  STV090x_IQPOWER_THRESHOLD)) {
dprintk(FE_ERROR, 1, No Signal: POWER_IQ=0x%02x, power_iq);
lock = 0;
-
+   signal_state = STV090x_NOAGC1;
} else {
reg = STV090x_READ_DEMOD(state, DEMOD);
STV090x_SETFIELD_Px(reg, SPECINV_CONTROL_FIELD, 
state-inversion);
@@ -4021,9 +4021,8 @@
}
}

-   /* need to check for AGC1 state */
-
-
+   if (signal_state == STV090x_NOAGC1)
+   return signal_state;

if (state-algo == STV090x_BLIND_SEARCH)
lock = stv090x_blind_search(state);
diff -r c6b33af45211 linux/drivers/media/dvb/frontends/stv090x_priv.h
--- a/linux/drivers/media/dvb/frontends/stv090x_priv.h  Mon Nov 02 23:03:44 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x_priv.h  Mon Nov 02 23:08:29 
2009 +0100
@@ -91,6 +91,7 @@
STV090x_SEARCH_AGC2_TH_CUT30)

enum stv090x_signal_state {
+   STV090x_NOAGC1,
STV090x_NOCARRIER,
STV090x_NODATA,
STV090x_DATAOK,
--
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 8/9] stv090x: additional check for packet delineator lock in stv090x_read_status

2009-11-02 Thread Andreas Regel

This patch add an additional check for packet delineator lock in 
stv090x_read_status in case of a tuned DVB-S2 signal.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r 07782fabbff1 linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:09:33 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:15:41 
2009 +0100
@@ -4136,7 +4136,6 @@
return DVBFE_ALGO_SEARCH_ERROR;
}

-/* FIXME! */
static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status)
{
struct stv090x_state *state = fe-demodulator_priv;
@@ -4158,9 +4157,15 @@
dprintk(FE_DEBUG, 1, Delivery system: DVB-S2);
reg = STV090x_READ_DEMOD(state, DSTATUS);
if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) {
-   reg = STV090x_READ_DEMOD(state, TSSTATUS);
-   if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) {
-   *status = FE_HAS_CARRIER | FE_HAS_VITERBI | 
FE_HAS_SYNC | FE_HAS_LOCK;
+   reg = STV090x_READ_DEMOD(state, PDELSTATUS1);
+   if (STV090x_GETFIELD_Px(reg, PKTDELIN_LOCK_FIELD)) {
+   reg = STV090x_READ_DEMOD(state, TSSTATUS);
+   if (STV090x_GETFIELD_Px(reg, 
TSFIFO_LINEOK_FIELD)) {
+   *status = FE_HAS_CARRIER |
+ FE_HAS_VITERBI |
+ FE_HAS_SYNC |
+ FE_HAS_LOCK;
+   }
}
}
break;
--
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 9/9] stv090x: corrections of some register values, blind scan related fixes

2009-11-02 Thread Andreas Regel

This patch adds corrections of some register values. It also contains some 
blind scan related fixes.

Signed-off-by: Andreas Regel andreas.re...@gmx.de

diff -r e8ae419fa64f linux/drivers/media/dvb/frontends/stv090x.c
--- a/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:16:29 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/stv090x.c   Mon Nov 02 23:25:35 
2009 +0100
@@ -1969,6 +1969,8 @@
goto err;
}

+   if (stv090x_set_vit_thtracq(state)  0)
+   goto err;
break;

case STV090x_SEARCH_AUTO:
@@ -2009,17 +2011,8 @@
goto err;
}

-   if (state-srate = 200) {
-   /* Srate = 2MSPS, Viterbi threshold to acquire */
-   if (stv090x_set_vit_thacq(state)  0)
-   goto err;
-   } else {
-   /* Srate  2MSPS, Reset Viterbi thresholdto track
-* and then re-acquire
-*/
-   if (stv090x_set_vit_thtracq(state)  0)
-   goto err;
-   }
+   if (stv090x_set_vit_thacq(state)  0)
+   goto err;

if (stv090x_set_viterbi(state)  0)
goto err;
@@ -2153,6 +2146,9 @@
if (STV090x_WRITE_DEMOD(state, DMDCFG2, reg)  0)
goto err;

+   if (STV090x_WRITE_DEMOD(state, RTC, 0x88)  0)
+   goto err;
+
if (state-dev_ver = 0x20) {
/*Frequency offset detector setting*/
if (state-srate  200) {
@@ -2161,7 +2157,7 @@
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x39)  
0)
goto err;
} else {
-   /* Cut 2 */
+   /* Cut 3 */
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x89)  
0)
goto err;
}
@@ -2170,8 +2166,12 @@
} else if (state-srate  1000) {
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c)  0)
goto err;
+   if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20)  0)
+   goto err;
} else {
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4b)  0)
+   goto err;
+   if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20)  0)
goto err;
}
} else {
@@ -2220,8 +2220,8 @@
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38)  0)
goto err;
reg = STV090x_READ_DEMOD(state, DMDCFGMD);
-   STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1);
-   STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1);
+   STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 0);
+   STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0);
if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg)  0)
goto err;

@@ -2238,10 +2238,8 @@
if (stv090x_set_srate(state, 100)  0)
goto err;

-   steps  = -1 + state-search_range / 100;
-   steps /= 2;
-   steps  = (2 * steps) + 1;
-   if (steps  0)
+   steps  = state-search_range / 100;
+   if (steps = 0)
steps = 1;

dir = 1;
@@ -2327,13 +2325,15 @@
goto err;
if (STV090x_WRITE_DEMOD(state, TMGCFG, 0x12)  0)
goto err;
+   if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc0)  0)
+   goto err;
if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xf0)  0)
goto err;
if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xe0)  0)
goto err;
reg = STV090x_READ_DEMOD(state, DMDCFGMD);
STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1);
-   STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1);
+   STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0);
if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg)  0)
goto err;

@@ -2353,7 +2353,7 @@
if (state-dev_ver = 0x30) {
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x99)  0)
goto err;
-   if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x95)  0)
+   if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x98)  0)
goto err;

} else if (state-dev_ver = 0x20) {
@@ -2388,9 +2388,16 @@
while ((!tmg_lock)  (cur_step  steps)) {
if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5f)  0) /* Demod 
RESET */
goto err;
-   reg = STV090x_READ_DEMOD(state, DMDISTATE);
-   STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x00); /* 
trigger acquisition

stv090x/stv6110x improvements and bug fixes

2009-10-14 Thread Andreas Regel

Hi,

some time ago, I made some improvements and fixed some bugs in the 
stv090x and stv6110x frontend drivers. These include:


- increased search range on STV090x based on symbol rate
- fixed some STV090x register definitions and typos
- fix STR and SNR calculation and normalize the value into the 0..0x 
range

- fixed STV6110x r divider calculation when setting frequency
- first disable DVB-S and DVB-S2 mode before enabling it again for 
automatic search

- fix calculation of AGC2 values
- corrections of several register values
- several blind scan related fixes

They were available since about two months and tested successfully using 
TT S2-1600 card by me and other people from vdrportal.de. I made them 
public in my repository available at http://powarman.dyndns.org/hg/v4l-dvb


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: [linux-dvb] Most stable DVB-S2 PCI Card?

2009-05-23 Thread Andreas Regel

David Lister schrieb:

I didn't want to write a long mail, but here goes:

The TechnoTrend company, as of Februay 2009, doesn't exists any more.
*It is bankrupt*. First, its owner Novabase sold as many of its shares
as it could in 2007, in hope that the proceeds would allow TechnoTrend
to get back on track. No such luck. A few months back this year, the
company was finally dumped and sold as a whole to some German telco
company in the Kathrein Group for liquidation, because of the tremendous
drop in it's market value and forthcoming bankruptcy. This might also be
of some interest to prospective buyers of it's former products. :) I
don't want to search for all the press releases, but you can verify this
claim here:
http://www.euronext.com/fic/000/044/480/444806.pdf


As written there the Görler Telekom bought the business and stock of TT, 
that includes the brand name, all products and most of the developers. 
They formed a new Company called TechnoTrend Görler GmbH, that will 
continue development, production and sales.


See here: http://www.kathrein.de//en/press/cont/texte2009/pi0910.htm

Even if not explicitely mentioned there, PC products are included in 
that deal.


New web site is still under construction: http://www.ttgoerler.de/

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