summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-03-14 13:48:32 +0000
committerAndrew de Quincy <devnull@localhost>2004-03-14 13:48:32 +0000
commit2199099acbd749dfcac8adfc5d2a33dce2111f0f (patch)
tree6d2fdf2538e5d444e977689a46a2b7f950a9fdcf /linux/drivers/media/dvb/frontends
parentaf1df40642bd545afee9fa5a31cfe6c49d4fe116 (diff)
downloadmediapointer-dvb-s2-2199099acbd749dfcac8adfc5d2a33dce2111f0f.tar.gz
mediapointer-dvb-s2-2199099acbd749dfcac8adfc5d2a33dce2111f0f.tar.bz2
ALPS BSRU6 needs inversion inverted.
Converted 8space->1tabs (formatting)
Diffstat (limited to 'linux/drivers/media/dvb/frontends')
-rw-r--r--linux/drivers/media/dvb/frontends/stv0299.c550
1 files changed, 278 insertions, 272 deletions
diff --git a/linux/drivers/media/dvb/frontends/stv0299.c b/linux/drivers/media/dvb/frontends/stv0299.c
index 2615042ab..90b214964 100644
--- a/linux/drivers/media/dvb/frontends/stv0299.c
+++ b/linux/drivers/media/dvb/frontends/stv0299.c
@@ -18,7 +18,7 @@
LG TDQF-S001F
Copyright (C) 2002 Felix Domke <tmbinc@elitedvb.net>
- & Andreas Oberritter <obi@linuxtv.org>
+ & Andreas Oberritter <obi@linuxtv.org>
Support for Samsung TBMU24112IMB used on Technisat SkyStar2 rev. 2.6B
@@ -69,12 +69,12 @@ static int stv0299_status = 0;
/* frontend types */
#define UNKNOWN_FRONTEND -1
-#define PHILIPS_SU1278_TSA 0 // SU1278 with TSA5059 synth and datasheet recommended settings
-#define ALPS_BSRU6 1
-#define LG_TDQF_S001F 2
-#define PHILIPS_SU1278_TUA 3 // SU1278 with TUA6100 synth
-#define SAMSUNG_TBMU24112IMB 4
-#define PHILIPS_SU1278_TSA_TT 5 // SU1278 with TSA5059 synth and TechnoTrend settings
+#define PHILIPS_SU1278_TSA 0 // SU1278 with TSA5059 synth and datasheet recommended settings
+#define ALPS_BSRU6 1
+#define LG_TDQF_S001F 2
+#define PHILIPS_SU1278_TUA 3 // SU1278 with TUA6100 synth
+#define SAMSUNG_TBMU24112IMB 4
+#define PHILIPS_SU1278_TSA_TT 5 // SU1278 with TSA5059 synth and TechnoTrend settings
/* Master Clock = 88 MHz */
#define M_CLK (88000000UL)
@@ -87,11 +87,11 @@ static struct dvb_frontend_info uni0299_info = {
.type = FE_QPSK,
.frequency_min = 950000,
.frequency_max = 2150000,
- .frequency_stepsize = 125, /* kHz for QPSK frontends */
+ .frequency_stepsize = 125, /* kHz for QPSK frontends */
.frequency_tolerance = M_CLK/2000,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 500, /* ppm */
+ .symbol_rate_tolerance = 500, /* ppm */
.notifier_delay = 0,
.caps = 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 |
@@ -101,39 +101,39 @@ static struct dvb_frontend_info uni0299_info = {
struct stv0299_state {
- u8 tuner_type;
- u8 initialised:1;
- u32 tuner_frequency;
- u32 symbol_rate;
- fe_code_rate_t fec_inner;
+ u8 tuner_type;
+ u8 initialised:1;
+ u32 tuner_frequency;
+ u32 symbol_rate;
+ fe_code_rate_t fec_inner;
};
static u8 init_tab [] = {
- 0x04, 0x7d, /* F22FR = 0x7d */
- /* F22 = f_VCO / 128 / 0x7d = 22 kHz */
+ 0x04, 0x7d, /* F22FR = 0x7d */
+ /* F22 = f_VCO / 128 / 0x7d = 22 kHz */
- /* I2C bus repeater */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
+ /* I2C bus repeater */
+ 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- /* general purpose DAC registers */
+ /* general purpose DAC registers */
0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
+ 0x07, 0x00, /* DAC LSB */
/* DiSEqC registers */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
+ 0x09, 0x00, /* FIFO */
- /* Input/Output configuration register */
+ /* Input/Output configuration register */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- /* OP0 ctl = Normal, OP0 val = 1 (18 V) */
- /* Nyquist filter = 00, QPSK reverse = 0 */
+ /* OP0 ctl = Normal, OP0 val = 1 (18 V) */
+ /* Nyquist filter = 00, QPSK reverse = 0 */
- /* AGC1 control register */
+ /* AGC1 control register */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- /* Timing loop register */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
+ /* Timing loop register */
+ 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
@@ -155,7 +155,7 @@ static u8 init_tab [] = {
0x22, 0x00,
0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
+ 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
@@ -218,48 +218,48 @@ static u8 init_tab_samsung [] = {
static u8 init_tab_su1278_tsa_tt [] = {
- 0x01, 0x0f,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x5b,
- 0x05, 0x85,
- 0x06, 0x02,
- 0x07, 0x00,
- 0x08, 0x02,
- 0x09, 0x00,
- 0x0C, 0x01,
- 0x0D, 0x81,
- 0x0E, 0x44,
- 0x0f, 0x14,
- 0x10, 0x3c,
- 0x11, 0x84,
- 0x12, 0xda,
- 0x13, 0x97,
- 0x14, 0x95,
- 0x15, 0xc9,
- 0x16, 0x19,
- 0x17, 0x8c,
- 0x18, 0x59,
- 0x19, 0xf8,
- 0x1a, 0xfe,
- 0x1c, 0x7f,
- 0x1d, 0x00,
- 0x1e, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00,
- 0x29, 0x28,
- 0x2a, 0x14,
- 0x2b, 0x0f,
- 0x2c, 0x09,
- 0x2d, 0x09,
- 0x31, 0x1f,
- 0x32, 0x19,
- 0x33, 0xfc,
- 0x34, 0x13
+ 0x01, 0x0f,
+ 0x02, 0x30,
+ 0x03, 0x00,
+ 0x04, 0x5b,
+ 0x05, 0x85,
+ 0x06, 0x02,
+ 0x07, 0x00,
+ 0x08, 0x02,
+ 0x09, 0x00,
+ 0x0C, 0x01,
+ 0x0D, 0x81,
+ 0x0E, 0x44,
+ 0x0f, 0x14,
+ 0x10, 0x3c,
+ 0x11, 0x84,
+ 0x12, 0xda,
+ 0x13, 0x97,
+ 0x14, 0x95,
+ 0x15, 0xc9,
+ 0x16, 0x19,
+ 0x17, 0x8c,
+ 0x18, 0x59,
+ 0x19, 0xf8,
+ 0x1a, 0xfe,
+ 0x1c, 0x7f,
+ 0x1d, 0x00,
+ 0x1e, 0x00,
+ 0x1f, 0x50,
+ 0x20, 0x00,
+ 0x21, 0x00,
+ 0x22, 0x00,
+ 0x23, 0x00,
+ 0x28, 0x00,
+ 0x29, 0x28,
+ 0x2a, 0x14,
+ 0x2b, 0x0f,
+ 0x2c, 0x09,
+ 0x2d, 0x09,
+ 0x31, 0x1f,
+ 0x32, 0x19,
+ 0x33, 0xfc,
+ 0x34, 0x13
};
static int stv0299_set_FEC (struct dvb_i2c_bus *i2c, fe_code_rate_t fec);
@@ -301,16 +301,16 @@ static u8 stv0299_readreg (struct dvb_i2c_bus *i2c, u8 reg)
static int stv0299_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len)
{
- int ret;
- struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 },
- { .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } };
+ int ret;
+ struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 },
+ { .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } };
- ret = i2c->xfer (i2c, msg, 2);
+ ret = i2c->xfer (i2c, msg, 2);
- if (ret != 2)
- dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
+ if (ret != 2)
+ dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
- return ret == 2 ? 0 : ret;
+ return ret == 2 ? 0 : ret;
}
@@ -361,18 +361,18 @@ static int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, in
u8 addr;
u32 div;
u8 buf[4];
- int divisor, regcode;
+ int divisor, regcode;
dprintk ("%s: freq %i, ftype %i\n", __FUNCTION__, freq, ftype);
if ((freq < 950000) || (freq > 2150000)) return -EINVAL;
- if (ftype == PHILIPS_SU1278_TSA_TT) {
- divisor = 500;
- regcode = 2;
+ if (ftype == PHILIPS_SU1278_TSA_TT) {
+ divisor = 500;
+ regcode = 2;
} else {
- divisor = 125;
- regcode = 4;
+ divisor = 125;
+ regcode = 4;
}
// setup frequency divisor
@@ -400,8 +400,8 @@ static int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, in
case ALPS_BSRU6:
addr = 0x61;
buf[3] = 0xC4;
- if (freq > 1530000) buf[3] = 0xc0;
- break;
+ if (freq > 1530000) buf[3] = 0xc0;
+ break;
default:
return -EINVAL;
@@ -461,12 +461,12 @@ static int tua6100_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq,
reg1[1] &= 0x7F;
if (_fband == 2) {
- if (first_ZF > 1430) { /* 1430MHZ */
- reg1[1] &= 0xCF; /* N2 */
+ if (first_ZF > 1430) { /* 1430MHZ */
+ reg1[1] &= 0xCF; /* N2 */
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
- } else {
- reg1[1] &= 0xCF; /* N2 */
+ } else {
+ reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
@@ -474,28 +474,28 @@ static int tua6100_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq,
}
if (_fband == 3) {
- if ((first_ZF >= 1455) &&
+ if ((first_ZF >= 1455) &&
(first_ZF < 1630)) {
reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
reg2[1] &= 0xCF; /* R2 */
- } else {
+ } else {
if (first_ZF < 1455) {
- reg1[1] &= 0xCF; /* N2 */
+ reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- } else {
- if (first_ZF >= 1630) {
- reg1[1] &= 0xCF; /* N2 */
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- }
- }
- }
+ reg2[1] &= 0xCF; /* R2 */
+ reg2[1] |= 0x10;
+ } else {
+ if (first_ZF >= 1630) {
+ reg1[1] &= 0xCF; /* N2 */
+ reg2[1] &= 0xCF; /* R2 */
+ reg2[1] |= 0x10;
+ }
+ }
+ }
}
- /* set ports, enable P0 for symbol rates > 4Ms/s */
+ /* set ports, enable P0 for symbol rates > 4Ms/s */
if (srate >= 4000000)
reg1[1] |= 0x0c;
else
@@ -505,17 +505,17 @@ static int tua6100_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq,
R = 64;
A = 64;
- P = 64; //32
+ P = 64; //32
M = (freq * R) / 4; /* in Mhz */
N = (M - A * 1000) / (P * 1000);
reg1[1] |= (N >> 9) & 0x03;
- reg1[2] = (N >> 1) & 0xff;
- reg1[3] = (N << 7) & 0x80;
+ reg1[2] = (N >> 1) & 0xff;
+ reg1[3] = (N << 7) & 0x80;
reg2[1] |= (R >> 8) & 0x03;
- reg2[2] = R & 0xFF; /* R */
+ reg2[2] = R & 0xFF; /* R */
reg1[3] |= A & 0x7f; /* A */
@@ -541,7 +541,7 @@ static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int sr
{
switch(ftype) {
case SAMSUNG_TBMU24112IMB:
- return sl1935_set_tv_freq(i2c, freq, ftype);
+ return sl1935_set_tv_freq(i2c, freq, ftype);
case LG_TDQF_S001F:
return sl1935_set_tv_freq(i2c, freq, ftype);
@@ -595,10 +595,10 @@ static int stv0299_init (struct dvb_i2c_bus *i2c, int ftype)
break;
case PHILIPS_SU1278_TSA_TT:
- for (i=0; i<sizeof(init_tab_su1278_tsa_tt); i+=2) {
+ for (i=0; i<sizeof(init_tab_su1278_tsa_tt); i+=2) {
stv0299_writereg (i2c, init_tab_su1278_tsa_tt[i], init_tab_su1278_tsa_tt[i+1]);
}
- break;
+ break;
default:
stv0299_writereg (i2c, 0x01, 0x15);
@@ -772,7 +772,7 @@ static int stv0299_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t
val = stv0299_readreg (i2c, 0x08);
- if (stv0299_writereg (i2c, 0x08, (val & ~0x7) | 0x2)) /* burst mode */
+ if (stv0299_writereg (i2c, 0x08, (val & ~0x7) | 0x2)) /* burst mode */
return -EREMOTEIO;
if (stv0299_writereg (i2c, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff))
@@ -804,17 +804,17 @@ static int stv0299_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone)
switch (tone) {
case SEC_TONE_ON:
{
- dprintk("%s: TONE_ON\n", __FUNCTION__);
+ dprintk("%s: TONE_ON\n", __FUNCTION__);
return stv0299_writereg (i2c, 0x08, val | 0x3);
}
case SEC_TONE_OFF:
{
- dprintk("%s: TONE_OFF\n", __FUNCTION__);
+ dprintk("%s: TONE_OFF\n", __FUNCTION__);
return stv0299_writereg (i2c, 0x08, (val & ~0x3) | 0x02);
}
default:
{
- dprintk("%s: TONE INVALID\n", __FUNCTION__);
+ dprintk("%s: TONE INVALID\n", __FUNCTION__);
return -EINVAL;
}
};
@@ -864,49 +864,49 @@ static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner
u8 aclk = 0;
u8 bclk = 0;
u8 m1;
- int Mclk = M_CLK;
+ int Mclk = M_CLK;
- // check rate is within limits
+ // check rate is within limits
if ((srate < 1000000) || (srate > 45000000)) return -EINVAL;
- // calculate value to program
+ // calculate value to program
if (tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT;
- big = big << 20;
- big += (Mclk-1); // round correctly
- do_div(big, Mclk);
- ratio = big << 4;
+ big = big << 20;
+ big += (Mclk-1); // round correctly
+ do_div(big, Mclk);
+ ratio = big << 4;
- // program registers
+ // program registers
switch(tuner_type) {
case PHILIPS_SU1278_TSA_TT:
- stv0299_writereg (i2c, 0x0e, 0x44);
- if (srate >= 10000000) {
- stv0299_writereg (i2c, 0x13, 0x97);
- stv0299_writereg (i2c, 0x14, 0x95);
- stv0299_writereg (i2c, 0x15, 0xc9);
- stv0299_writereg (i2c, 0x17, 0x8c);
- stv0299_writereg (i2c, 0x1a, 0xfe);
- stv0299_writereg (i2c, 0x1c, 0x7f);
- stv0299_writereg (i2c, 0x2d, 0x09);
+ stv0299_writereg (i2c, 0x0e, 0x44);
+ if (srate >= 10000000) {
+ stv0299_writereg (i2c, 0x13, 0x97);
+ stv0299_writereg (i2c, 0x14, 0x95);
+ stv0299_writereg (i2c, 0x15, 0xc9);
+ stv0299_writereg (i2c, 0x17, 0x8c);
+ stv0299_writereg (i2c, 0x1a, 0xfe);
+ stv0299_writereg (i2c, 0x1c, 0x7f);
+ stv0299_writereg (i2c, 0x2d, 0x09);
} else {
- stv0299_writereg (i2c, 0x13, 0x99);
- stv0299_writereg (i2c, 0x14, 0x8d);
- stv0299_writereg (i2c, 0x15, 0xce);
- stv0299_writereg (i2c, 0x17, 0x43);
- stv0299_writereg (i2c, 0x1a, 0x1d);
- stv0299_writereg (i2c, 0x1c, 0x12);
- stv0299_writereg (i2c, 0x2d, 0x05);
+ stv0299_writereg (i2c, 0x13, 0x99);
+ stv0299_writereg (i2c, 0x14, 0x8d);
+ stv0299_writereg (i2c, 0x15, 0xce);
+ stv0299_writereg (i2c, 0x17, 0x43);
+ stv0299_writereg (i2c, 0x1a, 0x1d);
+ stv0299_writereg (i2c, 0x1c, 0x12);
+ stv0299_writereg (i2c, 0x2d, 0x05);
}
- stv0299_writereg (i2c, 0x0e, 0x23);
- stv0299_writereg (i2c, 0x0f, 0x94);
- stv0299_writereg (i2c, 0x10, 0x39);
- stv0299_writereg (i2c, 0x15, 0xc9);
+ stv0299_writereg (i2c, 0x0e, 0x23);
+ stv0299_writereg (i2c, 0x0f, 0x94);
+ stv0299_writereg (i2c, 0x10, 0x39);
+ stv0299_writereg (i2c, 0x15, 0xc9);
- stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
- break;
+ stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
+ stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
+ stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
+ break;
case PHILIPS_SU1278_TSA:
aclk = 0xb5;
@@ -918,12 +918,12 @@ static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner
m1 = 0x14;
if (srate < 4000000) m1 = 0x10;
- stv0299_writereg (i2c, 0x13, aclk);
- stv0299_writereg (i2c, 0x14, bclk);
- stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
- stv0299_writereg (i2c, 0x0f, (stv0299_readreg(i2c, 0x0f) & 0xc0) | m1);
+ stv0299_writereg (i2c, 0x13, aclk);
+ stv0299_writereg (i2c, 0x14, bclk);
+ stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
+ stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
+ stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
+ stv0299_writereg (i2c, 0x0f, (stv0299_readreg(i2c, 0x0f) & 0xc0) | m1);
break;
case ALPS_BSRU6:
@@ -935,11 +935,11 @@ static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate, int tuner
else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
- stv0299_writereg (i2c, 0x13, aclk);
- stv0299_writereg (i2c, 0x14, bclk);
- stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
+ stv0299_writereg (i2c, 0x13, aclk);
+ stv0299_writereg (i2c, 0x14, bclk);
+ stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
+ stv0299_writereg (i2c, 0x20, (ratio >> 8) & 0xff);
+ stv0299_writereg (i2c, 0x21, (ratio ) & 0xf0);
break;
}
@@ -958,7 +958,7 @@ static int stv0299_get_symbolrate (struct dvb_i2c_bus *i2c, int tuner_type)
dprintk ("%s\n", __FUNCTION__);
- if (tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT / 4096L;
+ if (tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT / 4096L;
stv0299_readregs (i2c, 0x1f, sfr, 3);
stv0299_readregs (i2c, 0x1a, &rtf, 1);
@@ -985,18 +985,18 @@ static int stv0299_get_symbolrate (struct dvb_i2c_bus *i2c, int tuner_type)
static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct dvb_i2c_bus *i2c = fe->i2c;
- struct stv0299_state *state = (struct stv0299_state *) fe->data;
+ struct stv0299_state *state = (struct stv0299_state *) fe->data;
dprintk ("%s\n", __FUNCTION__);
switch (cmd) {
case FE_GET_INFO:
{
- struct dvb_frontend_info* tmp = (struct dvb_frontend_info*) arg;
+ struct dvb_frontend_info* tmp = (struct dvb_frontend_info*) arg;
memcpy (arg, &uni0299_info, sizeof(struct dvb_frontend_info));
- if (state->tuner_type == PHILIPS_SU1278_TSA_TT) {
- tmp->frequency_tolerance = M_CLK_SU1278_TSA_TT / 2000;
+ if (state->tuner_type == PHILIPS_SU1278_TSA_TT) {
+ tmp->frequency_tolerance = M_CLK_SU1278_TSA_TT / 2000;
}
break;
}
@@ -1032,7 +1032,7 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_READ_BER:
if (stv0299_status == STATUS_BER) {
*((u32*) arg) = (stv0299_readreg (i2c, 0x1d) << 8)
- | stv0299_readreg (i2c, 0x1e);
+ | stv0299_readreg (i2c, 0x1e);
} else {
*((u32*) arg) = 0;
}
@@ -1041,7 +1041,7 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_READ_SIGNAL_STRENGTH:
{
s32 signal = 0xffff - ((stv0299_readreg (i2c, 0x18) << 8)
- | stv0299_readreg (i2c, 0x19));
+ | stv0299_readreg (i2c, 0x19));
dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __FUNCTION__,
stv0299_readreg (i2c, 0x18),
@@ -1052,10 +1052,10 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
(signal < 0) ? 0 : signal;
break;
}
- case FE_READ_SNR:
+ case FE_READ_SNR:
{
s32 snr = 0xffff - ((stv0299_readreg (i2c, 0x24) << 8)
- | stv0299_readreg (i2c, 0x25));
+ | stv0299_readreg (i2c, 0x25));
snr = 3 * (snr - 0xa100);
*((u16*) arg) = (snr > 0xffff) ? 0xffff :
(snr < 0) ? 0 : snr;
@@ -1064,84 +1064,87 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_READ_UNCORRECTED_BLOCKS:
if (stv0299_status == STATUS_UCBLOCKS) {
*((u32*) arg) = (stv0299_readreg (i2c, 0x1d) << 8)
- | stv0299_readreg (i2c, 0x1e);
+ | stv0299_readreg (i2c, 0x1e);
} else {
*((u32*) arg) = 0;
}
break;
- case FE_SET_FRONTEND:
- {
- struct dvb_frontend_parameters *p = arg;
+ case FE_SET_FRONTEND:
+ {
+ struct dvb_frontend_parameters *p = arg;
+ int invval = 0;
- dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
+ dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
- if (p->inversion == INVERSION_OFF) {
- stv0299_writereg(i2c, 0x0c, stv0299_readreg(i2c, 0x0c) & 0xfe);
- } else if (p->inversion == INVERSION_ON) {
- stv0299_writereg(i2c, 0x0c, stv0299_readreg(i2c, 0x0c) | 1);
- } else {
- printk("stv0299 does not support auto-inversion\n");
- return -EINVAL;
+ // set the inversion
+ if (p->inversion == INVERSION_OFF) invval = 0;
+ else if (p->inversion == INVERSION_ON) invval = 1;
+ else {
+ printk("stv0299 does not support auto-inversion\n");
+ return -EINVAL;
}
+ if (state->tuner_type == ALPS_BSRU6) invval = (~invval) & 1;
+ stv0299_writereg(i2c, 0x0c, (stv0299_readreg(i2c, 0x0c) & 0xfe) | invval);
- switch(state->tuner_type) {
+ switch(state->tuner_type) {
case PHILIPS_SU1278_TSA_TT:
{
- /* check if we should do a finetune */
- int frequency_delta = p->frequency - state->tuner_frequency;
- int minmax = p->u.qpsk.symbol_rate / 2000;
- if (minmax < 5000) minmax = 5000;
+ /* check if we should do a finetune */
+ int frequency_delta = p->frequency - state->tuner_frequency;
+ int minmax = p->u.qpsk.symbol_rate / 2000;
+ if (minmax < 5000) minmax = 5000;
- if ((frequency_delta > -minmax) && (frequency_delta < minmax) && (frequency_delta != 0) &&
+ if ((frequency_delta > -minmax) && (frequency_delta < minmax) && (frequency_delta != 0) &&
(state->fec_inner == p->u.qpsk.fec_inner) &&
(state->symbol_rate == p->u.qpsk.symbol_rate)) {
- int Drot_freq = (frequency_delta << 16) / (M_CLK_SU1278_TSA_TT / 1000);
+ int Drot_freq = (frequency_delta << 16) / (M_CLK_SU1278_TSA_TT / 1000);
- // zap the derotator registers first
- stv0299_writereg (i2c, 0x22, 0x00);
- stv0299_writereg (i2c, 0x23, 0x00);
+ // zap the derotator registers first
+ stv0299_writereg (i2c, 0x22, 0x00);
+ stv0299_writereg (i2c, 0x23, 0x00);
- // now set them as we want
- stv0299_writereg (i2c, 0x22, Drot_freq >> 8);
- stv0299_writereg (i2c, 0x23, Drot_freq);
+ // now set them as we want
+ stv0299_writereg (i2c, 0x22, Drot_freq >> 8);
+ stv0299_writereg (i2c, 0x23, Drot_freq);
} else {
- /* A "normal" tune is requested */
- pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
- stv0299_writereg (i2c, 0x32, 0x80);
- stv0299_writereg (i2c, 0x22, 0x00);
- stv0299_writereg (i2c, 0x23, 0x00);
- stv0299_writereg (i2c, 0x32, 0x19);
- stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
- stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
+ /* A "normal" tune is requested */
+ pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
+ stv0299_writereg (i2c, 0x32, 0x80);
+ stv0299_writereg (i2c, 0x22, 0x00);
+ stv0299_writereg (i2c, 0x23, 0x00);
+ stv0299_writereg (i2c, 0x32, 0x19);
+ stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
+ stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
}
- break;
+ break;
}
default:
- pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
- stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
- stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
- stv0299_writereg (i2c, 0x22, 0x00);
- stv0299_writereg (i2c, 0x23, 0x00);
- stv0299_readreg (i2c, 0x23);
- stv0299_writereg (i2c, 0x12, 0xb9);
- break;
+ pll_set_tv_freq (i2c, p->frequency, state->tuner_type, p->u.qpsk.symbol_rate);
+ stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
+ stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate, state->tuner_type);
+ stv0299_writereg (i2c, 0x22, 0x00);
+ stv0299_writereg (i2c, 0x23, 0x00);
+ stv0299_readreg (i2c, 0x23);
+ stv0299_writereg (i2c, 0x12, 0xb9);
+ break;
}
- state->tuner_frequency = p->frequency;
- state->fec_inner = p->u.qpsk.fec_inner;
- state->symbol_rate = p->u.qpsk.symbol_rate;
- break;
- }
+ state->tuner_frequency = p->frequency;
+ state->fec_inner = p->u.qpsk.fec_inner;
+ state->symbol_rate = p->u.qpsk.symbol_rate;
+ break;
+ }
- case FE_GET_FRONTEND:
- {
+ case FE_GET_FRONTEND:
+ {
struct dvb_frontend_parameters *p = arg;
s32 derot_freq;
- int Mclk = M_CLK;
+ int Mclk = M_CLK;
+ int invval;
- if (state->tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT;
+ if (state->tuner_type == PHILIPS_SU1278_TSA_TT) Mclk = M_CLK_SU1278_TSA_TT;
derot_freq = (s32)(s16) ((stv0299_readreg (i2c, 0x22) << 8)
| stv0299_readreg (i2c, 0x23));
@@ -1151,34 +1154,37 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
derot_freq /= 1000;
p->frequency += derot_freq;
- p->inversion = (stv0299_readreg (i2c, 0x0c) & 1) ?
- INVERSION_ON : INVERSION_OFF;
+
+ invval = stv0299_readreg (i2c, 0x0c) & 1;
+ if (state->tuner_type == ALPS_BSRU6) invval = (~invval) & 1;
+ p->inversion = invval ? INVERSION_ON : INVERSION_OFF;
+
p->u.qpsk.fec_inner = stv0299_get_fec (i2c);
p->u.qpsk.symbol_rate = stv0299_get_symbolrate (i2c, state->tuner_type);
- break;
- }
+ break;
+ }
- case FE_SLEEP:
- stv0299_writereg (i2c, 0x0c, 0x00); /* LNB power off! */
- stv0299_writereg (i2c, 0x08, 0x00); /* LNB power off! */
+ case FE_SLEEP:
+ stv0299_writereg (i2c, 0x0c, 0x00); /* LNB power off! */
+ stv0299_writereg (i2c, 0x08, 0x00); /* LNB power off! */
stv0299_writereg (i2c, 0x02, 0x80);
- state->initialised = 0;
+ state->initialised = 0;
break;
- case FE_INIT:
- switch(state->tuner_type) {
+ case FE_INIT:
+ switch(state->tuner_type) {
case PHILIPS_SU1278_TSA_TT:
- state->tuner_frequency = 0;
- if (!state->initialised) {
- state->initialised = 1;
- return stv0299_init (i2c, state->tuner_type);
+ state->tuner_frequency = 0;
+ if (!state->initialised) {
+ state->initialised = 1;
+ return stv0299_init (i2c, state->tuner_type);
}
- break;
+ break;
default:
- return stv0299_init (i2c, state->tuner_type);
+ return stv0299_init (i2c, state->tuner_type);
}
- break;
+ break;
case FE_DISEQC_SEND_MASTER_CMD:
return stv0299_send_diseqc_msg (i2c, arg);
@@ -1194,33 +1200,33 @@ static int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_GET_TUNE_SETTINGS:
{
- struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
+ struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
- switch(state->tuner_type) {
+ switch(state->tuner_type) {
case PHILIPS_SU1278_TSA_TT:
- fesettings->min_delay_ms = 50;
- if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
- fesettings->max_drift = 5000;
+ fesettings->min_delay_ms = 50;
+ if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
+ fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
+ fesettings->max_drift = 5000;
} else {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
- fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
+ fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
+ fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
}
- break;
+ break;
default:
- fesettings->min_delay_ms = 100;
- if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
- fesettings->max_drift = 5000;
+ fesettings->min_delay_ms = 100;
+ if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
+ fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
+ fesettings->max_drift = 5000;
} else {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
- fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
+ fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
+ fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
}
- break;
+ break;
}
- return 0;
+ return 0;
}
default:
@@ -1234,15 +1240,15 @@ static long probe_tuner (struct dvb_i2c_bus *i2c)
{
struct dvb_adapter * adapter = (struct dvb_adapter *) i2c->adapter;
- /* read the status register of TSA5059 */
+ /* read the status register of TSA5059 */
u8 rpt[] = { 0x05, 0xb5 };
- u8 stat [] = { 0 };
+ u8 stat [] = { 0 };
u8 tda6100_buf [] = { 0, 0 };
int ret;
struct i2c_msg msg1 [] = {{ .addr = 0x68, .flags = 0, .buf = rpt, len: 2 },
- { .addr = 0x60, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
+ { .addr = 0x60, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
struct i2c_msg msg2 [] = {{ .addr = 0x68, .flags = 0, .buf = rpt, len: 2 },
- { .addr = 0x61, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
+ { .addr = 0x61, .flags = I2C_M_RD, .buf = stat, .len = 1 }};
struct i2c_msg msg3 [] = {{ .addr = 0x68, .flags = 0, .buf = rpt, len: 2 },
{ .addr = 0x60, .flags = 0, .buf = tda6100_buf, .len = 2 }};
@@ -1257,18 +1263,18 @@ static long probe_tuner (struct dvb_i2c_bus *i2c)
{
printk ("%s: setup for tuner Samsung TBMU24112IMB\n", __FILE__);
- return SAMSUNG_TBMU24112IMB;
+ return SAMSUNG_TBMU24112IMB;
}
if ((ret = i2c->xfer(i2c, msg1, 2)) == 2) {
- if ( strcmp(adapter->name, "TT-Budget/WinTV-NOVA-CI PCI") == 0 ) {
- // technotrend cards require non-datasheet settings
- printk ("%s: setup for tuner SU1278 (TSA5059 synth) on TechnoTrend hardware\n", __FILE__);
- return PHILIPS_SU1278_TSA_TT;
+ if ( strcmp(adapter->name, "TT-Budget/WinTV-NOVA-CI PCI") == 0 ) {
+ // technotrend cards require non-datasheet settings
+ printk ("%s: setup for tuner SU1278 (TSA5059 synth) on TechnoTrend hardware\n", __FILE__);
+ return PHILIPS_SU1278_TSA_TT;
} else {
- // fall back to datasheet-recommended settings
- printk ("%s: setup for tuner SU1278 (TSA5059 synth)\n", __FILE__);
- return PHILIPS_SU1278_TSA;
+ // fall back to datasheet-recommended settings
+ printk ("%s: setup for tuner SU1278 (TSA5059 synth)\n", __FILE__);
+ return PHILIPS_SU1278_TSA;
}
}
@@ -1304,8 +1310,8 @@ static long probe_tuner (struct dvb_i2c_bus *i2c)
static int uni0299_attach (struct dvb_i2c_bus *i2c, void **data)
{
- struct stv0299_state* state;
- int tuner_type;
+ struct stv0299_state* state;
+ int tuner_type;
u8 id;
stv0299_writereg (i2c, 0x02, 0x00); /* standby off */
@@ -1321,14 +1327,14 @@ static int uni0299_attach (struct dvb_i2c_bus *i2c, void **data)
if ((tuner_type = probe_tuner(i2c)) < 0)
return -ENODEV;
- if ((state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL)) == NULL) {
- return -ENOMEM;
+ if ((state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL)) == NULL) {
+ return -ENOMEM;
}
- *data = state;
- state->tuner_type = tuner_type;
- state->tuner_frequency = 0;
- state->initialised = 0;
+ *data = state;
+ state->tuner_type = tuner_type;
+ state->tuner_frequency = 0;
+ state->initialised = 0;
return dvb_register_frontend (uni0299_ioctl, i2c, (void *) state,
&uni0299_info);
}
@@ -1337,7 +1343,7 @@ static int uni0299_attach (struct dvb_i2c_bus *i2c, void **data)
static void uni0299_detach (struct dvb_i2c_bus *i2c, void *data)
{
dprintk ("%s\n", __FUNCTION__);
- kfree(data);
+ kfree(data);
dvb_unregister_frontend (uni0299_ioctl, i2c);
}