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/dvb/bt8xx/dst_ca.c | |
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/dvb/bt8xx/dst_ca.c')
-rw-r--r-- | drivers/media/dvb/bt8xx/dst_ca.c | 443 |
1 files changed, 183 insertions, 260 deletions
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 | } |