aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/bt8xx/dst.c
diff options
context:
space:
mode:
authorManu Abraham <manu@linuxtv.org>2005-09-09 16:03:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-09 16:57:43 -0400
commita427de6f72bc0d83ebb1d87f9003c5e1009f21cd (patch)
treed036ad01c3a278f9adf99e086ea66612817d4fa0 /drivers/media/dvb/bt8xx/dst.c
parent94b7410c8a2d23fad5937b326a0a9e8c5a876e2d (diff)
[PATCH] dvb: dst: dprrintk cleanup
Code Cleanup: o Remove debug noise o Remove debug module parameter debug level is achieved using the verbosity level o Updated to kernel coding style (case labels should not be indented) Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/dvb/bt8xx/dst.c')
-rw-r--r--drivers/media/dvb/bt8xx/dst.c649
1 files changed, 278 insertions, 371 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 66e69b8e1a0c..39835edba1d9 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 dprintk("%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 dprintk("%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 (verbose > 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,24 @@ 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) {
374 state->tx_tuna[2] = (freq >> 16) & 0xff; 362 state->tx_tuna[2] = (freq >> 16) & 0xff;
375 state->tx_tuna[3] = (freq >> 8) & 0xff; 363 state->tx_tuna[3] = (freq >> 8) & 0xff;
376 state->tx_tuna[4] = (u8) freq; 364 state->tx_tuna[4] = (u8) freq;
377
378 } else 365 } else
379 return -EINVAL; 366 return -EINVAL;
367
380 return 0; 368 return 0;
381} 369}
382 370
383static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) 371static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
384{ 372{
385 state->bandwidth = bandwidth; 373 state->bandwidth = bandwidth;
386 374
@@ -388,90 +376,82 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth)
388 return 0; 376 return 0;
389 377
390 switch (bandwidth) { 378 switch (bandwidth) {
391 case BANDWIDTH_6_MHZ: 379 case BANDWIDTH_6_MHZ:
392 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 380 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
393 state->tx_tuna[7] = 0x06; 381 state->tx_tuna[7] = 0x06;
394 else { 382 else {
395 state->tx_tuna[6] = 0x06; 383 state->tx_tuna[6] = 0x06;
396 state->tx_tuna[7] = 0x00; 384 state->tx_tuna[7] = 0x00;
397 } 385 }
398 break; 386 break;
399 387 case BANDWIDTH_7_MHZ:
400 case BANDWIDTH_7_MHZ: 388 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
401 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 389 state->tx_tuna[7] = 0x07;
402 state->tx_tuna[7] = 0x07; 390 else {
403 else { 391 state->tx_tuna[6] = 0x07;
404 state->tx_tuna[6] = 0x07; 392 state->tx_tuna[7] = 0x00;
405 state->tx_tuna[7] = 0x00; 393 }
406 } 394 break;
407 break; 395 case BANDWIDTH_8_MHZ:
408 396 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
409 case BANDWIDTH_8_MHZ: 397 state->tx_tuna[7] = 0x08;
410 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 398 else {
411 state->tx_tuna[7] = 0x08; 399 state->tx_tuna[6] = 0x08;
412 else { 400 state->tx_tuna[7] = 0x00;
413 state->tx_tuna[6] = 0x08; 401 }
414 state->tx_tuna[7] = 0x00; 402 break;
415 } 403 default:
416 break; 404 return -EINVAL;
417
418 default:
419 return -EINVAL;
420 } 405 }
406
421 return 0; 407 return 0;
422} 408}
423 409
424static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) 410static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion)
425{ 411{
426 state->inversion = inversion; 412 state->inversion = inversion;
427 switch (inversion) { 413 switch (inversion) {
428 case INVERSION_OFF: // Inversion = Normal 414 case INVERSION_OFF: /* Inversion = Normal */
429 state->tx_tuna[8] &= ~0x80; 415 state->tx_tuna[8] &= ~0x80;
430 break; 416 break;
431 417 case INVERSION_ON:
432 case INVERSION_ON: 418 state->tx_tuna[8] |= 0x80;
433 state->tx_tuna[8] |= 0x80; 419 break;
434 break; 420 default:
435 default: 421 return -EINVAL;
436 return -EINVAL;
437 } 422 }
423
438 return 0; 424 return 0;
439} 425}
440 426
441static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) 427static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec)
442{ 428{
443 state->fec = fec; 429 state->fec = fec;
444 return 0; 430 return 0;
445} 431}
446 432
447static fe_code_rate_t dst_get_fec(struct dst_state* state) 433static fe_code_rate_t dst_get_fec(struct dst_state *state)
448{ 434{
449 return state->fec; 435 return state->fec;
450} 436}
451 437
452static int dst_set_symbolrate(struct dst_state* state, u32 srate) 438static int dst_set_symbolrate(struct dst_state *state, u32 srate)
453{ 439{
454 u32 symcalc; 440 u32 symcalc;
455 u64 sval; 441 u64 sval;
456 442
457 state->symbol_rate = srate; 443 state->symbol_rate = srate;
458
459 if (state->dst_type == DST_TYPE_IS_TERR) { 444 if (state->dst_type == DST_TYPE_IS_TERR) {
460 return 0; 445 return 0;
461 } 446 }
462 if (debug > 4) 447 dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
463 dprintk("%s: set symrate %u\n", __FUNCTION__, srate);
464 srate /= 1000; 448 srate /= 1000;
465
466 if (state->type_flags & DST_TYPE_HAS_SYMDIV) { 449 if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
467 sval = srate; 450 sval = srate;
468 sval <<= 20; 451 sval <<= 20;
469 do_div(sval, 88000); 452 do_div(sval, 88000);
470 symcalc = (u32) sval; 453 symcalc = (u32) sval;
471 454 dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
472 if (debug > 4)
473 dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
474
475 state->tx_tuna[5] = (u8) (symcalc >> 12); 455 state->tx_tuna[5] = (u8) (symcalc >> 12);
476 state->tx_tuna[6] = (u8) (symcalc >> 4); 456 state->tx_tuna[6] = (u8) (symcalc >> 4);
477 state->tx_tuna[7] = (u8) (symcalc << 4); 457 state->tx_tuna[7] = (u8) (symcalc << 4);
@@ -496,32 +476,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio
496 476
497 state->modulation = modulation; 477 state->modulation = modulation;
498 switch (modulation) { 478 switch (modulation) {
499 case QAM_16: 479 case QAM_16:
500 state->tx_tuna[8] = 0x10; 480 state->tx_tuna[8] = 0x10;
501 break; 481 break;
502 482 case QAM_32:
503 case QAM_32: 483 state->tx_tuna[8] = 0x20;
504 state->tx_tuna[8] = 0x20; 484 break;
505 break; 485 case QAM_64:
506 486 state->tx_tuna[8] = 0x40;
507 case QAM_64: 487 break;
508 state->tx_tuna[8] = 0x40; 488 case QAM_128:
509 break; 489 state->tx_tuna[8] = 0x80;
510 490 break;
511 case QAM_128: 491 case QAM_256:
512 state->tx_tuna[8] = 0x80; 492 state->tx_tuna[8] = 0x00;
513 break; 493 break;
514 494 case QPSK:
515 case QAM_256: 495 case QAM_AUTO:
516 state->tx_tuna[8] = 0x00; 496 case VSB_8:
517 break; 497 case VSB_16:
518 498 default:
519 case QPSK: 499 return -EINVAL;
520 case QAM_AUTO:
521 case VSB_8:
522 case VSB_16:
523 default:
524 return -EINVAL;
525 500
526 } 501 }
527 502
@@ -534,7 +509,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state)
534} 509}
535 510
536 511
537u8 dst_check_sum(u8 * buf, u32 len) 512u8 dst_check_sum(u8 *buf, u32 len)
538{ 513{
539 u32 i; 514 u32 i;
540 u8 val = 0; 515 u8 val = 0;
@@ -549,26 +524,24 @@ EXPORT_SYMBOL(dst_check_sum);
549 524
550static void dst_type_flags_print(u32 type_flags) 525static void dst_type_flags_print(u32 type_flags)
551{ 526{
552 printk("DST type flags :"); 527 dprintk(verbose, DST_ERROR, 0, "DST type flags :");
553 if (type_flags & DST_TYPE_HAS_NEWTUNE) 528 if (type_flags & DST_TYPE_HAS_NEWTUNE)
554 printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); 529 dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
555 if (type_flags & DST_TYPE_HAS_TS204) 530 if (type_flags & DST_TYPE_HAS_TS204)
556 printk(" 0x%x ts204", DST_TYPE_HAS_TS204); 531 dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204);
557 if (type_flags & DST_TYPE_HAS_SYMDIV) 532 if (type_flags & DST_TYPE_HAS_SYMDIV)
558 printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); 533 dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
559 if (type_flags & DST_TYPE_HAS_FW_1) 534 if (type_flags & DST_TYPE_HAS_FW_1)
560 printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); 535 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
561 if (type_flags & DST_TYPE_HAS_FW_2) 536 if (type_flags & DST_TYPE_HAS_FW_2)
562 printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); 537 dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
563 if (type_flags & DST_TYPE_HAS_FW_3) 538 if (type_flags & DST_TYPE_HAS_FW_3)
564 printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); 539 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) 540 dprintk(verbose, DST_ERROR, 0, "\n");
566
567 printk("\n");
568} 541}
569 542
570 543
571static int dst_type_print (u8 type) 544static int dst_type_print(u8 type)
572{ 545{
573 char *otype; 546 char *otype;
574 switch (type) { 547 switch (type) {
@@ -585,10 +558,10 @@ static int dst_type_print (u8 type)
585 break; 558 break;
586 559
587 default: 560 default:
588 printk("%s: invalid dst type %d\n", __FUNCTION__, type); 561 dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type);
589 return -EINVAL; 562 return -EINVAL;
590 } 563 }
591 printk("DST type : %s\n", otype); 564 dprintk(verbose, DST_INFO, 1, "DST type: %s", otype);
592 565
593 return 0; 566 return 0;
594} 567}
@@ -772,53 +745,45 @@ static int dst_get_device_id(struct dst_state *state)
772 745
773 if (write_dst(state, device_type, FIXED_COMM)) 746 if (write_dst(state, device_type, FIXED_COMM))
774 return -1; /* Write failed */ 747 return -1; /* Write failed */
775
776 if ((dst_pio_disable(state)) < 0) 748 if ((dst_pio_disable(state)) < 0)
777 return -1; 749 return -1;
778
779 if (read_dst(state, &reply, GET_ACK)) 750 if (read_dst(state, &reply, GET_ACK))
780 return -1; /* Read failure */ 751 return -1; /* Read failure */
781
782 if (reply != ACK) { 752 if (reply != ACK) {
783 dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); 753 dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply);
784 return -1; /* Unack'd write */ 754 return -1; /* Unack'd write */
785 } 755 }
786
787 if (!dst_wait_dst_ready(state, DEVICE_INIT)) 756 if (!dst_wait_dst_ready(state, DEVICE_INIT))
788 return -1; /* DST not ready yet */ 757 return -1; /* DST not ready yet */
789
790 if (read_dst(state, state->rxbuffer, FIXED_COMM)) 758 if (read_dst(state, state->rxbuffer, FIXED_COMM))
791 return -1; 759 return -1;
792 760
793 dst_pio_disable(state); 761 dst_pio_disable(state);
794
795 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 762 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
796 dprintk("%s: Checksum failure! \n", __FUNCTION__); 763 dprintk(verbose, DST_INFO, 1, "Checksum failure!");
797 return -1; /* Checksum failure */ 764 return -1; /* Checksum failure */
798 } 765 }
799
800 state->rxbuffer[7] = '\0'; 766 state->rxbuffer[7] = '\0';
801 767
802 for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { 768 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))) { 769 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; 770 use_type_flags = p_dst_type->type_flags;
805 use_dst_type = p_dst_type->dst_type; 771 use_dst_type = p_dst_type->dst_type;
806 772
807 /* Card capabilities */ 773 /* Card capabilities */
808 state->dst_hw_cap = p_dst_type->dst_feature; 774 state->dst_hw_cap = p_dst_type->dst_feature;
809 printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); 775 dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id);
810 776
811 break; 777 break;
812 } 778 }
813 } 779 }
814 780
815 if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { 781 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]); 782 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__); 783 dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in");
818 use_dst_type = DST_TYPE_IS_SAT; 784 use_dst_type = DST_TYPE_IS_SAT;
819 use_type_flags = DST_TYPE_HAS_SYMDIV; 785 use_type_flags = DST_TYPE_HAS_SYMDIV;
820 } 786 }
821
822 dst_type_print(use_dst_type); 787 dst_type_print(use_dst_type);
823 state->type_flags = use_type_flags; 788 state->type_flags = use_type_flags;
824 state->dst_type = use_dst_type; 789 state->dst_type = use_dst_type;
@@ -834,7 +799,7 @@ static int dst_get_device_id(struct dst_state *state)
834static int dst_probe(struct dst_state *state) 799static int dst_probe(struct dst_state *state)
835{ 800{
836 if ((rdc_8820_reset(state)) < 0) { 801 if ((rdc_8820_reset(state)) < 0) {
837 dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); 802 dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
838 return -1; 803 return -1;
839 } 804 }
840 if (dst_addons & DST_TYPE_HAS_CA) 805 if (dst_addons & DST_TYPE_HAS_CA)
@@ -843,80 +808,69 @@ static int dst_probe(struct dst_state *state)
843 msleep(100); 808 msleep(100);
844 809
845 if ((dst_comm_init(state)) < 0) { 810 if ((dst_comm_init(state)) < 0) {
846 dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); 811 dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed.");
847 return -1; 812 return -1;
848 } 813 }
849 msleep(100); 814 msleep(100);
850 if (dst_get_device_id(state) < 0) { 815 if (dst_get_device_id(state) < 0) {
851 dprintk("%s: unknown device.\n", __FUNCTION__); 816 dprintk(verbose, DST_ERROR, 1, "unknown device.");
852 return -1; 817 return -1;
853 } 818 }
854 819
855 return 0; 820 return 0;
856} 821}
857 822
858int dst_command(struct dst_state* state, u8 * data, u8 len) 823int dst_command(struct dst_state *state, u8 *data, u8 len)
859{ 824{
860 u8 reply; 825 u8 reply;
861 if ((dst_comm_init(state)) < 0) { 826 if ((dst_comm_init(state)) < 0) {
862 dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); 827 dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
863 return -1; 828 return -1;
864 } 829 }
865
866 if (write_dst(state, data, len)) { 830 if (write_dst(state, data, len)) {
867 if (verbose > 1) 831 dprintk(verbose, DST_INFO, 1, "Tring to recover.. ");
868 dprintk("%s: Tring to recover.. \n", __FUNCTION__);
869 if ((dst_error_recovery(state)) < 0) { 832 if ((dst_error_recovery(state)) < 0) {
870 dprintk("%s: Recovery Failed.\n", __FUNCTION__); 833 dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
871 return -1; 834 return -1;
872 } 835 }
873 return -1; 836 return -1;
874 } 837 }
875 if ((dst_pio_disable(state)) < 0) { 838 if ((dst_pio_disable(state)) < 0) {
876 dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); 839 dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed.");
877 return -1; 840 return -1;
878 } 841 }
879 if (state->type_flags & DST_TYPE_HAS_FW_1) 842 if (state->type_flags & DST_TYPE_HAS_FW_1)
880 udelay(3000); 843 udelay(3000);
881
882 if (read_dst(state, &reply, GET_ACK)) { 844 if (read_dst(state, &reply, GET_ACK)) {
883 if (verbose > 1) 845 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
884 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
885 if ((dst_error_recovery(state)) < 0) { 846 if ((dst_error_recovery(state)) < 0) {
886 dprintk("%s: Recovery Failed.\n", __FUNCTION__); 847 dprintk(verbose, DST_INFO, 1, "Recovery Failed.");
887 return -1; 848 return -1;
888 } 849 }
889 return -1; 850 return -1;
890 } 851 }
891
892 if (reply != ACK) { 852 if (reply != ACK) {
893 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); 853 dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply);
894 return -1; 854 return -1;
895 } 855 }
896 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) 856 if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
897 return 0; 857 return 0;
898
899// udelay(3000);
900 if (state->type_flags & DST_TYPE_HAS_FW_1) 858 if (state->type_flags & DST_TYPE_HAS_FW_1)
901 udelay(3000); 859 udelay(3000);
902 else 860 else
903 udelay(2000); 861 udelay(2000);
904
905 if (!dst_wait_dst_ready(state, NO_DELAY)) 862 if (!dst_wait_dst_ready(state, NO_DELAY))
906 return -1; 863 return -1;
907
908 if (read_dst(state, state->rxbuffer, FIXED_COMM)) { 864 if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
909 if (verbose > 1) 865 dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
910 dprintk("%s: Trying to recover.. \n", __FUNCTION__);
911 if ((dst_error_recovery(state)) < 0) { 866 if ((dst_error_recovery(state)) < 0) {
912 dprintk("%s: Recovery failed.\n", __FUNCTION__); 867 dprintk(verbose, DST_INFO, 1, "Recovery failed.");
913 return -1; 868 return -1;
914 } 869 }
915 return -1; 870 return -1;
916 } 871 }
917
918 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { 872 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
919 dprintk("%s: checksum failure\n", __FUNCTION__); 873 dprintk(verbose, DST_INFO, 1, "checksum failure");
920 return -1; 874 return -1;
921 } 875 }
922 876
@@ -924,7 +878,7 @@ int dst_command(struct dst_state* state, u8 * data, u8 len)
924} 878}
925EXPORT_SYMBOL(dst_command); 879EXPORT_SYMBOL(dst_command);
926 880
927static int dst_get_signal(struct dst_state* state) 881static int dst_get_signal(struct dst_state *state)
928{ 882{
929 int retval; 883 int retval;
930 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; 884 u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
@@ -955,13 +909,12 @@ static int dst_get_signal(struct dst_state* state)
955 return 0; 909 return 0;
956} 910}
957 911
958static int dst_tone_power_cmd(struct dst_state* state) 912static int dst_tone_power_cmd(struct dst_state *state)
959{ 913{
960 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; 914 u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
961 915
962 if (state->dst_type == DST_TYPE_IS_TERR) 916 if (state->dst_type == DST_TYPE_IS_TERR)
963 return 0; 917 return 0;
964
965 paket[4] = state->tx_tuna[4]; 918 paket[4] = state->tx_tuna[4];
966 paket[2] = state->tx_tuna[2]; 919 paket[2] = state->tx_tuna[2];
967 paket[3] = state->tx_tuna[3]; 920 paket[3] = state->tx_tuna[3];
@@ -971,61 +924,53 @@ static int dst_tone_power_cmd(struct dst_state* state)
971 return 0; 924 return 0;
972} 925}
973 926
974static int dst_get_tuna(struct dst_state* state) 927static int dst_get_tuna(struct dst_state *state)
975{ 928{
976 int retval; 929 int retval;
977 930
978 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) 931 if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
979 return 0; 932 return 0;
980
981 state->diseq_flags &= ~(HAS_LOCK); 933 state->diseq_flags &= ~(HAS_LOCK);
982 if (!dst_wait_dst_ready(state, NO_DELAY)) 934 if (!dst_wait_dst_ready(state, NO_DELAY))
983 return 0; 935 return 0;
984 936 if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
985 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
986 /* how to get variable length reply ???? */ 937 /* how to get variable length reply ???? */
987 retval = read_dst(state, state->rx_tuna, 10); 938 retval = read_dst(state, state->rx_tuna, 10);
988 } else { 939 else
989 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); 940 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
990 }
991
992 if (retval < 0) { 941 if (retval < 0) {
993 dprintk("%s: read not successful\n", __FUNCTION__); 942 dprintk(verbose, DST_DEBUG, 1, "read not successful");
994 return 0; 943 return 0;
995 } 944 }
996
997 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 945 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
998 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { 946 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
999 dprintk("%s: checksum failure?\n", __FUNCTION__); 947 dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
1000 return 0; 948 return 0;
1001 } 949 }
1002 } else { 950 } else {
1003 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { 951 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
1004 dprintk("%s: checksum failure?\n", __FUNCTION__); 952 dprintk(verbose, DST_INFO, 1, "checksum failure? ");
1005 return 0; 953 return 0;
1006 } 954 }
1007 } 955 }
1008 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) 956 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
1009 return 0; 957 return 0;
1010 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; 958 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
1011
1012 state->decode_lock = 1; 959 state->decode_lock = 1;
1013 state->diseq_flags |= HAS_LOCK; 960 state->diseq_flags |= HAS_LOCK;
1014 961
1015 return 1; 962 return 1;
1016} 963}
1017 964
1018static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); 965static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
1019 966
1020static int dst_write_tuna(struct dvb_frontend* fe) 967static int dst_write_tuna(struct dvb_frontend *fe)
1021{ 968{
1022 struct dst_state* state = fe->demodulator_priv; 969 struct dst_state *state = fe->demodulator_priv;
1023 int retval; 970 int retval;
1024 u8 reply; 971 u8 reply;
1025 972
1026 if (debug > 4) 973 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; 974 state->decode_freq = 0;
1030 state->decode_lock = state->decode_strength = state->decode_snr = 0; 975 state->decode_lock = state->decode_strength = state->decode_snr = 0;
1031 if (state->dst_type == DST_TYPE_IS_SAT) { 976 if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1035,35 +980,31 @@ static int dst_write_tuna(struct dvb_frontend* fe)
1035 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 980 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
1036 981
1037 if ((dst_comm_init(state)) < 0) { 982 if ((dst_comm_init(state)) < 0) {
1038 dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); 983 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
1039 return -1; 984 return -1;
1040 } 985 }
1041
1042 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 986 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
1043 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); 987 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
1044 retval = write_dst(state, &state->tx_tuna[0], 10); 988 retval = write_dst(state, &state->tx_tuna[0], 10);
1045
1046 } else { 989 } else {
1047 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); 990 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
1048 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); 991 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM);
1049 } 992 }
1050 if (retval < 0) { 993 if (retval < 0) {
1051 dst_pio_disable(state); 994 dst_pio_disable(state);
1052 dprintk("%s: write not successful\n", __FUNCTION__); 995 dprintk(verbose, DST_DEBUG, 1, "write not successful");
1053 return retval; 996 return retval;
1054 } 997 }
1055
1056 if ((dst_pio_disable(state)) < 0) { 998 if ((dst_pio_disable(state)) < 0) {
1057 dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); 999 dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
1058 return -1; 1000 return -1;
1059 } 1001 }
1060
1061 if ((read_dst(state, &reply, GET_ACK) < 0)) { 1002 if ((read_dst(state, &reply, GET_ACK) < 0)) {
1062 dprintk("%s: read verify not successful.\n", __FUNCTION__); 1003 dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
1063 return -1; 1004 return -1;
1064 } 1005 }
1065 if (reply != ACK) { 1006 if (reply != ACK) {
1066 dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); 1007 dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
1067 return 0; 1008 return 0;
1068 } 1009 }
1069 state->diseq_flags |= ATTEMPT_TUNE; 1010 state->diseq_flags |= ATTEMPT_TUNE;
@@ -1085,14 +1026,13 @@ static int dst_write_tuna(struct dvb_frontend* fe)
1085 * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 1026 * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0
1086 */ 1027 */
1087 1028
1088static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) 1029static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd)
1089{ 1030{
1090 struct dst_state* state = fe->demodulator_priv; 1031 struct dst_state *state = fe->demodulator_priv;
1091 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; 1032 u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
1092 1033
1093 if (state->dst_type != DST_TYPE_IS_SAT) 1034 if (state->dst_type != DST_TYPE_IS_SAT)
1094 return 0; 1035 return 0;
1095
1096 if (cmd->msg_len == 0 || cmd->msg_len > 4) 1036 if (cmd->msg_len == 0 || cmd->msg_len > 4)
1097 return -EINVAL; 1037 return -EINVAL;
1098 memcpy(&paket[3], cmd->msg, cmd->msg_len); 1038 memcpy(&paket[3], cmd->msg, cmd->msg_len);
@@ -1101,65 +1041,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd*
1101 return 0; 1041 return 0;
1102} 1042}
1103 1043
1104static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 1044static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1105{ 1045{
1106 int need_cmd; 1046 int need_cmd;
1107 struct dst_state* state = fe->demodulator_priv; 1047 struct dst_state *state = fe->demodulator_priv;
1108 1048
1109 state->voltage = voltage; 1049 state->voltage = voltage;
1110
1111 if (state->dst_type != DST_TYPE_IS_SAT) 1050 if (state->dst_type != DST_TYPE_IS_SAT)
1112 return 0; 1051 return 0;
1113 1052
1114 need_cmd = 0; 1053 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 1054
1124 case SEC_VOLTAGE_OFF: 1055 switch (voltage) {
1056 case SEC_VOLTAGE_13:
1057 case SEC_VOLTAGE_18:
1058 if ((state->diseq_flags & HAS_POWER) == 0)
1125 need_cmd = 1; 1059 need_cmd = 1;
1126 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); 1060 state->diseq_flags |= HAS_POWER;
1127 state->tx_tuna[4] = 0x00; 1061 state->tx_tuna[4] = 0x01;
1128 break; 1062 break;
1129 1063 case SEC_VOLTAGE_OFF:
1130 default: 1064 need_cmd = 1;
1131 return -EINVAL; 1065 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
1066 state->tx_tuna[4] = 0x00;
1067 break;
1068 default:
1069 return -EINVAL;
1132 } 1070 }
1071
1133 if (need_cmd) 1072 if (need_cmd)
1134 dst_tone_power_cmd(state); 1073 dst_tone_power_cmd(state);
1135 1074
1136 return 0; 1075 return 0;
1137} 1076}
1138 1077
1139static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 1078static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
1140{ 1079{
1141 struct dst_state* state = fe->demodulator_priv; 1080 struct dst_state *state = fe->demodulator_priv;
1142 1081
1143 state->tone = tone; 1082 state->tone = tone;
1144
1145 if (state->dst_type != DST_TYPE_IS_SAT) 1083 if (state->dst_type != DST_TYPE_IS_SAT)
1146 return 0; 1084 return 0;
1147 1085
1148 switch (tone) { 1086 switch (tone) {
1149 case SEC_TONE_OFF: 1087 case SEC_TONE_OFF:
1150 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1088 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1151 state->tx_tuna[2] = 0x00; 1089 state->tx_tuna[2] = 0x00;
1152 else 1090 else
1153 state->tx_tuna[2] = 0xff; 1091 state->tx_tuna[2] = 0xff;
1154 1092 break;
1155 break;
1156
1157 case SEC_TONE_ON:
1158 state->tx_tuna[2] = 0x02;
1159 break;
1160 1093
1161 default: 1094 case SEC_TONE_ON:
1162 return -EINVAL; 1095 state->tx_tuna[2] = 0x02;
1096 break;
1097 default:
1098 return -EINVAL;
1163 } 1099 }
1164 dst_tone_power_cmd(state); 1100 dst_tone_power_cmd(state);
1165 1101
@@ -1172,16 +1108,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1172 1108
1173 if (state->dst_type != DST_TYPE_IS_SAT) 1109 if (state->dst_type != DST_TYPE_IS_SAT)
1174 return 0; 1110 return 0;
1175
1176 state->minicmd = minicmd; 1111 state->minicmd = minicmd;
1177
1178 switch (minicmd) { 1112 switch (minicmd) {
1179 case SEC_MINI_A: 1113 case SEC_MINI_A:
1180 state->tx_tuna[3] = 0x02; 1114 state->tx_tuna[3] = 0x02;
1181 break; 1115 break;
1182 case SEC_MINI_B: 1116 case SEC_MINI_B:
1183 state->tx_tuna[3] = 0xff; 1117 state->tx_tuna[3] = 0xff;
1184 break; 1118 break;
1185 } 1119 }
1186 dst_tone_power_cmd(state); 1120 dst_tone_power_cmd(state);
1187 1121
@@ -1189,42 +1123,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
1189} 1123}
1190 1124
1191 1125
1192static int dst_init(struct dvb_frontend* fe) 1126static int dst_init(struct dvb_frontend *fe)
1193{ 1127{
1194 struct dst_state* state = fe->demodulator_priv; 1128 struct dst_state *state = fe->demodulator_priv;
1195 static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; 1129
1196 static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; 1130 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 }; 1131 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 }; 1132 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 }; 1133 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 }; 1134 static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1201// state->inversion = INVERSION_ON; 1135 static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
1136
1202 state->inversion = INVERSION_OFF; 1137 state->inversion = INVERSION_OFF;
1203 state->voltage = SEC_VOLTAGE_13; 1138 state->voltage = SEC_VOLTAGE_13;
1204 state->tone = SEC_TONE_OFF; 1139 state->tone = SEC_TONE_OFF;
1205 state->symbol_rate = 29473000;
1206 state->fec = FEC_AUTO;
1207 state->diseq_flags = 0; 1140 state->diseq_flags = 0;
1208 state->k22 = 0x02; 1141 state->k22 = 0x02;
1209 state->bandwidth = BANDWIDTH_7_MHZ; 1142 state->bandwidth = BANDWIDTH_7_MHZ;
1210 state->cur_jiff = jiffies; 1143 state->cur_jiff = jiffies;
1211 if (state->dst_type == DST_TYPE_IS_SAT) { 1144 if (state->dst_type == DST_TYPE_IS_SAT)
1212 state->frequency = 950000; 1145 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)); 1146 else if (state->dst_type == DST_TYPE_IS_TERR)
1214 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1147 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; 1148 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)); 1149 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 1150
1222 return 0; 1151 return 0;
1223} 1152}
1224 1153
1225static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) 1154static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status)
1226{ 1155{
1227 struct dst_state* state = fe->demodulator_priv; 1156 struct dst_state *state = fe->demodulator_priv;
1228 1157
1229 *status = 0; 1158 *status = 0;
1230 if (state->diseq_flags & HAS_LOCK) { 1159 if (state->diseq_flags & HAS_LOCK) {
@@ -1236,9 +1165,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status)
1236 return 0; 1165 return 0;
1237} 1166}
1238 1167
1239static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) 1168static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
1240{ 1169{
1241 struct dst_state* state = fe->demodulator_priv; 1170 struct dst_state *state = fe->demodulator_priv;
1242 1171
1243 dst_get_signal(state); 1172 dst_get_signal(state);
1244 *strength = state->decode_strength; 1173 *strength = state->decode_strength;
@@ -1246,9 +1175,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength)
1246 return 0; 1175 return 0;
1247} 1176}
1248 1177
1249static int dst_read_snr(struct dvb_frontend* fe, u16* snr) 1178static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
1250{ 1179{
1251 struct dst_state* state = fe->demodulator_priv; 1180 struct dst_state *state = fe->demodulator_priv;
1252 1181
1253 dst_get_signal(state); 1182 dst_get_signal(state);
1254 *snr = state->decode_snr; 1183 *snr = state->decode_snr;
@@ -1256,28 +1185,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr)
1256 return 0; 1185 return 0;
1257} 1186}
1258 1187
1259static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1188static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1260{ 1189{
1261 struct dst_state* state = fe->demodulator_priv; 1190 struct dst_state *state = fe->demodulator_priv;
1262 1191
1263 dst_set_freq(state, p->frequency); 1192 dst_set_freq(state, p->frequency);
1264 if (verbose > 4) 1193 dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
1265 dprintk("Set Frequency=[%d]\n", p->frequency);
1266 1194
1267// dst_set_inversion(state, p->inversion);
1268 if (state->dst_type == DST_TYPE_IS_SAT) { 1195 if (state->dst_type == DST_TYPE_IS_SAT) {
1269 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1196 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1270 dst_set_inversion(state, p->inversion); 1197 dst_set_inversion(state, p->inversion);
1271
1272 dst_set_fec(state, p->u.qpsk.fec_inner); 1198 dst_set_fec(state, p->u.qpsk.fec_inner);
1273 dst_set_symbolrate(state, p->u.qpsk.symbol_rate); 1199 dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
1274 dst_set_polarization(state); 1200 dst_set_polarization(state);
1275 if (verbose > 4) 1201 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 1202
1278 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1203 } else if (state->dst_type == DST_TYPE_IS_TERR)
1279 dst_set_bandwidth(state, p->u.ofdm.bandwidth); 1204 dst_set_bandwidth(state, p->u.ofdm.bandwidth);
1280 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1205 else if (state->dst_type == DST_TYPE_IS_CABLE) {
1281 dst_set_fec(state, p->u.qam.fec_inner); 1206 dst_set_fec(state, p->u.qam.fec_inner);
1282 dst_set_symbolrate(state, p->u.qam.symbol_rate); 1207 dst_set_symbolrate(state, p->u.qam.symbol_rate);
1283 dst_set_modulation(state, p->u.qam.modulation); 1208 dst_set_modulation(state, p->u.qam.modulation);
@@ -1287,16 +1212,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1287 return 0; 1212 return 0;
1288} 1213}
1289 1214
1290static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 1215static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1291{ 1216{
1292 struct dst_state* state = fe->demodulator_priv; 1217 struct dst_state *state = fe->demodulator_priv;
1293 1218
1294 p->frequency = state->decode_freq; 1219 p->frequency = state->decode_freq;
1295// p->inversion = state->inversion;
1296 if (state->dst_type == DST_TYPE_IS_SAT) { 1220 if (state->dst_type == DST_TYPE_IS_SAT) {
1297 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) 1221 if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
1298 p->inversion = state->inversion; 1222 p->inversion = state->inversion;
1299
1300 p->u.qpsk.symbol_rate = state->symbol_rate; 1223 p->u.qpsk.symbol_rate = state->symbol_rate;
1301 p->u.qpsk.fec_inner = dst_get_fec(state); 1224 p->u.qpsk.fec_inner = dst_get_fec(state);
1302 } else if (state->dst_type == DST_TYPE_IS_TERR) { 1225 } else if (state->dst_type == DST_TYPE_IS_TERR) {
@@ -1304,16 +1227,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet
1304 } else if (state->dst_type == DST_TYPE_IS_CABLE) { 1227 } else if (state->dst_type == DST_TYPE_IS_CABLE) {
1305 p->u.qam.symbol_rate = state->symbol_rate; 1228 p->u.qam.symbol_rate = state->symbol_rate;
1306 p->u.qam.fec_inner = dst_get_fec(state); 1229 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); 1230 p->u.qam.modulation = dst_get_modulation(state);
1309 } 1231 }
1310 1232
1311 return 0; 1233 return 0;
1312} 1234}
1313 1235
1314static void dst_release(struct dvb_frontend* fe) 1236static void dst_release(struct dvb_frontend *fe)
1315{ 1237{
1316 struct dst_state* state = fe->demodulator_priv; 1238 struct dst_state *state = fe->demodulator_priv;
1317 kfree(state); 1239 kfree(state);
1318} 1240}
1319 1241
@@ -1321,9 +1243,8 @@ static struct dvb_frontend_ops dst_dvbt_ops;
1321static struct dvb_frontend_ops dst_dvbs_ops; 1243static struct dvb_frontend_ops dst_dvbs_ops;
1322static struct dvb_frontend_ops dst_dvbc_ops; 1244static struct dvb_frontend_ops dst_dvbc_ops;
1323 1245
1324struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) 1246struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
1325{ 1247{
1326
1327 /* check if the ASIC is there */ 1248 /* check if the ASIC is there */
1328 if (dst_probe(state) < 0) { 1249 if (dst_probe(state) < 0) {
1329 if (state) 1250 if (state)
@@ -1336,17 +1257,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
1336 case DST_TYPE_IS_TERR: 1257 case DST_TYPE_IS_TERR:
1337 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); 1258 memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
1338 break; 1259 break;
1339
1340 case DST_TYPE_IS_CABLE: 1260 case DST_TYPE_IS_CABLE:
1341 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); 1261 memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
1342 break; 1262 break;
1343
1344 case DST_TYPE_IS_SAT: 1263 case DST_TYPE_IS_SAT:
1345 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); 1264 memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
1346 break; 1265 break;
1347
1348 default: 1266 default:
1349 printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); 1267 dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
1350 if (state) 1268 if (state)
1351 kfree(state); 1269 kfree(state);
1352 1270
@@ -1374,12 +1292,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = {
1374 }, 1292 },
1375 1293
1376 .release = dst_release, 1294 .release = dst_release,
1377
1378 .init = dst_init, 1295 .init = dst_init,
1379
1380 .set_frontend = dst_set_frontend, 1296 .set_frontend = dst_set_frontend,
1381 .get_frontend = dst_get_frontend, 1297 .get_frontend = dst_get_frontend,
1382
1383 .read_status = dst_read_status, 1298 .read_status = dst_read_status,
1384 .read_signal_strength = dst_read_signal_strength, 1299 .read_signal_strength = dst_read_signal_strength,
1385 .read_snr = dst_read_snr, 1300 .read_snr = dst_read_snr,
@@ -1401,16 +1316,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = {
1401 }, 1316 },
1402 1317
1403 .release = dst_release, 1318 .release = dst_release,
1404
1405 .init = dst_init, 1319 .init = dst_init,
1406
1407 .set_frontend = dst_set_frontend, 1320 .set_frontend = dst_set_frontend,
1408 .get_frontend = dst_get_frontend, 1321 .get_frontend = dst_get_frontend,
1409
1410 .read_status = dst_read_status, 1322 .read_status = dst_read_status,
1411 .read_signal_strength = dst_read_signal_strength, 1323 .read_signal_strength = dst_read_signal_strength,
1412 .read_snr = dst_read_snr, 1324 .read_snr = dst_read_snr,
1413
1414 .diseqc_send_burst = dst_send_burst, 1325 .diseqc_send_burst = dst_send_burst,
1415 .diseqc_send_master_cmd = dst_set_diseqc, 1326 .diseqc_send_master_cmd = dst_set_diseqc,
1416 .set_voltage = dst_set_voltage, 1327 .set_voltage = dst_set_voltage,
@@ -1432,18 +1343,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = {
1432 }, 1343 },
1433 1344
1434 .release = dst_release, 1345 .release = dst_release,
1435
1436 .init = dst_init, 1346 .init = dst_init,
1437
1438 .set_frontend = dst_set_frontend, 1347 .set_frontend = dst_set_frontend,
1439 .get_frontend = dst_get_frontend, 1348 .get_frontend = dst_get_frontend,
1440
1441 .read_status = dst_read_status, 1349 .read_status = dst_read_status,
1442 .read_signal_strength = dst_read_signal_strength, 1350 .read_signal_strength = dst_read_signal_strength,
1443 .read_snr = dst_read_snr, 1351 .read_snr = dst_read_snr,
1444}; 1352};
1445 1353
1446
1447MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); 1354MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
1448MODULE_AUTHOR("Jamie Honan, Manu Abraham"); 1355MODULE_AUTHOR("Jamie Honan, Manu Abraham");
1449MODULE_LICENSE("GPL"); 1356MODULE_LICENSE("GPL");