diff options
author | Manu Abraham <manu@linuxtv.org> | 2005-09-09 16:03:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 16:57:43 -0400 |
commit | a427de6f72bc0d83ebb1d87f9003c5e1009f21cd (patch) | |
tree | d036ad01c3a278f9adf99e086ea66612817d4fa0 /drivers/media | |
parent | 94b7410c8a2d23fad5937b326a0a9e8c5a876e2d (diff) |
[PATCH] dvb: dst: dprrintk cleanup
Code Cleanup:
o Remove debug noise
o Remove debug module parameter
debug level is achieved using the verbosity level
o Updated to kernel coding style
(case labels should not be indented)
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/bt8xx/dst.c | 649 | ||||
-rw-r--r-- | drivers/media/dvb/bt8xx/dst_ca.c | 443 | ||||
-rw-r--r-- | drivers/media/dvb/bt8xx/dst_common.h | 4 |
3 files changed, 461 insertions, 635 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 66e69b8e1a0c..39835edba1d9 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | |||
3 | Frontend/Card driver for TwinHan DST Frontend | 2 | Frontend/Card driver for TwinHan DST Frontend |
4 | Copyright (C) 2003 Jamie Honan | 3 | Copyright (C) 2003 Jamie Honan |
5 | Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) | 4 | Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) |
@@ -19,7 +18,6 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 19 | */ |
21 | 20 | ||
22 | |||
23 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
24 | #include <linux/module.h> | 22 | #include <linux/module.h> |
25 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -28,31 +26,45 @@ | |||
28 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
29 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
30 | #include <asm/div64.h> | 28 | #include <asm/div64.h> |
31 | |||
32 | #include "dvb_frontend.h" | 29 | #include "dvb_frontend.h" |
33 | #include "dst_priv.h" | 30 | #include "dst_priv.h" |
34 | #include "dst_common.h" | 31 | #include "dst_common.h" |
35 | 32 | ||
36 | |||
37 | static unsigned int verbose = 1; | 33 | static unsigned int verbose = 1; |
38 | module_param(verbose, int, 0644); | 34 | module_param(verbose, int, 0644); |
39 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | 35 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); |
40 | 36 | ||
41 | static unsigned int debug = 1; | ||
42 | module_param(debug, int, 0644); | ||
43 | MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)"); | ||
44 | |||
45 | static unsigned int dst_addons; | 37 | static unsigned int dst_addons; |
46 | module_param(dst_addons, int, 0644); | 38 | module_param(dst_addons, int, 0644); |
47 | MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); | 39 | MODULE_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 | |
55 | static 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 | |||
67 | static 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 | ||
63 | int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) | 75 | int 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 | } |
95 | EXPORT_SYMBOL(dst_gpio_outb); | 104 | EXPORT_SYMBOL(dst_gpio_outb); |
96 | 105 | ||
97 | int dst_gpio_inb(struct dst_state *state, u8 * result) | 106 | int 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 | } |
112 | EXPORT_SYMBOL(dst_gpio_inb); | 120 | EXPORT_SYMBOL(dst_gpio_inb); |
113 | 121 | ||
114 | int rdc_reset_state(struct dst_state *state) | 122 | int 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 | ||
136 | int rdc_8820_reset(struct dst_state *state) | 140 | int 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); | |||
155 | int dst_pio_enable(struct dst_state *state) | 157 | int 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 | } |
164 | EXPORT_SYMBOL(dst_pio_enable); | 167 | EXPORT_SYMBOL(dst_pio_enable); |
@@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable); | |||
166 | int dst_pio_disable(struct dst_state *state) | 169 | int 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 | ||
204 | int dst_error_recovery(struct dst_state *state) | 204 | int 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 | ||
216 | int dst_error_bailout(struct dst_state *state) | 216 | int 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 | } |
225 | EXPORT_SYMBOL(dst_error_bailout); | 225 | EXPORT_SYMBOL(dst_error_bailout); |
226 | 226 | ||
227 | 227 | int dst_comm_init(struct dst_state *state) | |
228 | int 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 | } |
247 | EXPORT_SYMBOL(dst_comm_init); | 245 | EXPORT_SYMBOL(dst_comm_init); |
248 | 246 | ||
249 | |||
250 | int write_dst(struct dst_state *state, u8 *data, u8 len) | 247 | int 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 | } |
286 | EXPORT_SYMBOL(write_dst); | 281 | EXPORT_SYMBOL(write_dst); |
287 | 282 | ||
288 | int read_dst(struct dst_state *state, u8 * ret, u8 len) | 283 | int 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); | |||
323 | static int dst_set_polarization(struct dst_state *state) | 319 | static int dst_set_polarization(struct dst_state *state) |
324 | { | 320 | { |
325 | switch (state->voltage) { | 321 | switch (state->voltage) { |
326 | case SEC_VOLTAGE_13: // vertical | 322 | case SEC_VOLTAGE_13: /* Vertical */ |
327 | dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__); | 323 | dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); |
328 | state->tx_tuna[8] &= ~0x40; //1 | 324 | state->tx_tuna[8] &= ~0x40; |
329 | break; | 325 | break; |
330 | 326 | case SEC_VOLTAGE_18: /* Horizontal */ | |
331 | case SEC_VOLTAGE_18: // horizontal | 327 | dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); |
332 | dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__); | 328 | state->tx_tuna[8] |= 0x40; |
333 | state->tx_tuna[8] |= 0x40; // 0 | 329 | break; |
334 | break; | 330 | case SEC_VOLTAGE_OFF: |
335 | 331 | break; | |
336 | case SEC_VOLTAGE_OFF: | ||
337 | |||
338 | break; | ||
339 | } | 332 | } |
340 | 333 | ||
341 | return 0; | 334 | return 0; |
@@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state) | |||
344 | static int dst_set_freq(struct dst_state *state, u32 freq) | 337 | static int dst_set_freq(struct dst_state *state, u32 freq) |
345 | { | 338 | { |
346 | state->frequency = freq; | 339 | state->frequency = freq; |
347 | if (verbose > 4) | 340 | dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); |
348 | dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); | ||
349 | 341 | ||
350 | if (state->dst_type == DST_TYPE_IS_SAT) { | 342 | if (state->dst_type == DST_TYPE_IS_SAT) { |
351 | freq = freq / 1000; | 343 | freq = freq / 1000; |
352 | if (freq < 950 || freq > 2150) | 344 | if (freq < 950 || freq > 2150) |
353 | return -EINVAL; | 345 | return -EINVAL; |
354 | |||
355 | state->tx_tuna[2] = (freq >> 8); | 346 | state->tx_tuna[2] = (freq >> 8); |
356 | state->tx_tuna[3] = (u8) freq; | 347 | state->tx_tuna[3] = (u8) freq; |
357 | state->tx_tuna[4] = 0x01; | 348 | state->tx_tuna[4] = 0x01; |
@@ -360,27 +351,24 @@ static int dst_set_freq(struct dst_state *state, u32 freq) | |||
360 | if (freq < 1531) | 351 | if (freq < 1531) |
361 | state->tx_tuna[8] |= 0x04; | 352 | state->tx_tuna[8] |= 0x04; |
362 | } | 353 | } |
363 | |||
364 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 354 | } else if (state->dst_type == DST_TYPE_IS_TERR) { |
365 | freq = freq / 1000; | 355 | freq = freq / 1000; |
366 | if (freq < 137000 || freq > 858000) | 356 | if (freq < 137000 || freq > 858000) |
367 | return -EINVAL; | 357 | return -EINVAL; |
368 | |||
369 | state->tx_tuna[2] = (freq >> 16) & 0xff; | 358 | state->tx_tuna[2] = (freq >> 16) & 0xff; |
370 | state->tx_tuna[3] = (freq >> 8) & 0xff; | 359 | state->tx_tuna[3] = (freq >> 8) & 0xff; |
371 | state->tx_tuna[4] = (u8) freq; | 360 | state->tx_tuna[4] = (u8) freq; |
372 | |||
373 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 361 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { |
374 | state->tx_tuna[2] = (freq >> 16) & 0xff; | 362 | state->tx_tuna[2] = (freq >> 16) & 0xff; |
375 | state->tx_tuna[3] = (freq >> 8) & 0xff; | 363 | state->tx_tuna[3] = (freq >> 8) & 0xff; |
376 | state->tx_tuna[4] = (u8) freq; | 364 | state->tx_tuna[4] = (u8) freq; |
377 | |||
378 | } else | 365 | } else |
379 | return -EINVAL; | 366 | return -EINVAL; |
367 | |||
380 | return 0; | 368 | return 0; |
381 | } | 369 | } |
382 | 370 | ||
383 | static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) | 371 | static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth) |
384 | { | 372 | { |
385 | state->bandwidth = bandwidth; | 373 | state->bandwidth = bandwidth; |
386 | 374 | ||
@@ -388,90 +376,82 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) | |||
388 | return 0; | 376 | return 0; |
389 | 377 | ||
390 | switch (bandwidth) { | 378 | switch (bandwidth) { |
391 | case BANDWIDTH_6_MHZ: | 379 | case BANDWIDTH_6_MHZ: |
392 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 380 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) |
393 | state->tx_tuna[7] = 0x06; | 381 | state->tx_tuna[7] = 0x06; |
394 | else { | 382 | else { |
395 | state->tx_tuna[6] = 0x06; | 383 | state->tx_tuna[6] = 0x06; |
396 | state->tx_tuna[7] = 0x00; | 384 | state->tx_tuna[7] = 0x00; |
397 | } | 385 | } |
398 | break; | 386 | break; |
399 | 387 | case BANDWIDTH_7_MHZ: | |
400 | case BANDWIDTH_7_MHZ: | 388 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) |
401 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 389 | state->tx_tuna[7] = 0x07; |
402 | state->tx_tuna[7] = 0x07; | 390 | else { |
403 | else { | 391 | state->tx_tuna[6] = 0x07; |
404 | state->tx_tuna[6] = 0x07; | 392 | state->tx_tuna[7] = 0x00; |
405 | state->tx_tuna[7] = 0x00; | 393 | } |
406 | } | 394 | break; |
407 | break; | 395 | case BANDWIDTH_8_MHZ: |
408 | 396 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | |
409 | case BANDWIDTH_8_MHZ: | 397 | state->tx_tuna[7] = 0x08; |
410 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 398 | else { |
411 | state->tx_tuna[7] = 0x08; | 399 | state->tx_tuna[6] = 0x08; |
412 | else { | 400 | state->tx_tuna[7] = 0x00; |
413 | state->tx_tuna[6] = 0x08; | 401 | } |
414 | state->tx_tuna[7] = 0x00; | 402 | break; |
415 | } | 403 | default: |
416 | break; | 404 | return -EINVAL; |
417 | |||
418 | default: | ||
419 | return -EINVAL; | ||
420 | } | 405 | } |
406 | |||
421 | return 0; | 407 | return 0; |
422 | } | 408 | } |
423 | 409 | ||
424 | static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) | 410 | static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion) |
425 | { | 411 | { |
426 | state->inversion = inversion; | 412 | state->inversion = inversion; |
427 | switch (inversion) { | 413 | switch (inversion) { |
428 | case INVERSION_OFF: // Inversion = Normal | 414 | case INVERSION_OFF: /* Inversion = Normal */ |
429 | state->tx_tuna[8] &= ~0x80; | 415 | state->tx_tuna[8] &= ~0x80; |
430 | break; | 416 | break; |
431 | 417 | case INVERSION_ON: | |
432 | case INVERSION_ON: | 418 | state->tx_tuna[8] |= 0x80; |
433 | state->tx_tuna[8] |= 0x80; | 419 | break; |
434 | break; | 420 | default: |
435 | default: | 421 | return -EINVAL; |
436 | return -EINVAL; | ||
437 | } | 422 | } |
423 | |||
438 | return 0; | 424 | return 0; |
439 | } | 425 | } |
440 | 426 | ||
441 | static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) | 427 | static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec) |
442 | { | 428 | { |
443 | state->fec = fec; | 429 | state->fec = fec; |
444 | return 0; | 430 | return 0; |
445 | } | 431 | } |
446 | 432 | ||
447 | static fe_code_rate_t dst_get_fec(struct dst_state* state) | 433 | static fe_code_rate_t dst_get_fec(struct dst_state *state) |
448 | { | 434 | { |
449 | return state->fec; | 435 | return state->fec; |
450 | } | 436 | } |
451 | 437 | ||
452 | static int dst_set_symbolrate(struct dst_state* state, u32 srate) | 438 | static int dst_set_symbolrate(struct dst_state *state, u32 srate) |
453 | { | 439 | { |
454 | u32 symcalc; | 440 | u32 symcalc; |
455 | u64 sval; | 441 | u64 sval; |
456 | 442 | ||
457 | state->symbol_rate = srate; | 443 | state->symbol_rate = srate; |
458 | |||
459 | if (state->dst_type == DST_TYPE_IS_TERR) { | 444 | if (state->dst_type == DST_TYPE_IS_TERR) { |
460 | return 0; | 445 | return 0; |
461 | } | 446 | } |
462 | if (debug > 4) | 447 | dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); |
463 | dprintk("%s: set symrate %u\n", __FUNCTION__, srate); | ||
464 | srate /= 1000; | 448 | srate /= 1000; |
465 | |||
466 | if (state->type_flags & DST_TYPE_HAS_SYMDIV) { | 449 | if (state->type_flags & DST_TYPE_HAS_SYMDIV) { |
467 | sval = srate; | 450 | sval = srate; |
468 | sval <<= 20; | 451 | sval <<= 20; |
469 | do_div(sval, 88000); | 452 | do_div(sval, 88000); |
470 | symcalc = (u32) sval; | 453 | symcalc = (u32) sval; |
471 | 454 | dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); | |
472 | if (debug > 4) | ||
473 | dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); | ||
474 | |||
475 | state->tx_tuna[5] = (u8) (symcalc >> 12); | 455 | state->tx_tuna[5] = (u8) (symcalc >> 12); |
476 | state->tx_tuna[6] = (u8) (symcalc >> 4); | 456 | state->tx_tuna[6] = (u8) (symcalc >> 4); |
477 | state->tx_tuna[7] = (u8) (symcalc << 4); | 457 | state->tx_tuna[7] = (u8) (symcalc << 4); |
@@ -496,32 +476,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio | |||
496 | 476 | ||
497 | state->modulation = modulation; | 477 | state->modulation = modulation; |
498 | switch (modulation) { | 478 | switch (modulation) { |
499 | case QAM_16: | 479 | case QAM_16: |
500 | state->tx_tuna[8] = 0x10; | 480 | state->tx_tuna[8] = 0x10; |
501 | break; | 481 | break; |
502 | 482 | case QAM_32: | |
503 | case QAM_32: | 483 | state->tx_tuna[8] = 0x20; |
504 | state->tx_tuna[8] = 0x20; | 484 | break; |
505 | break; | 485 | case QAM_64: |
506 | 486 | state->tx_tuna[8] = 0x40; | |
507 | case QAM_64: | 487 | break; |
508 | state->tx_tuna[8] = 0x40; | 488 | case QAM_128: |
509 | break; | 489 | state->tx_tuna[8] = 0x80; |
510 | 490 | break; | |
511 | case QAM_128: | 491 | case QAM_256: |
512 | state->tx_tuna[8] = 0x80; | 492 | state->tx_tuna[8] = 0x00; |
513 | break; | 493 | break; |
514 | 494 | case QPSK: | |
515 | case QAM_256: | 495 | case QAM_AUTO: |
516 | state->tx_tuna[8] = 0x00; | 496 | case VSB_8: |
517 | break; | 497 | case VSB_16: |
518 | 498 | default: | |
519 | case QPSK: | 499 | return -EINVAL; |
520 | case QAM_AUTO: | ||
521 | case VSB_8: | ||
522 | case VSB_16: | ||
523 | default: | ||
524 | return -EINVAL; | ||
525 | 500 | ||
526 | } | 501 | } |
527 | 502 | ||
@@ -534,7 +509,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state) | |||
534 | } | 509 | } |
535 | 510 | ||
536 | 511 | ||
537 | u8 dst_check_sum(u8 * buf, u32 len) | 512 | u8 dst_check_sum(u8 *buf, u32 len) |
538 | { | 513 | { |
539 | u32 i; | 514 | u32 i; |
540 | u8 val = 0; | 515 | u8 val = 0; |
@@ -549,26 +524,24 @@ EXPORT_SYMBOL(dst_check_sum); | |||
549 | 524 | ||
550 | static void dst_type_flags_print(u32 type_flags) | 525 | static void dst_type_flags_print(u32 type_flags) |
551 | { | 526 | { |
552 | printk("DST type flags :"); | 527 | dprintk(verbose, DST_ERROR, 0, "DST type flags :"); |
553 | if (type_flags & DST_TYPE_HAS_NEWTUNE) | 528 | if (type_flags & DST_TYPE_HAS_NEWTUNE) |
554 | printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); | 529 | dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); |
555 | if (type_flags & DST_TYPE_HAS_TS204) | 530 | if (type_flags & DST_TYPE_HAS_TS204) |
556 | printk(" 0x%x ts204", DST_TYPE_HAS_TS204); | 531 | dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); |
557 | if (type_flags & DST_TYPE_HAS_SYMDIV) | 532 | if (type_flags & DST_TYPE_HAS_SYMDIV) |
558 | printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); | 533 | dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); |
559 | if (type_flags & DST_TYPE_HAS_FW_1) | 534 | if (type_flags & DST_TYPE_HAS_FW_1) |
560 | printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); | 535 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); |
561 | if (type_flags & DST_TYPE_HAS_FW_2) | 536 | if (type_flags & DST_TYPE_HAS_FW_2) |
562 | printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); | 537 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); |
563 | if (type_flags & DST_TYPE_HAS_FW_3) | 538 | if (type_flags & DST_TYPE_HAS_FW_3) |
564 | printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); | 539 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); |
565 | // if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) | 540 | dprintk(verbose, DST_ERROR, 0, "\n"); |
566 | |||
567 | printk("\n"); | ||
568 | } | 541 | } |
569 | 542 | ||
570 | 543 | ||
571 | static int dst_type_print (u8 type) | 544 | static int dst_type_print(u8 type) |
572 | { | 545 | { |
573 | char *otype; | 546 | char *otype; |
574 | switch (type) { | 547 | switch (type) { |
@@ -585,10 +558,10 @@ static int dst_type_print (u8 type) | |||
585 | break; | 558 | break; |
586 | 559 | ||
587 | default: | 560 | default: |
588 | printk("%s: invalid dst type %d\n", __FUNCTION__, type); | 561 | dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); |
589 | return -EINVAL; | 562 | return -EINVAL; |
590 | } | 563 | } |
591 | printk("DST type : %s\n", otype); | 564 | dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); |
592 | 565 | ||
593 | return 0; | 566 | return 0; |
594 | } | 567 | } |
@@ -772,53 +745,45 @@ static int dst_get_device_id(struct dst_state *state) | |||
772 | 745 | ||
773 | if (write_dst(state, device_type, FIXED_COMM)) | 746 | if (write_dst(state, device_type, FIXED_COMM)) |
774 | return -1; /* Write failed */ | 747 | return -1; /* Write failed */ |
775 | |||
776 | if ((dst_pio_disable(state)) < 0) | 748 | if ((dst_pio_disable(state)) < 0) |
777 | return -1; | 749 | return -1; |
778 | |||
779 | if (read_dst(state, &reply, GET_ACK)) | 750 | if (read_dst(state, &reply, GET_ACK)) |
780 | return -1; /* Read failure */ | 751 | return -1; /* Read failure */ |
781 | |||
782 | if (reply != ACK) { | 752 | if (reply != ACK) { |
783 | dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); | 753 | dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); |
784 | return -1; /* Unack'd write */ | 754 | return -1; /* Unack'd write */ |
785 | } | 755 | } |
786 | |||
787 | if (!dst_wait_dst_ready(state, DEVICE_INIT)) | 756 | if (!dst_wait_dst_ready(state, DEVICE_INIT)) |
788 | return -1; /* DST not ready yet */ | 757 | return -1; /* DST not ready yet */ |
789 | |||
790 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) | 758 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) |
791 | return -1; | 759 | return -1; |
792 | 760 | ||
793 | dst_pio_disable(state); | 761 | dst_pio_disable(state); |
794 | |||
795 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { | 762 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { |
796 | dprintk("%s: Checksum failure! \n", __FUNCTION__); | 763 | dprintk(verbose, DST_INFO, 1, "Checksum failure!"); |
797 | return -1; /* Checksum failure */ | 764 | return -1; /* Checksum failure */ |
798 | } | 765 | } |
799 | |||
800 | state->rxbuffer[7] = '\0'; | 766 | state->rxbuffer[7] = '\0'; |
801 | 767 | ||
802 | for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { | 768 | for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) { |
803 | if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { | 769 | if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { |
804 | use_type_flags = p_dst_type->type_flags; | 770 | use_type_flags = p_dst_type->type_flags; |
805 | use_dst_type = p_dst_type->dst_type; | 771 | use_dst_type = p_dst_type->dst_type; |
806 | 772 | ||
807 | /* Card capabilities */ | 773 | /* Card capabilities */ |
808 | state->dst_hw_cap = p_dst_type->dst_feature; | 774 | state->dst_hw_cap = p_dst_type->dst_feature; |
809 | printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); | 775 | dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id); |
810 | 776 | ||
811 | break; | 777 | break; |
812 | } | 778 | } |
813 | } | 779 | } |
814 | 780 | ||
815 | if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { | 781 | if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { |
816 | printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); | 782 | dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); |
817 | printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); | 783 | dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); |
818 | use_dst_type = DST_TYPE_IS_SAT; | 784 | use_dst_type = DST_TYPE_IS_SAT; |
819 | use_type_flags = DST_TYPE_HAS_SYMDIV; | 785 | use_type_flags = DST_TYPE_HAS_SYMDIV; |
820 | } | 786 | } |
821 | |||
822 | dst_type_print(use_dst_type); | 787 | dst_type_print(use_dst_type); |
823 | state->type_flags = use_type_flags; | 788 | state->type_flags = use_type_flags; |
824 | state->dst_type = use_dst_type; | 789 | state->dst_type = use_dst_type; |
@@ -834,7 +799,7 @@ static int dst_get_device_id(struct dst_state *state) | |||
834 | static int dst_probe(struct dst_state *state) | 799 | static int dst_probe(struct dst_state *state) |
835 | { | 800 | { |
836 | if ((rdc_8820_reset(state)) < 0) { | 801 | if ((rdc_8820_reset(state)) < 0) { |
837 | dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); | 802 | dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); |
838 | return -1; | 803 | return -1; |
839 | } | 804 | } |
840 | if (dst_addons & DST_TYPE_HAS_CA) | 805 | if (dst_addons & DST_TYPE_HAS_CA) |
@@ -843,80 +808,69 @@ static int dst_probe(struct dst_state *state) | |||
843 | msleep(100); | 808 | msleep(100); |
844 | 809 | ||
845 | if ((dst_comm_init(state)) < 0) { | 810 | if ((dst_comm_init(state)) < 0) { |
846 | dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); | 811 | dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); |
847 | return -1; | 812 | return -1; |
848 | } | 813 | } |
849 | msleep(100); | 814 | msleep(100); |
850 | if (dst_get_device_id(state) < 0) { | 815 | if (dst_get_device_id(state) < 0) { |
851 | dprintk("%s: unknown device.\n", __FUNCTION__); | 816 | dprintk(verbose, DST_ERROR, 1, "unknown device."); |
852 | return -1; | 817 | return -1; |
853 | } | 818 | } |
854 | 819 | ||
855 | return 0; | 820 | return 0; |
856 | } | 821 | } |
857 | 822 | ||
858 | int dst_command(struct dst_state* state, u8 * data, u8 len) | 823 | int dst_command(struct dst_state *state, u8 *data, u8 len) |
859 | { | 824 | { |
860 | u8 reply; | 825 | u8 reply; |
861 | if ((dst_comm_init(state)) < 0) { | 826 | if ((dst_comm_init(state)) < 0) { |
862 | dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); | 827 | dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); |
863 | return -1; | 828 | return -1; |
864 | } | 829 | } |
865 | |||
866 | if (write_dst(state, data, len)) { | 830 | if (write_dst(state, data, len)) { |
867 | if (verbose > 1) | 831 | dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); |
868 | dprintk("%s: Tring to recover.. \n", __FUNCTION__); | ||
869 | if ((dst_error_recovery(state)) < 0) { | 832 | if ((dst_error_recovery(state)) < 0) { |
870 | dprintk("%s: Recovery Failed.\n", __FUNCTION__); | 833 | dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); |
871 | return -1; | 834 | return -1; |
872 | } | 835 | } |
873 | return -1; | 836 | return -1; |
874 | } | 837 | } |
875 | if ((dst_pio_disable(state)) < 0) { | 838 | if ((dst_pio_disable(state)) < 0) { |
876 | dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); | 839 | dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); |
877 | return -1; | 840 | return -1; |
878 | } | 841 | } |
879 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 842 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
880 | udelay(3000); | 843 | udelay(3000); |
881 | |||
882 | if (read_dst(state, &reply, GET_ACK)) { | 844 | if (read_dst(state, &reply, GET_ACK)) { |
883 | if (verbose > 1) | 845 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); |
884 | dprintk("%s: Trying to recover.. \n", __FUNCTION__); | ||
885 | if ((dst_error_recovery(state)) < 0) { | 846 | if ((dst_error_recovery(state)) < 0) { |
886 | dprintk("%s: Recovery Failed.\n", __FUNCTION__); | 847 | dprintk(verbose, DST_INFO, 1, "Recovery Failed."); |
887 | return -1; | 848 | return -1; |
888 | } | 849 | } |
889 | return -1; | 850 | return -1; |
890 | } | 851 | } |
891 | |||
892 | if (reply != ACK) { | 852 | if (reply != ACK) { |
893 | dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); | 853 | dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); |
894 | return -1; | 854 | return -1; |
895 | } | 855 | } |
896 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) | 856 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) |
897 | return 0; | 857 | return 0; |
898 | |||
899 | // udelay(3000); | ||
900 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 858 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
901 | udelay(3000); | 859 | udelay(3000); |
902 | else | 860 | else |
903 | udelay(2000); | 861 | udelay(2000); |
904 | |||
905 | if (!dst_wait_dst_ready(state, NO_DELAY)) | 862 | if (!dst_wait_dst_ready(state, NO_DELAY)) |
906 | return -1; | 863 | return -1; |
907 | |||
908 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) { | 864 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) { |
909 | if (verbose > 1) | 865 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); |
910 | dprintk("%s: Trying to recover.. \n", __FUNCTION__); | ||
911 | if ((dst_error_recovery(state)) < 0) { | 866 | if ((dst_error_recovery(state)) < 0) { |
912 | dprintk("%s: Recovery failed.\n", __FUNCTION__); | 867 | dprintk(verbose, DST_INFO, 1, "Recovery failed."); |
913 | return -1; | 868 | return -1; |
914 | } | 869 | } |
915 | return -1; | 870 | return -1; |
916 | } | 871 | } |
917 | |||
918 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { | 872 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { |
919 | dprintk("%s: checksum failure\n", __FUNCTION__); | 873 | dprintk(verbose, DST_INFO, 1, "checksum failure"); |
920 | return -1; | 874 | return -1; |
921 | } | 875 | } |
922 | 876 | ||
@@ -924,7 +878,7 @@ int dst_command(struct dst_state* state, u8 * data, u8 len) | |||
924 | } | 878 | } |
925 | EXPORT_SYMBOL(dst_command); | 879 | EXPORT_SYMBOL(dst_command); |
926 | 880 | ||
927 | static int dst_get_signal(struct dst_state* state) | 881 | static int dst_get_signal(struct dst_state *state) |
928 | { | 882 | { |
929 | int retval; | 883 | int retval; |
930 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; | 884 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; |
@@ -955,13 +909,12 @@ static int dst_get_signal(struct dst_state* state) | |||
955 | return 0; | 909 | return 0; |
956 | } | 910 | } |
957 | 911 | ||
958 | static int dst_tone_power_cmd(struct dst_state* state) | 912 | static int dst_tone_power_cmd(struct dst_state *state) |
959 | { | 913 | { |
960 | u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; | 914 | u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; |
961 | 915 | ||
962 | if (state->dst_type == DST_TYPE_IS_TERR) | 916 | if (state->dst_type == DST_TYPE_IS_TERR) |
963 | return 0; | 917 | return 0; |
964 | |||
965 | paket[4] = state->tx_tuna[4]; | 918 | paket[4] = state->tx_tuna[4]; |
966 | paket[2] = state->tx_tuna[2]; | 919 | paket[2] = state->tx_tuna[2]; |
967 | paket[3] = state->tx_tuna[3]; | 920 | paket[3] = state->tx_tuna[3]; |
@@ -971,61 +924,53 @@ static int dst_tone_power_cmd(struct dst_state* state) | |||
971 | return 0; | 924 | return 0; |
972 | } | 925 | } |
973 | 926 | ||
974 | static int dst_get_tuna(struct dst_state* state) | 927 | static int dst_get_tuna(struct dst_state *state) |
975 | { | 928 | { |
976 | int retval; | 929 | int retval; |
977 | 930 | ||
978 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) | 931 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) |
979 | return 0; | 932 | return 0; |
980 | |||
981 | state->diseq_flags &= ~(HAS_LOCK); | 933 | state->diseq_flags &= ~(HAS_LOCK); |
982 | if (!dst_wait_dst_ready(state, NO_DELAY)) | 934 | if (!dst_wait_dst_ready(state, NO_DELAY)) |
983 | return 0; | 935 | return 0; |
984 | 936 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) | |
985 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | ||
986 | /* how to get variable length reply ???? */ | 937 | /* how to get variable length reply ???? */ |
987 | retval = read_dst(state, state->rx_tuna, 10); | 938 | retval = read_dst(state, state->rx_tuna, 10); |
988 | } else { | 939 | else |
989 | retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); | 940 | retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); |
990 | } | ||
991 | |||
992 | if (retval < 0) { | 941 | if (retval < 0) { |
993 | dprintk("%s: read not successful\n", __FUNCTION__); | 942 | dprintk(verbose, DST_DEBUG, 1, "read not successful"); |
994 | return 0; | 943 | return 0; |
995 | } | 944 | } |
996 | |||
997 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | 945 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { |
998 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { | 946 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { |
999 | dprintk("%s: checksum failure?\n", __FUNCTION__); | 947 | dprintk(verbose, DST_INFO, 1, "checksum failure ? "); |
1000 | return 0; | 948 | return 0; |
1001 | } | 949 | } |
1002 | } else { | 950 | } else { |
1003 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { | 951 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { |
1004 | dprintk("%s: checksum failure?\n", __FUNCTION__); | 952 | dprintk(verbose, DST_INFO, 1, "checksum failure? "); |
1005 | return 0; | 953 | return 0; |
1006 | } | 954 | } |
1007 | } | 955 | } |
1008 | if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) | 956 | if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) |
1009 | return 0; | 957 | return 0; |
1010 | state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; | 958 | state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; |
1011 | |||
1012 | state->decode_lock = 1; | 959 | state->decode_lock = 1; |
1013 | state->diseq_flags |= HAS_LOCK; | 960 | state->diseq_flags |= HAS_LOCK; |
1014 | 961 | ||
1015 | return 1; | 962 | return 1; |
1016 | } | 963 | } |
1017 | 964 | ||
1018 | static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); | 965 | static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); |
1019 | 966 | ||
1020 | static int dst_write_tuna(struct dvb_frontend* fe) | 967 | static int dst_write_tuna(struct dvb_frontend *fe) |
1021 | { | 968 | { |
1022 | struct dst_state* state = fe->demodulator_priv; | 969 | struct dst_state *state = fe->demodulator_priv; |
1023 | int retval; | 970 | int retval; |
1024 | u8 reply; | 971 | u8 reply; |
1025 | 972 | ||
1026 | if (debug > 4) | 973 | dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); |
1027 | dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); | ||
1028 | |||
1029 | state->decode_freq = 0; | 974 | state->decode_freq = 0; |
1030 | state->decode_lock = state->decode_strength = state->decode_snr = 0; | 975 | state->decode_lock = state->decode_strength = state->decode_snr = 0; |
1031 | if (state->dst_type == DST_TYPE_IS_SAT) { | 976 | if (state->dst_type == DST_TYPE_IS_SAT) { |
@@ -1035,35 +980,31 @@ static int dst_write_tuna(struct dvb_frontend* fe) | |||
1035 | state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); | 980 | state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); |
1036 | 981 | ||
1037 | if ((dst_comm_init(state)) < 0) { | 982 | if ((dst_comm_init(state)) < 0) { |
1038 | dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); | 983 | dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); |
1039 | return -1; | 984 | return -1; |
1040 | } | 985 | } |
1041 | |||
1042 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | 986 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { |
1043 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); | 987 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); |
1044 | retval = write_dst(state, &state->tx_tuna[0], 10); | 988 | retval = write_dst(state, &state->tx_tuna[0], 10); |
1045 | |||
1046 | } else { | 989 | } else { |
1047 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); | 990 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); |
1048 | retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); | 991 | retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); |
1049 | } | 992 | } |
1050 | if (retval < 0) { | 993 | if (retval < 0) { |
1051 | dst_pio_disable(state); | 994 | dst_pio_disable(state); |
1052 | dprintk("%s: write not successful\n", __FUNCTION__); | 995 | dprintk(verbose, DST_DEBUG, 1, "write not successful"); |
1053 | return retval; | 996 | return retval; |
1054 | } | 997 | } |
1055 | |||
1056 | if ((dst_pio_disable(state)) < 0) { | 998 | if ((dst_pio_disable(state)) < 0) { |
1057 | dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); | 999 | dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); |
1058 | return -1; | 1000 | return -1; |
1059 | } | 1001 | } |
1060 | |||
1061 | if ((read_dst(state, &reply, GET_ACK) < 0)) { | 1002 | if ((read_dst(state, &reply, GET_ACK) < 0)) { |
1062 | dprintk("%s: read verify not successful.\n", __FUNCTION__); | 1003 | dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); |
1063 | return -1; | 1004 | return -1; |
1064 | } | 1005 | } |
1065 | if (reply != ACK) { | 1006 | if (reply != ACK) { |
1066 | dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); | 1007 | dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); |
1067 | return 0; | 1008 | return 0; |
1068 | } | 1009 | } |
1069 | state->diseq_flags |= ATTEMPT_TUNE; | 1010 | state->diseq_flags |= ATTEMPT_TUNE; |
@@ -1085,14 +1026,13 @@ static int dst_write_tuna(struct dvb_frontend* fe) | |||
1085 | * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 | 1026 | * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 |
1086 | */ | 1027 | */ |
1087 | 1028 | ||
1088 | static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) | 1029 | static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) |
1089 | { | 1030 | { |
1090 | struct dst_state* state = fe->demodulator_priv; | 1031 | struct dst_state *state = fe->demodulator_priv; |
1091 | u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; | 1032 | u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; |
1092 | 1033 | ||
1093 | if (state->dst_type != DST_TYPE_IS_SAT) | 1034 | if (state->dst_type != DST_TYPE_IS_SAT) |
1094 | return 0; | 1035 | return 0; |
1095 | |||
1096 | if (cmd->msg_len == 0 || cmd->msg_len > 4) | 1036 | if (cmd->msg_len == 0 || cmd->msg_len > 4) |
1097 | return -EINVAL; | 1037 | return -EINVAL; |
1098 | memcpy(&paket[3], cmd->msg, cmd->msg_len); | 1038 | memcpy(&paket[3], cmd->msg, cmd->msg_len); |
@@ -1101,65 +1041,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* | |||
1101 | return 0; | 1041 | return 0; |
1102 | } | 1042 | } |
1103 | 1043 | ||
1104 | static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) | 1044 | static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
1105 | { | 1045 | { |
1106 | int need_cmd; | 1046 | int need_cmd; |
1107 | struct dst_state* state = fe->demodulator_priv; | 1047 | struct dst_state *state = fe->demodulator_priv; |
1108 | 1048 | ||
1109 | state->voltage = voltage; | 1049 | state->voltage = voltage; |
1110 | |||
1111 | if (state->dst_type != DST_TYPE_IS_SAT) | 1050 | if (state->dst_type != DST_TYPE_IS_SAT) |
1112 | return 0; | 1051 | return 0; |
1113 | 1052 | ||
1114 | need_cmd = 0; | 1053 | need_cmd = 0; |
1115 | switch (voltage) { | ||
1116 | case SEC_VOLTAGE_13: | ||
1117 | case SEC_VOLTAGE_18: | ||
1118 | if ((state->diseq_flags & HAS_POWER) == 0) | ||
1119 | need_cmd = 1; | ||
1120 | state->diseq_flags |= HAS_POWER; | ||
1121 | state->tx_tuna[4] = 0x01; | ||
1122 | break; | ||
1123 | 1054 | ||
1124 | case SEC_VOLTAGE_OFF: | 1055 | switch (voltage) { |
1056 | case SEC_VOLTAGE_13: | ||
1057 | case SEC_VOLTAGE_18: | ||
1058 | if ((state->diseq_flags & HAS_POWER) == 0) | ||
1125 | need_cmd = 1; | 1059 | need_cmd = 1; |
1126 | state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); | 1060 | state->diseq_flags |= HAS_POWER; |
1127 | state->tx_tuna[4] = 0x00; | 1061 | state->tx_tuna[4] = 0x01; |
1128 | break; | 1062 | break; |
1129 | 1063 | case SEC_VOLTAGE_OFF: | |
1130 | default: | 1064 | need_cmd = 1; |
1131 | return -EINVAL; | 1065 | state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); |
1066 | state->tx_tuna[4] = 0x00; | ||
1067 | break; | ||
1068 | default: | ||
1069 | return -EINVAL; | ||
1132 | } | 1070 | } |
1071 | |||
1133 | if (need_cmd) | 1072 | if (need_cmd) |
1134 | dst_tone_power_cmd(state); | 1073 | dst_tone_power_cmd(state); |
1135 | 1074 | ||
1136 | return 0; | 1075 | return 0; |
1137 | } | 1076 | } |
1138 | 1077 | ||
1139 | static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 1078 | static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) |
1140 | { | 1079 | { |
1141 | struct dst_state* state = fe->demodulator_priv; | 1080 | struct dst_state *state = fe->demodulator_priv; |
1142 | 1081 | ||
1143 | state->tone = tone; | 1082 | state->tone = tone; |
1144 | |||
1145 | if (state->dst_type != DST_TYPE_IS_SAT) | 1083 | if (state->dst_type != DST_TYPE_IS_SAT) |
1146 | return 0; | 1084 | return 0; |
1147 | 1085 | ||
1148 | switch (tone) { | 1086 | switch (tone) { |
1149 | case SEC_TONE_OFF: | 1087 | case SEC_TONE_OFF: |
1150 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1088 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
1151 | state->tx_tuna[2] = 0x00; | 1089 | state->tx_tuna[2] = 0x00; |
1152 | else | 1090 | else |
1153 | state->tx_tuna[2] = 0xff; | 1091 | state->tx_tuna[2] = 0xff; |
1154 | 1092 | break; | |
1155 | break; | ||
1156 | |||
1157 | case SEC_TONE_ON: | ||
1158 | state->tx_tuna[2] = 0x02; | ||
1159 | break; | ||
1160 | 1093 | ||
1161 | default: | 1094 | case SEC_TONE_ON: |
1162 | return -EINVAL; | 1095 | state->tx_tuna[2] = 0x02; |
1096 | break; | ||
1097 | default: | ||
1098 | return -EINVAL; | ||
1163 | } | 1099 | } |
1164 | dst_tone_power_cmd(state); | 1100 | dst_tone_power_cmd(state); |
1165 | 1101 | ||
@@ -1172,16 +1108,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) | |||
1172 | 1108 | ||
1173 | if (state->dst_type != DST_TYPE_IS_SAT) | 1109 | if (state->dst_type != DST_TYPE_IS_SAT) |
1174 | return 0; | 1110 | return 0; |
1175 | |||
1176 | state->minicmd = minicmd; | 1111 | state->minicmd = minicmd; |
1177 | |||
1178 | switch (minicmd) { | 1112 | switch (minicmd) { |
1179 | case SEC_MINI_A: | 1113 | case SEC_MINI_A: |
1180 | state->tx_tuna[3] = 0x02; | 1114 | state->tx_tuna[3] = 0x02; |
1181 | break; | 1115 | break; |
1182 | case SEC_MINI_B: | 1116 | case SEC_MINI_B: |
1183 | state->tx_tuna[3] = 0xff; | 1117 | state->tx_tuna[3] = 0xff; |
1184 | break; | 1118 | break; |
1185 | } | 1119 | } |
1186 | dst_tone_power_cmd(state); | 1120 | dst_tone_power_cmd(state); |
1187 | 1121 | ||
@@ -1189,42 +1123,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) | |||
1189 | } | 1123 | } |
1190 | 1124 | ||
1191 | 1125 | ||
1192 | static int dst_init(struct dvb_frontend* fe) | 1126 | static int dst_init(struct dvb_frontend *fe) |
1193 | { | 1127 | { |
1194 | struct dst_state* state = fe->demodulator_priv; | 1128 | struct dst_state *state = fe->demodulator_priv; |
1195 | static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; | 1129 | |
1196 | static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; | 1130 | static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 }; |
1197 | static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1131 | static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 }; |
1198 | static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1132 | static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
1199 | static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1133 | static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
1200 | static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1134 | static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
1201 | // state->inversion = INVERSION_ON; | 1135 | static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
1136 | |||
1202 | state->inversion = INVERSION_OFF; | 1137 | state->inversion = INVERSION_OFF; |
1203 | state->voltage = SEC_VOLTAGE_13; | 1138 | state->voltage = SEC_VOLTAGE_13; |
1204 | state->tone = SEC_TONE_OFF; | 1139 | state->tone = SEC_TONE_OFF; |
1205 | state->symbol_rate = 29473000; | ||
1206 | state->fec = FEC_AUTO; | ||
1207 | state->diseq_flags = 0; | 1140 | state->diseq_flags = 0; |
1208 | state->k22 = 0x02; | 1141 | state->k22 = 0x02; |
1209 | state->bandwidth = BANDWIDTH_7_MHZ; | 1142 | state->bandwidth = BANDWIDTH_7_MHZ; |
1210 | state->cur_jiff = jiffies; | 1143 | state->cur_jiff = jiffies; |
1211 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1144 | if (state->dst_type == DST_TYPE_IS_SAT) |
1212 | state->frequency = 950000; | 1145 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204)); |
1213 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); | 1146 | else if (state->dst_type == DST_TYPE_IS_TERR) |
1214 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1147 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204)); |
1215 | state->frequency = 137000000; | 1148 | else if (state->dst_type == DST_TYPE_IS_CABLE) |
1216 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); | 1149 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204)); |
1217 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | ||
1218 | state->frequency = 51000000; | ||
1219 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna)); | ||
1220 | } | ||
1221 | 1150 | ||
1222 | return 0; | 1151 | return 0; |
1223 | } | 1152 | } |
1224 | 1153 | ||
1225 | static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) | 1154 | static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status) |
1226 | { | 1155 | { |
1227 | struct dst_state* state = fe->demodulator_priv; | 1156 | struct dst_state *state = fe->demodulator_priv; |
1228 | 1157 | ||
1229 | *status = 0; | 1158 | *status = 0; |
1230 | if (state->diseq_flags & HAS_LOCK) { | 1159 | if (state->diseq_flags & HAS_LOCK) { |
@@ -1236,9 +1165,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
1236 | return 0; | 1165 | return 0; |
1237 | } | 1166 | } |
1238 | 1167 | ||
1239 | static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) | 1168 | static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
1240 | { | 1169 | { |
1241 | struct dst_state* state = fe->demodulator_priv; | 1170 | struct dst_state *state = fe->demodulator_priv; |
1242 | 1171 | ||
1243 | dst_get_signal(state); | 1172 | dst_get_signal(state); |
1244 | *strength = state->decode_strength; | 1173 | *strength = state->decode_strength; |
@@ -1246,9 +1175,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) | |||
1246 | return 0; | 1175 | return 0; |
1247 | } | 1176 | } |
1248 | 1177 | ||
1249 | static int dst_read_snr(struct dvb_frontend* fe, u16* snr) | 1178 | static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) |
1250 | { | 1179 | { |
1251 | struct dst_state* state = fe->demodulator_priv; | 1180 | struct dst_state *state = fe->demodulator_priv; |
1252 | 1181 | ||
1253 | dst_get_signal(state); | 1182 | dst_get_signal(state); |
1254 | *snr = state->decode_snr; | 1183 | *snr = state->decode_snr; |
@@ -1256,28 +1185,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr) | |||
1256 | return 0; | 1185 | return 0; |
1257 | } | 1186 | } |
1258 | 1187 | ||
1259 | static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 1188 | static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) |
1260 | { | 1189 | { |
1261 | struct dst_state* state = fe->demodulator_priv; | 1190 | struct dst_state *state = fe->demodulator_priv; |
1262 | 1191 | ||
1263 | dst_set_freq(state, p->frequency); | 1192 | dst_set_freq(state, p->frequency); |
1264 | if (verbose > 4) | 1193 | dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); |
1265 | dprintk("Set Frequency=[%d]\n", p->frequency); | ||
1266 | 1194 | ||
1267 | // dst_set_inversion(state, p->inversion); | ||
1268 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1195 | if (state->dst_type == DST_TYPE_IS_SAT) { |
1269 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1196 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
1270 | dst_set_inversion(state, p->inversion); | 1197 | dst_set_inversion(state, p->inversion); |
1271 | |||
1272 | dst_set_fec(state, p->u.qpsk.fec_inner); | 1198 | dst_set_fec(state, p->u.qpsk.fec_inner); |
1273 | dst_set_symbolrate(state, p->u.qpsk.symbol_rate); | 1199 | dst_set_symbolrate(state, p->u.qpsk.symbol_rate); |
1274 | dst_set_polarization(state); | 1200 | dst_set_polarization(state); |
1275 | if (verbose > 4) | 1201 | dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); |
1276 | dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate); | ||
1277 | 1202 | ||
1278 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1203 | } else if (state->dst_type == DST_TYPE_IS_TERR) |
1279 | dst_set_bandwidth(state, p->u.ofdm.bandwidth); | 1204 | dst_set_bandwidth(state, p->u.ofdm.bandwidth); |
1280 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 1205 | else if (state->dst_type == DST_TYPE_IS_CABLE) { |
1281 | dst_set_fec(state, p->u.qam.fec_inner); | 1206 | dst_set_fec(state, p->u.qam.fec_inner); |
1282 | dst_set_symbolrate(state, p->u.qam.symbol_rate); | 1207 | dst_set_symbolrate(state, p->u.qam.symbol_rate); |
1283 | dst_set_modulation(state, p->u.qam.modulation); | 1208 | dst_set_modulation(state, p->u.qam.modulation); |
@@ -1287,16 +1212,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
1287 | return 0; | 1212 | return 0; |
1288 | } | 1213 | } |
1289 | 1214 | ||
1290 | static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 1215 | static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) |
1291 | { | 1216 | { |
1292 | struct dst_state* state = fe->demodulator_priv; | 1217 | struct dst_state *state = fe->demodulator_priv; |
1293 | 1218 | ||
1294 | p->frequency = state->decode_freq; | 1219 | p->frequency = state->decode_freq; |
1295 | // p->inversion = state->inversion; | ||
1296 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1220 | if (state->dst_type == DST_TYPE_IS_SAT) { |
1297 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1221 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
1298 | p->inversion = state->inversion; | 1222 | p->inversion = state->inversion; |
1299 | |||
1300 | p->u.qpsk.symbol_rate = state->symbol_rate; | 1223 | p->u.qpsk.symbol_rate = state->symbol_rate; |
1301 | p->u.qpsk.fec_inner = dst_get_fec(state); | 1224 | p->u.qpsk.fec_inner = dst_get_fec(state); |
1302 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1225 | } else if (state->dst_type == DST_TYPE_IS_TERR) { |
@@ -1304,16 +1227,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
1304 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 1227 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { |
1305 | p->u.qam.symbol_rate = state->symbol_rate; | 1228 | p->u.qam.symbol_rate = state->symbol_rate; |
1306 | p->u.qam.fec_inner = dst_get_fec(state); | 1229 | p->u.qam.fec_inner = dst_get_fec(state); |
1307 | // p->u.qam.modulation = QAM_AUTO; | ||
1308 | p->u.qam.modulation = dst_get_modulation(state); | 1230 | p->u.qam.modulation = dst_get_modulation(state); |
1309 | } | 1231 | } |
1310 | 1232 | ||
1311 | return 0; | 1233 | return 0; |
1312 | } | 1234 | } |
1313 | 1235 | ||
1314 | static void dst_release(struct dvb_frontend* fe) | 1236 | static void dst_release(struct dvb_frontend *fe) |
1315 | { | 1237 | { |
1316 | struct dst_state* state = fe->demodulator_priv; | 1238 | struct dst_state *state = fe->demodulator_priv; |
1317 | kfree(state); | 1239 | kfree(state); |
1318 | } | 1240 | } |
1319 | 1241 | ||
@@ -1321,9 +1243,8 @@ static struct dvb_frontend_ops dst_dvbt_ops; | |||
1321 | static struct dvb_frontend_ops dst_dvbs_ops; | 1243 | static struct dvb_frontend_ops dst_dvbs_ops; |
1322 | static struct dvb_frontend_ops dst_dvbc_ops; | 1244 | static struct dvb_frontend_ops dst_dvbc_ops; |
1323 | 1245 | ||
1324 | struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) | 1246 | struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) |
1325 | { | 1247 | { |
1326 | |||
1327 | /* check if the ASIC is there */ | 1248 | /* check if the ASIC is there */ |
1328 | if (dst_probe(state) < 0) { | 1249 | if (dst_probe(state) < 0) { |
1329 | if (state) | 1250 | if (state) |
@@ -1336,17 +1257,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad | |||
1336 | case DST_TYPE_IS_TERR: | 1257 | case DST_TYPE_IS_TERR: |
1337 | memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); | 1258 | memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); |
1338 | break; | 1259 | break; |
1339 | |||
1340 | case DST_TYPE_IS_CABLE: | 1260 | case DST_TYPE_IS_CABLE: |
1341 | memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); | 1261 | memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); |
1342 | break; | 1262 | break; |
1343 | |||
1344 | case DST_TYPE_IS_SAT: | 1263 | case DST_TYPE_IS_SAT: |
1345 | memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); | 1264 | memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); |
1346 | break; | 1265 | break; |
1347 | |||
1348 | default: | 1266 | default: |
1349 | printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); | 1267 | dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); |
1350 | if (state) | 1268 | if (state) |
1351 | kfree(state); | 1269 | kfree(state); |
1352 | 1270 | ||
@@ -1374,12 +1292,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = { | |||
1374 | }, | 1292 | }, |
1375 | 1293 | ||
1376 | .release = dst_release, | 1294 | .release = dst_release, |
1377 | |||
1378 | .init = dst_init, | 1295 | .init = dst_init, |
1379 | |||
1380 | .set_frontend = dst_set_frontend, | 1296 | .set_frontend = dst_set_frontend, |
1381 | .get_frontend = dst_get_frontend, | 1297 | .get_frontend = dst_get_frontend, |
1382 | |||
1383 | .read_status = dst_read_status, | 1298 | .read_status = dst_read_status, |
1384 | .read_signal_strength = dst_read_signal_strength, | 1299 | .read_signal_strength = dst_read_signal_strength, |
1385 | .read_snr = dst_read_snr, | 1300 | .read_snr = dst_read_snr, |
@@ -1401,16 +1316,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = { | |||
1401 | }, | 1316 | }, |
1402 | 1317 | ||
1403 | .release = dst_release, | 1318 | .release = dst_release, |
1404 | |||
1405 | .init = dst_init, | 1319 | .init = dst_init, |
1406 | |||
1407 | .set_frontend = dst_set_frontend, | 1320 | .set_frontend = dst_set_frontend, |
1408 | .get_frontend = dst_get_frontend, | 1321 | .get_frontend = dst_get_frontend, |
1409 | |||
1410 | .read_status = dst_read_status, | 1322 | .read_status = dst_read_status, |
1411 | .read_signal_strength = dst_read_signal_strength, | 1323 | .read_signal_strength = dst_read_signal_strength, |
1412 | .read_snr = dst_read_snr, | 1324 | .read_snr = dst_read_snr, |
1413 | |||
1414 | .diseqc_send_burst = dst_send_burst, | 1325 | .diseqc_send_burst = dst_send_burst, |
1415 | .diseqc_send_master_cmd = dst_set_diseqc, | 1326 | .diseqc_send_master_cmd = dst_set_diseqc, |
1416 | .set_voltage = dst_set_voltage, | 1327 | .set_voltage = dst_set_voltage, |
@@ -1432,18 +1343,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = { | |||
1432 | }, | 1343 | }, |
1433 | 1344 | ||
1434 | .release = dst_release, | 1345 | .release = dst_release, |
1435 | |||
1436 | .init = dst_init, | 1346 | .init = dst_init, |
1437 | |||
1438 | .set_frontend = dst_set_frontend, | 1347 | .set_frontend = dst_set_frontend, |
1439 | .get_frontend = dst_get_frontend, | 1348 | .get_frontend = dst_get_frontend, |
1440 | |||
1441 | .read_status = dst_read_status, | 1349 | .read_status = dst_read_status, |
1442 | .read_signal_strength = dst_read_signal_strength, | 1350 | .read_signal_strength = dst_read_signal_strength, |
1443 | .read_snr = dst_read_snr, | 1351 | .read_snr = dst_read_snr, |
1444 | }; | 1352 | }; |
1445 | 1353 | ||
1446 | |||
1447 | MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); | 1354 | MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); |
1448 | MODULE_AUTHOR("Jamie Honan, Manu Abraham"); | 1355 | MODULE_AUTHOR("Jamie Honan, Manu Abraham"); |
1449 | MODULE_LICENSE("GPL"); | 1356 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index d2e0b1cb39d9..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 | |||
35 | static unsigned int verbose = 5; | 53 | static unsigned int verbose = 5; |
36 | module_param(verbose, int, 0644); | 54 | module_param(verbose, int, 0644); |
37 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | 55 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); |
38 | 56 | ||
39 | static unsigned int debug = 1; | ||
40 | module_param(debug, int, 0644); | ||
41 | MODULE_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 */ |
46 | static int ca_set_slot_descr(void) | 58 | static 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,39 +214,32 @@ 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 | } |
@@ -268,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
268 | 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))) |
269 | return -EFAULT; | 254 | return -EFAULT; |
270 | 255 | ||
271 | |||
272 | if (p_ca_message->msg) { | 256 | if (p_ca_message->msg) { |
273 | 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]); |
274 | dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); | ||
275 | 258 | ||
276 | for (i = 0; i < 3; i++) { | 259 | for (i = 0; i < 3; i++) { |
277 | command = command | p_ca_message->msg[i]; | 260 | command = command | p_ca_message->msg[i]; |
278 | if (i < 2) | 261 | if (i < 2) |
279 | command = command << 8; | 262 | command = command << 8; |
280 | } | 263 | } |
281 | if (verbose > 3) | 264 | dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command); |
282 | dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); | ||
283 | 265 | ||
284 | switch (command) { | 266 | switch (command) { |
285 | case CA_APP_INFO: | 267 | case CA_APP_INFO: |
286 | memcpy(p_ca_message->msg, state->messages, 128); | 268 | memcpy(p_ca_message->msg, state->messages, 128); |
287 | 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)) ) |
288 | return -EFAULT; | 270 | return -EFAULT; |
289 | break; | 271 | break; |
290 | } | 272 | } |
291 | } | 273 | } |
@@ -300,10 +282,9 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, | |||
300 | hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ | 282 | hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ |
301 | } else { | 283 | } else { |
302 | if (length > 247) { | 284 | if (length > 247) { |
303 | dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__); | 285 | dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); |
304 | return -1; | 286 | return -1; |
305 | } | 287 | } |
306 | |||
307 | hw_buffer->msg[0] = (length & 0xff) + 7; | 288 | hw_buffer->msg[0] = (length & 0xff) + 7; |
308 | hw_buffer->msg[1] = 0x40; | 289 | hw_buffer->msg[1] = 0x40; |
309 | hw_buffer->msg[2] = 0x03; | 290 | hw_buffer->msg[2] = 0x03; |
@@ -324,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, | |||
324 | static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) | 305 | static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) |
325 | { | 306 | { |
326 | 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) { |
327 | dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); | 308 | dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); |
328 | dprintk("%s: Resetting DST.\n", __FUNCTION__); | 309 | dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); |
329 | rdc_reset_state(state); | 310 | rdc_reset_state(state); |
330 | return -1; | 311 | return -1; |
331 | } | 312 | } |
332 | if (verbose > 2) | 313 | dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes."); |
333 | dprintk("%s: DST-CI Command succes.\n", __FUNCTION__); | ||
334 | 314 | ||
335 | return 0; | 315 | return 0; |
336 | } | 316 | } |
@@ -341,15 +321,15 @@ u32 asn_1_decode(u8 *asn_1_array) | |||
341 | u32 length = 0; | 321 | u32 length = 0; |
342 | 322 | ||
343 | length_field = asn_1_array[0]; | 323 | length_field = asn_1_array[0]; |
344 | dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); | 324 | dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field); |
345 | if (length_field < 0x80) { | 325 | if (length_field < 0x80) { |
346 | length = length_field & 0x7f; | 326 | length = length_field & 0x7f; |
347 | dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); | 327 | dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length); |
348 | } else { | 328 | } else { |
349 | word_count = length_field & 0x7f; | 329 | word_count = length_field & 0x7f; |
350 | for (count = 0; count < word_count; count++) { | 330 | for (count = 0; count < word_count; count++) { |
351 | length = (length | asn_1_array[count + 1]) << 8; | 331 | length = (length | asn_1_array[count + 1]) << 8; |
352 | dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); | 332 | dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length); |
353 | } | 333 | } |
354 | } | 334 | } |
355 | return length; | 335 | return length; |
@@ -359,10 +339,10 @@ static int debug_string(u8 *msg, u32 length, u32 offset) | |||
359 | { | 339 | { |
360 | u32 i; | 340 | u32 i; |
361 | 341 | ||
362 | dprintk(" String=[ "); | 342 | dprintk(verbose, DST_CA_DEBUG, 0, " String=[ "); |
363 | for (i = offset; i < length; i++) | 343 | for (i = offset; i < length; i++) |
364 | dprintk("%02x ", msg[i]); | 344 | dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]); |
365 | dprintk("]\n"); | 345 | dprintk(verbose, DST_CA_DEBUG, 0, "]\n"); |
366 | 346 | ||
367 | return 0; | 347 | return 0; |
368 | } | 348 | } |
@@ -373,8 +353,7 @@ static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, stru | |||
373 | u8 tag_length = 8; | 353 | u8 tag_length = 8; |
374 | 354 | ||
375 | length = asn_1_decode(&p_ca_message->msg[3]); | 355 | length = asn_1_decode(&p_ca_message->msg[3]); |
376 | dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); | 356 | dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length); |
377 | dprintk("%s: ASN.1 ", __FUNCTION__); | ||
378 | debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ | 357 | debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ |
379 | 358 | ||
380 | memset(hw_buffer->msg, '\0', length); | 359 | memset(hw_buffer->msg, '\0', length); |
@@ -396,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message | |||
396 | /* Do test board */ | 375 | /* Do test board */ |
397 | /* Not there yet but soon */ | 376 | /* Not there yet but soon */ |
398 | 377 | ||
399 | |||
400 | /* CA PMT Reply capable */ | 378 | /* CA PMT Reply capable */ |
401 | if (ca_pmt_reply_test) { | 379 | if (ca_pmt_reply_test) { |
402 | 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) { |
403 | dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); | 381 | dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); |
404 | return -1; | 382 | return -1; |
405 | } | 383 | } |
406 | 384 | ||
407 | /* Process CA PMT Reply */ | 385 | /* Process CA PMT Reply */ |
408 | /* will implement soon */ | 386 | /* will implement soon */ |
409 | dprintk("%s: Not there yet\n", __FUNCTION__); | 387 | dprintk(verbose, DST_CA_ERROR, 1, " Not there yet"); |
410 | } | 388 | } |
411 | /* CA PMT Reply not capable */ | 389 | /* CA PMT Reply not capable */ |
412 | if (!ca_pmt_reply_test) { | 390 | if (!ca_pmt_reply_test) { |
413 | 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) { |
414 | dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); | 392 | dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); |
415 | return -1; | 393 | return -1; |
416 | } | 394 | } |
417 | if (verbose > 3) | 395 | dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); |
418 | dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__); | ||
419 | /* put a dummy message */ | 396 | /* put a dummy message */ |
420 | 397 | ||
421 | } | 398 | } |
@@ -431,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
431 | struct ca_msg *hw_buffer; | 408 | struct ca_msg *hw_buffer; |
432 | 409 | ||
433 | 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) { |
434 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 411 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
435 | return -ENOMEM; | 412 | return -ENOMEM; |
436 | } | 413 | } |
437 | if (verbose > 3) | 414 | dprintk(verbose, DST_CA_DEBUG, 1, " "); |
438 | dprintk("%s\n", __FUNCTION__); | ||
439 | 415 | ||
440 | 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))) |
441 | return -EFAULT; | 417 | return -EFAULT; |
@@ -450,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
450 | if (i < 2) | 426 | if (i < 2) |
451 | command = command << 8; | 427 | command = command << 8; |
452 | } | 428 | } |
453 | if (verbose > 3) | 429 | dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); |
454 | dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); | ||
455 | 430 | ||
456 | switch (command) { | 431 | switch (command) { |
457 | case CA_PMT: | 432 | case CA_PMT: |
458 | if (verbose > 3) | 433 | dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); |
459 | // dprintk("Command = SEND_CA_PMT\n"); | 434 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started |
460 | dprintk("Command = SEND_CA_PMT\n"); | 435 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); |
461 | // if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { | 436 | return -1; |
462 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started | 437 | } |
463 | dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); | 438 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); |
464 | return -1; | 439 | break; |
465 | } | 440 | case CA_PMT_REPLY: |
466 | if (verbose > 3) | 441 | dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); |
467 | dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); | 442 | /* Have to handle the 2 basic types of cards here */ |
468 | // 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) { |
469 | 444 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); | |
470 | break; | 445 | return -1; |
471 | 446 | } | |
472 | case CA_PMT_REPLY: | 447 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !"); |
473 | if (verbose > 3) | 448 | break; |
474 | dprintk("Command = CA_PMT_REPLY\n"); | 449 | case CA_APP_INFO_ENQUIRY: // only for debugging |
475 | /* Have to handle the 2 basic types of cards here */ | 450 | dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information"); |
476 | if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { | 451 | |
477 | dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); | 452 | if ((ca_get_app_info(state)) < 0) { |
478 | return -1; | 453 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !"); |
479 | } | 454 | return -1; |
480 | if (verbose > 3) | 455 | } |
481 | dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); | 456 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !"); |
482 | 457 | break; | |
483 | /* Certain boards do behave different ? */ | ||
484 | // retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1); | ||
485 | |||
486 | case CA_APP_INFO_ENQUIRY: // only for debugging | ||
487 | if (verbose > 3) | ||
488 | dprintk("%s: Getting Cam Application information\n", __FUNCTION__); | ||
489 | |||
490 | if ((ca_get_app_info(state)) < 0) { | ||
491 | dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__); | ||
492 | return -1; | ||
493 | } | ||
494 | if (verbose > 3) | ||
495 | dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); | ||
496 | |||
497 | break; | ||
498 | } | 458 | } |
499 | } | 459 | } |
500 | return 0; | 460 | return 0; |
@@ -509,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
509 | struct ca_msg *p_ca_message; | 469 | struct ca_msg *p_ca_message; |
510 | 470 | ||
511 | 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) { |
512 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 472 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
513 | return -ENOMEM; | 473 | return -ENOMEM; |
514 | } | 474 | } |
515 | |||
516 | 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) { |
517 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 476 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
518 | return -ENOMEM; | 477 | return -ENOMEM; |
519 | } | 478 | } |
520 | |||
521 | 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) { |
522 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 480 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
523 | return -ENOMEM; | 481 | return -ENOMEM; |
524 | } | 482 | } |
525 | |||
526 | /* 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. */ |
527 | switch (cmd) { | 484 | switch (cmd) { |
528 | case CA_SEND_MSG: | 485 | case CA_SEND_MSG: |
529 | if (verbose > 1) | 486 | dprintk(verbose, DST_CA_INFO, 1, " Sending message"); |
530 | dprintk("%s: Sending message\n", __FUNCTION__); | 487 | if ((ca_send_message(state, p_ca_message, arg)) < 0) { |
531 | if ((ca_send_message(state, p_ca_message, arg)) < 0) { | 488 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); |
532 | dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); | 489 | return -1; |
533 | return -1; | 490 | } |
534 | } | 491 | break; |
535 | 492 | case CA_GET_MSG: | |
536 | break; | 493 | dprintk(verbose, DST_CA_INFO, 1, " Getting message"); |
537 | 494 | if ((ca_get_message(state, p_ca_message, arg)) < 0) { | |
538 | case CA_GET_MSG: | 495 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); |
539 | if (verbose > 1) | 496 | return -1; |
540 | dprintk("%s: Getting message\n", __FUNCTION__); | 497 | } |
541 | if ((ca_get_message(state, p_ca_message, arg)) < 0) { | 498 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); |
542 | dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); | 499 | break; |
543 | return -1; | 500 | case CA_RESET: |
544 | } | 501 | dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST"); |
545 | if (verbose > 1) | 502 | dst_error_bailout(state); |
546 | dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); | 503 | msleep(4000); |
547 | 504 | break; | |
548 | break; | 505 | case CA_GET_SLOT_INFO: |
549 | 506 | dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); | |
550 | case CA_RESET: | 507 | if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { |
551 | if (verbose > 1) | 508 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); |
552 | dprintk("%s: Resetting DST\n", __FUNCTION__); | 509 | return -1; |
553 | dst_error_bailout(state); | 510 | } |
554 | msleep(4000); | 511 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !"); |
555 | 512 | break; | |
556 | break; | 513 | case CA_GET_CAP: |
557 | 514 | dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); | |
558 | case CA_GET_SLOT_INFO: | 515 | if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { |
559 | if (verbose > 1) | 516 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); |
560 | dprintk("%s: Getting Slot info\n", __FUNCTION__); | 517 | return -1; |
561 | if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { | 518 | } |
562 | dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); | 519 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); |
563 | return -1; | 520 | break; |
564 | } | 521 | case CA_GET_DESCR_INFO: |
565 | if (verbose > 1) | 522 | dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); |
566 | dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); | 523 | if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { |
567 | 524 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); | |
568 | break; | 525 | return -1; |
569 | 526 | } | |
570 | case CA_GET_CAP: | 527 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); |
571 | if (verbose > 1) | 528 | break; |
572 | dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); | 529 | case CA_SET_DESCR: |
573 | if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { | 530 | dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler"); |
574 | dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); | 531 | if ((ca_set_slot_descr()) < 0) { |
575 | return -1; | 532 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !"); |
576 | } | 533 | return -1; |
577 | if (verbose > 1) | 534 | } |
578 | dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); | 535 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !"); |
579 | 536 | break; | |
580 | break; | 537 | case CA_SET_PID: |
581 | 538 | dprintk(verbose, DST_CA_INFO, 1, " Setting PID"); | |
582 | case CA_GET_DESCR_INFO: | 539 | if ((ca_set_pid()) < 0) { |
583 | if (verbose > 1) | 540 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !"); |
584 | dprintk("%s: Getting descrambler description\n", __FUNCTION__); | 541 | return -1; |
585 | if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { | 542 | } |
586 | dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); | 543 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !"); |
587 | return -1; | 544 | default: |
588 | } | 545 | return -EOPNOTSUPP; |
589 | if (verbose > 1) | 546 | }; |
590 | dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__); | ||
591 | |||
592 | break; | ||
593 | |||
594 | case CA_SET_DESCR: | ||
595 | if (verbose > 1) | ||
596 | dprintk("%s: Setting descrambler\n", __FUNCTION__); | ||
597 | if ((ca_set_slot_descr()) < 0) { | ||
598 | dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__); | ||
599 | return -1; | ||
600 | } | ||
601 | if (verbose > 1) | ||
602 | dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__); | ||
603 | |||
604 | break; | ||
605 | |||
606 | case CA_SET_PID: | ||
607 | if (verbose > 1) | ||
608 | dprintk("%s: Setting PID\n", __FUNCTION__); | ||
609 | if ((ca_set_pid()) < 0) { | ||
610 | dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__); | ||
611 | return -1; | ||
612 | } | ||
613 | if (verbose > 1) | ||
614 | dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__); | ||
615 | |||
616 | default: | ||
617 | return -EOPNOTSUPP; | ||
618 | }; | ||
619 | 547 | ||
620 | return 0; | 548 | return 0; |
621 | } | 549 | } |
622 | 550 | ||
623 | static int dst_ca_open(struct inode *inode, struct file *file) | 551 | static int dst_ca_open(struct inode *inode, struct file *file) |
624 | { | 552 | { |
625 | if (verbose > 4) | 553 | dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file); |
626 | dprintk("%s:Device opened [%p]\n", __FUNCTION__, file); | ||
627 | try_module_get(THIS_MODULE); | 554 | try_module_get(THIS_MODULE); |
628 | 555 | ||
629 | return 0; | 556 | return 0; |
@@ -631,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file) | |||
631 | 558 | ||
632 | static int dst_ca_release(struct inode *inode, struct file *file) | 559 | static int dst_ca_release(struct inode *inode, struct file *file) |
633 | { | 560 | { |
634 | if (verbose > 4) | 561 | dprintk(verbose, DST_CA_DEBUG, 1, " Device closed."); |
635 | dprintk("%s:Device closed.\n", __FUNCTION__); | ||
636 | module_put(THIS_MODULE); | 562 | module_put(THIS_MODULE); |
637 | 563 | ||
638 | return 0; | 564 | return 0; |
639 | } | 565 | } |
640 | 566 | ||
641 | static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) | 567 | static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) |
642 | { | 568 | { |
643 | int bytes_read = 0; | 569 | int bytes_read = 0; |
644 | 570 | ||
645 | if (verbose > 4) | 571 | dprintk(verbose, DST_CA_DEBUG, 1, " Device read."); |
646 | dprintk("%s:Device read.\n", __FUNCTION__); | ||
647 | 572 | ||
648 | return bytes_read; | 573 | return bytes_read; |
649 | } | 574 | } |
650 | 575 | ||
651 | static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) | 576 | static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) |
652 | { | 577 | { |
653 | if (verbose > 4) | 578 | dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); |
654 | dprintk("%s:Device write.\n", __FUNCTION__); | ||
655 | 579 | ||
656 | return 0; | 580 | return 0; |
657 | } | 581 | } |
@@ -676,8 +600,7 @@ static struct dvb_device dvbdev_ca = { | |||
676 | int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) | 600 | int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) |
677 | { | 601 | { |
678 | struct dvb_device *dvbdev; | 602 | struct dvb_device *dvbdev; |
679 | if (verbose > 4) | 603 | dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); |
680 | dprintk("%s:registering DST-CA device\n", __FUNCTION__); | ||
681 | 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); |
682 | return 0; | 605 | return 0; |
683 | } | 606 | } |
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index ef532a6aceaa..c0ee0b197bb8 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 |
@@ -124,15 +123,12 @@ struct dst_types { | |||
124 | u32 dst_feature; | 123 | u32 dst_feature; |
125 | }; | 124 | }; |
126 | 125 | ||
127 | |||
128 | |||
129 | struct dst_config | 126 | struct dst_config |
130 | { | 127 | { |
131 | /* the ASIC i2c address */ | 128 | /* the ASIC i2c address */ |
132 | u8 demod_address; | 129 | u8 demod_address; |
133 | }; | 130 | }; |
134 | 131 | ||
135 | |||
136 | int rdc_reset_state(struct dst_state *state); | 132 | int rdc_reset_state(struct dst_state *state); |
137 | int rdc_8820_reset(struct dst_state *state); | 133 | int rdc_8820_reset(struct dst_state *state); |
138 | 134 | ||