1 /* $Id: hycapi.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $
3 * Linux driver for HYSDN cards, CAPI2.0-Interface.
5 * Author Ulrich Albrecht <u.albrecht@hypercope.de> for Hypercope GmbH
6 * Copyright 2000 by Hypercope GmbH
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
13 #include <linux/module.h>
14 #include <linux/version.h>
15 #include <linux/signal.h>
16 #include <linux/kernel.h>
17 #include <linux/skbuff.h>
18 #include <linux/netdevice.h>
21 #define VER_CARDTYPE 1
29 #include "hysdn_defs.h"
30 #include <linux/kernelcapi.h>
32 static char hycapi_revision
[]="$Revision: 1.8.6.4 $";
34 unsigned int hycapi_enable
= 0xffffffff;
35 MODULE_PARM(hycapi_enable
, "i");
37 typedef struct _hycapi_appl
{
38 unsigned int ctrl_mask
;
39 capi_register_params rp
;
40 struct sk_buff
*listen_req
[CAPI_MAXCONTR
];
43 static hycapi_appl hycapi_applications
[CAPI_MAXAPPL
];
45 static u16
hycapi_send_message(struct capi_ctr
*ctrl
, struct sk_buff
*skb
);
47 static inline int _hycapi_appCheck(int app_id
, int ctrl_no
)
49 if((ctrl_no
<= 0) || (ctrl_no
> CAPI_MAXCONTR
) || (app_id
<= 0) ||
50 (app_id
> CAPI_MAXAPPL
))
52 printk(KERN_ERR
"HYCAPI: Invalid request app_id %d for controller %d", app_id
, ctrl_no
);
55 return ((hycapi_applications
[app_id
-1].ctrl_mask
& (1 << (ctrl_no
-1))) != 0);
58 /******************************
59 Kernel-Capi callback reset_ctr
60 ******************************/
63 hycapi_reset_ctr(struct capi_ctr
*ctrl
)
65 hycapictrl_info
*cinfo
= ctrl
->driverdata
;
67 #ifdef HYCAPI_PRINTFNAMES
68 printk(KERN_NOTICE
"HYCAPI hycapi_reset_ctr\n");
70 capilib_release(&cinfo
->ncci_head
);
71 capi_ctr_reseted(ctrl
);
74 /******************************
75 Kernel-Capi callback remove_ctr
76 ******************************/
79 hycapi_remove_ctr(struct capi_ctr
*ctrl
)
82 hycapictrl_info
*cinfo
= NULL
;
83 hysdn_card
*card
= NULL
;
84 #ifdef HYCAPI_PRINTFNAMES
85 printk(KERN_NOTICE
"HYCAPI hycapi_remove_ctr\n");
87 cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
89 printk(KERN_ERR
"No hycapictrl_info set!");
93 capi_ctr_suspend_output(ctrl
);
94 for(i
=0; i
<CAPI_MAXAPPL
;i
++) {
95 if(hycapi_applications
[i
].listen_req
[ctrl
->cnr
-1]) {
96 kfree_skb(hycapi_applications
[i
].listen_req
[ctrl
->cnr
-1]);
97 hycapi_applications
[i
].listen_req
[ctrl
->cnr
-1] = NULL
;
100 detach_capi_ctr(ctrl
);
101 ctrl
->driverdata
= NULL
;
102 kfree(card
->hyctrlinfo
);
105 card
->hyctrlinfo
= NULL
;
108 /***********************************************************
110 Queue a CAPI-message to the controller.
112 ***********************************************************/
115 hycapi_sendmsg_internal(struct capi_ctr
*ctrl
, struct sk_buff
*skb
)
117 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
118 hysdn_card
*card
= cinfo
->card
;
120 spin_lock_irq(&cinfo
->lock
);
121 #ifdef HYCAPI_PRINTFNAMES
122 printk(KERN_NOTICE
"hycapi_send_message\n");
124 cinfo
->skbs
[cinfo
->in_idx
++] = skb
; /* add to buffer list */
125 if (cinfo
->in_idx
>= HYSDN_MAX_CAPI_SKB
)
126 cinfo
->in_idx
= 0; /* wrap around */
127 cinfo
->sk_count
++; /* adjust counter */
128 if (cinfo
->sk_count
>= HYSDN_MAX_CAPI_SKB
) {
129 /* inform upper layers we're full */
130 printk(KERN_ERR
"HYSDN Card%d: CAPI-buffer overrun!\n",
132 capi_ctr_suspend_output(ctrl
);
135 spin_unlock_irq(&cinfo
->lock
);
136 schedule_work(&card
->irq_queue
);
139 /***********************************************************
140 hycapi_register_internal
142 Send down the CAPI_REGISTER-Command to the controller.
143 This functions will also be used if the adapter has been rebooted to
144 re-register any applications in the private list.
146 ************************************************************/
149 hycapi_register_internal(struct capi_ctr
*ctrl
, __u16 appl
,
150 capi_register_params
*rp
)
152 char ExtFeatureDefaults
[] = "49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*";
153 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
154 hysdn_card
*card
= cinfo
->card
;
157 __u8 _command
= 0xa0, _subcommand
= 0x80;
158 __u16 MessageNumber
= 0x0000;
159 __u16 MessageBufferSize
= 0;
160 int slen
= strlen(ExtFeatureDefaults
);
161 #ifdef HYCAPI_PRINTFNAMES
162 printk(KERN_NOTICE
"hycapi_register_appl\n");
164 MessageBufferSize
= rp
->level3cnt
* rp
->datablkcnt
* rp
->datablklen
;
166 len
= CAPI_MSG_BASELEN
+ 8 + slen
+ 1;
167 if (!(skb
= alloc_skb(len
, GFP_ATOMIC
))) {
168 printk(KERN_ERR
"HYSDN card%d: memory squeeze in hycapi_register_appl\n",
172 memcpy(skb_put(skb
,sizeof(__u16
)), &len
, sizeof(__u16
));
173 memcpy(skb_put(skb
,sizeof(__u16
)), &appl
, sizeof(__u16
));
174 memcpy(skb_put(skb
,sizeof(__u8
)), &_command
, sizeof(_command
));
175 memcpy(skb_put(skb
,sizeof(__u8
)), &_subcommand
, sizeof(_subcommand
));
176 memcpy(skb_put(skb
,sizeof(__u16
)), &MessageNumber
, sizeof(__u16
));
177 memcpy(skb_put(skb
,sizeof(__u16
)), &MessageBufferSize
, sizeof(__u16
));
178 memcpy(skb_put(skb
,sizeof(__u16
)), &(rp
->level3cnt
), sizeof(__u16
));
179 memcpy(skb_put(skb
,sizeof(__u16
)), &(rp
->datablkcnt
), sizeof(__u16
));
180 memcpy(skb_put(skb
,sizeof(__u16
)), &(rp
->datablklen
), sizeof(__u16
));
181 memcpy(skb_put(skb
,slen
), ExtFeatureDefaults
, slen
);
182 hycapi_applications
[appl
-1].ctrl_mask
|= (1 << (ctrl
->cnr
-1));
183 hycapi_send_message(ctrl
, skb
);
186 /************************************************************
187 hycapi_restart_internal
189 After an adapter has been rebootet, re-register all applications and
190 send a LISTEN_REQ (if there has been such a thing )
192 *************************************************************/
194 static void hycapi_restart_internal(struct capi_ctr
*ctrl
)
198 #ifdef HYCAPI_PRINTFNAMES
199 printk(KERN_WARNING
"HYSDN: hycapi_restart_internal");
201 for(i
=0; i
<CAPI_MAXAPPL
; i
++) {
202 if(_hycapi_appCheck(i
+1, ctrl
->cnr
) == 1) {
203 hycapi_register_internal(ctrl
, i
+1,
204 &hycapi_applications
[i
].rp
);
205 if(hycapi_applications
[i
].listen_req
[ctrl
->cnr
-1]) {
206 skb
= skb_copy(hycapi_applications
[i
].listen_req
[ctrl
->cnr
-1], GFP_ATOMIC
);
207 hycapi_sendmsg_internal(ctrl
, skb
);
213 /*************************************************************
214 Register an application.
215 Error-checking is done for CAPI-compliance.
217 The application is recorded in the internal list.
218 *************************************************************/
221 hycapi_register_appl(struct capi_ctr
*ctrl
, __u16 appl
,
222 capi_register_params
*rp
)
224 int MaxLogicalConnections
= 0, MaxBDataBlocks
= 0, MaxBDataLen
= 0;
225 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
226 hysdn_card
*card
= cinfo
->card
;
227 int chk
= _hycapi_appCheck(appl
, ctrl
->cnr
);
232 printk(KERN_INFO
"HYSDN: apl %d already registered\n", appl
);
235 MaxBDataBlocks
= rp
->datablkcnt
> CAPI_MAXDATAWINDOW
? CAPI_MAXDATAWINDOW
: rp
->datablkcnt
;
236 rp
->datablkcnt
= MaxBDataBlocks
;
237 MaxBDataLen
= rp
->datablklen
< 1024 ? 1024 : rp
->datablklen
;
238 rp
->datablklen
= MaxBDataLen
;
240 MaxLogicalConnections
= rp
->level3cnt
;
241 if (MaxLogicalConnections
< 0) {
242 MaxLogicalConnections
= card
->bchans
* -MaxLogicalConnections
;
244 if (MaxLogicalConnections
== 0) {
245 MaxLogicalConnections
= card
->bchans
;
248 rp
->level3cnt
= MaxLogicalConnections
;
249 memcpy(&hycapi_applications
[appl
-1].rp
,
250 rp
, sizeof(capi_register_params
));
253 /*********************************************************************
255 hycapi_release_internal
257 Send down a CAPI_RELEASE to the controller.
258 *********************************************************************/
260 static void hycapi_release_internal(struct capi_ctr
*ctrl
, __u16 appl
)
262 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
263 hysdn_card
*card
= cinfo
->card
;
266 __u8 _command
= 0xa1, _subcommand
= 0x80;
267 __u16 MessageNumber
= 0x0000;
269 capilib_release_appl(&cinfo
->ncci_head
, appl
);
271 #ifdef HYCAPI_PRINTFNAMES
272 printk(KERN_NOTICE
"hycapi_release_appl\n");
274 len
= CAPI_MSG_BASELEN
;
275 if (!(skb
= alloc_skb(len
, GFP_ATOMIC
))) {
276 printk(KERN_ERR
"HYSDN card%d: memory squeeze in hycapi_register_appl\n",
280 memcpy(skb_put(skb
,sizeof(__u16
)), &len
, sizeof(__u16
));
281 memcpy(skb_put(skb
,sizeof(__u16
)), &appl
, sizeof(__u16
));
282 memcpy(skb_put(skb
,sizeof(__u8
)), &_command
, sizeof(_command
));
283 memcpy(skb_put(skb
,sizeof(__u8
)), &_subcommand
, sizeof(_subcommand
));
284 memcpy(skb_put(skb
,sizeof(__u16
)), &MessageNumber
, sizeof(__u16
));
285 hycapi_send_message(ctrl
, skb
);
286 hycapi_applications
[appl
-1].ctrl_mask
&= ~(1 << (ctrl
->cnr
-1));
289 /******************************************************************
292 Release the application from the internal list an remove it's
293 registration at controller-level
294 ******************************************************************/
297 hycapi_release_appl(struct capi_ctr
*ctrl
, __u16 appl
)
301 chk
= _hycapi_appCheck(appl
, ctrl
->cnr
);
303 printk(KERN_ERR
"HYCAPI: Releasing invalid appl %d on controller %d\n", appl
, ctrl
->cnr
);
306 if(hycapi_applications
[appl
-1].listen_req
[ctrl
->cnr
-1]) {
307 kfree_skb(hycapi_applications
[appl
-1].listen_req
[ctrl
->cnr
-1]);
308 hycapi_applications
[appl
-1].listen_req
[ctrl
->cnr
-1] = NULL
;
312 hycapi_release_internal(ctrl
, appl
);
317 /**************************************************************
318 Kill a single controller.
319 **************************************************************/
321 int hycapi_capi_release(hysdn_card
*card
)
323 hycapictrl_info
*cinfo
= card
->hyctrlinfo
;
324 struct capi_ctr
*ctrl
;
325 #ifdef HYCAPI_PRINTFNAMES
326 printk(KERN_NOTICE
"hycapi_capi_release\n");
329 ctrl
= &cinfo
->capi_ctrl
;
330 hycapi_remove_ctr(ctrl
);
335 /**************************************************************
338 Stop CAPI-Output on a card. (e.g. during reboot)
339 ***************************************************************/
341 int hycapi_capi_stop(hysdn_card
*card
)
343 hycapictrl_info
*cinfo
= card
->hyctrlinfo
;
344 struct capi_ctr
*ctrl
;
345 #ifdef HYCAPI_PRINTFNAMES
346 printk(KERN_NOTICE
"hycapi_capi_stop\n");
349 ctrl
= &cinfo
->capi_ctrl
;
350 /* ctrl->suspend_output(ctrl); */
351 capi_ctr_reseted(ctrl
);
356 /***************************************************************
359 Send a message to the controller.
361 Messages are parsed for their Command/Subcommand-type, and appropriate
362 action's are performed.
364 Note that we have to muck around with a 64Bit-DATA_REQ as there are
365 firmware-releases that do not check the MsgLen-Indication!
367 ***************************************************************/
369 static u16
hycapi_send_message(struct capi_ctr
*ctrl
, struct sk_buff
*skb
)
374 hycapictrl_info
*cinfo
= ctrl
->driverdata
;
375 u16 retval
= CAPI_NOERROR
;
377 appl_id
= CAPIMSG_APPID(skb
->data
);
378 switch(_hycapi_appCheck(appl_id
, ctrl
->cnr
))
381 /* printk(KERN_INFO "Need to register\n"); */
382 hycapi_register_internal(ctrl
,
384 &(hycapi_applications
[appl_id
-1].rp
));
389 printk(KERN_ERR
"HYCAPI: Controller mixup!\n");
390 retval
= CAPI_ILLAPPNR
;
393 switch(CAPIMSG_CMD(skb
->data
)) {
394 case CAPI_DISCONNECT_B3_RESP
:
395 capilib_free_ncci(&cinfo
->ncci_head
, appl_id
,
396 CAPIMSG_NCCI(skb
->data
));
398 case CAPI_DATA_B3_REQ
:
399 _len
= CAPIMSG_LEN(skb
->data
);
402 memcpy(msghead
, skb
->data
, 22);
403 memcpy(skb
->data
+ _len2
, msghead
, 22);
404 skb_pull(skb
, _len2
);
405 CAPIMSG_SETLEN(skb
->data
, 22);
406 retval
= capilib_data_b3_req(&cinfo
->ncci_head
,
407 CAPIMSG_APPID(skb
->data
),
408 CAPIMSG_NCCI(skb
->data
),
409 CAPIMSG_MSGID(skb
->data
));
412 case CAPI_LISTEN_REQ
:
413 if(hycapi_applications
[appl_id
-1].listen_req
[ctrl
->cnr
-1])
415 kfree_skb(hycapi_applications
[appl_id
-1].listen_req
[ctrl
->cnr
-1]);
416 hycapi_applications
[appl_id
-1].listen_req
[ctrl
->cnr
-1] = NULL
;
418 if (!(hycapi_applications
[appl_id
-1].listen_req
[ctrl
->cnr
-1] = skb_copy(skb
, GFP_ATOMIC
)))
420 printk(KERN_ERR
"HYSDN: memory squeeze in private_listen\n");
427 if (retval
== CAPI_NOERROR
)
428 hycapi_sendmsg_internal(ctrl
, skb
);
430 dev_kfree_skb_any(skb
);
435 /*********************************************************************
438 Informations provided in the /proc/capi-entries.
440 *********************************************************************/
442 static int hycapi_read_proc(char *page
, char **start
, off_t off
,
443 int count
, int *eof
, struct capi_ctr
*ctrl
)
445 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
446 hysdn_card
*card
= cinfo
->card
;
449 #ifdef HYCAPI_PRINTFNAMES
450 printk(KERN_NOTICE
"hycapi_read_proc\n");
452 len
+= sprintf(page
+len
, "%-16s %s\n", "name", cinfo
->cardname
);
453 len
+= sprintf(page
+len
, "%-16s 0x%x\n", "io", card
->iobase
);
454 len
+= sprintf(page
+len
, "%-16s %d\n", "irq", card
->irq
);
456 switch (card
->brdtype
) {
457 case BD_PCCARD
: s
= "HYSDN Hycard"; break;
458 case BD_ERGO
: s
= "HYSDN Ergo2"; break;
459 case BD_METRO
: s
= "HYSDN Metro4"; break;
460 case BD_CHAMP2
: s
= "HYSDN Champ2"; break;
461 case BD_PLEXUS
: s
= "HYSDN Plexus30"; break;
462 default: s
= "???"; break;
464 len
+= sprintf(page
+len
, "%-16s %s\n", "type", s
);
465 if ((s
= cinfo
->version
[VER_DRIVER
]) != 0)
466 len
+= sprintf(page
+len
, "%-16s %s\n", "ver_driver", s
);
467 if ((s
= cinfo
->version
[VER_CARDTYPE
]) != 0)
468 len
+= sprintf(page
+len
, "%-16s %s\n", "ver_cardtype", s
);
469 if ((s
= cinfo
->version
[VER_SERIAL
]) != 0)
470 len
+= sprintf(page
+len
, "%-16s %s\n", "ver_serial", s
);
472 len
+= sprintf(page
+len
, "%-16s %s\n", "cardname", cinfo
->cardname
);
474 if (off
+count
>= len
)
479 return ((count
< len
-off
) ? count
: len
-off
);
482 /**************************************************************
485 This does NOT load any firmware, but the callback somehow is needed
486 on capi-interface registration.
488 **************************************************************/
490 static int hycapi_load_firmware(struct capi_ctr
*ctrl
, capiloaddata
*data
)
492 #ifdef HYCAPI_PRINTFNAMES
493 printk(KERN_NOTICE
"hycapi_load_firmware\n");
499 static char *hycapi_procinfo(struct capi_ctr
*ctrl
)
501 hycapictrl_info
*cinfo
= (hycapictrl_info
*)(ctrl
->driverdata
);
502 #ifdef HYCAPI_PRINTFNAMES
503 printk(KERN_NOTICE
"hycapi_proc_info\n");
507 sprintf(cinfo
->infobuf
, "%s %s 0x%x %d %s",
508 cinfo
->cardname
[0] ? cinfo
->cardname
: "-",
509 cinfo
->version
[VER_DRIVER
] ? cinfo
->version
[VER_DRIVER
] : "-",
510 cinfo
->card
? cinfo
->card
->iobase
: 0x0,
511 cinfo
->card
? cinfo
->card
->irq
: 0,
514 return cinfo
->infobuf
;
517 /******************************************************************
520 Receive a capi-message.
522 All B3_DATA_IND are converted to 64K-extension compatible format.
523 New nccis are created if necessary.
524 *******************************************************************/
527 hycapi_rx_capipkt(hysdn_card
* card
, uchar
* buf
, word len
)
530 hycapictrl_info
*cinfo
= card
->hyctrlinfo
;
531 struct capi_ctr
*ctrl
;
535 __u32 CP64
[2] = {0,0};
536 #ifdef HYCAPI_PRINTFNAMES
537 printk(KERN_NOTICE
"hycapi_rx_capipkt\n");
542 ctrl
= &cinfo
->capi_ctrl
;
543 if(len
< CAPI_MSG_BASELEN
) {
544 printk(KERN_ERR
"HYSDN Card%d: invalid CAPI-message, lenght %d!\n",
548 MsgLen
= CAPIMSG_LEN(buf
);
549 ApplId
= CAPIMSG_APPID(buf
);
550 CapiCmd
= CAPIMSG_CMD(buf
);
552 if((CapiCmd
== CAPI_DATA_B3_IND
) && (MsgLen
< 30)) {
553 len2
= len
+ (30 - MsgLen
);
554 if (!(skb
= alloc_skb(len2
, GFP_ATOMIC
))) {
555 printk(KERN_ERR
"HYSDN Card%d: incoming packet dropped\n",
559 memcpy(skb_put(skb
, MsgLen
), buf
, MsgLen
);
560 memcpy(skb_put(skb
, 2*sizeof(__u32
)), CP64
, 2* sizeof(__u32
));
561 memcpy(skb_put(skb
, len
- MsgLen
), buf
+ MsgLen
,
563 CAPIMSG_SETLEN(skb
->data
, 30);
565 if (!(skb
= alloc_skb(len
, GFP_ATOMIC
))) {
566 printk(KERN_ERR
"HYSDN Card%d: incoming packet dropped\n",
570 memcpy(skb_put(skb
, len
), buf
, len
);
572 switch(CAPIMSG_CMD(skb
->data
))
574 case CAPI_CONNECT_B3_CONF
:
575 /* Check info-field for error-indication: */
576 info
= CAPIMSG_U16(skb
->data
, 12);
580 capilib_new_ncci(&cinfo
->ncci_head
, ApplId
, CAPIMSG_NCCI(skb
->data
),
581 hycapi_applications
[ApplId
-1].rp
.datablkcnt
);
585 printk(KERN_ERR
"HYSDN Card%d: NCPI not supported by current "
586 "protocol. NCPI ignored.\n", card
->myid
);
589 printk(KERN_ERR
"HYSDN Card%d: Message not supported in"
590 " current state\n", card
->myid
);
593 printk(KERN_ERR
"HYSDN Card%d: invalid PLCI\n", card
->myid
);
596 printk(KERN_ERR
"HYSDN Card%d: out of NCCI\n", card
->myid
);
599 printk(KERN_ERR
"HYSDN Card%d: NCPI not supported\n",
603 printk(KERN_ERR
"HYSDN Card%d: Info in CONNECT_B3_CONF: %d\n",
608 case CAPI_CONNECT_B3_IND
:
609 capilib_new_ncci(&cinfo
->ncci_head
, ApplId
,
610 CAPIMSG_NCCI(skb
->data
),
611 hycapi_applications
[ApplId
-1].rp
.datablkcnt
);
613 case CAPI_DATA_B3_CONF
:
614 capilib_data_b3_conf(&cinfo
->ncci_head
, ApplId
,
615 CAPIMSG_NCCI(skb
->data
),
616 CAPIMSG_MSGID(skb
->data
));
621 capi_ctr_handle_message(ctrl
, ApplId
, skb
);
624 /******************************************************************
627 Internally acknowledge a msg sent. This will remove the msg from the
630 *******************************************************************/
632 void hycapi_tx_capiack(hysdn_card
* card
)
634 hycapictrl_info
*cinfo
= card
->hyctrlinfo
;
635 #ifdef HYCAPI_PRINTFNAMES
636 printk(KERN_NOTICE
"hycapi_tx_capiack\n");
641 spin_lock_irq(&cinfo
->lock
);
642 kfree_skb(cinfo
->skbs
[cinfo
->out_idx
]); /* free skb */
643 cinfo
->skbs
[cinfo
->out_idx
++] = NULL
;
644 if (cinfo
->out_idx
>= HYSDN_MAX_CAPI_SKB
)
645 cinfo
->out_idx
= 0; /* wrap around */
647 if (cinfo
->sk_count
-- == HYSDN_MAX_CAPI_SKB
) /* dec usage count */
648 capi_ctr_resume_output(&cinfo
->capi_ctrl
);
649 spin_unlock_irq(&cinfo
->lock
);
652 /***************************************************************
653 hycapi_tx_capiget(hysdn_card *card)
655 This is called when polling for messages to SEND.
657 ****************************************************************/
660 hycapi_tx_capiget(hysdn_card
*card
)
662 hycapictrl_info
*cinfo
= card
->hyctrlinfo
;
664 return (struct sk_buff
*)NULL
;
666 if (!cinfo
->sk_count
)
667 return (struct sk_buff
*)NULL
; /* nothing available */
669 return (cinfo
->skbs
[cinfo
->out_idx
]); /* next packet to send */
673 /**********************************************************
676 attach the capi-driver to the kernel-capi.
678 ***********************************************************/
680 int hycapi_init(void)
683 for(i
=0;i
<CAPI_MAXAPPL
;i
++) {
684 memset(&(hycapi_applications
[i
]), 0, sizeof(hycapi_appl
));
689 /**************************************************************
692 detach the capi-driver to the kernel-capi. Actually this should
693 free some more ressources. Do that later.
694 **************************************************************/
701 /********************************************************************
702 hycapi_capi_create(hysdn_card *card)
704 Attach the card with its capi-ctrl.
705 *********************************************************************/
707 static void hycapi_fill_profile(hysdn_card
*card
)
709 hycapictrl_info
*cinfo
= NULL
;
710 struct capi_ctr
*ctrl
= NULL
;
711 cinfo
= card
->hyctrlinfo
;
713 ctrl
= &cinfo
->capi_ctrl
;
714 strcpy(ctrl
->manu
, "Hypercope");
715 ctrl
->version
.majorversion
= 2;
716 ctrl
->version
.minorversion
= 0;
717 ctrl
->version
.majormanuversion
= 3;
718 ctrl
->version
.minormanuversion
= 2;
719 ctrl
->profile
.ncontroller
= card
->myid
;
720 ctrl
->profile
.nbchannel
= card
->bchans
;
721 ctrl
->profile
.goptions
= GLOBAL_OPTION_INTERNAL_CONTROLLER
|
722 GLOBAL_OPTION_B_CHANNEL_OPERATION
;
723 ctrl
->profile
.support1
= B1_PROT_64KBIT_HDLC
|
724 (card
->faxchans
? B1_PROT_T30
: 0) |
725 B1_PROT_64KBIT_TRANSPARENT
;
726 ctrl
->profile
.support2
= B2_PROT_ISO7776
|
727 (card
->faxchans
? B2_PROT_T30
: 0) |
729 ctrl
->profile
.support3
= B3_PROT_TRANSPARENT
|
731 (card
->faxchans
? B3_PROT_T30
: 0) |
732 (card
->faxchans
? B3_PROT_T30EXT
: 0) |
737 hycapi_capi_create(hysdn_card
*card
)
739 hycapictrl_info
*cinfo
= NULL
;
740 struct capi_ctr
*ctrl
= NULL
;
742 #ifdef HYCAPI_PRINTFNAMES
743 printk(KERN_NOTICE
"hycapi_capi_create\n");
745 if((hycapi_enable
& (1 << card
->myid
)) == 0) {
748 if (!card
->hyctrlinfo
) {
749 cinfo
= (hycapictrl_info
*) kmalloc(sizeof(hycapictrl_info
), GFP_ATOMIC
);
751 printk(KERN_WARNING
"HYSDN: no memory for capi-ctrl.\n");
754 memset(cinfo
, 0, sizeof(hycapictrl_info
));
755 card
->hyctrlinfo
= cinfo
;
757 spin_lock_init(&cinfo
->lock
);
758 INIT_LIST_HEAD(&cinfo
->ncci_head
);
760 switch (card
->brdtype
) {
761 case BD_PCCARD
: strcpy(cinfo
->cardname
,"HYSDN Hycard"); break;
762 case BD_ERGO
: strcpy(cinfo
->cardname
,"HYSDN Ergo2"); break;
763 case BD_METRO
: strcpy(cinfo
->cardname
,"HYSDN Metro4"); break;
764 case BD_CHAMP2
: strcpy(cinfo
->cardname
,"HYSDN Champ2"); break;
765 case BD_PLEXUS
: strcpy(cinfo
->cardname
,"HYSDN Plexus30"); break;
766 default: strcpy(cinfo
->cardname
,"HYSDN ???"); break;
769 ctrl
= &cinfo
->capi_ctrl
;
770 ctrl
->driver_name
= "hycapi";
771 ctrl
->driverdata
= cinfo
;
772 ctrl
->register_appl
= hycapi_register_appl
;
773 ctrl
->release_appl
= hycapi_release_appl
;
774 ctrl
->send_message
= hycapi_send_message
;
775 ctrl
->load_firmware
= hycapi_load_firmware
;
776 ctrl
->reset_ctr
= hycapi_reset_ctr
;
777 ctrl
->procinfo
= hycapi_procinfo
;
778 ctrl
->ctr_read_proc
= hycapi_read_proc
;
779 strcpy(ctrl
->name
, cinfo
->cardname
);
780 ctrl
->owner
= THIS_MODULE
;
782 retval
= attach_capi_ctr(ctrl
);
784 printk(KERN_ERR
"hycapi: attach controller failed.\n");
787 /* fill in the blanks: */
788 hycapi_fill_profile(card
);
789 capi_ctr_ready(ctrl
);
791 /* resume output on stopped ctrl */
792 ctrl
= &card
->hyctrlinfo
->capi_ctrl
;
793 hycapi_fill_profile(card
);
794 capi_ctr_ready(ctrl
);
795 hycapi_restart_internal(ctrl
);
796 /* ctrl->resume_output(ctrl); */