aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/bt8xx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/bt8xx')
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c4
-rw-r--r--drivers/media/dvb/bt8xx/bt878.h2
-rw-r--r--drivers/media/dvb/bt8xx/dst.c763
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c554
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h8
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c282
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.h2
7 files changed, 767 insertions, 848 deletions
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
index 3c5a8e273c4a..f29571450038 100644
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ b/drivers/media/dvb/bt8xx/bt878.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card 2 * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card
3 * 3 *
4 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> 4 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
5 * 5 *
6 * large parts based on the bttv driver 6 * large parts based on the bttv driver
7 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) 7 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de)
@@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
219 controlreg &= ~0x1f; 219 controlreg &= ~0x1f;
220 controlreg |= 0x1b; 220 controlreg |= 0x1b;
221 221
222 btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START); 222 btwrite(bt->risc_dma, BT878_ARISC_START);
223 223
224 /* original int mask had : 224 /* original int mask had :
225 * 6 2 8 4 0 225 * 6 2 8 4 0
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
index 837623f7fcdf..a73baf00ca39 100644
--- a/drivers/media/dvb/bt8xx/bt878.h
+++ b/drivers/media/dvb/bt8xx/bt878.h
@@ -1,7 +1,7 @@
1/* 1/*
2 bt878.h - Bt878 audio module (register offsets) 2 bt878.h - Bt878 audio module (register offsets)
3 3
4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> 4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
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");
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index bfaacd5fc20f..6776a592045f 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -18,30 +18,42 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21
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>
26#include <linux/string.h> 24#include <linux/string.h>
27
28#include <linux/dvb/ca.h> 25#include <linux/dvb/ca.h>
29#include "dvbdev.h" 26#include "dvbdev.h"
30#include "dvb_frontend.h" 27#include "dvb_frontend.h"
31
32#include "dst_ca.h" 28#include "dst_ca.h"
33#include "dst_common.h" 29#include "dst_common.h"
34 30
31#define DST_CA_ERROR 0
32#define DST_CA_NOTICE 1
33#define DST_CA_INFO 2
34#define DST_CA_DEBUG 3
35
36#define dprintk(x, y, z, format, arg...) do { \
37 if (z) { \
38 if ((x > DST_CA_ERROR) && (x > y)) \
39 printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \
40 else if ((x > DST_CA_NOTICE) && (x > y)) \
41 printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \
42 else if ((x > DST_CA_INFO) && (x > y)) \
43 printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \
44 else if ((x > DST_CA_DEBUG) && (x > y)) \
45 printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \
46 } else { \
47 if (x > y) \
48 printk(format, ## arg); \
49 } \
50} while(0)
51
52
35static unsigned int verbose = 5; 53static unsigned int verbose = 5;
36module_param(verbose, int, 0644); 54module_param(verbose, int, 0644);
37MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 55MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
38 56
39static unsigned int debug = 1;
40module_param(debug, int, 0644);
41MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)");
42
43#define dprintk if (debug) printk
44
45/* Need some more work */ 57/* Need some more work */
46static int ca_set_slot_descr(void) 58static int ca_set_slot_descr(void)
47{ 59{
@@ -61,27 +73,20 @@ static int put_checksum(u8 *check_string, int length)
61{ 73{
62 u8 i = 0, checksum = 0; 74 u8 i = 0, checksum = 0;
63 75
64 if (verbose > 3) { 76 dprintk(verbose, DST_CA_DEBUG, 1, " ========================= Checksum calculation ===========================");
65 dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__); 77 dprintk(verbose, DST_CA_DEBUG, 1, " String Length=[0x%02x]", length);
66 dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length); 78 dprintk(verbose, DST_CA_DEBUG, 1, " String=[");
67 79
68 dprintk("%s: String=[", __FUNCTION__);
69 }
70 while (i < length) { 80 while (i < length) {
71 if (verbose > 3) 81 dprintk(verbose, DST_CA_DEBUG, 0, " %02x", check_string[i]);
72 dprintk(" %02x", check_string[i]);
73 checksum += check_string[i]; 82 checksum += check_string[i];
74 i++; 83 i++;
75 } 84 }
76 if (verbose > 3) { 85 dprintk(verbose, DST_CA_DEBUG, 0, " ]\n");
77 dprintk(" ]\n"); 86 dprintk(verbose, DST_CA_DEBUG, 1, "Sum=[%02x]\n", checksum);
78 dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum);
79 }
80 check_string[length] = ~checksum + 1; 87 check_string[length] = ~checksum + 1;
81 if (verbose > 3) { 88 dprintk(verbose, DST_CA_DEBUG, 1, " Checksum=[%02x]", check_string[length]);
82 dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]); 89 dprintk(verbose, DST_CA_DEBUG, 1, " ==========================================================================");
83 dprintk("%s: ==========================================================================\n", __FUNCTION__);
84 }
85 90
86 return 0; 91 return 0;
87} 92}
@@ -94,30 +99,26 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
94 msleep(65); 99 msleep(65);
95 100
96 if (write_dst(state, data, len)) { 101 if (write_dst(state, data, len)) {
97 dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__); 102 dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover");
98 dst_error_recovery(state); 103 dst_error_recovery(state);
99 return -1; 104 return -1;
100 } 105 }
101
102 if ((dst_pio_disable(state)) < 0) { 106 if ((dst_pio_disable(state)) < 0) {
103 dprintk("%s: DST PIO disable failed.\n", __FUNCTION__); 107 dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed.");
104 return -1; 108 return -1;
105 } 109 }
106
107 if (read_dst(state, &reply, GET_ACK) < 0) { 110 if (read_dst(state, &reply, GET_ACK) < 0) {
108 dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); 111 dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
109 dst_error_recovery(state); 112 dst_error_recovery(state);
110 return -1; 113 return -1;
111 } 114 }
112
113 if (read) { 115 if (read) {
114 if (! dst_wait_dst_ready(state, LONG_DELAY)) { 116 if (! dst_wait_dst_ready(state, LONG_DELAY)) {
115 dprintk("%s: 8820 not ready\n", __FUNCTION__); 117 dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready");
116 return -1; 118 return -1;
117 } 119 }
118
119 if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ 120 if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */
120 dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); 121 dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
121 dst_error_recovery(state); 122 dst_error_recovery(state);
122 return -1; 123 return -1;
123 } 124 }
@@ -133,8 +134,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string,
133 134
134 while (dst_ca_comm_err < RETRIES) { 135 while (dst_ca_comm_err < RETRIES) {
135 dst_comm_init(state); 136 dst_comm_init(state);
136 if (verbose > 2) 137 dprintk(verbose, DST_CA_NOTICE, 1, " Put Command");
137 dprintk("%s: Put Command\n", __FUNCTION__);
138 if (dst_ci_command(state, data, ca_string, len, read)) { // If error 138 if (dst_ci_command(state, data, ca_string, len, read)) { // If error
139 dst_error_recovery(state); 139 dst_error_recovery(state);
140 dst_ca_comm_err++; // work required here. 140 dst_ca_comm_err++; // work required here.
@@ -153,18 +153,15 @@ static int ca_get_app_info(struct dst_state *state)
153 153
154 put_checksum(&command[0], command[0]); 154 put_checksum(&command[0], command[0]);
155 if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { 155 if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) {
156 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); 156 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
157 return -1; 157 return -1;
158 } 158 }
159 if (verbose > 1) { 159 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
160 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); 160 dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================");
161 161 dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]",
162 dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__); 162 state->messages[7], (state->messages[8] << 8) | state->messages[9],
163 dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n", 163 (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
164 __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9], 164 dprintk(verbose, DST_CA_INFO, 1, " ==================================================================================================");
165 (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
166 dprintk("%s: ==================================================================================================\n", __FUNCTION__);
167 }
168 165
169 return 0; 166 return 0;
170} 167}
@@ -177,31 +174,26 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps,
177 174
178 put_checksum(&slot_command[0], slot_command[0]); 175 put_checksum(&slot_command[0], slot_command[0]);
179 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { 176 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) {
180 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); 177 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
181 return -1; 178 return -1;
182 } 179 }
183 if (verbose > 1) 180 dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
184 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__);
185 181
186 /* Will implement the rest soon */ 182 /* Will implement the rest soon */
187 183
188 if (verbose > 1) { 184 dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]);
189 dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]); 185 dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
190 dprintk("===================================\n"); 186 for (i = 0; i < 8; i++)
191 for (i = 0; i < 8; i++) 187 dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]);
192 dprintk(" %d", slot_cap[i]); 188 dprintk(verbose, DST_CA_INFO, 0, "\n");
193 dprintk("\n");
194 }
195 189
196 p_ca_caps->slot_num = 1; 190 p_ca_caps->slot_num = 1;
197 p_ca_caps->slot_type = 1; 191 p_ca_caps->slot_type = 1;
198 p_ca_caps->descr_num = slot_cap[7]; 192 p_ca_caps->descr_num = slot_cap[7];
199 p_ca_caps->descr_type = 1; 193 p_ca_caps->descr_type = 1;
200 194
201 195 if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps)))
202 if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) {
203 return -EFAULT; 196 return -EFAULT;
204 }
205 197
206 return 0; 198 return 0;
207} 199}
@@ -222,46 +214,37 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s
222 214
223 put_checksum(&slot_command[0], 7); 215 put_checksum(&slot_command[0], 7);
224 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { 216 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) {
225 dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); 217 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
226 return -1; 218 return -1;
227 } 219 }
228 if (verbose > 1) 220 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
229 dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__);
230 221
231 /* Will implement the rest soon */ 222 /* Will implement the rest soon */
232 223
233 if (verbose > 1) { 224 dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]);
234 dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]); 225 dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
235 dprintk("===================================\n"); 226 for (i = 0; i < 8; i++)
236 for (i = 0; i < 8; i++) 227 dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]);
237 dprintk(" %d", slot_info[i]); 228 dprintk(verbose, DST_CA_INFO, 0, "\n");
238 dprintk("\n");
239 }
240 229
241 if (slot_info[4] & 0x80) { 230 if (slot_info[4] & 0x80) {
242 p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; 231 p_ca_slot_info->flags = CA_CI_MODULE_PRESENT;
243 p_ca_slot_info->num = 1; 232 p_ca_slot_info->num = 1;
244 p_ca_slot_info->type = CA_CI; 233 p_ca_slot_info->type = CA_CI;
245 } 234 } else if (slot_info[4] & 0x40) {
246 else if (slot_info[4] & 0x40) {
247 p_ca_slot_info->flags = CA_CI_MODULE_READY; 235 p_ca_slot_info->flags = CA_CI_MODULE_READY;
248 p_ca_slot_info->num = 1; 236 p_ca_slot_info->num = 1;
249 p_ca_slot_info->type = CA_CI; 237 p_ca_slot_info->type = CA_CI;
250 } 238 } else
251 else {
252 p_ca_slot_info->flags = 0; 239 p_ca_slot_info->flags = 0;
253 }
254 240
255 if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) { 241 if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info)))
256 return -EFAULT; 242 return -EFAULT;
257 }
258 243
259 return 0; 244 return 0;
260} 245}
261 246
262 247
263
264
265static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) 248static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
266{ 249{
267 u8 i = 0; 250 u8 i = 0;
@@ -270,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message,
270 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) 253 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg)))
271 return -EFAULT; 254 return -EFAULT;
272 255
273
274 if (p_ca_message->msg) { 256 if (p_ca_message->msg) {
275 if (verbose > 3) 257 dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]);
276 dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]);
277 258
278 for (i = 0; i < 3; i++) { 259 for (i = 0; i < 3; i++) {
279 command = command | p_ca_message->msg[i]; 260 command = command | p_ca_message->msg[i];
280 if (i < 2) 261 if (i < 2)
281 command = command << 8; 262 command = command << 8;
282 } 263 }
283 if (verbose > 3) 264 dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command);
284 dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command);
285 265
286 switch (command) { 266 switch (command) {
287 case CA_APP_INFO: 267 case CA_APP_INFO:
288 memcpy(p_ca_message->msg, state->messages, 128); 268 memcpy(p_ca_message->msg, state->messages, 128);
289 if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) 269 if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) )
290 return -EFAULT; 270 return -EFAULT;
291 break; 271 break;
292 } 272 }
293 } 273 }
@@ -298,10 +278,13 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message,
298static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) 278static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length)
299{ 279{
300 if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { 280 if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
301 hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ 281 hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
302 hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ 282 hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
303 } 283 } else {
304 else { 284 if (length > 247) {
285 dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !");
286 return -1;
287 }
305 hw_buffer->msg[0] = (length & 0xff) + 7; 288 hw_buffer->msg[0] = (length & 0xff) + 7;
306 hw_buffer->msg[1] = 0x40; 289 hw_buffer->msg[1] = 0x40;
307 hw_buffer->msg[2] = 0x03; 290 hw_buffer->msg[2] = 0x03;
@@ -309,6 +292,11 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message,
309 hw_buffer->msg[4] = 0x03; 292 hw_buffer->msg[4] = 0x03;
310 hw_buffer->msg[5] = length & 0xff; 293 hw_buffer->msg[5] = length & 0xff;
311 hw_buffer->msg[6] = 0x00; 294 hw_buffer->msg[6] = 0x00;
295 /*
296 * Need to compute length for EN50221 section 8.3.2, for the time being
297 * assuming 8.3.2 is not applicable
298 */
299 memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length);
312 } 300 }
313 return 0; 301 return 0;
314} 302}
@@ -317,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message,
317static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) 305static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply)
318{ 306{
319 if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { 307 if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) {
320 dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); 308 dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed.");
321 dprintk("%s: Resetting DST.\n", __FUNCTION__); 309 dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST.");
322 rdc_reset_state(state); 310 rdc_reset_state(state);
323 return -1; 311 return -1;
324 } 312 }
325 if (verbose > 2) 313 dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes.");
326 dprintk("%s: DST-CI Command succes.\n", __FUNCTION__);
327 314
328 return 0; 315 return 0;
329} 316}
@@ -334,130 +321,47 @@ u32 asn_1_decode(u8 *asn_1_array)
334 u32 length = 0; 321 u32 length = 0;
335 322
336 length_field = asn_1_array[0]; 323 length_field = asn_1_array[0];
337 dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); 324 dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field);
338 if (length_field < 0x80) { 325 if (length_field < 0x80) {
339 length = length_field & 0x7f; 326 length = length_field & 0x7f;
340 dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); 327 dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length);
341 } else { 328 } else {
342 word_count = length_field & 0x7f; 329 word_count = length_field & 0x7f;
343 for (count = 0; count < word_count; count++) { 330 for (count = 0; count < word_count; count++) {
344 length = (length | asn_1_array[count + 1]) << 8; 331 length = (length | asn_1_array[count + 1]) << 8;
345 dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); 332 dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length);
346 } 333 }
347 } 334 }
348 return length; 335 return length;
349} 336}
350 337
351static int init_buffer(u8 *buffer, u32 length)
352{
353 u32 i;
354 for (i = 0; i < length; i++)
355 buffer[i] = 0;
356
357 return 0;
358}
359
360static int debug_string(u8 *msg, u32 length, u32 offset) 338static int debug_string(u8 *msg, u32 length, u32 offset)
361{ 339{
362 u32 i; 340 u32 i;
363 341
364 dprintk(" String=[ "); 342 dprintk(verbose, DST_CA_DEBUG, 0, " String=[ ");
365 for (i = offset; i < length; i++) 343 for (i = offset; i < length; i++)
366 dprintk("%02x ", msg[i]); 344 dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]);
367 dprintk("]\n"); 345 dprintk(verbose, DST_CA_DEBUG, 0, "]\n");
368
369 return 0;
370}
371
372static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length)
373{
374 u32 i;
375 dprintk("%s: Copying [", __FUNCTION__);
376 for (i = 0; i < length; i++) {
377 destination[i + dest_offset] = source[i + source_offset];
378 dprintk(" %02x", source[i + source_offset]);
379 }
380 dprintk("]\n");
381
382 return i;
383}
384
385static int modify_4_bits(u8 *message, u32 pos)
386{
387 message[pos] &= 0x0f;
388 346
389 return 0; 347 return 0;
390} 348}
391 349
392
393
394static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) 350static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
395{ 351{
396 u32 length = 0, count = 0; 352 u32 length = 0;
397 u8 asn_1_words, program_header_length; 353 u8 tag_length = 8;
398 u16 program_info_length = 0, es_info_length = 0;
399 u32 hw_offset = 0, buf_offset = 0, i;
400 u8 dst_tag_length;
401 354
402 length = asn_1_decode(&p_ca_message->msg[3]); 355 length = asn_1_decode(&p_ca_message->msg[3]);
403 dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); 356 dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length);
404 dprintk("%s: ASN.1 ", __FUNCTION__); 357 debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */
405 debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length
406 358
407 init_buffer(hw_buffer->msg, length); 359 memset(hw_buffer->msg, '\0', length);
408 handle_dst_tag(state, p_ca_message, hw_buffer, length); 360 handle_dst_tag(state, p_ca_message, hw_buffer, length);
361 put_checksum(hw_buffer->msg, hw_buffer->msg[0]);
409 362
410 hw_offset = 7; 363 debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */
411 asn_1_words = 1; // just a hack to test, should compute this one 364 write_to_8820(state, hw_buffer, (length + tag_length), reply);
412 buf_offset = 3;
413 program_header_length = 6;
414 dst_tag_length = 7;
415
416// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset);
417// dprintk("%s: Program Header(BUF)", __FUNCTION__);
418// debug_string(&p_ca_message->msg[4], program_header_length, 0);
419// dprintk("%s: Copying Program header\n", __FUNCTION__);
420 copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length);
421 buf_offset += program_header_length, hw_offset += program_header_length;
422 modify_4_bits(hw_buffer->msg, (hw_offset - 2));
423 if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround
424 dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__);
425 debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0);
426 hw_buffer->msg[hw_offset - 1] += 1;
427 }
428
429// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count);
430// debug_string(hw_buffer->msg, hw_offset, 0);
431
432 program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
433 dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length);
434 if (program_info_length) {
435 count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current
436 buf_offset += count, hw_offset += count;
437// dprintk("%s: Program level ", __FUNCTION__);
438// debug_string(hw_buffer->msg, hw_offset, 0);
439 }
440
441 buf_offset += 1;// hw_offset += 1;
442 for (i = buf_offset; i < length; i++) {
443// dprintk("%s: Stream Header ", __FUNCTION__);
444 count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5);
445 modify_4_bits(hw_buffer->msg, (hw_offset + 3));
446
447 hw_offset += 5, buf_offset += 5, i += 4;
448// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5));
449 es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
450 dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length);
451 if (es_info_length) {
452 // copy descriptors @ STREAM level
453 dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__);
454 }
455
456 }
457 hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length));
458// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]);
459 debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also
460 write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum
461 365
462 return 0; 366 return 0;
463} 367}
@@ -471,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message
471 /* Do test board */ 375 /* Do test board */
472 /* Not there yet but soon */ 376 /* Not there yet but soon */
473 377
474
475 /* CA PMT Reply capable */ 378 /* CA PMT Reply capable */
476 if (ca_pmt_reply_test) { 379 if (ca_pmt_reply_test) {
477 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { 380 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) {
478 dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); 381 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
479 return -1; 382 return -1;
480 } 383 }
481 384
482 /* Process CA PMT Reply */ 385 /* Process CA PMT Reply */
483 /* will implement soon */ 386 /* will implement soon */
484 dprintk("%s: Not there yet\n", __FUNCTION__); 387 dprintk(verbose, DST_CA_ERROR, 1, " Not there yet");
485 } 388 }
486 /* CA PMT Reply not capable */ 389 /* CA PMT Reply not capable */
487 if (!ca_pmt_reply_test) { 390 if (!ca_pmt_reply_test) {
488 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { 391 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) {
489 dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); 392 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
490 return -1; 393 return -1;
491 } 394 }
492 if (verbose > 3) 395 dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !");
493 dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__);
494 /* put a dummy message */ 396 /* put a dummy message */
495 397
496 } 398 }
@@ -506,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
506 struct ca_msg *hw_buffer; 408 struct ca_msg *hw_buffer;
507 409
508 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 410 if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
509 dprintk("%s: Memory allocation failure\n", __FUNCTION__); 411 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
510 return -ENOMEM; 412 return -ENOMEM;
511 } 413 }
512 if (verbose > 3) 414 dprintk(verbose, DST_CA_DEBUG, 1, " ");
513 dprintk("%s\n", __FUNCTION__);
514 415
515 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) 416 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg)))
516 return -EFAULT; 417 return -EFAULT;
@@ -525,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
525 if (i < 2) 426 if (i < 2)
526 command = command << 8; 427 command = command << 8;
527 } 428 }
528 if (verbose > 3) 429 dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command);
529 dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command);
530 430
531 switch (command) { 431 switch (command) {
532 case CA_PMT: 432 case CA_PMT:
533 if (verbose > 3) 433 dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT");
534// dprintk("Command = SEND_CA_PMT\n"); 434 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started
535 dprintk("Command = SEND_CA_PMT\n"); 435 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !");
536// if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { 436 return -1;
537 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started 437 }
538 dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); 438 dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !");
539 return -1; 439 break;
540 } 440 case CA_PMT_REPLY:
541 if (verbose > 3) 441 dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY");
542 dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); 442 /* Have to handle the 2 basic types of cards here */
543// retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0); 443 if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) {
544 444 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !");
545 break; 445 return -1;
546 446 }
547 case CA_PMT_REPLY: 447 dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !");
548 if (verbose > 3) 448 break;
549 dprintk("Command = CA_PMT_REPLY\n"); 449 case CA_APP_INFO_ENQUIRY: // only for debugging
550 /* Have to handle the 2 basic types of cards here */ 450 dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information");
551 if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { 451
552 dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); 452 if ((ca_get_app_info(state)) < 0) {
553 return -1; 453 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !");
554 } 454 return -1;
555 if (verbose > 3) 455 }
556 dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); 456 dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !");
557 457 break;
558 /* Certain boards do behave different ? */
559// retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1);
560
561 case CA_APP_INFO_ENQUIRY: // only for debugging
562 if (verbose > 3)
563 dprintk("%s: Getting Cam Application information\n", __FUNCTION__);
564
565 if ((ca_get_app_info(state)) < 0) {
566 dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__);
567 return -1;
568 }
569 if (verbose > 3)
570 dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__);
571
572 break;
573 } 458 }
574 } 459 }
575 return 0; 460 return 0;
@@ -584,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
584 struct ca_msg *p_ca_message; 469 struct ca_msg *p_ca_message;
585 470
586 if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { 471 if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
587 dprintk("%s: Memory allocation failure\n", __FUNCTION__); 472 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
588 return -ENOMEM; 473 return -ENOMEM;
589 } 474 }
590
591 if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { 475 if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) {
592 dprintk("%s: Memory allocation failure\n", __FUNCTION__); 476 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
593 return -ENOMEM; 477 return -ENOMEM;
594 } 478 }
595
596 if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { 479 if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) {
597 dprintk("%s: Memory allocation failure\n", __FUNCTION__); 480 dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
598 return -ENOMEM; 481 return -ENOMEM;
599 } 482 }
600
601 /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ 483 /* We have now only the standard ioctl's, the driver is upposed to handle internals. */
602 switch (cmd) { 484 switch (cmd) {
603 case CA_SEND_MSG: 485 case CA_SEND_MSG:
604 if (verbose > 1) 486 dprintk(verbose, DST_CA_INFO, 1, " Sending message");
605 dprintk("%s: Sending message\n", __FUNCTION__); 487 if ((ca_send_message(state, p_ca_message, arg)) < 0) {
606 if ((ca_send_message(state, p_ca_message, arg)) < 0) { 488 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !");
607 dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); 489 return -1;
608 return -1; 490 }
609 } 491 break;
610 492 case CA_GET_MSG:
611 break; 493 dprintk(verbose, DST_CA_INFO, 1, " Getting message");
612 494 if ((ca_get_message(state, p_ca_message, arg)) < 0) {
613 case CA_GET_MSG: 495 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !");
614 if (verbose > 1) 496 return -1;
615 dprintk("%s: Getting message\n", __FUNCTION__); 497 }
616 if ((ca_get_message(state, p_ca_message, arg)) < 0) { 498 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !");
617 dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); 499 break;
618 return -1; 500 case CA_RESET:
619 } 501 dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST");
620 if (verbose > 1) 502 dst_error_bailout(state);
621 dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); 503 msleep(4000);
622 504 break;
623 break; 505 case CA_GET_SLOT_INFO:
624 506 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info");
625 case CA_RESET: 507 if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) {
626 if (verbose > 1) 508 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !");
627 dprintk("%s: Resetting DST\n", __FUNCTION__); 509 return -1;
628 dst_error_bailout(state); 510 }
629 msleep(4000); 511 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !");
630 512 break;
631 break; 513 case CA_GET_CAP:
632 514 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities");
633 case CA_GET_SLOT_INFO: 515 if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) {
634 if (verbose > 1) 516 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !");
635 dprintk("%s: Getting Slot info\n", __FUNCTION__); 517 return -1;
636 if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { 518 }
637 dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); 519 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !");
638 return -1; 520 break;
639 } 521 case CA_GET_DESCR_INFO:
640 if (verbose > 1) 522 dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description");
641 dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); 523 if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) {
642 524 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !");
643 break; 525 return -1;
644 526 }
645 case CA_GET_CAP: 527 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !");
646 if (verbose > 1) 528 break;
647 dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); 529 case CA_SET_DESCR:
648 if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { 530 dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler");
649 dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); 531 if ((ca_set_slot_descr()) < 0) {
650 return -1; 532 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !");
651 } 533 return -1;
652 if (verbose > 1) 534 }
653 dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); 535 dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !");
654 536 break;
655 break; 537 case CA_SET_PID:
656 538 dprintk(verbose, DST_CA_INFO, 1, " Setting PID");
657 case CA_GET_DESCR_INFO: 539 if ((ca_set_pid()) < 0) {
658 if (verbose > 1) 540 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !");
659 dprintk("%s: Getting descrambler description\n", __FUNCTION__); 541 return -1;
660 if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { 542 }
661 dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); 543 dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !");
662 return -1; 544 default:
663 } 545 return -EOPNOTSUPP;
664 if (verbose > 1) 546 };
665 dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__);
666
667 break;
668
669 case CA_SET_DESCR:
670 if (verbose > 1)
671 dprintk("%s: Setting descrambler\n", __FUNCTION__);
672 if ((ca_set_slot_descr()) < 0) {
673 dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__);
674 return -1;
675 }
676 if (verbose > 1)
677 dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__);
678
679 break;
680
681 case CA_SET_PID:
682 if (verbose > 1)
683 dprintk("%s: Setting PID\n", __FUNCTION__);
684 if ((ca_set_pid()) < 0) {
685 dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__);
686 return -1;
687 }
688 if (verbose > 1)
689 dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__);
690
691 default:
692 return -EOPNOTSUPP;
693 };
694 547
695 return 0; 548 return 0;
696} 549}
697 550
698static int dst_ca_open(struct inode *inode, struct file *file) 551static int dst_ca_open(struct inode *inode, struct file *file)
699{ 552{
700 if (verbose > 4) 553 dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file);
701 dprintk("%s:Device opened [%p]\n", __FUNCTION__, file);
702 try_module_get(THIS_MODULE); 554 try_module_get(THIS_MODULE);
703 555
704 return 0; 556 return 0;
@@ -706,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file)
706 558
707static int dst_ca_release(struct inode *inode, struct file *file) 559static int dst_ca_release(struct inode *inode, struct file *file)
708{ 560{
709 if (verbose > 4) 561 dprintk(verbose, DST_CA_DEBUG, 1, " Device closed.");
710 dprintk("%s:Device closed.\n", __FUNCTION__);
711 module_put(THIS_MODULE); 562 module_put(THIS_MODULE);
712 563
713 return 0; 564 return 0;
714} 565}
715 566
716static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) 567static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
717{ 568{
718 int bytes_read = 0; 569 int bytes_read = 0;
719 570
720 if (verbose > 4) 571 dprintk(verbose, DST_CA_DEBUG, 1, " Device read.");
721 dprintk("%s:Device read.\n", __FUNCTION__);
722 572
723 return bytes_read; 573 return bytes_read;
724} 574}
725 575
726static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) 576static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
727{ 577{
728 if (verbose > 4) 578 dprintk(verbose, DST_CA_DEBUG, 1, " Device write.");
729 dprintk("%s:Device write.\n", __FUNCTION__);
730 579
731 return 0; 580 return 0;
732} 581}
@@ -751,8 +600,7 @@ static struct dvb_device dvbdev_ca = {
751int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) 600int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
752{ 601{
753 struct dvb_device *dvbdev; 602 struct dvb_device *dvbdev;
754 if (verbose > 4) 603 dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device");
755 dprintk("%s:registering DST-CA device\n", __FUNCTION__);
756 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); 604 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA);
757 return 0; 605 return 0;
758} 606}
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index ef532a6aceaa..3281a6ca3685 100644
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -61,7 +61,6 @@
61#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ 61#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
62#define DST_TYPE_HAS_SESSION 128 62#define DST_TYPE_HAS_SESSION 128
63 63
64
65#define RDC_8820_PIO_0_DISABLE 0 64#define RDC_8820_PIO_0_DISABLE 0
66#define RDC_8820_PIO_0_ENABLE 1 65#define RDC_8820_PIO_0_ENABLE 1
67#define RDC_8820_INT 2 66#define RDC_8820_INT 2
@@ -114,6 +113,10 @@ struct dst_state {
114 fe_sec_mini_cmd_t minicmd; 113 fe_sec_mini_cmd_t minicmd;
115 fe_modulation_t modulation; 114 fe_modulation_t modulation;
116 u8 messages[256]; 115 u8 messages[256];
116 u8 mac_address[8];
117 u8 fw_version[8];
118 u8 card_info[8];
119 u8 vendor[8];
117}; 120};
118 121
119struct dst_types { 122struct dst_types {
@@ -124,15 +127,12 @@ struct dst_types {
124 u32 dst_feature; 127 u32 dst_feature;
125}; 128};
126 129
127
128
129struct dst_config 130struct dst_config
130{ 131{
131 /* the ASIC i2c address */ 132 /* the ASIC i2c address */
132 u8 demod_address; 133 u8 demod_address;
133}; 134};
134 135
135
136int rdc_reset_state(struct dst_state *state); 136int rdc_reset_state(struct dst_state *state);
137int rdc_8820_reset(struct dst_state *state); 137int rdc_8820_reset(struct dst_state *state);
138 138
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index 6f857c6091f3..c5c7672cd538 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -32,9 +32,7 @@
32#include "dvbdev.h" 32#include "dvbdev.h"
33#include "dvb_demux.h" 33#include "dvb_demux.h"
34#include "dvb_frontend.h" 34#include "dvb_frontend.h"
35
36#include "dvb-bt8xx.h" 35#include "dvb-bt8xx.h"
37
38#include "bt878.h" 36#include "bt878.h"
39 37
40static int debug; 38static int debug;
@@ -43,9 +41,11 @@ module_param(debug, int, 0644);
43MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); 41MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
44 42
45#define dprintk( args... ) \ 43#define dprintk( args... ) \
46 do { \ 44 do \
47 if (debug) printk(KERN_DEBUG args); \ 45 if (debug) printk(KERN_DEBUG args); \
48 } while (0) 46 while (0)
47
48#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
49 49
50static void dvb_bt8xx_task(unsigned long data) 50static void dvb_bt8xx_task(unsigned long data)
51{ 51{
@@ -119,14 +119,12 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci
119 unsigned int card_nr; 119 unsigned int card_nr;
120 120
121 /* Hmm, n squared. Hope n is small */ 121 /* Hmm, n squared. Hope n is small */
122 for (card_nr = 0; card_nr < bt878_num; card_nr++) { 122 for (card_nr = 0; card_nr < bt878_num; card_nr++)
123 if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) 123 if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev))
124 return &bt878[card_nr]; 124 return &bt878[card_nr];
125 }
126 return NULL; 125 return NULL;
127} 126}
128 127
129
130static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) 128static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
131{ 129{
132 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; 130 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
@@ -154,16 +152,21 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
154 unsigned char bs = 0; 152 unsigned char bs = 0;
155 unsigned char cp = 0; 153 unsigned char cp = 0;
156 154
157 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
158 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 155 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
159 156
160 if (params->frequency < 542000000) cp = 0xb4; 157 if (params->frequency < 542000000)
161 else if (params->frequency < 771000000) cp = 0xbc; 158 cp = 0xb4;
162 else cp = 0xf4; 159 else if (params->frequency < 771000000)
160 cp = 0xbc;
161 else
162 cp = 0xf4;
163 163
164 if (params->frequency == 0) bs = 0x03; 164 if (params->frequency == 0)
165 else if (params->frequency < 443250000) bs = 0x02; 165 bs = 0x03;
166 else bs = 0x08; 166 else if (params->frequency < 443250000)
167 bs = 0x02;
168 else
169 bs = 0x08;
167 170
168 pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address 171 pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
169 pllbuf[1] = div >> 8; 172 pllbuf[1] = div >> 8;
@@ -175,7 +178,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
175} 178}
176 179
177static struct mt352_config thomson_dtt7579_config = { 180static struct mt352_config thomson_dtt7579_config = {
178
179 .demod_address = 0x0f, 181 .demod_address = 0x0f,
180 .demod_init = thomson_dtt7579_demod_init, 182 .demod_init = thomson_dtt7579_demod_init,
181 .pll_set = thomson_dtt7579_pll_set, 183 .pll_set = thomson_dtt7579_pll_set,
@@ -183,25 +185,26 @@ static struct mt352_config thomson_dtt7579_config = {
183 185
184static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 186static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
185{ 187{
186 u32 freq = params->frequency; 188 u32 freq = params->frequency;
187
188 int i, a, n, pump;
189 u32 band, pll;
190 189
190 int i, a, n, pump;
191 u32 band, pll;
191 192
192 u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, 193 u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
193 1576000,1718000,1856000,2036000,2150000}; 194 1576000,1718000,1856000,2036000,2150000};
194 u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, 195 u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
195 0x00102000,0x00104000,0x00108000,0x00110000, 196 0x00102000,0x00104000,0x00108000,0x00110000,
196 0x00120000,0x00140000}; 197 0x00120000,0x00140000};
197 198
198#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ 199 #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
199 printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); 200 printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
200 201
201 /* This is really the bit driving the tuner chip cx24108 */ 202 /* This is really the bit driving the tuner chip cx24108 */
202 203
203 if(freq<950000) freq=950000; /* kHz */ 204 if (freq<950000)
204 if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ 205 freq = 950000; /* kHz */
206 else if (freq>2150000)
207 freq = 2150000; /* satellite IF is 950..2150MHz */
205 208
206 /* decide which VCO to use for the input frequency */ 209 /* decide which VCO to use for the input frequency */
207 for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++); 210 for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
@@ -228,25 +231,22 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete
228 cx24110_pll_write(fe,0x500c0000); 231 cx24110_pll_write(fe,0x500c0000);
229 cx24110_pll_write(fe,0x83f1f800); 232 cx24110_pll_write(fe,0x83f1f800);
230 cx24110_pll_write(fe,pll); 233 cx24110_pll_write(fe,pll);
231/* writereg(client,0x56,0x7f);*/ 234 //writereg(client,0x56,0x7f);
232 235
233 return 0; 236 return 0;
234} 237}
235 238
236static int pinnsat_pll_init(struct dvb_frontend* fe) 239static int pinnsat_pll_init(struct dvb_frontend* fe)
237{ 240{
238 return 0; 241 return 0;
239} 242}
240 243
241
242static struct cx24110_config pctvsat_config = { 244static struct cx24110_config pctvsat_config = {
243
244 .demod_address = 0x55, 245 .demod_address = 0x55,
245 .pll_init = pinnsat_pll_init, 246 .pll_init = pinnsat_pll_init,
246 .pll_set = cx24108_pll_set, 247 .pll_set = cx24108_pll_set,
247}; 248};
248 249
249
250static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 250static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
251{ 251{
252 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; 252 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
@@ -258,15 +258,23 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front
258 div = (36000000 + params->frequency + 83333) / 166666; 258 div = (36000000 + params->frequency + 83333) / 166666;
259 cfg = 0x88; 259 cfg = 0x88;
260 260
261 if (params->frequency < 175000000) cpump = 2; 261 if (params->frequency < 175000000)
262 else if (params->frequency < 390000000) cpump = 1; 262 cpump = 2;
263 else if (params->frequency < 470000000) cpump = 2; 263 else if (params->frequency < 390000000)
264 else if (params->frequency < 750000000) cpump = 2; 264 cpump = 1;
265 else cpump = 3; 265 else if (params->frequency < 470000000)
266 cpump = 2;
267 else if (params->frequency < 750000000)
268 cpump = 2;
269 else
270 cpump = 3;
266 271
267 if (params->frequency < 175000000) band_select = 0x0e; 272 if (params->frequency < 175000000)
268 else if (params->frequency < 470000000) band_select = 0x05; 273 band_select = 0x0e;
269 else band_select = 0x03; 274 else if (params->frequency < 470000000)
275 band_select = 0x05;
276 else
277 band_select = 0x03;
270 278
271 data[0] = (div >> 8) & 0x7f; 279 data[0] = (div >> 8) & 0x7f;
272 data[1] = div & 0xff; 280 data[1] = div & 0xff;
@@ -285,14 +293,11 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s
285} 293}
286 294
287static struct sp887x_config microtune_mt7202dtf_config = { 295static struct sp887x_config microtune_mt7202dtf_config = {
288
289 .demod_address = 0x70, 296 .demod_address = 0x70,
290 .pll_set = microtune_mt7202dtf_pll_set, 297 .pll_set = microtune_mt7202dtf_pll_set,
291 .request_firmware = microtune_mt7202dtf_request_firmware, 298 .request_firmware = microtune_mt7202dtf_request_firmware,
292}; 299};
293 300
294
295
296static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) 301static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
297{ 302{
298 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; 303 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
@@ -303,7 +308,6 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
303 static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; 308 static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
304 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; 309 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
305 310
306
307 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); 311 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
308 udelay(2000); 312 udelay(2000);
309 mt352_write(fe, mt352_reset, sizeof(mt352_reset)); 313 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
@@ -323,28 +327,45 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct
323 unsigned char bs = 0; 327 unsigned char bs = 0;
324 unsigned char cp = 0; 328 unsigned char cp = 0;
325 329
326 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
327 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 330 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
328 331
329 if (params->frequency < 150000000) cp = 0xB4; 332 if (params->frequency < 150000000)
330 else if (params->frequency < 173000000) cp = 0xBC; 333 cp = 0xB4;
331 else if (params->frequency < 250000000) cp = 0xB4; 334 else if (params->frequency < 173000000)
332 else if (params->frequency < 400000000) cp = 0xBC; 335 cp = 0xBC;
333 else if (params->frequency < 420000000) cp = 0xF4; 336 else if (params->frequency < 250000000)
334 else if (params->frequency < 470000000) cp = 0xFC; 337 cp = 0xB4;
335 else if (params->frequency < 600000000) cp = 0xBC; 338 else if (params->frequency < 400000000)
336 else if (params->frequency < 730000000) cp = 0xF4; 339 cp = 0xBC;
337 else cp = 0xFC; 340 else if (params->frequency < 420000000)
338 341 cp = 0xF4;
339 if (params->frequency < 150000000) bs = 0x01; 342 else if (params->frequency < 470000000)
340 else if (params->frequency < 173000000) bs = 0x01; 343 cp = 0xFC;
341 else if (params->frequency < 250000000) bs = 0x02; 344 else if (params->frequency < 600000000)
342 else if (params->frequency < 400000000) bs = 0x02; 345 cp = 0xBC;
343 else if (params->frequency < 420000000) bs = 0x02; 346 else if (params->frequency < 730000000)
344 else if (params->frequency < 470000000) bs = 0x02; 347 cp = 0xF4;
345 else if (params->frequency < 600000000) bs = 0x08; 348 else
346 else if (params->frequency < 730000000) bs = 0x08; 349 cp = 0xFC;
347 else bs = 0x08; 350
351 if (params->frequency < 150000000)
352 bs = 0x01;
353 else if (params->frequency < 173000000)
354 bs = 0x01;
355 else if (params->frequency < 250000000)
356 bs = 0x02;
357 else if (params->frequency < 400000000)
358 bs = 0x02;
359 else if (params->frequency < 420000000)
360 bs = 0x02;
361 else if (params->frequency < 470000000)
362 bs = 0x02;
363 else if (params->frequency < 600000000)
364 bs = 0x08;
365 else if (params->frequency < 730000000)
366 bs = 0x08;
367 else
368 bs = 0x08;
348 369
349 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address 370 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
350 pllbuf[1] = div >> 8; 371 pllbuf[1] = div >> 8;
@@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct
356} 377}
357 378
358static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { 379static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
359
360 .demod_address = 0x0f, 380 .demod_address = 0x0f,
361 .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, 381 .demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
362 .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, 382 .pll_set = advbt771_samsung_tdtc9251dh0_pll_set,
363}; 383};
364 384
365
366static struct dst_config dst_config = { 385static struct dst_config dst_config = {
367
368 .demod_address = 0x55, 386 .demod_address = 0x55,
369}; 387};
370 388
371
372static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) 389static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
373{ 390{
374 struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; 391 struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
@@ -398,10 +415,8 @@ static void or51211_reset(struct dvb_frontend * fe)
398 */ 415 */
399 /* reset & PRM1,2&4 are outputs */ 416 /* reset & PRM1,2&4 are outputs */
400 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); 417 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
401 if (ret != 0) { 418 if (ret != 0)
402 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " 419 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret);
403 "(%i)\n", ret);
404 }
405 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ 420 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */
406 msleep(20); 421 msleep(20);
407 /* Now set for normal operation */ 422 /* Now set for normal operation */
@@ -417,7 +432,6 @@ static void or51211_sleep(struct dvb_frontend * fe)
417} 432}
418 433
419static struct or51211_config or51211_config = { 434static struct or51211_config or51211_config = {
420
421 .demod_address = 0x15, 435 .demod_address = 0x15,
422 .request_firmware = or51211_request_firmware, 436 .request_firmware = or51211_request_firmware,
423 .setmode = or51211_setmode, 437 .setmode = or51211_setmode,
@@ -425,7 +439,6 @@ static struct or51211_config or51211_config = {
425 .sleep = or51211_sleep, 439 .sleep = or51211_sleep,
426}; 440};
427 441
428
429static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 442static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
430{ 443{
431 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; 444 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
@@ -454,12 +467,84 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten
454} 467}
455 468
456static struct nxt6000_config vp3021_alps_tded4_config = { 469static struct nxt6000_config vp3021_alps_tded4_config = {
457
458 .demod_address = 0x0a, 470 .demod_address = 0x0a,
459 .clock_inversion = 1, 471 .clock_inversion = 1,
460 .pll_set = vp3021_alps_tded4_pll_set, 472 .pll_set = vp3021_alps_tded4_pll_set,
461}; 473};
462 474
475static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
476{
477 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
478 static u8 mt352_reset [] = { 0x50, 0x80 };
479 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
480 static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 };
481 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
482
483 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
484 udelay(2000);
485 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
486 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
487 mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
488 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
489
490 return 0;
491}
492
493static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
494{
495 u32 div;
496 struct dvb_ofdm_parameters *op = &params->u.ofdm;
497
498 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
499
500 pllbuf[0] = 0xc2;
501 pllbuf[1] = (div >> 8) & 0x7F;
502 pllbuf[2] = div & 0xFF;
503 pllbuf[3] = 0x85;
504
505 dprintk("frequency %u, div %u\n", params->frequency, div);
506
507 if (params->frequency < 470000000)
508 pllbuf[4] = 0x02;
509 else if (params->frequency > 823000000)
510 pllbuf[4] = 0x88;
511 else
512 pllbuf[4] = 0x08;
513
514 if (op->bandwidth == 8)
515 pllbuf[4] |= 0x04;
516
517 return 0;
518}
519
520static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
521{
522 /*
523 * Reset the frontend, must be called before trying
524 * to initialise the MT352 or mt352_attach
525 * will fail.
526 *
527 * Presumably not required for the NXT6000 frontend.
528 *
529 */
530
531 int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08);
532 if (ret != 0)
533 printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret);
534
535 /* Pulse the reset line */
536 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
537 bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */
538 msleep(100);
539
540 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
541}
542
543static struct mt352_config digitv_alps_tded4_config = {
544 .demod_address = 0x0a,
545 .demod_init = digitv_alps_tded4_demod_init,
546 .pll_set = digitv_alps_tded4_pll_set,
547};
463 548
464static void frontend_init(struct dvb_bt8xx_card *card, u32 type) 549static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
465{ 550{
@@ -473,7 +558,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
473 if (card->fe != NULL) { 558 if (card->fe != NULL) {
474 card->fe->ops->info.frequency_min = 174000000; 559 card->fe->ops->info.frequency_min = 174000000;
475 card->fe->ops->info.frequency_max = 862000000; 560 card->fe->ops->info.frequency_max = 862000000;
476 break;
477 } 561 }
478 break; 562 break;
479#endif 563#endif
@@ -483,17 +567,28 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
483#else 567#else
484 case BTTV_NEBULA_DIGITV: 568 case BTTV_NEBULA_DIGITV:
485#endif 569#endif
570 /*
571 * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK);
572 * this would be a cleaner solution than trying each frontend in turn.
573 */
574
575 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
486 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); 576 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
487 if (card->fe != NULL) { 577 if (card->fe != NULL) {
578 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
488 break; 579 break;
489 } 580 }
581
582 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
583 digitv_alps_tded4_reset(card);
584 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
585
586 if (card->fe != NULL)
587 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
490 break; 588 break;
491 589
492 case BTTV_AVDVBT_761: 590 case BTTV_AVDVBT_761:
493 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter); 591 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
494 if (card->fe != NULL) {
495 break;
496 }
497 break; 592 break;
498 593
499 case BTTV_AVDVBT_771: 594 case BTTV_AVDVBT_771:
@@ -501,7 +596,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
501 if (card->fe != NULL) { 596 if (card->fe != NULL) {
502 card->fe->ops->info.frequency_min = 174000000; 597 card->fe->ops->info.frequency_min = 174000000;
503 card->fe->ops->info.frequency_max = 862000000; 598 card->fe->ops->info.frequency_max = 862000000;
504 break;
505 } 599 }
506 break; 600 break;
507 601
@@ -522,54 +616,41 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
522 616
523 /* Attach other DST peripherals if any */ 617 /* Attach other DST peripherals if any */
524 /* Conditional Access device */ 618 /* Conditional Access device */
525 if (state->dst_hw_cap & DST_TYPE_HAS_CA) { 619 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
526 ret = dst_ca_attach(state, &card->dvb_adapter); 620 ret = dst_ca_attach(state, &card->dvb_adapter);
527 }
528 if (card->fe != NULL) {
529 break;
530 }
531 break; 621 break;
532 622
533 case BTTV_PINNACLESAT: 623 case BTTV_PINNACLESAT:
534 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); 624 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
535 if (card->fe != NULL) {
536 break;
537 }
538 break; 625 break;
539 626
540 case BTTV_PC_HDTV: 627 case BTTV_PC_HDTV:
541 card->fe = or51211_attach(&or51211_config, card->i2c_adapter); 628 card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
542 if (card->fe != NULL) {
543 break;
544 }
545 break; 629 break;
546 } 630 }
547 631
548 if (card->fe == NULL) { 632 if (card->fe == NULL)
549 printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", 633 printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
550 card->bt->dev->vendor, 634 card->bt->dev->vendor,
551 card->bt->dev->device, 635 card->bt->dev->device,
552 card->bt->dev->subsystem_vendor, 636 card->bt->dev->subsystem_vendor,
553 card->bt->dev->subsystem_device); 637 card->bt->dev->subsystem_device);
554 } else { 638 else
555 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { 639 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
556 printk("dvb-bt8xx: Frontend registration failed!\n"); 640 printk("dvb-bt8xx: Frontend registration failed!\n");
557 if (card->fe->ops->release) 641 if (card->fe->ops->release)
558 card->fe->ops->release(card->fe); 642 card->fe->ops->release(card->fe);
559 card->fe = NULL; 643 card->fe = NULL;
560 } 644 }
561 }
562} 645}
563 646
564static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) 647static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
565{ 648{
566 int result; 649 int result;
567 650
568 if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, 651 if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) {
569 THIS_MODULE)) < 0) {
570 printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); 652 printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
571 return result; 653 return result;
572
573 } 654 }
574 card->dvb_adapter.priv = card; 655 card->dvb_adapter.priv = card;
575 656
@@ -664,8 +745,7 @@ static int dvb_bt8xx_probe(struct device *dev)
664 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); 745 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
665 card->i2c_adapter = &sub->core->i2c_adap; 746 card->i2c_adapter = &sub->core->i2c_adap;
666 747
667 switch(sub->core->type) 748 switch(sub->core->type) {
668 {
669 case BTTV_PINNACLESAT: 749 case BTTV_PINNACLESAT:
670 card->gpio_mode = 0x0400c060; 750 card->gpio_mode = 0x0400c060;
671 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, 751 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
@@ -751,7 +831,6 @@ static int dvb_bt8xx_probe(struct device *dev)
751 831
752 kfree(card); 832 kfree(card);
753 return -EFAULT; 833 return -EFAULT;
754
755 } 834 }
756 835
757 init_MUTEX(&card->bt->gpio_lock); 836 init_MUTEX(&card->bt->gpio_lock);
@@ -779,7 +858,8 @@ static int dvb_bt8xx_remove(struct device *dev)
779 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); 858 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
780 dvb_dmxdev_release(&card->dmxdev); 859 dvb_dmxdev_release(&card->dmxdev);
781 dvb_dmx_release(&card->demux); 860 dvb_dmx_release(&card->demux);
782 if (card->fe) dvb_unregister_frontend(card->fe); 861 if (card->fe)
862 dvb_unregister_frontend(card->fe);
783 dvb_unregister_adapter(&card->dvb_adapter); 863 dvb_unregister_adapter(&card->dvb_adapter);
784 864
785 kfree(card); 865 kfree(card);
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
index 2923b3b0dd3c..9ec8e5bd6c1f 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
@@ -2,7 +2,7 @@
2 * Bt8xx based DVB adapter driver 2 * Bt8xx based DVB adapter driver
3 * 3 *
4 * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org> 4 * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org>
5 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> 5 * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
6 * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH 6 * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH
7 * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de> 7 * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
8 * 8 *