aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/bt8xx/dst.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/bt8xx/dst.c')
-rw-r--r--drivers/media/dvb/bt8xx/dst.c763
1 files changed, 377 insertions, 386 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 07a0b0a968a6..34a837a1abf4 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1,5 +1,4 @@
1/* 1/*
2
3 Frontend/Card driver for TwinHan DST Frontend 2 Frontend/Card driver for TwinHan DST Frontend
4 Copyright (C) 2003 Jamie Honan 3 Copyright (C) 2003 Jamie Honan
5 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) 4 Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
@@ -19,7 +18,6 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 19*/
21 20
22
23#include <linux/kernel.h> 21#include <linux/kernel.h>
24#include <linux/module.h> 22#include <linux/module.h>
25#include <linux/init.h> 23#include <linux/init.h>
@@ -28,31 +26,45 @@
28#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
29#include <linux/delay.h> 27#include <linux/delay.h>
30#include <asm/div64.h> 28#include <asm/div64.h>
31
32#include "dvb_frontend.h" 29#include "dvb_frontend.h"
33#include "dst_priv.h" 30#include "dst_priv.h"
34#include "dst_common.h" 31#include "dst_common.h"
35 32
36
37static unsigned int verbose = 1; 33static unsigned int verbose = 1;
38module_param(verbose, int, 0644); 34module_param(verbose, int, 0644);
39MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 35MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
40 36
41static unsigned int debug = 1;
42module_param(debug, int, 0644);
43MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)");
44
45static unsigned int dst_addons; 37static unsigned int dst_addons;
46module_param(dst_addons, int, 0644); 38module_param(dst_addons, int, 0644);
47MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); 39MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)");
48 40
49#define dprintk if (debug) printk 41#define HAS_LOCK 1
50 42#define ATTEMPT_TUNE 2
51#define HAS_LOCK 1 43#define HAS_POWER 4
52#define ATTEMPT_TUNE 2 44
53#define HAS_POWER 4 45#define DST_ERROR 0
54 46#define DST_NOTICE 1
55static void dst_packsize(struct dst_state* state, int psize) 47#define DST_INFO 2
48#define DST_DEBUG 3
49
50#define dprintk(x, y, z, format, arg...) do { \
51 if (z) { \
52 if ((x > DST_ERROR) && (x > y)) \
53 printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \
54 else if ((x > DST_NOTICE) && (x > y)) \
55 printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \
56 else if ((x > DST_INFO) && (x > y)) \
57 printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \
58 else if ((x > DST_DEBUG) && (x > y)) \
59 printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \
60 } else { \
61 if (x > y) \
62 printk(format, ##arg); \
63 } \
64} while(0)
65
66
67static void dst_packsize(struct dst_state *state, int psize)
56{ 68{
57 union dst_gpio_packet bits; 69 union dst_gpio_packet bits;
58 70
@@ -60,7 +72,7 @@ static void dst_packsize(struct dst_state* state, int psize)
60 bt878_device_control(state->bt, DST_IG_TS, &bits); 72 bt878_device_control(state->bt, DST_IG_TS, &bits);
61} 73}
62 74
63int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) 75int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay)
64{ 76{
65 union dst_gpio_packet enb; 77 union dst_gpio_packet enb;
66 union dst_gpio_packet bits; 78 union dst_gpio_packet bits;
@@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int
68 80
69 enb.enb.mask = mask; 81 enb.enb.mask = mask;
70 enb.enb.enable = enbb; 82 enb.enb.enable = enbb;
71 if (verbose > 4)
72 dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh);
73 83
84 dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh);
74 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { 85 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
75 dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb); 86 dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb);
76 return -EREMOTEIO; 87 return -EREMOTEIO;
77 } 88 }
78 udelay(1000); 89 udelay(1000);
79 /* because complete disabling means no output, no need to do output packet */ 90 /* because complete disabling means no output, no need to do output packet */
80 if (enbb == 0) 91 if (enbb == 0)
81 return 0; 92 return 0;
82
83 if (delay) 93 if (delay)
84 msleep(10); 94 msleep(10);
85
86 bits.outp.mask = enbb; 95 bits.outp.mask = enbb;
87 bits.outp.highvals = outhigh; 96 bits.outp.highvals = outhigh;
88
89 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { 97 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
90 dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh); 98 dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh);
91 return -EREMOTEIO; 99 return -EREMOTEIO;
92 } 100 }
101
93 return 0; 102 return 0;
94} 103}
95EXPORT_SYMBOL(dst_gpio_outb); 104EXPORT_SYMBOL(dst_gpio_outb);
96 105
97int dst_gpio_inb(struct dst_state *state, u8 * result) 106int dst_gpio_inb(struct dst_state *state, u8 *result)
98{ 107{
99 union dst_gpio_packet rd_packet; 108 union dst_gpio_packet rd_packet;
100 int err; 109 int err;
101 110
102 *result = 0; 111 *result = 0;
103
104 if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { 112 if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
105 dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err); 113 dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err);
106 return -EREMOTEIO; 114 return -EREMOTEIO;
107 } 115 }
108
109 *result = (u8) rd_packet.rd.value; 116 *result = (u8) rd_packet.rd.value;
117
110 return 0; 118 return 0;
111} 119}
112EXPORT_SYMBOL(dst_gpio_inb); 120EXPORT_SYMBOL(dst_gpio_inb);
113 121
114int rdc_reset_state(struct dst_state *state) 122int rdc_reset_state(struct dst_state *state)
115{ 123{
116 if (verbose > 1) 124 dprintk(verbose, DST_INFO, 1, "Resetting state machine");
117 dprintk("%s: Resetting state machine\n", __FUNCTION__);
118
119 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { 125 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) {
120 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 126 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
121 return -1; 127 return -1;
122 } 128 }
123
124 msleep(10); 129 msleep(10);
125
126 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { 130 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) {
127 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 131 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
128 msleep(10); 132 msleep(10);
129 return -1; 133 return -1;
130 } 134 }
@@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state);
135 139
136int rdc_8820_reset(struct dst_state *state) 140int rdc_8820_reset(struct dst_state *state)
137{ 141{
138 if (verbose > 1) 142 dprintk(verbose, DST_DEBUG, 1, "Resetting DST");
139 dprintk("%s: Resetting DST\n", __FUNCTION__);
140
141 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { 143 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
142 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 144 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
143 return -1; 145 return -1;
144 } 146 }
145 udelay(1000); 147 udelay(1000);
146 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { 148 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
147 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 149 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
148 return -1; 150 return -1;
149 } 151 }
150 152
@@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset);
155int dst_pio_enable(struct dst_state *state) 157int dst_pio_enable(struct dst_state *state)
156{ 158{
157 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { 159 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) {
158 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 160 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
159 return -1; 161 return -1;
160 } 162 }
161 udelay(1000); 163 udelay(1000);
164
162 return 0; 165 return 0;
163} 166}
164EXPORT_SYMBOL(dst_pio_enable); 167EXPORT_SYMBOL(dst_pio_enable);
@@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable);
166int dst_pio_disable(struct dst_state *state) 169int dst_pio_disable(struct dst_state *state)
167{ 170{
168 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { 171 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) {
169 dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); 172 dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
170 return -1; 173 return -1;
171 } 174 }
172 if (state->type_flags & DST_TYPE_HAS_FW_1) 175 if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode)
183 186
184 for (i = 0; i < 200; i++) { 187 for (i = 0; i < 200; i++) {
185 if (dst_gpio_inb(state, &reply) < 0) { 188 if (dst_gpio_inb(state, &reply) < 0) {
186 dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__); 189 dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !");
187 return -1; 190 return -1;
188 } 191 }
189
190 if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { 192 if ((reply & RDC_8820_PIO_0_ENABLE) == 0) {
191 if (verbose > 4) 193 dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i);
192 dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i);
193 return 1; 194 return 1;
194 } 195 }
195 msleep(10); 196 msleep(10);
196 } 197 }
197 if (verbose > 1) 198 dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i);
198 dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i);
199 199
200 return 0; 200 return 0;
201} 201}
@@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready);
203 203
204int dst_error_recovery(struct dst_state *state) 204int dst_error_recovery(struct dst_state *state)
205{ 205{
206 dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__); 206 dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors.");
207 dst_pio_disable(state); 207 dst_pio_disable(state);
208 msleep(10); 208 msleep(10);
209 dst_pio_enable(state); 209 dst_pio_enable(state);
@@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery);
215 215
216int dst_error_bailout(struct dst_state *state) 216int dst_error_bailout(struct dst_state *state)
217{ 217{
218 dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__); 218 dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error.");
219 rdc_8820_reset(state); 219 rdc_8820_reset(state);
220 dst_pio_disable(state); 220 dst_pio_disable(state);
221 msleep(10); 221 msleep(10);
@@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *state)
224} 224}
225EXPORT_SYMBOL(dst_error_bailout); 225EXPORT_SYMBOL(dst_error_bailout);
226 226
227 227int dst_comm_init(struct dst_state *state)
228int dst_comm_init(struct dst_state* state)
229{ 228{
230 if (verbose > 1) 229 dprintk(verbose, DST_INFO, 1, "Initializing DST.");
231 dprintk ("%s: Initializing DST..\n", __FUNCTION__);
232 if ((dst_pio_enable(state)) < 0) { 230 if ((dst_pio_enable(state)) < 0) {
233 dprintk("%s: PIO Enable Failed.\n", __FUNCTION__); 231 dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed");
234 return -1; 232 return -1;
235 } 233 }
236 if ((rdc_reset_state(state)) < 0) { 234 if ((rdc_reset_state(state)) < 0) {
237 dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__); 235 dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed.");
238 return -1; 236 return -1;
239 } 237 }
240 if (state->type_flags & DST_TYPE_HAS_FW_1) 238 if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* state)
246} 244}
247EXPORT_SYMBOL(dst_comm_init); 245EXPORT_SYMBOL(dst_comm_init);
248 246
249
250int write_dst(struct dst_state *state, u8 *data, u8 len) 247int write_dst(struct dst_state *state, u8 *data, u8 len)
251{ 248{
252 struct i2c_msg msg = { 249 struct i2c_msg msg = {
253 .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len 250 .addr = state->config->demod_address,
251 .flags = 0,
252 .buf = data,
253 .len = len
254 }; 254 };
255 255
256 int err; 256 int err;
257 int cnt; 257 u8 cnt, i;
258 if (debug && (verbose > 4)) { 258
259 u8 i; 259 dprintk(verbose, DST_NOTICE, 0, "writing [ ");
260 if (verbose > 4) { 260 for (i = 0; i < len; i++)
261 dprintk("%s writing [ ", __FUNCTION__); 261 dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]);
262 for (i = 0; i < len; i++) 262 dprintk(verbose, DST_NOTICE, 0, "]\n");
263 dprintk("%02x ", data[i]); 263
264 dprintk("]\n");
265 }
266 }
267 for (cnt = 0; cnt < 2; cnt++) { 264 for (cnt = 0; cnt < 2; cnt++) {
268 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 265 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
269 dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); 266 dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]);
270 dst_error_recovery(state); 267 dst_error_recovery(state);
271 continue; 268 continue;
272 } else 269 } else
273 break; 270 break;
274 } 271 }
275
276 if (cnt >= 2) { 272 if (cnt >= 2) {
277 if (verbose > 1) 273 dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
278 printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
279 dst_error_bailout(state); 274 dst_error_bailout(state);
280 275
281 return -1; 276 return -1;
@@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u8 *data, u8 len)
285} 280}
286EXPORT_SYMBOL(write_dst); 281EXPORT_SYMBOL(write_dst);
287 282
288int read_dst(struct dst_state *state, u8 * ret, u8 len) 283int read_dst(struct dst_state *state, u8 *ret, u8 len)
289{ 284{
290 struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; 285 struct i2c_msg msg = {
286 .addr = state->config->demod_address,
287 .flags = I2C_M_RD,
288 .buf = ret,
289 .len = len
290 };
291
291 int err; 292 int err;
292 int cnt; 293 int cnt;
293 294
294 for (cnt = 0; cnt < 2; cnt++) { 295 for (cnt = 0; cnt < 2; cnt++) {
295 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { 296 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
296 297 dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]);
297 dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]);
298 dst_error_recovery(state); 298 dst_error_recovery(state);
299
300 continue; 299 continue;
301 } else 300 } else
302 break; 301 break;
303 } 302 }
304 if (cnt >= 2) { 303 if (cnt >= 2) {
305 if (verbose > 1) 304 dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
306 printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
307 dst_error_bailout(state); 305 dst_error_bailout(state);
308 306
309 return -1; 307 return -1;
310 } 308 }
311 if (debug && (verbose > 4)) { 309 dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]);
312 dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); 310 for (err = 1; err < len; err++)
313 for (err = 1; err < len; err++) 311 dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]);
314 dprintk(" 0x%x", ret[err]); 312 if (err > 1)
315 if (err > 1) 313 dprintk(verbose, DST_DEBUG, 0, "\n");
316 dprintk("\n");
317 }
318 314
319 return 0; 315 return 0;
320} 316}
@@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst);
323static int dst_set_polarization(struct dst_state *state) 319static int dst_set_polarization(struct dst_state *state)
324{ 320{
325 switch (state->voltage) { 321 switch (state->voltage) {
326 case SEC_VOLTAGE_13: // vertical 322 case SEC_VOLTAGE_13: /* Vertical */
327 printk("%s: Polarization=[Vertical]\n", __FUNCTION__); 323 dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]");
328 state->tx_tuna[8] &= ~0x40; //1 324 state->tx_tuna[8] &= ~0x40;
329 break; 325 break;
330 326 case SEC_VOLTAGE_18: /* Horizontal */
331 case SEC_VOLTAGE_18: // horizontal 327 dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]");
332 printk("%s: Polarization=[Horizontal]\n", __FUNCTION__); 328 state->tx_tuna[8] |= 0x40;
333 state->tx_tuna[8] |= 0x40; // 0 329 break;
334 break; 330 case SEC_VOLTAGE_OFF:
335 331 break;
336 case SEC_VOLTAGE_OFF:
337
338 break;
339 } 332 }
340 333
341 return 0; 334 return 0;
@@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state)
344static int dst_set_freq(struct dst_state *state, u32 freq) 337static int dst_set_freq(struct dst_state *state, u32 freq)
345{ 338{
346 state->frequency = freq; 339 state->frequency = freq;
347 if (debug > 4) 340 dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq);
348 dprintk("%s: set Frequency %u\n", __FUNCTION__, freq);
349 341
350 if (state->dst_type == DST_TYPE_IS_SAT) { 342 if (state->dst_type == DST_TYPE_IS_SAT) {
351 freq = freq / 1000; 343 freq = freq / 1000;
352 if (freq < 950 || freq > 2150) 344 if (freq < 950 || freq > 2150)
353 return -EINVAL; 345 return -EINVAL;
354
355 state->tx_tuna[2] = (freq >> 8); 346 state->tx_tuna[2] = (freq >> 8);
356 state->tx_tuna[3] = (u8) freq; 347 state->tx_tuna[3] = (u8) freq;
357 state->tx_tuna[4] = 0x01; 348 state->tx_tuna[4] = 0x01;
@@ -360,27 +351,25 @@ static int dst_set_freq(struct dst_state *state, u32 freq)
360 if (freq < 1531) 351 if (freq < 1531)
361 state->tx_tuna[8] |= 0x04; 352 state->tx_tuna[8] |= 0x04;
362 } 353 }
363
364 } else if (state->dst_type == DST_TYPE_IS_TERR) { 354 } else if (state->dst_type == DST_TYPE_IS_TERR) {
365 freq = freq / 1000; 355 freq = freq / 1000;
366 if (freq < 137000 || freq > 858000) 356 if (freq < 137000 || freq > 858000)
367 return -EINVAL; 357 return -EINVAL;
368
369 state->tx_tuna[2] = (freq >> 16) & 0xff; 358 state->tx_tuna[2] = (freq >> 16) & 0xff;
370 state->tx_tuna[3] = (freq >> 8) & 0xff; 359 state->tx_tuna[3] = (freq >> 8) & 0xff;
371 state->tx_tuna[4] = (u8) freq; 360 state->tx_tuna[4] = (u8) freq;
372
373 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 361 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
362 freq = freq / 1000;
374 state->tx_tuna[2] = (freq >> 16) & 0xff; 363 state->tx_tuna[2] = (freq >> 16) & 0xff;
375 state->tx_tuna[3] = (freq >> 8) & 0xff; 364 state->tx_tuna[3] = (freq >> 8) & 0xff;
376 state->tx_tuna[4] = (u8) freq; 365 state->tx_tuna[4] = (u8) freq;
377
378 } else 366 } else
379 return -EINVAL; 367 return -EINVAL;
368
380 return 0; 369 return 0;
381} 370}
382 371
383static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) 372static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
384{ 373{
385 state->bandwidth = bandwidth; 374 state->bandwidth = bandwidth;
386 375
@@ -388,103 +377,95 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth)
388 return 0; 377 return 0;
389 378
390 switch (bandwidth) { 379 switch (bandwidth) {
391 case BANDWIDTH_6_MHZ: 380 case BANDWIDTH_6_MHZ:
392 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 381 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
393 state->tx_tuna[7] = 0x06; 382 state->tx_tuna[7] = 0x06;
394 else { 383 else {
395 state->tx_tuna[6] = 0x06; 384 state->tx_tuna[6] = 0x06;
396 state->tx_tuna[7] = 0x00; 385 state->tx_tuna[7] = 0x00;
397 } 386 }
398 break; 387 break;
399 388 case BANDWIDTH_7_MHZ:
400 case BANDWIDTH_7_MHZ: 389 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
401 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 390 state->tx_tuna[7] = 0x07;
402 state->tx_tuna[7] = 0x07; 391 else {
403 else { 392 state->tx_tuna[6] = 0x07;
404 state->tx_tuna[6] = 0x07; 393 state->tx_tuna[7] = 0x00;
405 state->tx_tuna[7] = 0x00; 394 }
406 } 395 break;
407 break; 396 case BANDWIDTH_8_MHZ:
408 397 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
409 case BANDWIDTH_8_MHZ: 398 state->tx_tuna[7] = 0x08;
410 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 399 else {
411 state->tx_tuna[7] = 0x08; 400 state->tx_tuna[6] = 0x08;
412 else { 401 state->tx_tuna[7] = 0x00;
413 state->tx_tuna[6] = 0x08; 402 }
414 state->tx_tuna[7] = 0x00; 403 break;
415 } 404 default:
416 break; 405 return -EINVAL;
417
418 default:
419 return -EINVAL;
420 } 406 }
407
421 return 0; 408 return 0;
422} 409}
423 410
424static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) 411static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion)
425{ 412{
426 state->inversion = inversion; 413 state->inversion = inversion;
427 switch (inversion) { 414 switch (inversion) {
428 case INVERSION_OFF: // Inversion = Normal 415 case INVERSION_OFF: /* Inversion = Normal */
429 state->tx_tuna[8] &= ~0x80; 416 state->tx_tuna[8] &= ~0x80;
430 break; 417 break;
431 418 case INVERSION_ON:
432 case INVERSION_ON: 419 state->tx_tuna[8] |= 0x80;
433 state->tx_tuna[8] |= 0x80; 420 break;
434 break; 421 default:
435 default: 422 return -EINVAL;
436 return -EINVAL;
437 } 423 }
424
438 return 0; 425 return 0;
439} 426}
440 427
441static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) 428static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec)
442{ 429{
443 state->fec = fec; 430 state->fec = fec;
444 return 0; 431 return 0;
445} 432}
446 433
447static fe_code_rate_t dst_get_fec(struct dst_state* state) 434static fe_code_rate_t dst_get_fec(struct dst_state *state)
448{ 435{
449 return state->fec; 436 return state->fec;
450} 437}
451 438
452static int dst_set_symbolrate(struct dst_state* state, u32 srate) 439static int dst_set_symbolrate(struct dst_state *state, u32 srate)
453{ 440{
454 u8 *val;
455 u32 symcalc; 441 u32 symcalc;
456 u64 sval; 442 u64 sval;
457 443
458 state->symbol_rate = srate; 444 state->symbol_rate = srate;
459
460 if (state->dst_type == DST_TYPE_IS_TERR) { 445 if (state->dst_type == DST_TYPE_IS_TERR) {
461 return 0; 446 return 0;
462 } 447 }
463 if (debug > 4) 448 dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
464 dprintk("%s: set symrate %u\n", __FUNCTION__, srate);
465 srate /= 1000; 449 srate /= 1000;
466 val = &state->tx_tuna[0];
467
468 if (state->type_flags & DST_TYPE_HAS_SYMDIV) { 450 if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
469 sval = srate; 451 sval = srate;
470 sval <<= 20; 452 sval <<= 20;
471 do_div(sval, 88000); 453 do_div(sval, 88000);
472 symcalc = (u32) sval; 454 symcalc = (u32) sval;
473 455 dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
474 if (debug > 4) 456 state->tx_tuna[5] = (u8) (symcalc >> 12);
475 dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); 457 state->tx_tuna[6] = (u8) (symcalc >> 4);
476 458 state->tx_tuna[7] = (u8) (symcalc << 4);
477 val[5] = (u8) (symcalc >> 12);
478 val[6] = (u8) (symcalc >> 4);
479 val[7] = (u8) (symcalc << 4);
480 } else { 459 } else {
481 val[5] = (u8) (srate >> 16) & 0x7f; 460 state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f;
482 val[6] = (u8) (srate >> 8); 461 state->tx_tuna[6] = (u8) (srate >> 8);
483 val[7] = (u8) srate; 462 state->tx_tuna[7] = (u8) srate;
463 }
464 state->tx_tuna[8] &= ~0x20;
465 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
466 if (srate > 8000)
467 state->tx_tuna[8] |= 0x20;
484 } 468 }
485 val[8] &= ~0x20;
486 if (srate > 8000)
487 val[8] |= 0x20;
488 return 0; 469 return 0;
489} 470}
490 471
@@ -496,32 +477,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio
496 477
497 state->modulation = modulation; 478 state->modulation = modulation;
498 switch (modulation) { 479 switch (modulation) {
499 case QAM_16: 480 case QAM_16:
500 state->tx_tuna[8] = 0x10; 481 state->tx_tuna[8] = 0x10;
501 break; 482 break;
502 483 case QAM_32:
503 case QAM_32: 484 state->tx_tuna[8] = 0x20;
504 state->tx_tuna[8] = 0x20; 485 break;
505 break; 486 case QAM_64:
506 487 state->tx_tuna[8] = 0x40;
507 case QAM_64: 488 break;
508 state->tx_tuna[8] = 0x40; 489 case QAM_128:
509 break; 490 state->tx_tuna[8] = 0x80;
510 491 break;
511 case QAM_128: 492 case QAM_256:
512 state->tx_tuna[8] = 0x80; 493 state->tx_tuna[8] = 0x00;
513 break; 494 break;
514 495 case QPSK:
515 case QAM_256: 496 case QAM_AUTO:
516 state->tx_tuna[8] = 0x00; 497 case VSB_8:
517 break; 498 case VSB_16:
518 499 default:
519 case QPSK: 500 return -EINVAL;
520 case QAM_AUTO:
521 case VSB_8:
522 case VSB_16:
523 default:
524 return -EINVAL;
525 501
526 } 502 }
527 503
@@ -534,7 +510,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state)
534} 510}
535 511
536 512
537u8 dst_check_sum(u8 * buf, u32 len) 513u8 dst_check_sum(u8 *buf, u32 len)
538{ 514{
539 u32 i; 515 u32 i;
540 u8 val = 0; 516 u8 val = 0;
@@ -549,26 +525,24 @@ EXPORT_SYMBOL(dst_check_sum);
549 525
550static void dst_type_flags_print(u32 type_flags) 526static void dst_type_flags_print(u32 type_flags)
551{ 527{
552 printk("DST type flags :"); 528 dprintk(verbose, DST_ERROR, 0, "DST type flags :");
553 if (type_flags & DST_TYPE_HAS_NEWTUNE) 529 if (type_flags & DST_TYPE_HAS_NEWTUNE)
554 printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); 530 dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
555 if (type_flags & DST_TYPE_HAS_TS204) 531 if (type_flags & DST_TYPE_HAS_TS204)
556 printk(" 0x%x ts204", DST_TYPE_HAS_TS204); 532 dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204);
557 if (type_flags & DST_TYPE_HAS_SYMDIV) 533 if (type_flags & DST_TYPE_HAS_SYMDIV)
558 printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); 534 dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
559 if (type_flags & DST_TYPE_HAS_FW_1) 535 if (type_flags & DST_TYPE_HAS_FW_1)
560 printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); 536 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
561 if (type_flags & DST_TYPE_HAS_FW_2) 537 if (type_flags & DST_TYPE_HAS_FW_2)
562 printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); 538 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
563 if (type_flags & DST_TYPE_HAS_FW_3) 539 if (type_flags & DST_TYPE_HAS_FW_3)
564 printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); 540 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3);
565// if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) 541 dprintk(verbose, DST_ERROR, 0, "\n");
566
567 printk("\n");
568} 542}
569 543
570 544
571static int dst_type_print (u8 type) 545static int dst_type_print(u8 type)
572{ 546{
573 char *otype; 547 char *otype;
574 switch (type) { 548 switch (type) {
@@ -585,10 +559,10 @@ static int dst_type_print (u8 type)
585 break; 559 break;
586 560
587 default: 561 default:
588 printk("%s: invalid dst type %d\n", __FUNCTION__, type); 562 dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type);
589 return -EINVAL; 563 return -EINVAL;
590 } 564 }
591 printk("DST type : %s\n", otype); 565 dprintk(verbose, DST_INFO, 1, "DST type: %s", otype);
592 566
593 return 0; 567 return 0;
594} 568}
@@ -700,7 +674,7 @@ struct dst_types dst_tlist[] = {
700 .offset = 1, 674 .offset = 1,
701 .dst_type = DST_TYPE_IS_CABLE, 675 .dst_type = DST_TYPE_IS_CABLE,
702 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 676 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1
703 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, 677 | DST_TYPE_HAS_FW_2,
704 .dst_feature = DST_TYPE_HAS_CA 678 .dst_feature = DST_TYPE_HAS_CA
705 }, 679 },
706 680
@@ -708,7 +682,7 @@ struct dst_types dst_tlist[] = {
708 .device_id = "DCTNEW", 682 .device_id = "DCTNEW",
709 .offset = 1, 683 .offset = 1,
710 .dst_type = DST_TYPE_IS_CABLE, 684 .dst_type = DST_TYPE_IS_CABLE,
711 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3, 685 .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD,
712 .dst_feature = 0 686 .dst_feature = 0
713 }, 687 },
714 688
@@ -716,7 +690,7 @@ struct dst_types dst_tlist[] = {
716 .device_id = "DTT-CI", 690 .device_id = "DTT-CI",
717 .offset = 1, 691 .offset = 1,
718 .dst_type = DST_TYPE_IS_TERR, 692 .dst_type = DST_TYPE_IS_TERR,
719 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, 693 .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2,
720 .dst_feature = 0 694 .dst_feature = 0
721 }, 695 },
722 696
@@ -756,6 +730,71 @@ struct dst_types dst_tlist[] = {
756 730
757}; 731};
758 732
733static int dst_get_mac(struct dst_state *state)
734{
735 u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
736 get_mac[7] = dst_check_sum(get_mac, 7);
737 if (dst_command(state, get_mac, 8) < 0) {
738 dprintk(verbose, DST_INFO, 1, "Unsupported Command");
739 return -1;
740 }
741 memset(&state->mac_address, '\0', 8);
742 memcpy(&state->mac_address, &state->rxbuffer, 6);
743 dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]",
744 state->mac_address[0], state->mac_address[1], state->mac_address[2],
745 state->mac_address[4], state->mac_address[5], state->mac_address[6]);
746
747 return 0;
748}
749
750static int dst_fw_ver(struct dst_state *state)
751{
752 u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
753 get_ver[7] = dst_check_sum(get_ver, 7);
754 if (dst_command(state, get_ver, 8) < 0) {
755 dprintk(verbose, DST_INFO, 1, "Unsupported Command");
756 return -1;
757 }
758 memset(&state->fw_version, '\0', 8);
759 memcpy(&state->fw_version, &state->rxbuffer, 8);
760 dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x",
761 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f,
762 state->fw_version[1],
763 state->fw_version[5], state->fw_version[6],
764 state->fw_version[4], state->fw_version[3], state->fw_version[2]);
765
766 return 0;
767}
768
769static int dst_card_type(struct dst_state *state)
770{
771 u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
772 get_type[7] = dst_check_sum(get_type, 7);
773 if (dst_command(state, get_type, 8) < 0) {
774 dprintk(verbose, DST_INFO, 1, "Unsupported Command");
775 return -1;
776 }
777 memset(&state->card_info, '\0', 8);
778 memcpy(&state->card_info, &state->rxbuffer, 8);
779 dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]);
780
781 return 0;
782}
783
784static int dst_get_vendor(struct dst_state *state)
785{
786 u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
787 get_vendor[7] = dst_check_sum(get_vendor, 7);
788 if (dst_command(state, get_vendor, 8) < 0) {
789 dprintk(verbose, DST_INFO, 1, "Unsupported Command");
790 return -1;
791 }
792 memset(&state->vendor, '\0', 8);
793 memcpy(&state->vendor, &state->rxbuffer, 8);
794 dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]);
795
796 return 0;
797}
759 798
760static int dst_get_device_id(struct dst_state *state) 799static int dst_get_device_id(struct dst_state *state)
761{ 800{
@@ -772,53 +811,45 @@ static int dst_get_device_id(struct dst_state *state)
772 811
773 if (write_dst(state, device_type, FIXED_COMM)) 812 if (write_dst(state, device_type, FIXED_COMM))
774 return -1; /* Write failed */ 813 return -1; /* Write failed */
775
776 if ((dst_pio_disable(state)) < 0) 814 if ((dst_pio_disable(state)) < 0)
777 return -1; 815 return -1;
778
779 if (read_dst(state, &reply, GET_ACK)) 816 if (read_dst(state, &reply, GET_ACK))
780 return -1; /* Read failure */ 817 return -1; /* Read failure */
781
782 if (reply != ACK) { 818 if (reply != ACK) {
783 dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); 819 dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply);
784 return -1; /* Unack'd write */ 820 return -1; /* Unack'd write */
785 } 821 }
786
787 if (!dst_wait_dst_ready(state, DEVICE_INIT)) 822 if (!dst_wait_dst_ready(state, DEVICE_INIT))
788 return -1; /* DST not ready yet */ 823 return -1; /* DST not ready yet */
789
790 if (read_dst(state, state->rxbuffer, FIXED_COMM)) 824 if (read_dst(state, state->rxbuffer, FIXED_COMM))
791 return -1; 825 return -1;
792 826
793 dst_pio_disable(state); 827 dst_pio_disable(state);
794
795 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 828 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
796 dprintk("%s: Checksum failure! \n", __FUNCTION__); 829 dprintk(verbose, DST_INFO, 1, "Checksum failure!");
797 return -1; /* Checksum failure */ 830 return -1; /* Checksum failure */
798 } 831 }
799
800 state->rxbuffer[7] = '\0'; 832 state->rxbuffer[7] = '\0';
801 833
802 for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { 834 for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) {
803 if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { 835 if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) {
804 use_type_flags = p_dst_type->type_flags; 836 use_type_flags = p_dst_type->type_flags;
805 use_dst_type = p_dst_type->dst_type; 837 use_dst_type = p_dst_type->dst_type;
806 838
807 /* Card capabilities */ 839 /* Card capabilities */
808 state->dst_hw_cap = p_dst_type->dst_feature; 840 state->dst_hw_cap = p_dst_type->dst_feature;
809 printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); 841 dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id);
810 842
811 break; 843 break;
812 } 844 }
813 } 845 }
814 846
815 if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { 847 if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) {
816 printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); 848 dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]);
817 printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); 849 dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in");
818 use_dst_type = DST_TYPE_IS_SAT; 850 use_dst_type = DST_TYPE_IS_SAT;
819 use_type_flags = DST_TYPE_HAS_SYMDIV; 851 use_type_flags = DST_TYPE_HAS_SYMDIV;
820 } 852 }
821
822 dst_type_print(use_dst_type); 853 dst_type_print(use_dst_type);
823 state->type_flags = use_type_flags; 854 state->type_flags = use_type_flags;
824 state->dst_type = use_dst_type; 855 state->dst_type = use_dst_type;
@@ -834,7 +865,7 @@ static int dst_get_device_id(struct dst_state *state)
834static int dst_probe(struct dst_state *state) 865static int dst_probe(struct dst_state *state)
835{ 866{
836 if ((rdc_8820_reset(state)) < 0) { 867 if ((rdc_8820_reset(state)) < 0) {
837 dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); 868 dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
838 return -1; 869 return -1;
839 } 870 }
840 if (dst_addons & DST_TYPE_HAS_CA) 871 if (dst_addons & DST_TYPE_HAS_CA)
@@ -843,80 +874,87 @@ static int dst_probe(struct dst_state *state)
843 msleep(100); 874 msleep(100);
844 875
845 if ((dst_comm_init(state)) < 0) { 876 if ((dst_comm_init(state)) < 0) {
846 dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); 877 dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed.");
847 return -1; 878 return -1;
848 } 879 }
849 msleep(100); 880 msleep(100);
850 if (dst_get_device_id(state) < 0) { 881 if (dst_get_device_id(state) < 0) {
851 dprintk("%s: unknown device.\n", __FUNCTION__); 882 dprintk(verbose, DST_ERROR, 1, "unknown device.");
852 return -1; 883 return -1;
853 } 884 }
885 if (dst_get_mac(state) < 0) {
886 dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command");
887 return 0;
888 }
889 if (state->type_flags & DST_TYPE_HAS_FW_BUILD) {
890 if (dst_fw_ver(state) < 0) {
891 dprintk(verbose, DST_INFO, 1, "FW: Unsupported command");
892 return 0;
893 }
894 if (dst_card_type(state) < 0) {
895 dprintk(verbose, DST_INFO, 1, "Card: Unsupported command");
896 return 0;
897 }
898 if (dst_get_vendor(state) < 0) {
899 dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command");
900 return 0;
901 }
902 }
854 903
855 return 0; 904 return 0;
856} 905}
857 906
858int dst_command(struct dst_state* state, u8 * data, u8 len) 907int dst_command(struct dst_state *state, u8 *data, u8 len)
859{ 908{
860 u8 reply; 909 u8 reply;
861 if ((dst_comm_init(state)) < 0) { 910 if ((dst_comm_init(state)) < 0) {
862 dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); 911 dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
863 return -1; 912 return -1;
864 } 913 }
865
866 if (write_dst(state, data, len)) { 914 if (write_dst(state, data, len)) {
867 if (verbose > 1) 915 dprintk(verbose, DST_INFO, 1, "Tring to recover.. ");
868 dprintk("%s: Tring to recover.. \n", __FUNCTION__);
869 if ((dst_error_recovery(state)) < 0) { 916 if ((dst_error_recovery(state)) < 0) {
870 dprintk("%s: Recovery Failed.\n", __FUNCTION__); 917 dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
871 return -1; 918 return -1;
872 } 919 }
873 return -1; 920 return -1;
874 } 921 }
875 if ((dst_pio_disable(state)) < 0) { 922 if ((dst_pio_disable(state)) < 0) {
876 dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); 923 dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed.");
877 return -1; 924 return -1;
878 } 925 }
879 if (state->type_flags & DST_TYPE_HAS_FW_1) 926 if (state->type_flags & DST_TYPE_HAS_FW_1)
880 udelay(3000); 927 udelay(3000);
881
882 if (read_dst(state, &reply, GET_ACK)) { 928 if (read_dst(state, &reply, GET_ACK)) {
883 if (verbose > 1) 929 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
884 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
885 if ((dst_error_recovery(state)) < 0) { 930 if ((dst_error_recovery(state)) < 0) {
886 dprintk("%s: Recovery Failed.\n", __FUNCTION__); 931 dprintk(verbose, DST_INFO, 1, "Recovery Failed.");
887 return -1; 932 return -1;
888 } 933 }
889 return -1; 934 return -1;
890 } 935 }
891
892 if (reply != ACK) { 936 if (reply != ACK) {
893 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); 937 dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply);
894 return -1; 938 return -1;
895 } 939 }
896 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) 940 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
897 return 0; 941 return 0;
898
899// udelay(3000);
900 if (state->type_flags & DST_TYPE_HAS_FW_1) 942 if (state->type_flags & DST_TYPE_HAS_FW_1)
901 udelay(3000); 943 udelay(3000);
902 else 944 else
903 udelay(2000); 945 udelay(2000);
904
905 if (!dst_wait_dst_ready(state, NO_DELAY)) 946 if (!dst_wait_dst_ready(state, NO_DELAY))
906 return -1; 947 return -1;
907
908 if (read_dst(state, state->rxbuffer, FIXED_COMM)) { 948 if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
909 if (verbose > 1) 949 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
910 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
911 if ((dst_error_recovery(state)) < 0) { 950 if ((dst_error_recovery(state)) < 0) {
912 dprintk("%s: Recovery failed.\n", __FUNCTION__); 951 dprintk(verbose, DST_INFO, 1, "Recovery failed.");
913 return -1; 952 return -1;
914 } 953 }
915 return -1; 954 return -1;
916 } 955 }
917
918 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 956 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
919 dprintk("%s: checksum failure\n", __FUNCTION__); 957 dprintk(verbose, DST_INFO, 1, "checksum failure");
920 return -1; 958 return -1;
921 } 959 }
922 960
@@ -924,11 +962,11 @@ int dst_command(struct dst_state* state, u8 * data, u8 len)
924} 962}
925EXPORT_SYMBOL(dst_command); 963EXPORT_SYMBOL(dst_command);
926 964
927static int dst_get_signal(struct dst_state* state) 965static int dst_get_signal(struct dst_state *state)
928{ 966{
929 int retval; 967 int retval;
930 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; 968 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
931 dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); 969 //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
932 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { 970 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
933 state->decode_lock = state->decode_strength = state->decode_snr = 0; 971 state->decode_lock = state->decode_strength = state->decode_snr = 0;
934 return 0; 972 return 0;
@@ -955,13 +993,12 @@ static int dst_get_signal(struct dst_state* state)
955 return 0; 993 return 0;
956} 994}
957 995
958static int dst_tone_power_cmd(struct dst_state* state) 996static int dst_tone_power_cmd(struct dst_state *state)
959{ 997{
960 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; 998 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
961 999
962 if (state->dst_type == DST_TYPE_IS_TERR) 1000 if (state->dst_type == DST_TYPE_IS_TERR)
963 return 0; 1001 return 0;
964
965 paket[4] = state->tx_tuna[4]; 1002 paket[4] = state->tx_tuna[4];
966 paket[2] = state->tx_tuna[2]; 1003 paket[2] = state->tx_tuna[2];
967 paket[3] = state->tx_tuna[3]; 1004 paket[3] = state->tx_tuna[3];
@@ -971,61 +1008,53 @@ static int dst_tone_power_cmd(struct dst_state* state)
971 return 0; 1008 return 0;
972} 1009}
973 1010
974static int dst_get_tuna(struct dst_state* state) 1011static int dst_get_tuna(struct dst_state *state)
975{ 1012{
976 int retval; 1013 int retval;
977 1014
978 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) 1015 if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
979 return 0; 1016 return 0;
980
981 state->diseq_flags &= ~(HAS_LOCK); 1017 state->diseq_flags &= ~(HAS_LOCK);
982 if (!dst_wait_dst_ready(state, NO_DELAY)) 1018 if (!dst_wait_dst_ready(state, NO_DELAY))
983 return 0; 1019 return 0;
984 1020 if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
985 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
986 /* how to get variable length reply ???? */ 1021 /* how to get variable length reply ???? */
987 retval = read_dst(state, state->rx_tuna, 10); 1022 retval = read_dst(state, state->rx_tuna, 10);
988 } else { 1023 else
989 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); 1024 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
990 }
991
992 if (retval < 0) { 1025 if (retval < 0) {
993 dprintk("%s: read not successful\n", __FUNCTION__); 1026 dprintk(verbose, DST_DEBUG, 1, "read not successful");
994 return 0; 1027 return 0;
995 } 1028 }
996
997 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1029 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
998 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { 1030 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
999 dprintk("%s: checksum failure?\n", __FUNCTION__); 1031 dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
1000 return 0; 1032 return 0;
1001 } 1033 }
1002 } else { 1034 } else {
1003 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { 1035 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
1004 dprintk("%s: checksum failure?\n", __FUNCTION__); 1036 dprintk(verbose, DST_INFO, 1, "checksum failure? ");
1005 return 0; 1037 return 0;
1006 } 1038 }
1007 } 1039 }
1008 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) 1040 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
1009 return 0; 1041 return 0;
1010 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; 1042 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
1011
1012 state->decode_lock = 1; 1043 state->decode_lock = 1;
1013 state->diseq_flags |= HAS_LOCK; 1044 state->diseq_flags |= HAS_LOCK;
1014 1045
1015 return 1; 1046 return 1;
1016} 1047}
1017 1048
1018static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); 1049static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
1019 1050
1020static int dst_write_tuna(struct dvb_frontend* fe) 1051static int dst_write_tuna(struct dvb_frontend *fe)
1021{ 1052{
1022 struct dst_state* state = fe->demodulator_priv; 1053 struct dst_state *state = fe->demodulator_priv;
1023 int retval; 1054 int retval;
1024 u8 reply; 1055 u8 reply;
1025 1056
1026 if (debug > 4) 1057 dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags);
1027 dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags);
1028
1029 state->decode_freq = 0; 1058 state->decode_freq = 0;
1030 state->decode_lock = state->decode_strength = state->decode_snr = 0; 1059 state->decode_lock = state->decode_strength = state->decode_snr = 0;
1031 if (state->dst_type == DST_TYPE_IS_SAT) { 1060 if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1035,35 +1064,31 @@ static int dst_write_tuna(struct dvb_frontend* fe)
1035 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 1064 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
1036 1065
1037 if ((dst_comm_init(state)) < 0) { 1066 if ((dst_comm_init(state)) < 0) {
1038 dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); 1067 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
1039 return -1; 1068 return -1;
1040 } 1069 }
1041
1042 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1070 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
1043 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); 1071 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
1044 retval = write_dst(state, &state->tx_tuna[0], 10); 1072 retval = write_dst(state, &state->tx_tuna[0], 10);
1045
1046 } else { 1073 } else {
1047 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); 1074 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
1048 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); 1075 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM);
1049 } 1076 }
1050 if (retval < 0) { 1077 if (retval < 0) {
1051 dst_pio_disable(state); 1078 dst_pio_disable(state);
1052 dprintk("%s: write not successful\n", __FUNCTION__); 1079 dprintk(verbose, DST_DEBUG, 1, "write not successful");
1053 return retval; 1080 return retval;
1054 } 1081 }
1055
1056 if ((dst_pio_disable(state)) < 0) { 1082 if ((dst_pio_disable(state)) < 0) {
1057 dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); 1083 dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
1058 return -1; 1084 return -1;
1059 } 1085 }
1060
1061 if ((read_dst(state, &reply, GET_ACK) < 0)) { 1086 if ((read_dst(state, &reply, GET_ACK) < 0)) {
1062 dprintk("%s: read verify not successful.\n", __FUNCTION__); 1087 dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
1063 return -1; 1088 return -1;
1064 } 1089 }
1065 if (reply != ACK) { 1090 if (reply != ACK) {
1066 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); 1091 dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
1067 return 0; 1092 return 0;
1068 } 1093 }
1069 state->diseq_flags |= ATTEMPT_TUNE; 1094 state->diseq_flags |= ATTEMPT_TUNE;
@@ -1085,14 +1110,13 @@ static int dst_write_tuna(struct dvb_frontend* fe)
1085 * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 1110 * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0
1086 */ 1111 */
1087 1112
1088static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) 1113static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd)
1089{ 1114{
1090 struct dst_state* state = fe->demodulator_priv; 1115 struct dst_state *state = fe->demodulator_priv;
1091 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; 1116 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
1092 1117
1093 if (state->dst_type != DST_TYPE_IS_SAT) 1118 if (state->dst_type != DST_TYPE_IS_SAT)
1094 return 0; 1119 return 0;
1095
1096 if (cmd->msg_len == 0 || cmd->msg_len > 4) 1120 if (cmd->msg_len == 0 || cmd->msg_len > 4)
1097 return -EINVAL; 1121 return -EINVAL;
1098 memcpy(&paket[3], cmd->msg, cmd->msg_len); 1122 memcpy(&paket[3], cmd->msg, cmd->msg_len);
@@ -1101,65 +1125,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd*
1101 return 0; 1125 return 0;
1102} 1126}
1103 1127
1104static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 1128static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1105{ 1129{
1106 int need_cmd; 1130 int need_cmd;
1107 struct dst_state* state = fe->demodulator_priv; 1131 struct dst_state *state = fe->demodulator_priv;
1108 1132
1109 state->voltage = voltage; 1133 state->voltage = voltage;
1110
1111 if (state->dst_type != DST_TYPE_IS_SAT) 1134 if (state->dst_type != DST_TYPE_IS_SAT)
1112 return 0; 1135 return 0;
1113 1136
1114 need_cmd = 0; 1137 need_cmd = 0;
1115 switch (voltage) {
1116 case SEC_VOLTAGE_13:
1117 case SEC_VOLTAGE_18:
1118 if ((state->diseq_flags & HAS_POWER) == 0)
1119 need_cmd = 1;
1120 state->diseq_flags |= HAS_POWER;
1121 state->tx_tuna[4] = 0x01;
1122 break;
1123 1138
1124 case SEC_VOLTAGE_OFF: 1139 switch (voltage) {
1140 case SEC_VOLTAGE_13:
1141 case SEC_VOLTAGE_18:
1142 if ((state->diseq_flags & HAS_POWER) == 0)
1125 need_cmd = 1; 1143 need_cmd = 1;
1126 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); 1144 state->diseq_flags |= HAS_POWER;
1127 state->tx_tuna[4] = 0x00; 1145 state->tx_tuna[4] = 0x01;
1128 break; 1146 break;
1129 1147 case SEC_VOLTAGE_OFF:
1130 default: 1148 need_cmd = 1;
1131 return -EINVAL; 1149 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
1150 state->tx_tuna[4] = 0x00;
1151 break;
1152 default:
1153 return -EINVAL;
1132 } 1154 }
1155
1133 if (need_cmd) 1156 if (need_cmd)
1134 dst_tone_power_cmd(state); 1157 dst_tone_power_cmd(state);
1135 1158
1136 return 0; 1159 return 0;
1137} 1160}
1138 1161
1139static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 1162static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
1140{ 1163{
1141 struct dst_state* state = fe->demodulator_priv; 1164 struct dst_state *state = fe->demodulator_priv;
1142 1165
1143 state->tone = tone; 1166 state->tone = tone;
1144
1145 if (state->dst_type != DST_TYPE_IS_SAT) 1167 if (state->dst_type != DST_TYPE_IS_SAT)
1146 return 0; 1168 return 0;
1147 1169
1148 switch (tone) { 1170 switch (tone) {
1149 case SEC_TONE_OFF: 1171 case SEC_TONE_OFF:
1150 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1172 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1151 state->tx_tuna[2] = 0x00; 1173 state->tx_tuna[2] = 0x00;
1152 else 1174 else
1153 state->tx_tuna[2] = 0xff; 1175 state->tx_tuna[2] = 0xff;
1154 1176 break;
1155 break;
1156
1157 case SEC_TONE_ON:
1158 state->tx_tuna[2] = 0x02;
1159 break;
1160 1177
1161 default: 1178 case SEC_TONE_ON:
1162 return -EINVAL; 1179 state->tx_tuna[2] = 0x02;
1180 break;
1181 default:
1182 return -EINVAL;
1163 } 1183 }
1164 dst_tone_power_cmd(state); 1184 dst_tone_power_cmd(state);
1165 1185
@@ -1172,16 +1192,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1172 1192
1173 if (state->dst_type != DST_TYPE_IS_SAT) 1193 if (state->dst_type != DST_TYPE_IS_SAT)
1174 return 0; 1194 return 0;
1175
1176 state->minicmd = minicmd; 1195 state->minicmd = minicmd;
1177
1178 switch (minicmd) { 1196 switch (minicmd) {
1179 case SEC_MINI_A: 1197 case SEC_MINI_A:
1180 state->tx_tuna[3] = 0x02; 1198 state->tx_tuna[3] = 0x02;
1181 break; 1199 break;
1182 case SEC_MINI_B: 1200 case SEC_MINI_B:
1183 state->tx_tuna[3] = 0xff; 1201 state->tx_tuna[3] = 0xff;
1184 break; 1202 break;
1185 } 1203 }
1186 dst_tone_power_cmd(state); 1204 dst_tone_power_cmd(state);
1187 1205
@@ -1189,42 +1207,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1189} 1207}
1190 1208
1191 1209
1192static int dst_init(struct dvb_frontend* fe) 1210static int dst_init(struct dvb_frontend *fe)
1193{ 1211{
1194 struct dst_state* state = fe->demodulator_priv; 1212 struct dst_state *state = fe->demodulator_priv;
1195 static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; 1213
1196 static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; 1214 static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 };
1197 static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1215 static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 };
1198 static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1216 static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1199 static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1217 static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1200 static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; 1218 static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1201// state->inversion = INVERSION_ON; 1219 static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1220
1202 state->inversion = INVERSION_OFF; 1221 state->inversion = INVERSION_OFF;
1203 state->voltage = SEC_VOLTAGE_13; 1222 state->voltage = SEC_VOLTAGE_13;
1204 state->tone = SEC_TONE_OFF; 1223 state->tone = SEC_TONE_OFF;
1205 state->symbol_rate = 29473000;
1206 state->fec = FEC_AUTO;
1207 state->diseq_flags = 0; 1224 state->diseq_flags = 0;
1208 state->k22 = 0x02; 1225 state->k22 = 0x02;
1209 state->bandwidth = BANDWIDTH_7_MHZ; 1226 state->bandwidth = BANDWIDTH_7_MHZ;
1210 state->cur_jiff = jiffies; 1227 state->cur_jiff = jiffies;
1211 if (state->dst_type == DST_TYPE_IS_SAT) { 1228 if (state->dst_type == DST_TYPE_IS_SAT)
1212 state->frequency = 950000; 1229 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204));
1213 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); 1230 else if (state->dst_type == DST_TYPE_IS_TERR)
1214 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1231 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204));
1215 state->frequency = 137000000; 1232 else if (state->dst_type == DST_TYPE_IS_CABLE)
1216 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); 1233 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204));
1217 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
1218 state->frequency = 51000000;
1219 memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna));
1220 }
1221 1234
1222 return 0; 1235 return 0;
1223} 1236}
1224 1237
1225static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) 1238static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status)
1226{ 1239{
1227 struct dst_state* state = fe->demodulator_priv; 1240 struct dst_state *state = fe->demodulator_priv;
1228 1241
1229 *status = 0; 1242 *status = 0;
1230 if (state->diseq_flags & HAS_LOCK) { 1243 if (state->diseq_flags & HAS_LOCK) {
@@ -1236,9 +1249,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status)
1236 return 0; 1249 return 0;
1237} 1250}
1238 1251
1239static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) 1252static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1240{ 1253{
1241 struct dst_state* state = fe->demodulator_priv; 1254 struct dst_state *state = fe->demodulator_priv;
1242 1255
1243 dst_get_signal(state); 1256 dst_get_signal(state);
1244 *strength = state->decode_strength; 1257 *strength = state->decode_strength;
@@ -1246,9 +1259,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength)
1246 return 0; 1259 return 0;
1247} 1260}
1248 1261
1249static int dst_read_snr(struct dvb_frontend* fe, u16* snr) 1262static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
1250{ 1263{
1251 struct dst_state* state = fe->demodulator_priv; 1264 struct dst_state *state = fe->demodulator_priv;
1252 1265
1253 dst_get_signal(state); 1266 dst_get_signal(state);
1254 *snr = state->decode_snr; 1267 *snr = state->decode_snr;
@@ -1256,28 +1269,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr)
1256 return 0; 1269 return 0;
1257} 1270}
1258 1271
1259static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1272static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1260{ 1273{
1261 struct dst_state* state = fe->demodulator_priv; 1274 struct dst_state *state = fe->demodulator_priv;
1262 1275
1263 dst_set_freq(state, p->frequency); 1276 dst_set_freq(state, p->frequency);
1264 if (verbose > 4) 1277 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
1265 dprintk("Set Frequency=[%d]\n", p->frequency);
1266 1278
1267// dst_set_inversion(state, p->inversion);
1268 if (state->dst_type == DST_TYPE_IS_SAT) { 1279 if (state->dst_type == DST_TYPE_IS_SAT) {
1269 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1280 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1270 dst_set_inversion(state, p->inversion); 1281 dst_set_inversion(state, p->inversion);
1271
1272 dst_set_fec(state, p->u.qpsk.fec_inner); 1282 dst_set_fec(state, p->u.qpsk.fec_inner);
1273 dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1283 dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
1274 dst_set_polarization(state); 1284 dst_set_polarization(state);
1275 if (verbose > 4) 1285 dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate);
1276 dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate);
1277 1286
1278 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1287 } else if (state->dst_type == DST_TYPE_IS_TERR)
1279 dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1288 dst_set_bandwidth(state, p->u.ofdm.bandwidth);
1280 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1289 else if (state->dst_type == DST_TYPE_IS_CABLE) {
1281 dst_set_fec(state, p->u.qam.fec_inner); 1290 dst_set_fec(state, p->u.qam.fec_inner);
1282 dst_set_symbolrate(state, p->u.qam.symbol_rate); 1291 dst_set_symbolrate(state, p->u.qam.symbol_rate);
1283 dst_set_modulation(state, p->u.qam.modulation); 1292 dst_set_modulation(state, p->u.qam.modulation);
@@ -1287,16 +1296,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1287 return 0; 1296 return 0;
1288} 1297}
1289 1298
1290static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1299static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1291{ 1300{
1292 struct dst_state* state = fe->demodulator_priv; 1301 struct dst_state *state = fe->demodulator_priv;
1293 1302
1294 p->frequency = state->decode_freq; 1303 p->frequency = state->decode_freq;
1295// p->inversion = state->inversion;
1296 if (state->dst_type == DST_TYPE_IS_SAT) { 1304 if (state->dst_type == DST_TYPE_IS_SAT) {
1297 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1305 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1298 p->inversion = state->inversion; 1306 p->inversion = state->inversion;
1299
1300 p->u.qpsk.symbol_rate = state->symbol_rate; 1307 p->u.qpsk.symbol_rate = state->symbol_rate;
1301 p->u.qpsk.fec_inner = dst_get_fec(state); 1308 p->u.qpsk.fec_inner = dst_get_fec(state);
1302 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1309 } else if (state->dst_type == DST_TYPE_IS_TERR) {
@@ -1304,16 +1311,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1304 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1311 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
1305 p->u.qam.symbol_rate = state->symbol_rate; 1312 p->u.qam.symbol_rate = state->symbol_rate;
1306 p->u.qam.fec_inner = dst_get_fec(state); 1313 p->u.qam.fec_inner = dst_get_fec(state);
1307// p->u.qam.modulation = QAM_AUTO;
1308 p->u.qam.modulation = dst_get_modulation(state); 1314 p->u.qam.modulation = dst_get_modulation(state);
1309 } 1315 }
1310 1316
1311 return 0; 1317 return 0;
1312} 1318}
1313 1319
1314static void dst_release(struct dvb_frontend* fe) 1320static void dst_release(struct dvb_frontend *fe)
1315{ 1321{
1316 struct dst_state* state = fe->demodulator_priv; 1322 struct dst_state *state = fe->demodulator_priv;
1317 kfree(state); 1323 kfree(state);
1318} 1324}
1319 1325
@@ -1321,9 +1327,8 @@ static struct dvb_frontend_ops dst_dvbt_ops;
1321static struct dvb_frontend_ops dst_dvbs_ops; 1327static struct dvb_frontend_ops dst_dvbs_ops;
1322static struct dvb_frontend_ops dst_dvbc_ops; 1328static struct dvb_frontend_ops dst_dvbc_ops;
1323 1329
1324struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) 1330struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
1325{ 1331{
1326
1327 /* check if the ASIC is there */ 1332 /* check if the ASIC is there */
1328 if (dst_probe(state) < 0) { 1333 if (dst_probe(state) < 0) {
1329 if (state) 1334 if (state)
@@ -1336,17 +1341,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1336 case DST_TYPE_IS_TERR: 1341 case DST_TYPE_IS_TERR:
1337 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); 1342 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
1338 break; 1343 break;
1339
1340 case DST_TYPE_IS_CABLE: 1344 case DST_TYPE_IS_CABLE:
1341 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); 1345 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
1342 break; 1346 break;
1343
1344 case DST_TYPE_IS_SAT: 1347 case DST_TYPE_IS_SAT:
1345 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); 1348 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
1346 break; 1349 break;
1347
1348 default: 1350 default:
1349 printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); 1351 dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
1350 if (state) 1352 if (state)
1351 kfree(state); 1353 kfree(state);
1352 1354
@@ -1374,12 +1376,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = {
1374 }, 1376 },
1375 1377
1376 .release = dst_release, 1378 .release = dst_release,
1377
1378 .init = dst_init, 1379 .init = dst_init,
1379
1380 .set_frontend = dst_set_frontend, 1380 .set_frontend = dst_set_frontend,
1381 .get_frontend = dst_get_frontend, 1381 .get_frontend = dst_get_frontend,
1382
1383 .read_status = dst_read_status, 1382 .read_status = dst_read_status,
1384 .read_signal_strength = dst_read_signal_strength, 1383 .read_signal_strength = dst_read_signal_strength,
1385 .read_snr = dst_read_snr, 1384 .read_snr = dst_read_snr,
@@ -1401,16 +1400,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = {
1401 }, 1400 },
1402 1401
1403 .release = dst_release, 1402 .release = dst_release,
1404
1405 .init = dst_init, 1403 .init = dst_init,
1406
1407 .set_frontend = dst_set_frontend, 1404 .set_frontend = dst_set_frontend,
1408 .get_frontend = dst_get_frontend, 1405 .get_frontend = dst_get_frontend,
1409
1410 .read_status = dst_read_status, 1406 .read_status = dst_read_status,
1411 .read_signal_strength = dst_read_signal_strength, 1407 .read_signal_strength = dst_read_signal_strength,
1412 .read_snr = dst_read_snr, 1408 .read_snr = dst_read_snr,
1413
1414 .diseqc_send_burst = dst_send_burst, 1409 .diseqc_send_burst = dst_send_burst,
1415 .diseqc_send_master_cmd = dst_set_diseqc, 1410 .diseqc_send_master_cmd = dst_set_diseqc,
1416 .set_voltage = dst_set_voltage, 1411 .set_voltage = dst_set_voltage,
@@ -1432,18 +1427,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = {
1432 }, 1427 },
1433 1428
1434 .release = dst_release, 1429 .release = dst_release,
1435
1436 .init = dst_init, 1430 .init = dst_init,
1437
1438 .set_frontend = dst_set_frontend, 1431 .set_frontend = dst_set_frontend,
1439 .get_frontend = dst_get_frontend, 1432 .get_frontend = dst_get_frontend,
1440
1441 .read_status = dst_read_status, 1433 .read_status = dst_read_status,
1442 .read_signal_strength = dst_read_signal_strength, 1434 .read_signal_strength = dst_read_signal_strength,
1443 .read_snr = dst_read_snr, 1435 .read_snr = dst_read_snr,
1444}; 1436};
1445 1437
1446
1447MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); 1438MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
1448MODULE_AUTHOR("Jamie Honan, Manu Abraham"); 1439MODULE_AUTHOR("Jamie Honan, Manu Abraham");
1449MODULE_LICENSE("GPL"); 1440MODULE_LICENSE("GPL");