1 /* $Id: hycapi.c,v 1.1.1.1 2005/04/11 02:50:24 jack 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>
21 #define VER_CARDTYPE 1
29 #include "hysdn_defs.h"
30 #include <linux/kernelcapi.h>
32 static char hycapi_revision[]="$Revision: 1.1.1.1 $";
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 inline int _hycapi_appCheck(int app_id, int ctrl_no)
47 if((ctrl_no <= 0) || (ctrl_no > CAPI_MAXCONTR) || (app_id <= 0) ||
48 (app_id > CAPI_MAXAPPL))
50 printk(KERN_ERR "HYCAPI: Invalid request app_id %d for controller %d", app_id, ctrl_no);
53 return ((hycapi_applications[app_id-1].ctrl_mask & (1 << (ctrl_no-1))) != 0);
56 struct capi_driver_interface *hy_di = NULL;
58 /******************************
59 Kernel-Capi callback reset_ctr
60 ******************************/
63 hycapi_reset_ctr(struct capi_ctr *ctrl)
65 #ifdef HYCAPI_PRINTFNAMES
66 printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
71 /******************************
72 Kernel-Capi callback remove_ctr
73 ******************************/
76 hycapi_remove_ctr(struct capi_ctr *ctrl)
79 hycapictrl_info *cinfo = NULL;
80 hysdn_card *card = NULL;
81 #ifdef HYCAPI_PRINTFNAMES
82 printk(KERN_NOTICE "HYCAPI hycapi_remove_ctr\n");
85 printk(KERN_ERR "No capi_driver_interface set!");
88 cinfo = (hycapictrl_info *)(ctrl->driverdata);
90 printk(KERN_ERR "No hycapictrl_info set!");
94 ctrl->suspend_output(ctrl);
95 for(i=0; i<CAPI_MAXAPPL;i++) {
96 if(hycapi_applications[i].listen_req[ctrl->cnr-1]) {
97 kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr-1]);
98 hycapi_applications[i].listen_req[ctrl->cnr-1] = NULL;
101 hy_di->detach_ctr(ctrl);
102 ctrl->driverdata = 0;
103 kfree(card->hyctrlinfo);
106 card->hyctrlinfo = NULL;
109 /***********************************************************
111 Queue a CAPI-message to the controller.
113 ***********************************************************/
116 hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb)
118 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
119 hysdn_card *card = cinfo->card;
121 spin_lock_irq(&cinfo->lock);
122 #ifdef HYCAPI_PRINTFNAMES
123 printk(KERN_NOTICE "hycapi_send_message\n");
125 cinfo->skbs[cinfo->in_idx++] = skb; /* add to buffer list */
126 if (cinfo->in_idx >= HYSDN_MAX_CAPI_SKB)
127 cinfo->in_idx = 0; /* wrap around */
128 cinfo->sk_count++; /* adjust counter */
129 if (cinfo->sk_count >= HYSDN_MAX_CAPI_SKB) {
130 /* inform upper layers we're full */
131 printk(KERN_ERR "HYSDN Card%d: CAPI-buffer overrun!\n",
133 ctrl->suspend_output(ctrl);
136 spin_unlock_irq(&cinfo->lock);
137 queue_task(&card->irq_queue, &tq_immediate);
138 mark_bh(IMMEDIATE_BH);
141 /***********************************************************
142 hycapi_register_internal
144 Send down the CAPI_REGISTER-Command to the controller.
145 This functions will also be used if the adapter has been rebooted to
146 re-register any applications in the private list.
148 ************************************************************/
151 hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl,
152 capi_register_params *rp)
154 char ExtFeatureDefaults[] = "49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*";
155 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
156 hysdn_card *card = cinfo->card;
159 __u8 _command = 0xa0, _subcommand = 0x80;
160 __u16 MessageNumber = 0x0000;
161 __u16 MessageBufferSize = 0;
162 int slen = strlen(ExtFeatureDefaults);
163 #ifdef HYCAPI_PRINTFNAMES
164 printk(KERN_NOTICE "hycapi_register_appl\n");
166 MessageBufferSize = rp->level3cnt * rp->datablkcnt * rp->datablklen;
168 len = CAPI_MSG_BASELEN + 8 + slen + 1;
169 if (!(skb = alloc_skb(len, GFP_ATOMIC))) {
170 printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
174 memcpy(skb_put(skb,sizeof(__u16)), &len, sizeof(__u16));
175 memcpy(skb_put(skb,sizeof(__u16)), &appl, sizeof(__u16));
176 memcpy(skb_put(skb,sizeof(__u8)), &_command, sizeof(_command));
177 memcpy(skb_put(skb,sizeof(__u8)), &_subcommand, sizeof(_subcommand));
178 memcpy(skb_put(skb,sizeof(__u16)), &MessageNumber, sizeof(__u16));
179 memcpy(skb_put(skb,sizeof(__u16)), &MessageBufferSize, sizeof(__u16));
180 memcpy(skb_put(skb,sizeof(__u16)), &(rp->level3cnt), sizeof(__u16));
181 memcpy(skb_put(skb,sizeof(__u16)), &(rp->datablkcnt), sizeof(__u16));
182 memcpy(skb_put(skb,sizeof(__u16)), &(rp->datablklen), sizeof(__u16));
183 memcpy(skb_put(skb,slen), ExtFeatureDefaults, slen);
184 hycapi_applications[appl-1].ctrl_mask |= (1 << (ctrl->cnr-1));
185 hycapi_send_message(ctrl, skb);
188 /************************************************************
189 hycapi_restart_internal
191 After an adapter has been rebootet, re-register all applications and
192 send a LISTEN_REQ (if there has been such a thing )
194 *************************************************************/
196 static void hycapi_restart_internal(struct capi_ctr *ctrl)
200 #ifdef HYCAPI_PRINTFNAMES
201 printk(KERN_WARNING "HYSDN: hycapi_restart_internal");
203 for(i=0; i<CAPI_MAXAPPL; i++) {
204 if(_hycapi_appCheck(i+1, ctrl->cnr) == 1) {
205 hycapi_register_internal(ctrl, i+1,
206 &hycapi_applications[i].rp);
207 if(hycapi_applications[i].listen_req[ctrl->cnr-1]) {
208 skb = skb_copy(hycapi_applications[i].listen_req[ctrl->cnr-1], GFP_ATOMIC);
209 hycapi_sendmsg_internal(ctrl, skb);
215 /*************************************************************
216 Register an application.
217 Error-checking is done for CAPI-compliance.
219 The application is recorded in the internal list.
220 *************************************************************/
223 hycapi_register_appl(struct capi_ctr *ctrl, __u16 appl,
224 capi_register_params *rp)
226 int MaxLogicalConnections = 0, MaxBDataBlocks = 0, MaxBDataLen = 0;
227 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
228 hysdn_card *card = cinfo->card;
229 int chk = _hycapi_appCheck(appl, ctrl->cnr);
234 printk(KERN_INFO "HYSDN: apl %d allready registered\n", appl);
237 MaxBDataBlocks = rp->datablkcnt > CAPI_MAXDATAWINDOW ? CAPI_MAXDATAWINDOW : rp->datablkcnt;
238 rp->datablkcnt = MaxBDataBlocks;
239 MaxBDataLen = rp->datablklen < 1024 ? 1024 : rp->datablklen ;
240 rp->datablklen = MaxBDataLen;
242 MaxLogicalConnections = rp->level3cnt;
243 if (MaxLogicalConnections < 0) {
244 MaxLogicalConnections = card->bchans * -MaxLogicalConnections;
246 if (MaxLogicalConnections == 0) {
247 MaxLogicalConnections = card->bchans;
250 rp->level3cnt = MaxLogicalConnections;
251 memcpy(&hycapi_applications[appl-1].rp,
252 rp, sizeof(capi_register_params));
254 /* MOD_INC_USE_COUNT; */
255 ctrl->appl_registered(ctrl, appl);
258 /*********************************************************************
260 hycapi_release_internal
262 Send down a CAPI_RELEASE to the controller.
263 *********************************************************************/
265 static void hycapi_release_internal(struct capi_ctr *ctrl, __u16 appl)
267 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
268 hysdn_card *card = cinfo->card;
271 __u8 _command = 0xa1, _subcommand = 0x80;
272 __u16 MessageNumber = 0x0000;
273 #ifdef HYCAPI_PRINTFNAMES
274 printk(KERN_NOTICE "hycapi_release_appl\n");
276 len = CAPI_MSG_BASELEN;
277 if (!(skb = alloc_skb(len, GFP_ATOMIC))) {
278 printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
282 memcpy(skb_put(skb,sizeof(__u16)), &len, sizeof(__u16));
283 memcpy(skb_put(skb,sizeof(__u16)), &appl, sizeof(__u16));
284 memcpy(skb_put(skb,sizeof(__u8)), &_command, sizeof(_command));
285 memcpy(skb_put(skb,sizeof(__u8)), &_subcommand, sizeof(_subcommand));
286 memcpy(skb_put(skb,sizeof(__u16)), &MessageNumber, sizeof(__u16));
287 hycapi_send_message(ctrl, skb);
288 hycapi_applications[appl-1].ctrl_mask &= ~(1 << (ctrl->cnr-1));
291 /******************************************************************
294 Release the application from the internal list an remove it's
295 registration at controller-level
296 ******************************************************************/
299 hycapi_release_appl(struct capi_ctr *ctrl, __u16 appl)
303 chk = _hycapi_appCheck(appl, ctrl->cnr);
305 printk(KERN_ERR "HYCAPI: Releasing invalid appl %d on controller %d\n", appl, ctrl->cnr);
308 if(hycapi_applications[appl-1].listen_req[ctrl->cnr-1]) {
309 kfree_skb(hycapi_applications[appl-1].listen_req[ctrl->cnr-1]);
310 hycapi_applications[appl-1].listen_req[ctrl->cnr-1] = NULL;
314 hycapi_release_internal(ctrl, appl);
316 ctrl->appl_released(ctrl, appl);
317 /* MOD_DEC_USE_COUNT; */
321 /**************************************************************
322 Kill a single controller.
323 **************************************************************/
325 int hycapi_capi_release(hysdn_card *card)
327 hycapictrl_info *cinfo = card->hyctrlinfo;
328 struct capi_ctr *ctrl;
329 #ifdef HYCAPI_PRINTFNAMES
330 printk(KERN_NOTICE "hycapi_capi_release\n");
333 ctrl = cinfo->capi_ctrl;
334 hycapi_remove_ctr(ctrl);
339 /**************************************************************
342 Stop CAPI-Output on a card. (e.g. during reboot)
343 ***************************************************************/
345 int hycapi_capi_stop(hysdn_card *card)
347 hycapictrl_info *cinfo = card->hyctrlinfo;
348 struct capi_ctr *ctrl;
349 #ifdef HYCAPI_PRINTFNAMES
350 printk(KERN_NOTICE "hycapi_capi_stop\n");
353 if(cinfo->capi_ctrl) {
354 ctrl = cinfo->capi_ctrl;
355 /* ctrl->suspend_output(ctrl); */
359 printk(KERN_NOTICE "hycapi_capi_stop: cinfo but no capi_ctrl\n");
365 /***************************************************************
368 Send a message to the controller.
370 Messages are parsed for their Command/Subcommand-type, and appropriate
371 action's are performed.
373 Note that we have to muck around with a 64Bit-DATA_REQ as there are
374 firmware-releases that do not check the MsgLen-Indication!
376 ***************************************************************/
378 void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
384 appl_id = CAPIMSG_APPID(skb->data);
385 switch(_hycapi_appCheck(appl_id, ctrl->cnr))
388 /* printk(KERN_INFO "Need to register\n"); */
389 hycapi_register_internal(ctrl,
391 &(hycapi_applications[appl_id-1].rp));
396 printk(KERN_ERR "HYCAPI: Controller mixup!\n");
399 switch(CAPIMSG_CMD(skb->data)) {
400 case CAPI_DISCONNECT_B3_RESP:
401 ctrl->free_ncci(ctrl, appl_id,
402 CAPIMSG_NCCI(skb->data));
404 case CAPI_DATA_B3_REQ:
405 _len = CAPIMSG_LEN(skb->data);
408 memcpy(msghead, skb->data, 22);
409 memcpy(skb->data + _len2, msghead, 22);
410 skb_pull(skb, _len2);
411 CAPIMSG_SETLEN(skb->data, 22);
414 case CAPI_LISTEN_REQ:
415 if(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1])
417 kfree_skb(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1]);
418 hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = NULL;
420 if (!(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = skb_copy(skb, GFP_ATOMIC)))
422 printk(KERN_ERR "HYSDN: memory squeeze in private_listen\n");
428 hycapi_sendmsg_internal(ctrl, skb);
431 /*********************************************************************
434 Informations provided in the /proc/capi-entries.
436 *********************************************************************/
438 int hycapi_read_proc(char *page, char **start, off_t off,
439 int count, int *eof, struct capi_ctr *ctrl)
441 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
442 hysdn_card *card = cinfo->card;
445 #ifdef HYCAPI_PRINTFNAMES
446 printk(KERN_NOTICE "hycapi_read_proc\n");
448 len += sprintf(page+len, "%-16s %s\n", "name", cinfo->cardname);
449 len += sprintf(page+len, "%-16s 0x%x\n", "io", card->iobase);
450 len += sprintf(page+len, "%-16s %d\n", "irq", card->irq);
452 switch (card->brdtype) {
453 case BD_PCCARD: s = "HYSDN Hycard"; break;
454 case BD_ERGO: s = "HYSDN Ergo2"; break;
455 case BD_METRO: s = "HYSDN Metro4"; break;
456 case BD_CHAMP2: s = "HYSDN Champ2"; break;
457 case BD_PLEXUS: s = "HYSDN Plexus30"; break;
458 default: s = "???"; break;
460 len += sprintf(page+len, "%-16s %s\n", "type", s);
461 if ((s = cinfo->version[VER_DRIVER]) != 0)
462 len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
463 if ((s = cinfo->version[VER_CARDTYPE]) != 0)
464 len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
465 if ((s = cinfo->version[VER_SERIAL]) != 0)
466 len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
468 len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
470 if (off+count >= len)
475 return ((count < len-off) ? count : len-off);
478 /**************************************************************
481 This does NOT load any firmware, but the callback somehow is needed
482 on capi-interface registration.
484 **************************************************************/
486 int hycapi_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
488 #ifdef HYCAPI_PRINTFNAMES
489 printk(KERN_NOTICE "hycapi_load_firmware\n");
495 char *hycapi_procinfo(struct capi_ctr *ctrl)
497 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
498 #ifdef HYCAPI_PRINTFNAMES
499 printk(KERN_NOTICE "hycapi_proc_info\n");
503 sprintf(cinfo->infobuf, "%s %s 0x%x %d %s",
504 cinfo->cardname[0] ? cinfo->cardname : "-",
505 cinfo->version[VER_DRIVER] ? cinfo->version[VER_DRIVER] : "-",
506 cinfo->card ? cinfo->card->iobase : 0x0,
507 cinfo->card ? cinfo->card->irq : 0,
510 return cinfo->infobuf;
513 /******************************************************************
516 Receive a capi-message.
518 All B3_DATA_IND are converted to 64K-extension compatible format.
519 New nccis are created if neccessary.
520 *******************************************************************/
523 hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
526 hycapictrl_info *cinfo = card->hyctrlinfo;
527 struct capi_ctr *ctrl;
531 __u32 CP64[2] = {0,0};
532 #ifdef HYCAPI_PRINTFNAMES
533 printk(KERN_NOTICE "hycapi_rx_capipkt\n");
538 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 ctrl->new_ncci(ctrl, 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: illegal 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 ctrl->new_ncci(ctrl, ApplId,
610 CAPIMSG_NCCI(skb->data),
611 hycapi_applications[ApplId-1].rp.datablkcnt);
616 ctrl->handle_capimsg(ctrl, ApplId, skb);
619 /******************************************************************
622 Internally acknowledge a msg sent. This will remove the msg from the
625 *******************************************************************/
627 void hycapi_tx_capiack(hysdn_card * card)
629 hycapictrl_info *cinfo = card->hyctrlinfo;
630 #ifdef HYCAPI_PRINTFNAMES
631 printk(KERN_NOTICE "hycapi_tx_capiack\n");
636 spin_lock_irq(&cinfo->lock);
637 kfree_skb(cinfo->skbs[cinfo->out_idx]); /* free skb */
638 cinfo->skbs[cinfo->out_idx++] = NULL;
639 if (cinfo->out_idx >= HYSDN_MAX_CAPI_SKB)
640 cinfo->out_idx = 0; /* wrap around */
642 if (cinfo->sk_count-- == HYSDN_MAX_CAPI_SKB) /* dec usage count */
643 cinfo->capi_ctrl->resume_output(cinfo->capi_ctrl);
644 spin_unlock_irq(&cinfo->lock);
647 /***************************************************************
648 hycapi_tx_capiget(hysdn_card *card)
650 This is called when polling for messages to SEND.
652 ****************************************************************/
655 hycapi_tx_capiget(hysdn_card *card)
657 hycapictrl_info *cinfo = card->hyctrlinfo;
659 return (struct sk_buff *)NULL;
661 if (!cinfo->sk_count)
662 return (struct sk_buff *)NULL; /* nothing available */
664 return (cinfo->skbs[cinfo->out_idx]); /* next packet to send */
668 static struct capi_driver hycapi_driver = {
671 hycapi_load_firmware,
674 hycapi_register_appl,
679 0, /* use standard driver_read_proc */
680 0, /* no add_card function */
684 /**********************************************************
687 attach the capi-driver to the kernel-capi.
689 ***********************************************************/
693 struct capi_driver *driver;
696 printk(KERN_NOTICE "HyDI allready set\n");
699 driver = &hycapi_driver;
700 printk(KERN_NOTICE "HYSDN: Attaching capi-driver\n");
701 hy_di = attach_capi_driver(driver);
703 printk(KERN_ERR "HYCAPI: failed to attach capi_driver\n");
706 for(i=0;i<CAPI_MAXAPPL;i++) {
707 memset(&(hycapi_applications[i]), 0, sizeof(hycapi_appl));
712 /**************************************************************
715 detach the capi-driver to the kernel-capi. Actually this should
716 free some more ressources. Do that later.
717 **************************************************************/
722 struct capi_driver *driver;
723 driver = &hycapi_driver;
725 printk(KERN_ERR "HYSDN: no capi-driver to detach (?)\n");
728 printk(KERN_NOTICE "HYSDN: Detaching capi-driver\n");
729 detach_capi_driver(driver);
734 /********************************************************************
735 hycapi_capi_create(hysdn_card *card)
737 Attach the card with it's capi-ctrl.
738 *********************************************************************/
740 static void hycapi_fill_profile(hysdn_card *card)
742 hycapictrl_info *cinfo = NULL;
743 struct capi_ctr *ctrl = NULL;
744 cinfo = card->hyctrlinfo;
746 ctrl = cinfo->capi_ctrl;
748 strcpy(ctrl->manu, "Hypercope");
749 ctrl->version.majorversion = 2;
750 ctrl->version.minorversion = 0;
751 ctrl->version.majormanuversion = 3;
752 ctrl->version.minormanuversion = 2;
753 ctrl->profile.ncontroller = card->myid;
754 ctrl->profile.nbchannel = card->bchans;
755 ctrl->profile.goptions = GLOBAL_OPTION_INTERNAL_CONTROLLER |
756 GLOBAL_OPTION_B_CHANNEL_OPERATION;
757 ctrl->profile.support1 = B1_PROT_64KBIT_HDLC |
758 (card->faxchans ? B1_PROT_T30 : 0) |
759 B1_PROT_64KBIT_TRANSPARENT;
760 ctrl->profile.support2 = B2_PROT_ISO7776 |
761 (card->faxchans ? B2_PROT_T30 : 0) |
763 ctrl->profile.support3 = B3_PROT_TRANSPARENT |
765 (card->faxchans ? B3_PROT_T30 : 0) |
766 (card->faxchans ? B3_PROT_T30EXT : 0) |
771 hycapi_capi_create(hysdn_card *card)
773 hycapictrl_info *cinfo = NULL;
774 struct capi_ctr *ctrl = NULL;
775 #ifdef HYCAPI_PRINTFNAMES
776 printk(KERN_NOTICE "hycapi_capi_create\n");
778 if((hycapi_enable & (1 << card->myid)) == 0) {
781 if (!card->hyctrlinfo) {
782 cinfo = (hycapictrl_info *) kmalloc(sizeof(hycapictrl_info), GFP_ATOMIC);
784 printk(KERN_WARNING "HYSDN: no memory for capi-ctrl.\n");
787 memset(cinfo, 0, sizeof(hycapictrl_info));
788 card->hyctrlinfo = cinfo;
790 spin_lock_init(&cinfo->lock);
792 switch (card->brdtype) {
793 case BD_PCCARD: strcpy(cinfo->cardname,"HYSDN Hycard"); break;
794 case BD_ERGO: strcpy(cinfo->cardname,"HYSDN Ergo2"); break;
795 case BD_METRO: strcpy(cinfo->cardname,"HYSDN Metro4"); break;
796 case BD_CHAMP2: strcpy(cinfo->cardname,"HYSDN Champ2"); break;
797 case BD_PLEXUS: strcpy(cinfo->cardname,"HYSDN Plexus30"); break;
798 default: strcpy(cinfo->cardname,"HYSDN ???"); break;
801 cinfo->capi_ctrl = hy_di->attach_ctr(&hycapi_driver,
802 cinfo->cardname, cinfo);
803 ctrl = cinfo->capi_ctrl;
805 printk(KERN_ERR "%s: attach controller failed.\n",
809 /* fill in the blanks: */
810 hycapi_fill_profile(card);
813 /* resume output on stopped ctrl */
814 ctrl = card->hyctrlinfo->capi_ctrl;
816 hycapi_fill_profile(card);
818 hycapi_restart_internal(ctrl);
819 /* ctrl->resume_output(ctrl); */
821 printk(KERN_WARNING "HYSDN: No ctrl???? How come?\n");