summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-03-14 13:46:20 +0000
committerAndrew de Quincy <devnull@localhost>2004-03-14 13:46:20 +0000
commit88b768d2c49c62fcaa4dacae229d83b91629b70e (patch)
tree61e534231366513c0680aba3ddcfb3ccdbf51d9f /linux/drivers/media/dvb
parent3db8e7c4112efb6084607b0a927ced1f38ea4963 (diff)
downloadmediapointer-dvb-s2-88b768d2c49c62fcaa4dacae229d83b91629b70e.tar.gz
mediapointer-dvb-s2-88b768d2c49c62fcaa4dacae229d83b91629b70e.tar.bz2
Fixed INVERSION_AUTO code so it no longer writes to the global initalisation values.
Converted 8space->1tabs (formatting) Added extra printks to report _exact_ ves1x93 version detected
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r--linux/drivers/media/dvb/frontends/ves1x93.c153
1 files changed, 84 insertions, 69 deletions
diff --git a/linux/drivers/media/dvb/frontends/ves1x93.c b/linux/drivers/media/dvb/frontends/ves1x93.c
index b1b02a4d9..170416d5f 100644
--- a/linux/drivers/media/dvb/frontends/ves1x93.c
+++ b/linux/drivers/media/dvb/frontends/ves1x93.c
@@ -49,12 +49,12 @@ 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 = 250, /* kHz for QPSK frontends */
.frequency_tolerance = 29500,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
-/* .symbol_rate_tolerance = ???,*/
- .notifier_delay = 50, /* 1/20 s */
+/* .symbol_rate_tolerance = ???,*/
+ .notifier_delay = 50, /* 1/20 s */
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
@@ -95,10 +95,10 @@ static u8 * init_1x93_tab;
static u8 init_1893_wtab[] =
{
- 1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
- 0,1,0,0,0,0,0,0, 1,0,1,1,0,0,0,1,
- 1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
- 1,1,1,0,1,1
+ 1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
+ 0,1,0,0,0,0,0,0, 1,0,1,1,0,0,0,1,
+ 1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
+ 1,1,1,0,1,1
};
@@ -110,19 +110,24 @@ static u8 init_1993_wtab[] =
1,1,1,0,1,1,1,1, 1,1,1,1,1
};
+struct ves1x93_state {
+ fe_spectral_inversion_t inversion;
+};
+
+
static int ves1x93_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
{
- u8 buf [] = { 0x00, reg, data };
+ u8 buf [] = { 0x00, reg, data };
struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 3 };
int err;
- if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
+ if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
return -EREMOTEIO;
}
- return 0;
+ return 0;
}
@@ -145,17 +150,17 @@ static u8 ves1x93_readreg (struct dvb_i2c_bus *i2c, u8 reg)
static int tuner_write (struct dvb_i2c_bus *i2c, u8 *data, u8 len)
{
- int ret;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = len };
+ int ret;
+ struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = len };
ves1x93_writereg(i2c, 0x00, 0x11);
- ret = i2c->xfer (i2c, &msg, 1);
+ ret = i2c->xfer (i2c, &msg, 1);
ves1x93_writereg(i2c, 0x00, 0x01);
- if (ret != 1)
- printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
+ if (ret != 1)
+ printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
- return (ret != 1) ? -1 : 0;
+ return (ret != 1) ? -1 : 0;
}
@@ -166,7 +171,7 @@ static int tuner_write (struct dvb_i2c_bus *i2c, u8 *data, u8 len)
*/
static int sp5659_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, u8 pwr)
{
- u32 div = (freq + 479500) / 125;
+ u32 div = (freq + 479500) / 125;
u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x95, (pwr << 5) | 0x30 };
return tuner_write (i2c, buf, sizeof(buf));
@@ -246,18 +251,18 @@ static int ves1x93_init (struct dvb_i2c_bus *i2c)
static int ves1x93_clr_bit (struct dvb_i2c_bus *i2c)
{
- ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
- ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
- dvb_delay(5);
- return 0;
+ ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
+ ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
+ dvb_delay(5);
+ return 0;
}
static int ves1x93_init_aquire (struct dvb_i2c_bus *i2c)
{
- ves1x93_writereg (i2c, 3, 0x00);
- ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
- dvb_delay(5);
- return 0;
+ ves1x93_writereg (i2c, 3, 0x00);
+ ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
+ dvb_delay(5);
+ return 0;
}
@@ -284,10 +289,7 @@ static int ves1x93_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion
return -EINVAL;
}
- /* needs to be saved for FE_GET_FRONTEND */
- init_1x93_tab[0x0c] = (init_1x93_tab[0x0c] & 0x3f) | val;
-
- return ves1x93_writereg (i2c, 0x0c, init_1x93_tab[0x0c]);
+ return ves1x93_writereg (i2c, 0x0c, (init_1x93_tab[0x0c] & 0x3f) | val);
}
@@ -311,7 +313,7 @@ static fe_code_rate_t ves1x93_get_fec (struct dvb_i2c_bus *i2c)
static int ves1x93_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
{
u32 BDR;
- u32 ratio;
+ u32 ratio;
u8 ADCONF, FCONF, FNR;
u32 BDRI;
u32 tmp;
@@ -359,15 +361,15 @@ static int ves1x93_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
FNR = 0xff;
- if (ratio < MUL/3) FNR = 0;
+ if (ratio < MUL/3) FNR = 0;
if (ratio < (MUL*11)/50) FNR = 1;
- if (ratio < MUL/6) FNR = 2;
- if (ratio < MUL/9) FNR = 3;
- if (ratio < MUL/12) FNR = 4;
+ if (ratio < MUL/6) FNR = 2;
+ if (ratio < MUL/9) FNR = 3;
+ if (ratio < MUL/12) FNR = 4;
if (ratio < (MUL*11)/200) FNR = 5;
- if (ratio < MUL/24) FNR = 6;
+ if (ratio < MUL/24) FNR = 6;
if (ratio < (MUL*27)/1000) FNR = 7;
- if (ratio < MUL/48) FNR = 8;
+ if (ratio < MUL/48) FNR = 8;
if (ratio < (MUL*137)/10000) FNR = 9;
if (FNR == 0xff) {
@@ -377,16 +379,16 @@ static int ves1x93_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
} else {
ADCONF = 0x81;
FCONF = 0x88 | (FNR >> 1) | ((FNR & 0x01) << 5);
- /*FCONF = 0x80 | ((FNR & 0x01) << 5) | (((FNR > 1) & 0x03) << 3) | ((FNR >> 1) & 0x07);*/
+ /*FCONF = 0x80 | ((FNR & 0x01) << 5) | (((FNR > 1) & 0x03) << 3) | ((FNR >> 1) & 0x07);*/
}
BDR = (( (ratio << (FNR >> 1)) >> 4) + 1) >> 1;
BDRI = ( ((FIN << 8) / ((srate << (FNR >> 1)) >> 2)) + 1) >> 1;
- dprintk("FNR= %d\n", FNR);
- dprintk("ratio= %08x\n", (unsigned int) ratio);
- dprintk("BDR= %08x\n", (unsigned int) BDR);
- dprintk("BDRI= %02x\n", (unsigned int) BDRI);
+ dprintk("FNR= %d\n", FNR);
+ dprintk("ratio= %08x\n", (unsigned int) ratio);
+ dprintk("BDR= %08x\n", (unsigned int) BDR);
+ dprintk("BDRI= %02x\n", (unsigned int) BDRI);
if (BDRI > 0xff)
BDRI = 0xff;
@@ -416,8 +418,8 @@ static int ves1x93_afc (struct dvb_i2c_bus *i2c, u32 freq, u32 srate)
{
int afc;
- afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
- afc = (afc * (int)(srate/1000/8))/16;
+ afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
+ afc = (afc * (int)(srate/1000/8))/16;
if (afc) {
@@ -425,13 +427,10 @@ static int ves1x93_afc (struct dvb_i2c_bus *i2c, u32 freq, u32 srate)
tuner_set_tv_freq (i2c, freq, 0);
- ves1x93_init_aquire (i2c);
-
- afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
- afc = (afc * (int)(srate/1000/8))/16;
+ ves1x93_init_aquire (i2c);
}
- return 0;
+ return 0;
}
static int ves1x93_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
@@ -452,13 +451,14 @@ static int ves1x93_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltag
static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct dvb_i2c_bus *i2c = fe->i2c;
+ struct ves1x93_state *state = (struct ves1x93_state*) fe->data;
- switch (cmd) {
- case FE_GET_INFO:
+ switch (cmd) {
+ case FE_GET_INFO:
memcpy (arg, &ves1x93_info, sizeof(struct dvb_frontend_info));
break;
- case FE_READ_STATUS:
+ case FE_READ_STATUS:
{
fe_status_t *status = arg;
u8 sync = ves1x93_readreg (i2c, 0x0e);
@@ -483,25 +483,25 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
break;
}
- case FE_READ_BER:
+ case FE_READ_BER:
{
u32 *ber = (u32 *) arg;
*ber = ves1x93_readreg (i2c, 0x15);
- *ber |= (ves1x93_readreg (i2c, 0x16) << 8);
- *ber |= ((ves1x93_readreg (i2c, 0x17) & 0x0F) << 16);
+ *ber |= (ves1x93_readreg (i2c, 0x16) << 8);
+ *ber |= ((ves1x93_readreg (i2c, 0x17) & 0x0F) << 16);
*ber *= 10;
break;
}
- case FE_READ_SIGNAL_STRENGTH:
+ case FE_READ_SIGNAL_STRENGTH:
{
u8 signal = ~ves1x93_readreg (i2c, 0x0b);
*((u16*) arg) = (signal << 8) | signal;
break;
}
- case FE_READ_SNR:
+ case FE_READ_SNR:
{
u8 snr = ~ves1x93_readreg (i2c, 0x1c);
*(u16*) arg = (snr << 8) | snr;
@@ -520,8 +520,8 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
break;
}
- case FE_SET_FRONTEND:
- {
+ case FE_SET_FRONTEND:
+ {
struct dvb_frontend_parameters *p = arg;
tuner_set_tv_freq (i2c, p->frequency, 0);
@@ -529,8 +529,9 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
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);
- break;
- }
+ state->inversion = p->inversion;
+ break;
+ }
case FE_GET_FRONTEND:
{
@@ -546,7 +547,7 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
* inversion indicator is only valid
* if auto inversion was used
*/
- if (!(init_1x93_tab[0x0c] & 0x80))
+ if (state->inversion == INVERSION_AUTO)
p->inversion = (ves1x93_readreg (i2c, 0x0f) & 2) ?
INVERSION_OFF : INVERSION_ON;
p->u.qpsk.fec_inner = ves1x93_get_fec (i2c);
@@ -554,41 +555,48 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
break;
}
- case FE_SLEEP:
+ case FE_SLEEP:
if (board_type == BOARD_SIEMENS_PCI)
ves1x93_writereg (i2c, 0x1f, 0x00); /* LNB power off */
return ves1x93_writereg (i2c, 0x00, 0x08);
- case FE_INIT:
+ case FE_INIT:
return ves1x93_init (i2c);
case FE_SET_TONE:
return -EOPNOTSUPP; /* the ves1893 can generate the 22k */
- /* let's implement this when we have */
- /* a box that uses the 22K_0 pin... */
+ /* let's implement this when we have */
+ /* a box that uses the 22K_0 pin... */
case FE_SET_VOLTAGE:
return ves1x93_set_voltage (i2c, (fe_sec_voltage_t) arg);
default:
return -EOPNOTSUPP;
- };
-
- return 0;
+ };
+
+ return 0;
}
static int ves1x93_attach (struct dvb_i2c_bus *i2c, void **data)
{
u8 identity = ves1x93_readreg(i2c, 0x1e);
+ struct ves1x93_state* state;
switch (identity) {
case 0xdc: /* VES1893A rev1 */
+ printk("ves1x93: Detected ves1893a rev1\n");
+ demod_type = DEMOD_VES1893;
+ ves1x93_info.name[4] = '8';
+ break;
case 0xdd: /* VES1893A rev2 */
+ printk("ves1x93: Detected ves1893a rev2\n");
demod_type = DEMOD_VES1893;
ves1x93_info.name[4] = '8';
break;
case 0xde: /* VES1993 */
+ printk("ves1x93: Detected ves1993\n");
demod_type = DEMOD_VES1993;
ves1x93_info.name[4] = '9';
break;
@@ -597,12 +605,19 @@ static int ves1x93_attach (struct dvb_i2c_bus *i2c, void **data)
return -ENODEV;
}
- return dvb_register_frontend (ves1x93_ioctl, i2c, NULL, &ves1x93_info);
+ if ((state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL)) == NULL) {
+ return -ENOMEM;
+ }
+ state->inversion = INVERSION_OFF;
+ *data = state;
+
+ return dvb_register_frontend (ves1x93_ioctl, i2c, (void*) state, &ves1x93_info);
}
static void ves1x93_detach (struct dvb_i2c_bus *i2c, void *data)
{
+ kfree(data);
dvb_unregister_frontend (ves1x93_ioctl, i2c);
}