aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda826x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda826x.c')
-rw-r--r--drivers/media/dvb/frontends/tda826x.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index bd3ebc284835..a051554b5e25 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -26,7 +26,7 @@
26 26
27#include "tda826x.h" 27#include "tda826x.h"
28 28
29static int debug = 0; 29static int debug;
30#define dprintk(args...) \ 30#define dprintk(args...) \
31 do { \ 31 do { \
32 if (debug) printk(KERN_DEBUG "tda826x: " args); \ 32 if (debug) printk(KERN_DEBUG "tda826x: " args); \
@@ -54,7 +54,7 @@ static int tda826x_sleep(struct dvb_frontend *fe)
54 u8 buf [] = { 0x00, 0x8d }; 54 u8 buf [] = { 0x00, 0x8d };
55 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 2 }; 55 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 2 };
56 56
57 dprintk("%s:\n", __FUNCTION__); 57 dprintk("%s:\n", __func__);
58 58
59 if (!priv->has_loopthrough) 59 if (!priv->has_loopthrough)
60 buf[1] = 0xad; 60 buf[1] = 0xad;
@@ -62,7 +62,7 @@ static int tda826x_sleep(struct dvb_frontend *fe)
62 if (fe->ops.i2c_gate_ctrl) 62 if (fe->ops.i2c_gate_ctrl)
63 fe->ops.i2c_gate_ctrl(fe, 1); 63 fe->ops.i2c_gate_ctrl(fe, 1);
64 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { 64 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
65 dprintk("%s: i2c error\n", __FUNCTION__); 65 dprintk("%s: i2c error\n", __func__);
66 } 66 }
67 if (fe->ops.i2c_gate_ctrl) 67 if (fe->ops.i2c_gate_ctrl)
68 fe->ops.i2c_gate_ctrl(fe, 0); 68 fe->ops.i2c_gate_ctrl(fe, 0);
@@ -75,13 +75,24 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
75 struct tda826x_priv *priv = fe->tuner_priv; 75 struct tda826x_priv *priv = fe->tuner_priv;
76 int ret; 76 int ret;
77 u32 div; 77 u32 div;
78 u32 ksyms;
79 u32 bandwidth;
78 u8 buf [11]; 80 u8 buf [11];
79 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 11 }; 81 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 11 };
80 82
81 dprintk("%s:\n", __FUNCTION__); 83 dprintk("%s:\n", __func__);
82 84
83 div = (params->frequency + (1000-1)) / 1000; 85 div = (params->frequency + (1000-1)) / 1000;
84 86
87 /* BW = ((1 + RO) * SR/2 + 5) * 1.3 [SR in MSPS, BW in MHz] */
88 /* with R0 = 0.35 and some transformations: */
89 ksyms = params->u.qpsk.symbol_rate / 1000;
90 bandwidth = (878 * ksyms + 6500000) / 1000000 + 1;
91 if (bandwidth < 5)
92 bandwidth = 5;
93 else if (bandwidth > 36)
94 bandwidth = 36;
95
85 buf[0] = 0x00; // subaddress 96 buf[0] = 0x00; // subaddress
86 buf[1] = 0x09; // powerdown RSSI + the magic value 1 97 buf[1] = 0x09; // powerdown RSSI + the magic value 1
87 if (!priv->has_loopthrough) 98 if (!priv->has_loopthrough)
@@ -89,7 +100,7 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
89 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO 100 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO
90 buf[3] = div >> 7; 101 buf[3] = div >> 7;
91 buf[4] = div << 1; 102 buf[4] = div << 1;
92 buf[5] = 0x77; // baseband cut-off 19 MHz 103 buf[5] = ((bandwidth - 5) << 3) | 7; /* baseband cut-off */
93 buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation 104 buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation
94 buf[7] = 0x83; // charge pumps at high, tests off 105 buf[7] = 0x83; // charge pumps at high, tests off
95 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports. 106 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports.
@@ -99,7 +110,7 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
99 if (fe->ops.i2c_gate_ctrl) 110 if (fe->ops.i2c_gate_ctrl)
100 fe->ops.i2c_gate_ctrl(fe, 1); 111 fe->ops.i2c_gate_ctrl(fe, 1);
101 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { 112 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
102 dprintk("%s: i2c error\n", __FUNCTION__); 113 dprintk("%s: i2c error\n", __func__);
103 } 114 }
104 if (fe->ops.i2c_gate_ctrl) 115 if (fe->ops.i2c_gate_ctrl)
105 fe->ops.i2c_gate_ctrl(fe, 0); 116 fe->ops.i2c_gate_ctrl(fe, 0);
@@ -138,7 +149,7 @@ struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2
138 }; 149 };
139 int ret; 150 int ret;
140 151
141 dprintk("%s:\n", __FUNCTION__); 152 dprintk("%s:\n", __func__);
142 153
143 if (fe->ops.i2c_gate_ctrl) 154 if (fe->ops.i2c_gate_ctrl)
144 fe->ops.i2c_gate_ctrl(fe, 1); 155 fe->ops.i2c_gate_ctrl(fe, 1);