summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-08-25 19:27:08 +0000
committerAndrew de Quincy <devnull@localhost>2004-08-25 19:27:08 +0000
commitde920e6c4a904f0c6a11698706a60da0ea21813a (patch)
tree3a20dddd542edc41a4d5be670cbcf6e0fe4e7168 /linux/drivers
parentb3e7dadf5cc76766b37ca1af7f333d76bde55c6a (diff)
downloadmediapointer-dvb-s2-de920e6c4a904f0c6a11698706a60da0ea21813a.tar.gz
mediapointer-dvb-s2-de920e6c4a904f0c6a11698706a60da0ea21813a.tar.bz2
Patch from Andreas Share / Gregoire Favre to fix tuning issues.
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/dvb/frontends/ves1x93.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/linux/drivers/media/dvb/frontends/ves1x93.c b/linux/drivers/media/dvb/frontends/ves1x93.c
index 3c78c5706..35d0019b4 100644
--- a/linux/drivers/media/dvb/frontends/ves1x93.c
+++ b/linux/drivers/media/dvb/frontends/ves1x93.c
@@ -28,6 +28,7 @@
#include <linux/init.h>
#include <linux/string.h>
#include <linux/slab.h>
+#include <linux/delay.h>
#include "dvb_frontend.h"
@@ -48,7 +49,7 @@ static struct dvb_frontend_info ves1x93_info = {
.type = FE_QPSK,
.frequency_min = 950000,
.frequency_max = 2150000,
- .frequency_stepsize = 250, /* kHz for QPSK frontends */
+ .frequency_stepsize = 125, /* kHz for QPSK frontends */
.frequency_tolerance = 29500,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
@@ -170,10 +171,26 @@ static int tuner_write (struct i2c_adapter *i2c, u8 *data, u8 len)
* set up the downconverter frequency divisor for a
* reference clock comparision frequency of 125 kHz.
*/
-static int sp5659_set_tv_freq (struct i2c_adapter *i2c, u32 freq, u8 pwr)
+static int sp5659_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{
+ u8 pwr = 0;
+ u8 buf[4];
u32 div = (freq + 479500) / 125;
- u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x95, (pwr << 5) | 0x30 };
+
+ if (freq > 2000000) pwr = 3;
+ else if (freq > 1800000) pwr = 2;
+ else if (freq > 1600000) pwr = 1;
+ else if (freq > 1200000) pwr = 0;
+ else if (freq >= 1100000) pwr = 1;
+ else pwr = 2;
+
+ buf[0] = (div >> 8) & 0x7f;
+ buf[1] = div & 0xff;
+ buf[2] = ((div & 0x18000) >> 10) | 0x95;
+ buf[3] = (pwr << 6) | 0x30;
+
+ // NOTE: since we're using a prescaler of 2, we set the
+ // divisor frequency to 62.5kHz and divide by 125 above
return tuner_write (i2c, buf, sizeof(buf));
}
@@ -195,10 +212,10 @@ static int tsa5059_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
}
-static int tuner_set_tv_freq (struct i2c_adapter *i2c, u32 freq, u8 pwr)
+static int tuner_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{
if ((demod_type == DEMOD_VES1893) && (board_type == BOARD_SIEMENS_PCI))
- return sp5659_set_tv_freq (i2c, freq, pwr);
+ return sp5659_set_tv_freq (i2c, freq);
else if (demod_type == DEMOD_VES1993)
return tsa5059_set_tv_freq (i2c, freq);
@@ -252,21 +269,13 @@ static int ves1x93_init (struct i2c_adapter *i2c)
static int ves1x93_clr_bit (struct i2c_adapter *i2c)
{
+ msleep(10);
ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
- msleep(5);
+ msleep(50);
return 0;
}
-static int ves1x93_init_aquire (struct i2c_adapter *i2c)
-{
- ves1x93_writereg (i2c, 3, 0x00);
- ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
- msleep(5);
- return 0;
-}
-
-
static int ves1x93_set_inversion (struct i2c_adapter *i2c, fe_spectral_inversion_t inversion)
{
u8 val;
@@ -414,26 +423,6 @@ static int ves1x93_set_symbolrate (struct i2c_adapter *i2c, u32 srate)
return 0;
}
-
-static int ves1x93_afc (struct i2c_adapter *i2c, u32 freq, u32 srate)
-{
- int afc;
-
- afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
- afc = (afc * (int)(srate/1000/8))/16;
-
- if (afc) {
-
- freq -= afc;
-
- tuner_set_tv_freq (i2c, freq, 0);
-
- ves1x93_init_aquire (i2c);
- }
-
- return 0;
-}
-
static int ves1x93_set_voltage (struct i2c_adapter *i2c, fe_sec_voltage_t voltage)
{
switch (voltage) {
@@ -525,11 +514,10 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct dvb_frontend_parameters *p = arg;
- tuner_set_tv_freq (i2c, p->frequency, 0);
+ tuner_set_tv_freq (i2c, p->frequency);
ves1x93_set_inversion (i2c, p->inversion);
ves1x93_set_fec (i2c, p->u.qpsk.fec_inner);
ves1x93_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
- ves1x93_afc (i2c, p->frequency, p->u.qpsk.symbol_rate);
state->inversion = p->inversion;
break;
}