1 /* $Id: isar.c,v 1.22.2.6 2004/02/11 13:21:34 keil Exp $
3 * isar.c ISAR (Siemens PSB 7110) specific routines
5 * Author Karsten Keil (keil@isdn4linux.de)
7 * This file is (c) under GNU General Public License
11 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <linux/slab.h>
18 #define DBG_LOADFIRM 0
19 #define DUMP_MBOXFRAME 2
25 static const u_char faxmodulation
[] = {3,24,48,72,73,74,96,97,98,121,122,145,146};
26 static u_int modmask
= 0x1fff;
27 static int frm_extra_delay
= 2;
28 static int para_TOA
= 6;
29 static const u_char
*FC1_CMD
[] = {"FAE", "FTS", "FRS", "FTM", "FRM", "FTH", "FRH", "CTRL" };
31 static void isar_setup(struct IsdnCardState
*cs
);
32 static void isar_pump_cmd(struct BCState
*bcs
, u_char cmd
, u_char para
);
33 static void ll_deliver_faxstat(struct BCState
*bcs
, u_char status
);
36 waitforHIA(struct IsdnCardState
*cs
, int timeout
)
39 while ((cs
->BC_Read_Reg(cs
, 0, ISAR_HIA
) & 1) && timeout
) {
44 printk(KERN_WARNING
"HiSax: ISAR waitforHIA timeout\n");
50 sendmsg(struct IsdnCardState
*cs
, u_char his
, u_char creg
, u_char len
,
55 if (!waitforHIA(cs
, 4000))
58 if (cs
->debug
& L1_DEB_HSCX
)
59 debugl1(cs
, "sendmsg(%02x,%02x,%d)", his
, creg
, len
);
61 cs
->BC_Write_Reg(cs
, 0, ISAR_CTRL_H
, creg
);
62 cs
->BC_Write_Reg(cs
, 0, ISAR_CTRL_L
, len
);
63 cs
->BC_Write_Reg(cs
, 0, ISAR_WADR
, 0);
65 cs
->BC_Write_Reg(cs
, 1, ISAR_MBOX
, msg
[0]);
67 cs
->BC_Write_Reg(cs
, 2, ISAR_MBOX
, msg
[i
]);
69 if (cs
->debug
& L1_DEB_HSCX_FIFO
) {
75 t
+= sprintf(t
, "sendmbox cnt %d", len
);
76 QuickHex(t
, &msg
[len
-i
], (i
>64) ? 64:i
);
83 cs
->BC_Write_Reg(cs
, 1, ISAR_HIS
, his
);
84 waitforHIA(cs
, 10000);
88 /* Call only with IRQ disabled !!! */
90 rcv_mbox(struct IsdnCardState
*cs
, struct isar_reg
*ireg
, u_char
*msg
)
94 cs
->BC_Write_Reg(cs
, 1, ISAR_RADR
, 0);
95 if (msg
&& ireg
->clsb
) {
96 msg
[0] = cs
->BC_Read_Reg(cs
, 1, ISAR_MBOX
);
97 for (i
=1; i
< ireg
->clsb
; i
++)
98 msg
[i
] = cs
->BC_Read_Reg(cs
, 2, ISAR_MBOX
);
100 if (cs
->debug
& L1_DEB_HSCX_FIFO
) {
106 t
+= sprintf(t
, "rcv_mbox cnt %d", ireg
->clsb
);
107 QuickHex(t
, &msg
[ireg
->clsb
-i
], (i
>64) ? 64:i
);
114 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
117 /* Call only with IRQ disabled !!! */
119 get_irq_infos(struct IsdnCardState
*cs
, struct isar_reg
*ireg
)
121 ireg
->iis
= cs
->BC_Read_Reg(cs
, 1, ISAR_IIS
);
122 ireg
->cmsb
= cs
->BC_Read_Reg(cs
, 1, ISAR_CTRL_H
);
123 ireg
->clsb
= cs
->BC_Read_Reg(cs
, 1, ISAR_CTRL_L
);
125 if (cs
->debug
& L1_DEB_HSCX
)
126 debugl1(cs
, "irq_stat(%02x,%02x,%d)", ireg
->iis
, ireg
->cmsb
,
132 waitrecmsg(struct IsdnCardState
*cs
, u_char
*len
,
133 u_char
*msg
, int maxdelay
)
136 struct isar_reg
*ir
= cs
->bcs
[0].hw
.isar
.reg
;
139 while((!(cs
->BC_Read_Reg(cs
, 0, ISAR_IRQBIT
) & ISAR_IRQSTA
)) &&
140 (timeout
++ < maxdelay
))
142 if (timeout
> maxdelay
) {
143 printk(KERN_WARNING
"isar recmsg IRQSTA timeout\n");
146 get_irq_infos(cs
, ir
);
147 rcv_mbox(cs
, ir
, msg
);
153 ISARVersion(struct IsdnCardState
*cs
, char *s
)
156 u_char msg
[] = ISAR_MSG_HWVER
;
162 cs
->cardmsg(cs
, CARD_RESET
, NULL
);
163 spin_lock_irqsave(&cs
->lock
, flags
);
164 /* disable ISAR IRQ */
165 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
167 cs
->debug
&= ~(L1_DEB_HSCX
| L1_DEB_HSCX_FIFO
);
168 if (!sendmsg(cs
, ISAR_HIS_VNR
, 0, 3, msg
)) {
169 spin_unlock_irqrestore(&cs
->lock
, flags
);
172 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
173 spin_unlock_irqrestore(&cs
->lock
, flags
);
177 if (cs
->bcs
[0].hw
.isar
.reg
->iis
== ISAR_IIS_VNR
) {
180 printk(KERN_INFO
"%s ISAR version %d\n", s
, ver
);
185 spin_unlock_irqrestore(&cs
->lock
, flags
);
190 isar_load_firmware(struct IsdnCardState
*cs
, u_char __user
*buf
)
192 int ret
, size
, cnt
, debug
;
193 u_char len
, nom
, noc
;
194 u_short sadr
, left
, *sp
;
195 u_char __user
*p
= buf
;
196 u_char
*msg
, *tmpmsg
, *mp
, tmp
[64];
198 struct isar_reg
*ireg
= cs
->bcs
[0].hw
.isar
.reg
;
200 struct {u_short sadr
;
205 #define BLK_HEAD_SIZE 6
206 if (1 != (ret
= ISARVersion(cs
, "Testing"))) {
207 printk(KERN_ERR
"isar_load_firmware wrong isar version %d\n", ret
);
212 cs
->debug
&= ~(L1_DEB_HSCX
| L1_DEB_HSCX_FIFO
);
215 if ((ret
= copy_from_user(&size
, p
, sizeof(int)))) {
216 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", ret
);
220 printk(KERN_DEBUG
"isar_load_firmware size: %d\n", size
);
222 /* disable ISAR IRQ */
223 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
224 if (!(msg
= kmalloc(256, GFP_KERNEL
))) {
225 printk(KERN_ERR
"isar_load_firmware no buffer\n");
228 if (!(tmpmsg
= kmalloc(256, GFP_KERNEL
))) {
229 printk(KERN_ERR
"isar_load_firmware no tmp buffer\n");
233 spin_lock_irqsave(&cs
->lock
, flags
);
234 /* disable ISAR IRQ */
235 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
236 spin_unlock_irqrestore(&cs
->lock
, flags
);
238 if ((ret
= copy_from_user(&blk_head
, p
, BLK_HEAD_SIZE
))) {
239 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", ret
);
243 sadr
= (blk_head
.sadr
& 0xff)*256 + blk_head
.sadr
/256;
244 blk_head
.sadr
= sadr
;
245 sadr
= (blk_head
.len
& 0xff)*256 + blk_head
.len
/256;
247 sadr
= (blk_head
.d_key
& 0xff)*256 + blk_head
.d_key
/256;
248 blk_head
.d_key
= sadr
;
249 #endif /* __BIG_ENDIAN */
250 cnt
+= BLK_HEAD_SIZE
;
252 printk(KERN_DEBUG
"isar firmware block (%#x,%5d,%#x)\n",
253 blk_head
.sadr
, blk_head
.len
, blk_head
.d_key
& 0xff);
254 sadr
= blk_head
.sadr
;
256 spin_lock_irqsave(&cs
->lock
, flags
);
257 if (!sendmsg(cs
, ISAR_HIS_DKEY
, blk_head
.d_key
& 0xff, 0, NULL
)) {
258 printk(KERN_ERR
"isar sendmsg dkey failed\n");
259 ret
= 1;goto reterr_unlock
;
261 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
262 printk(KERN_ERR
"isar waitrecmsg dkey failed\n");
263 ret
= 1;goto reterr_unlock
;
265 if ((ireg
->iis
!= ISAR_IIS_DKEY
) || ireg
->cmsb
|| len
) {
266 printk(KERN_ERR
"isar wrong dkey response (%x,%x,%x)\n",
267 ireg
->iis
, ireg
->cmsb
, len
);
268 ret
= 1;goto reterr_unlock
;
270 spin_unlock_irqrestore(&cs
->lock
, flags
);
282 if ((ret
= copy_from_user(tmpmsg
, p
, nom
))) {
283 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", ret
);
289 sp
= (u_short
*)tmpmsg
;
291 printk(KERN_DEBUG
"isar: load %3d words at %04x left %d\n",
302 #endif /* __BIG_ENDIAN */
306 spin_lock_irqsave(&cs
->lock
, flags
);
307 if (!sendmsg(cs
, ISAR_HIS_FIRM
, 0, nom
, msg
)) {
308 printk(KERN_ERR
"isar sendmsg prog failed\n");
309 ret
= 1;goto reterr_unlock
;
311 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
312 printk(KERN_ERR
"isar waitrecmsg prog failed\n");
313 ret
= 1;goto reterr_unlock
;
315 if ((ireg
->iis
!= ISAR_IIS_FIRM
) || ireg
->cmsb
|| len
) {
316 printk(KERN_ERR
"isar wrong prog response (%x,%x,%x)\n",
317 ireg
->iis
, ireg
->cmsb
, len
);
318 ret
= 1;goto reterr_unlock
;
320 spin_unlock_irqrestore(&cs
->lock
, flags
);
322 printk(KERN_DEBUG
"isar firmware block %5d words loaded\n",
332 spin_lock_irqsave(&cs
->lock
, flags
);
333 if (!sendmsg(cs
, ISAR_HIS_STDSP
, 0, 2, msg
)) {
334 printk(KERN_ERR
"isar sendmsg start dsp failed\n");
335 ret
= 1;goto reterr_unlock
;
337 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
338 printk(KERN_ERR
"isar waitrecmsg start dsp failed\n");
339 ret
= 1;goto reterr_unlock
;
341 if ((ireg
->iis
!= ISAR_IIS_STDSP
) || ireg
->cmsb
|| len
) {
342 printk(KERN_ERR
"isar wrong start dsp response (%x,%x,%x)\n",
343 ireg
->iis
, ireg
->cmsb
, len
);
344 ret
= 1;goto reterr_unlock
;
346 printk(KERN_DEBUG
"isar start dsp success\n");
347 /* NORMAL mode entered */
348 /* Enable IRQs of ISAR */
349 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, ISAR_IRQSTA
);
350 spin_unlock_irqrestore(&cs
->lock
, flags
);
351 cnt
= 1000; /* max 1s */
352 while ((!ireg
->bstat
) && cnt
) {
357 printk(KERN_ERR
"isar no general status event received\n");
358 ret
= 1;goto reterror
;
360 printk(KERN_DEBUG
"isar general status event %x\n",
367 spin_lock_irqsave(&cs
->lock
, flags
);
369 if (!sendmsg(cs
, ISAR_HIS_DIAG
, ISAR_CTRL_STST
, 0, NULL
)) {
370 printk(KERN_ERR
"isar sendmsg self tst failed\n");
371 ret
= 1;goto reterr_unlock
;
373 cnt
= 10000; /* max 100 ms */
374 spin_unlock_irqrestore(&cs
->lock
, flags
);
375 while ((ireg
->iis
!= ISAR_IIS_DIAG
) && cnt
) {
381 printk(KERN_ERR
"isar no self tst response\n");
382 ret
= 1;goto reterror
;
384 if ((ireg
->cmsb
== ISAR_CTRL_STST
) && (ireg
->clsb
== 1)
385 && (ireg
->par
[0] == 0)) {
386 printk(KERN_DEBUG
"isar selftest OK\n");
388 printk(KERN_DEBUG
"isar selftest not OK %x/%x/%x\n",
389 ireg
->cmsb
, ireg
->clsb
, ireg
->par
[0]);
390 ret
= 1;goto reterror
;
392 spin_lock_irqsave(&cs
->lock
, flags
);
394 if (!sendmsg(cs
, ISAR_HIS_DIAG
, ISAR_CTRL_SWVER
, 0, NULL
)) {
395 printk(KERN_ERR
"isar RQST SVN failed\n");
396 ret
= 1;goto reterr_unlock
;
398 spin_unlock_irqrestore(&cs
->lock
, flags
);
399 cnt
= 30000; /* max 300 ms */
400 while ((ireg
->iis
!= ISAR_IIS_DIAG
) && cnt
) {
406 printk(KERN_ERR
"isar no SVN response\n");
407 ret
= 1;goto reterror
;
409 if ((ireg
->cmsb
== ISAR_CTRL_SWVER
) && (ireg
->clsb
== 1))
410 printk(KERN_DEBUG
"isar software version %#x\n",
413 printk(KERN_ERR
"isar wrong swver response (%x,%x) cnt(%d)\n",
414 ireg
->cmsb
, ireg
->clsb
, cnt
);
415 ret
= 1;goto reterror
;
418 spin_lock_irqsave(&cs
->lock
, flags
);
424 spin_unlock_irqrestore(&cs
->lock
, flags
);
428 /* disable ISAR IRQ */
429 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
435 #define B_LL_NOCARRIER 8
436 #define B_LL_CONNECT 9
440 isar_bh(struct work_struct
*work
)
442 struct BCState
*bcs
= container_of(work
, struct BCState
, tqueue
);
445 if (test_and_clear_bit(B_LL_NOCARRIER
, &bcs
->event
))
446 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_NOCARR
);
447 if (test_and_clear_bit(B_LL_CONNECT
, &bcs
->event
))
448 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
449 if (test_and_clear_bit(B_LL_OK
, &bcs
->event
))
450 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_OK
);
454 send_DLE_ETX(struct BCState
*bcs
)
456 u_char dleetx
[2] = {DLE
,ETX
};
459 if ((skb
= dev_alloc_skb(2))) {
460 memcpy(skb_put(skb
, 2), dleetx
, 2);
461 skb_queue_tail(&bcs
->rqueue
, skb
);
462 schedule_event(bcs
, B_RCVBUFREADY
);
464 printk(KERN_WARNING
"HiSax: skb out of memory\n");
469 dle_count(unsigned char *buf
, int len
)
480 insert_dle(unsigned char *dest
, unsigned char *src
, int count
) {
481 /* <DLE> in input stream have to be flagged as <DLE><DLE> */
490 isar_rcv_frame(struct IsdnCardState
*cs
, struct BCState
*bcs
)
494 struct isar_reg
*ireg
= bcs
->hw
.isar
.reg
;
497 debugl1(cs
, "isar zero len frame");
498 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
503 debugl1(cs
, "isar mode 0 spurious IIS_RDATA %x/%x/%x",
504 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
505 printk(KERN_WARNING
"isar mode 0 spurious IIS_RDATA %x/%x/%x\n",
506 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
507 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
511 if ((skb
= dev_alloc_skb(ireg
->clsb
))) {
512 rcv_mbox(cs
, ireg
, (u_char
*)skb_put(skb
, ireg
->clsb
));
513 skb_queue_tail(&bcs
->rqueue
, skb
);
514 schedule_event(bcs
, B_RCVBUFREADY
);
516 printk(KERN_WARNING
"HiSax: skb out of memory\n");
517 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
521 if ((bcs
->hw
.isar
.rcvidx
+ ireg
->clsb
) > HSCX_BUFMAX
) {
522 if (cs
->debug
& L1_DEB_WARN
)
523 debugl1(cs
, "isar_rcv_frame: incoming packet too large");
524 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
525 bcs
->hw
.isar
.rcvidx
= 0;
526 } else if (ireg
->cmsb
& HDLC_ERROR
) {
527 if (cs
->debug
& L1_DEB_WARN
)
528 debugl1(cs
, "isar frame error %x len %d",
529 ireg
->cmsb
, ireg
->clsb
);
530 #ifdef ERROR_STATISTIC
531 if (ireg
->cmsb
& HDLC_ERR_RER
)
533 if (ireg
->cmsb
& HDLC_ERR_CER
)
536 bcs
->hw
.isar
.rcvidx
= 0;
537 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
539 if (ireg
->cmsb
& HDLC_FSD
)
540 bcs
->hw
.isar
.rcvidx
= 0;
541 ptr
= bcs
->hw
.isar
.rcvbuf
+ bcs
->hw
.isar
.rcvidx
;
542 bcs
->hw
.isar
.rcvidx
+= ireg
->clsb
;
543 rcv_mbox(cs
, ireg
, ptr
);
544 if (ireg
->cmsb
& HDLC_FED
) {
545 if (bcs
->hw
.isar
.rcvidx
< 3) { /* last 2 bytes are the FCS */
546 if (cs
->debug
& L1_DEB_WARN
)
547 debugl1(cs
, "isar frame to short %d",
548 bcs
->hw
.isar
.rcvidx
);
549 } else if (!(skb
= dev_alloc_skb(bcs
->hw
.isar
.rcvidx
-2))) {
550 printk(KERN_WARNING
"ISAR: receive out of memory\n");
552 memcpy(skb_put(skb
, bcs
->hw
.isar
.rcvidx
-2),
553 bcs
->hw
.isar
.rcvbuf
, bcs
->hw
.isar
.rcvidx
-2);
554 skb_queue_tail(&bcs
->rqueue
, skb
);
555 schedule_event(bcs
, B_RCVBUFREADY
);
557 bcs
->hw
.isar
.rcvidx
= 0;
562 if (bcs
->hw
.isar
.state
!= STFAX_ACTIV
) {
563 if (cs
->debug
& L1_DEB_WARN
)
564 debugl1(cs
, "isar_rcv_frame: not ACTIV");
565 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
566 bcs
->hw
.isar
.rcvidx
= 0;
569 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) {
570 rcv_mbox(cs
, ireg
, bcs
->hw
.isar
.rcvbuf
);
571 bcs
->hw
.isar
.rcvidx
= ireg
->clsb
+
572 dle_count(bcs
->hw
.isar
.rcvbuf
, ireg
->clsb
);
573 if (cs
->debug
& L1_DEB_HSCX
)
574 debugl1(cs
, "isar_rcv_frame: raw(%d) dle(%d)",
575 ireg
->clsb
, bcs
->hw
.isar
.rcvidx
);
576 if ((skb
= dev_alloc_skb(bcs
->hw
.isar
.rcvidx
))) {
577 insert_dle((u_char
*)skb_put(skb
, bcs
->hw
.isar
.rcvidx
),
578 bcs
->hw
.isar
.rcvbuf
, ireg
->clsb
);
579 skb_queue_tail(&bcs
->rqueue
, skb
);
580 schedule_event(bcs
, B_RCVBUFREADY
);
581 if (ireg
->cmsb
& SART_NMD
) { /* ABORT */
582 if (cs
->debug
& L1_DEB_WARN
)
583 debugl1(cs
, "isar_rcv_frame: no more data");
584 bcs
->hw
.isar
.rcvidx
= 0;
586 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
587 ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
,
589 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
590 schedule_event(bcs
, B_LL_NOCARRIER
);
593 printk(KERN_WARNING
"HiSax: skb out of memory\n");
597 if (bcs
->hw
.isar
.cmd
!= PCTRL_CMD_FRH
) {
598 if (cs
->debug
& L1_DEB_WARN
)
599 debugl1(cs
, "isar_rcv_frame: unknown fax mode %x",
601 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
602 bcs
->hw
.isar
.rcvidx
= 0;
606 if ((bcs
->hw
.isar
.rcvidx
+ ireg
->clsb
) > HSCX_BUFMAX
) {
607 if (cs
->debug
& L1_DEB_WARN
)
608 debugl1(cs
, "isar_rcv_frame: incoming packet too large");
609 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
610 bcs
->hw
.isar
.rcvidx
= 0;
611 } else if (ireg
->cmsb
& HDLC_ERROR
) {
612 if (cs
->debug
& L1_DEB_WARN
)
613 debugl1(cs
, "isar frame error %x len %d",
614 ireg
->cmsb
, ireg
->clsb
);
615 bcs
->hw
.isar
.rcvidx
= 0;
616 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
618 if (ireg
->cmsb
& HDLC_FSD
) {
619 bcs
->hw
.isar
.rcvidx
= 0;
621 ptr
= bcs
->hw
.isar
.rcvbuf
+ bcs
->hw
.isar
.rcvidx
;
622 bcs
->hw
.isar
.rcvidx
+= ireg
->clsb
;
623 rcv_mbox(cs
, ireg
, ptr
);
624 if (ireg
->cmsb
& HDLC_FED
) {
625 int len
= bcs
->hw
.isar
.rcvidx
+
626 dle_count(bcs
->hw
.isar
.rcvbuf
, bcs
->hw
.isar
.rcvidx
);
627 if (bcs
->hw
.isar
.rcvidx
< 3) { /* last 2 bytes are the FCS */
628 if (cs
->debug
& L1_DEB_WARN
)
629 debugl1(cs
, "isar frame to short %d",
630 bcs
->hw
.isar
.rcvidx
);
631 printk(KERN_WARNING
"ISAR: frame to short %d\n",
632 bcs
->hw
.isar
.rcvidx
);
633 } else if (!(skb
= dev_alloc_skb(len
))) {
634 printk(KERN_WARNING
"ISAR: receive out of memory\n");
636 insert_dle((u_char
*)skb_put(skb
, len
),
638 bcs
->hw
.isar
.rcvidx
);
639 skb_queue_tail(&bcs
->rqueue
, skb
);
640 schedule_event(bcs
, B_RCVBUFREADY
);
642 schedule_event(bcs
, B_LL_OK
);
643 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
645 bcs
->hw
.isar
.rcvidx
= 0;
648 if (ireg
->cmsb
& SART_NMD
) { /* ABORT */
649 if (cs
->debug
& L1_DEB_WARN
)
650 debugl1(cs
, "isar_rcv_frame: no more data");
651 bcs
->hw
.isar
.rcvidx
= 0;
652 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
653 ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
, 0, NULL
);
654 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
655 if (test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
)) {
657 schedule_event(bcs
, B_LL_NOCARRIER
);
662 printk(KERN_ERR
"isar_rcv_frame mode (%x)error\n", bcs
->mode
);
663 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
669 isar_fill_fifo(struct BCState
*bcs
)
671 struct IsdnCardState
*cs
= bcs
->cs
;
676 if ((cs
->debug
& L1_DEB_HSCX
) && !(cs
->debug
& L1_DEB_HSCX_FIFO
))
677 debugl1(cs
, "isar_fill_fifo");
680 if (bcs
->tx_skb
->len
<= 0)
682 if (!(bcs
->hw
.isar
.reg
->bstat
&
683 (bcs
->hw
.isar
.dpath
== 1 ? BSTAT_RDM1
: BSTAT_RDM2
)))
685 if (bcs
->tx_skb
->len
> bcs
->hw
.isar
.mml
) {
687 count
= bcs
->hw
.isar
.mml
;
689 count
= bcs
->tx_skb
->len
;
692 ptr
= bcs
->tx_skb
->data
;
693 if (!bcs
->hw
.isar
.txcnt
) {
695 if ((bcs
->mode
== L1_MODE_FAX
) &&
696 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
)) {
697 if (bcs
->tx_skb
->len
> 1) {
698 if ((ptr
[0]== 0xff) && (ptr
[1] == 0x13))
700 test_and_set_bit(BC_FLG_LASTDATA
,
705 skb_pull(bcs
->tx_skb
, count
);
706 bcs
->tx_cnt
-= count
;
707 bcs
->hw
.isar
.txcnt
+= count
;
710 printk(KERN_ERR
"isar_fill_fifo wrong mode 0\n");
714 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
718 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
722 if (bcs
->hw
.isar
.state
!= STFAX_ACTIV
) {
723 if (cs
->debug
& L1_DEB_WARN
)
724 debugl1(cs
, "isar_fill_fifo: not ACTIV");
725 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
726 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
728 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) {
729 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
732 if (cs
->debug
& L1_DEB_WARN
)
733 debugl1(cs
, "isar_fill_fifo: not FTH/FTM");
738 debugl1(cs
, "isar_fill_fifo mode(%x) error", bcs
->mode
);
739 printk(KERN_ERR
"isar_fill_fifo mode(%x) error\n", bcs
->mode
);
745 struct BCState
*sel_bcs_isar(struct IsdnCardState
*cs
, u_char dpath
)
747 if ((!dpath
) || (dpath
== 3))
749 if (cs
->bcs
[0].hw
.isar
.dpath
== dpath
)
751 if (cs
->bcs
[1].hw
.isar
.dpath
== dpath
)
757 send_frames(struct BCState
*bcs
)
760 if (bcs
->tx_skb
->len
) {
764 if (test_bit(FLG_LLI_L1WAKEUP
,&bcs
->st
->lli
.flag
) &&
765 (PACKET_NOACK
!= bcs
->tx_skb
->pkt_type
)) {
767 spin_lock_irqsave(&bcs
->aclock
, flags
);
768 bcs
->ackcnt
+= bcs
->hw
.isar
.txcnt
;
769 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
770 schedule_event(bcs
, B_ACKPENDING
);
772 if (bcs
->mode
== L1_MODE_FAX
) {
773 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
774 if (test_bit(BC_FLG_LASTDATA
, &bcs
->Flag
)) {
775 test_and_set_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
);
777 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) {
778 if (test_bit(BC_FLG_DLEETX
, &bcs
->Flag
)) {
779 test_and_set_bit(BC_FLG_LASTDATA
, &bcs
->Flag
);
780 test_and_set_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
);
784 dev_kfree_skb_any(bcs
->tx_skb
);
785 bcs
->hw
.isar
.txcnt
= 0;
789 if ((bcs
->tx_skb
= skb_dequeue(&bcs
->squeue
))) {
790 bcs
->hw
.isar
.txcnt
= 0;
791 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
794 if (test_and_clear_bit(BC_FLG_DLEETX
, &bcs
->Flag
)) {
795 if (test_and_clear_bit(BC_FLG_LASTDATA
, &bcs
->Flag
)) {
796 if (test_and_clear_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
)) {
798 sendmsg(bcs
->cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
799 ISAR_HIS_SDATA
, 0x01, 1, &dummy
);
801 test_and_set_bit(BC_FLG_LL_OK
, &bcs
->Flag
);
803 schedule_event(bcs
, B_LL_CONNECT
);
806 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
807 schedule_event(bcs
, B_XMTBUFREADY
);
812 check_send(struct IsdnCardState
*cs
, u_char rdm
)
816 if (rdm
& BSTAT_RDM1
) {
817 if ((bcs
= sel_bcs_isar(cs
, 1))) {
823 if (rdm
& BSTAT_RDM2
) {
824 if ((bcs
= sel_bcs_isar(cs
, 2))) {
833 static const char *dmril
[] = {"NO SPEED", "1200/75", "NODEF2", "75/1200",
834 "NODEF4", "300", "600", "1200", "2400",
835 "4800", "7200", "9600nt", "9600t", "12000",
837 static const char *dmrim
[] = {"NO MOD", "NO DEF", "V32/V32b", "V22", "V21",
838 "Bell103", "V23", "Bell202", "V17", "V29",
842 isar_pump_status_rsp(struct BCState
*bcs
, struct isar_reg
*ireg
) {
843 struct IsdnCardState
*cs
= bcs
->cs
;
844 u_char ril
= ireg
->par
[0];
847 if (!test_and_clear_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
))
850 if (cs
->debug
& L1_DEB_WARN
)
851 debugl1(cs
, "wrong pstrsp ril=%d",ril
);
854 switch(ireg
->par
[1]) {
889 sprintf(bcs
->hw
.isar
.conmsg
,"%s %s", dmril
[ril
], dmrim
[rim
]);
890 bcs
->conmsg
= bcs
->hw
.isar
.conmsg
;
891 if (cs
->debug
& L1_DEB_HSCX
)
892 debugl1(cs
, "pump strsp %s", bcs
->conmsg
);
896 isar_pump_statev_modem(struct BCState
*bcs
, u_char devt
) {
897 struct IsdnCardState
*cs
= bcs
->cs
;
898 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
901 case PSEV_10MS_TIMER
:
902 if (cs
->debug
& L1_DEB_HSCX
)
903 debugl1(cs
, "pump stev TIMER");
906 if (cs
->debug
& L1_DEB_HSCX
)
907 debugl1(cs
, "pump stev CONNECT");
908 l1_msg_b(bcs
->st
, PH_ACTIVATE
| REQUEST
, NULL
);
911 if (cs
->debug
& L1_DEB_HSCX
)
912 debugl1(cs
, "pump stev NO CONNECT");
913 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
914 l1_msg_b(bcs
->st
, PH_DEACTIVATE
| REQUEST
, NULL
);
917 if (cs
->debug
& L1_DEB_HSCX
)
918 debugl1(cs
, "pump stev V24 OFF");
921 if (cs
->debug
& L1_DEB_HSCX
)
922 debugl1(cs
, "pump stev CTS ON");
925 if (cs
->debug
& L1_DEB_HSCX
)
926 debugl1(cs
, "pump stev CTS OFF");
929 if (cs
->debug
& L1_DEB_HSCX
)
930 debugl1(cs
, "pump stev CARRIER ON");
931 test_and_set_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
);
932 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
935 if (cs
->debug
& L1_DEB_HSCX
)
936 debugl1(cs
, "pump stev CARRIER OFF");
939 if (cs
->debug
& L1_DEB_HSCX
)
940 debugl1(cs
, "pump stev DSR ON");
943 if (cs
->debug
& L1_DEB_HSCX
)
944 debugl1(cs
, "pump stev DSR_OFF");
947 if (cs
->debug
& L1_DEB_HSCX
)
948 debugl1(cs
, "pump stev REMOTE RETRAIN");
951 if (cs
->debug
& L1_DEB_HSCX
)
952 debugl1(cs
, "pump stev REMOTE RENEGOTIATE");
955 if (cs
->debug
& L1_DEB_HSCX
)
956 debugl1(cs
, "pump stev GSTN CLEAR", devt
);
959 if (cs
->debug
& L1_DEB_HSCX
)
960 debugl1(cs
, "unknown pump stev %x", devt
);
966 ll_deliver_faxstat(struct BCState
*bcs
, u_char status
)
969 struct Channel
*chanp
= (struct Channel
*) bcs
->st
->lli
.userdata
;
971 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
972 debugl1(bcs
->cs
, "HL->LL FAXIND %x", status
);
973 ic
.driver
= bcs
->cs
->myid
;
974 ic
.command
= ISDN_STAT_FAXIND
;
975 ic
.arg
= chanp
->chan
;
976 ic
.parm
.aux
.cmd
= status
;
977 bcs
->cs
->iif
.statcallb(&ic
);
981 isar_pump_statev_fax(struct BCState
*bcs
, u_char devt
) {
982 struct IsdnCardState
*cs
= bcs
->cs
;
983 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
987 case PSEV_10MS_TIMER
:
988 if (cs
->debug
& L1_DEB_HSCX
)
989 debugl1(cs
, "pump stev TIMER");
992 if (cs
->debug
& L1_DEB_HSCX
)
993 debugl1(cs
, "pump stev RSP_READY");
994 bcs
->hw
.isar
.state
= STFAX_READY
;
995 l1_msg_b(bcs
->st
, PH_ACTIVATE
| REQUEST
, NULL
);
996 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
997 isar_pump_cmd(bcs
, ISDN_FAX_CLASS1_FRH
, 3);
999 isar_pump_cmd(bcs
, ISDN_FAX_CLASS1_FTH
, 3);
1002 case PSEV_LINE_TX_H
:
1003 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1004 if (cs
->debug
& L1_DEB_HSCX
)
1005 debugl1(cs
, "pump stev LINE_TX_H");
1006 bcs
->hw
.isar
.state
= STFAX_CONT
;
1007 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1009 if (cs
->debug
& L1_DEB_WARN
)
1010 debugl1(cs
, "pump stev LINE_TX_H wrong st %x",
1011 bcs
->hw
.isar
.state
);
1014 case PSEV_LINE_RX_H
:
1015 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1016 if (cs
->debug
& L1_DEB_HSCX
)
1017 debugl1(cs
, "pump stev LINE_RX_H");
1018 bcs
->hw
.isar
.state
= STFAX_CONT
;
1019 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1021 if (cs
->debug
& L1_DEB_WARN
)
1022 debugl1(cs
, "pump stev LINE_RX_H wrong st %x",
1023 bcs
->hw
.isar
.state
);
1026 case PSEV_LINE_TX_B
:
1027 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1028 if (cs
->debug
& L1_DEB_HSCX
)
1029 debugl1(cs
, "pump stev LINE_TX_B");
1030 bcs
->hw
.isar
.state
= STFAX_CONT
;
1031 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1033 if (cs
->debug
& L1_DEB_WARN
)
1034 debugl1(cs
, "pump stev LINE_TX_B wrong st %x",
1035 bcs
->hw
.isar
.state
);
1038 case PSEV_LINE_RX_B
:
1039 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1040 if (cs
->debug
& L1_DEB_HSCX
)
1041 debugl1(cs
, "pump stev LINE_RX_B");
1042 bcs
->hw
.isar
.state
= STFAX_CONT
;
1043 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1045 if (cs
->debug
& L1_DEB_WARN
)
1046 debugl1(cs
, "pump stev LINE_RX_B wrong st %x",
1047 bcs
->hw
.isar
.state
);
1051 if (bcs
->hw
.isar
.state
== STFAX_CONT
) {
1052 if (cs
->debug
& L1_DEB_HSCX
)
1053 debugl1(cs
, "pump stev RSP_CONN");
1054 bcs
->hw
.isar
.state
= STFAX_ACTIV
;
1055 test_and_set_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
);
1056 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
1057 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
1058 /* 1s Flags before data */
1059 if (test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
))
1060 del_timer(&bcs
->hw
.isar
.ftimer
);
1062 bcs
->hw
.isar
.ftimer
.expires
=
1063 jiffies
+ ((1000 * HZ
)/1000);
1064 test_and_set_bit(BC_FLG_LL_CONN
,
1066 add_timer(&bcs
->hw
.isar
.ftimer
);
1068 schedule_event(bcs
, B_LL_CONNECT
);
1071 if (cs
->debug
& L1_DEB_WARN
)
1072 debugl1(cs
, "pump stev RSP_CONN wrong st %x",
1073 bcs
->hw
.isar
.state
);
1076 case PSEV_FLAGS_DET
:
1077 if (cs
->debug
& L1_DEB_HSCX
)
1078 debugl1(cs
, "pump stev FLAGS_DET");
1081 if (cs
->debug
& L1_DEB_HSCX
)
1082 debugl1(cs
, "pump stev RSP_DISC");
1083 if (bcs
->hw
.isar
.state
== STFAX_ESCAPE
) {
1085 switch(bcs
->hw
.isar
.newcmd
) {
1087 bcs
->hw
.isar
.state
= STFAX_READY
;
1092 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1093 PCTRL_CMD_SILON
, 1, &p1
);
1094 bcs
->hw
.isar
.state
= STFAX_SILDET
;
1097 if (frm_extra_delay
)
1098 mdelay(frm_extra_delay
);
1100 p1
= bcs
->hw
.isar
.mod
= bcs
->hw
.isar
.newmod
;
1101 bcs
->hw
.isar
.newmod
= 0;
1102 bcs
->hw
.isar
.cmd
= bcs
->hw
.isar
.newcmd
;
1103 bcs
->hw
.isar
.newcmd
= 0;
1104 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1105 bcs
->hw
.isar
.cmd
, 1, &p1
);
1106 bcs
->hw
.isar
.state
= STFAX_LINE
;
1107 bcs
->hw
.isar
.try_mod
= 3;
1110 if (cs
->debug
& L1_DEB_HSCX
)
1111 debugl1(cs
, "RSP_DISC unknown newcmd %x", bcs
->hw
.isar
.newcmd
);
1114 } else if (bcs
->hw
.isar
.state
== STFAX_ACTIV
) {
1115 if (test_and_clear_bit(BC_FLG_LL_OK
, &bcs
->Flag
)) {
1116 schedule_event(bcs
, B_LL_OK
);
1117 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) {
1119 schedule_event(bcs
, B_LL_NOCARRIER
);
1121 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1123 bcs
->hw
.isar
.state
= STFAX_READY
;
1125 bcs
->hw
.isar
.state
= STFAX_READY
;
1126 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1129 case PSEV_RSP_SILDET
:
1130 if (cs
->debug
& L1_DEB_HSCX
)
1131 debugl1(cs
, "pump stev RSP_SILDET");
1132 if (bcs
->hw
.isar
.state
== STFAX_SILDET
) {
1133 p1
= bcs
->hw
.isar
.mod
= bcs
->hw
.isar
.newmod
;
1134 bcs
->hw
.isar
.newmod
= 0;
1135 bcs
->hw
.isar
.cmd
= bcs
->hw
.isar
.newcmd
;
1136 bcs
->hw
.isar
.newcmd
= 0;
1137 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1138 bcs
->hw
.isar
.cmd
, 1, &p1
);
1139 bcs
->hw
.isar
.state
= STFAX_LINE
;
1140 bcs
->hw
.isar
.try_mod
= 3;
1143 case PSEV_RSP_SILOFF
:
1144 if (cs
->debug
& L1_DEB_HSCX
)
1145 debugl1(cs
, "pump stev RSP_SILOFF");
1147 case PSEV_RSP_FCERR
:
1148 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1149 if (cs
->debug
& L1_DEB_HSCX
)
1150 debugl1(cs
, "pump stev RSP_FCERR try %d",
1151 bcs
->hw
.isar
.try_mod
);
1152 if (bcs
->hw
.isar
.try_mod
--) {
1153 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1154 bcs
->hw
.isar
.cmd
, 1,
1159 if (cs
->debug
& L1_DEB_HSCX
)
1160 debugl1(cs
, "pump stev RSP_FCERR");
1161 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1162 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
, 0, NULL
);
1163 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1170 static char debbuf
[128];
1173 isar_int_main(struct IsdnCardState
*cs
)
1175 struct isar_reg
*ireg
= cs
->bcs
[0].hw
.isar
.reg
;
1176 struct BCState
*bcs
;
1178 get_irq_infos(cs
, ireg
);
1179 switch (ireg
->iis
& ISAR_IIS_MSCMSD
) {
1180 case ISAR_IIS_RDATA
:
1181 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1182 isar_rcv_frame(cs
, bcs
);
1184 debugl1(cs
, "isar spurious IIS_RDATA %x/%x/%x",
1185 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1186 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1189 case ISAR_IIS_GSTEV
:
1190 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1191 ireg
->bstat
|= ireg
->cmsb
;
1192 check_send(cs
, ireg
->cmsb
);
1194 case ISAR_IIS_BSTEV
:
1195 #ifdef ERROR_STATISTIC
1196 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1197 if (ireg
->cmsb
== BSTEV_TBO
)
1199 if (ireg
->cmsb
== BSTEV_RBO
)
1203 if (cs
->debug
& L1_DEB_WARN
)
1204 debugl1(cs
, "Buffer STEV dpath%d msb(%x)",
1205 ireg
->iis
>>6, ireg
->cmsb
);
1206 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1208 case ISAR_IIS_PSTEV
:
1209 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1210 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1211 if (bcs
->mode
== L1_MODE_V32
) {
1212 isar_pump_statev_modem(bcs
, ireg
->cmsb
);
1213 } else if (bcs
->mode
== L1_MODE_FAX
) {
1214 isar_pump_statev_fax(bcs
, ireg
->cmsb
);
1215 } else if (ireg
->cmsb
== PSEV_10MS_TIMER
) {
1216 if (cs
->debug
& L1_DEB_HSCX
)
1217 debugl1(cs
, "pump stev TIMER");
1219 if (cs
->debug
& L1_DEB_WARN
)
1220 debugl1(cs
, "isar IIS_PSTEV pmode %d stat %x",
1221 bcs
->mode
, ireg
->cmsb
);
1224 debugl1(cs
, "isar spurious IIS_PSTEV %x/%x/%x",
1225 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1226 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1229 case ISAR_IIS_PSTRSP
:
1230 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1231 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1232 isar_pump_status_rsp(bcs
, ireg
);
1234 debugl1(cs
, "isar spurious IIS_PSTRSP %x/%x/%x",
1235 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1236 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1240 case ISAR_IIS_BSTRSP
:
1241 case ISAR_IIS_IOM2RSP
:
1242 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1243 if ((cs
->debug
& (L1_DEB_HSCX
| L1_DEB_HSCX_FIFO
))
1247 tp
+= sprintf(debbuf
, "msg iis(%x) msb(%x)",
1248 ireg
->iis
, ireg
->cmsb
);
1249 QuickHex(tp
, (u_char
*)ireg
->par
, ireg
->clsb
);
1250 debugl1(cs
, debbuf
);
1253 case ISAR_IIS_INVMSG
:
1254 rcv_mbox(cs
, ireg
, debbuf
);
1255 if (cs
->debug
& L1_DEB_WARN
)
1256 debugl1(cs
, "invalid msg his:%x",
1260 rcv_mbox(cs
, ireg
, debbuf
);
1261 if (cs
->debug
& L1_DEB_WARN
)
1262 debugl1(cs
, "unhandled msg iis(%x) ctrl(%x/%x)",
1263 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1269 ftimer_handler(struct BCState
*bcs
) {
1271 debugl1(bcs
->cs
, "ftimer flags %04x",
1273 test_and_clear_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
);
1274 if (test_and_clear_bit(BC_FLG_LL_CONN
, &bcs
->Flag
)) {
1275 schedule_event(bcs
, B_LL_CONNECT
);
1277 if (test_and_clear_bit(BC_FLG_FTI_FTS
, &bcs
->Flag
)) {
1278 schedule_event(bcs
, B_LL_OK
);
1283 setup_pump(struct BCState
*bcs
) {
1284 struct IsdnCardState
*cs
= bcs
->cs
;
1285 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1286 u_char ctrl
, param
[6];
1288 switch (bcs
->mode
) {
1292 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, PMOD_BYPASS
, 0, NULL
);
1295 ctrl
= PMOD_DATAMODEM
;
1296 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
1298 param
[5] = PV32P6_CTN
;
1300 param
[5] = PV32P6_ATN
;
1302 param
[0] = para_TOA
; /* 6 db */
1303 param
[1] = PV32P2_V23R
| PV32P2_V22A
| PV32P2_V22B
|
1304 PV32P2_V22C
| PV32P2_V21
| PV32P2_BEL
;
1305 param
[2] = PV32P3_AMOD
| PV32P3_V32B
| PV32P3_V23B
;
1306 param
[3] = PV32P4_UT144
;
1307 param
[4] = PV32P5_UT144
;
1308 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, ctrl
, 6, param
);
1312 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
1314 param
[1] = PFAXP2_CTN
;
1316 param
[1] = PFAXP2_ATN
;
1318 param
[0] = para_TOA
; /* 6 db */
1319 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, ctrl
, 2, param
);
1320 bcs
->hw
.isar
.state
= STFAX_NULL
;
1321 bcs
->hw
.isar
.newcmd
= 0;
1322 bcs
->hw
.isar
.newmod
= 0;
1323 test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
);
1327 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
1332 setup_sart(struct BCState
*bcs
) {
1333 struct IsdnCardState
*cs
= bcs
->cs
;
1334 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1335 u_char ctrl
, param
[2];
1337 switch (bcs
->mode
) {
1339 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_DISABLE
, 0,
1343 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_BINARY
, 2,
1348 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_HDLC
, 1,
1352 ctrl
= SMODE_V14
| SCTRL_HDMC_BOTH
;
1353 param
[0] = S_P1_CHS_8
;
1354 param
[1] = S_P2_BFT_DEF
;
1355 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, ctrl
, 2,
1359 /* SART must not configured with FAX */
1363 sendmsg(cs
, dps
| ISAR_HIS_BSTREQ
, 0, 0, NULL
);
1368 setup_iom2(struct BCState
*bcs
) {
1369 struct IsdnCardState
*cs
= bcs
->cs
;
1370 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1371 u_char cmsb
= IOM_CTRL_ENA
, msg
[5] = {IOM_P1_TXD
,0,0,0,0};
1374 msg
[1] = msg
[3] = 1;
1375 switch (bcs
->mode
) {
1379 msg
[1] = msg
[3] = bcs
->hw
.isar
.dpath
+ 2;
1386 cmsb
|= IOM_CTRL_ALAW
| IOM_CTRL_RCV
;
1389 sendmsg(cs
, dps
| ISAR_HIS_IOM2CFG
, cmsb
, 5, msg
);
1391 sendmsg(cs
, dps
| ISAR_HIS_IOM2REQ
, 0, 0, NULL
);
1396 modeisar(struct BCState
*bcs
, int mode
, int bc
)
1398 struct IsdnCardState
*cs
= bcs
->cs
;
1400 /* Here we are selecting the best datapath for requested mode */
1401 if(bcs
->mode
== L1_MODE_NULL
) { /* New Setup */
1404 case L1_MODE_NULL
: /* init */
1405 if (!bcs
->hw
.isar
.dpath
)
1406 /* no init for dpath 0 */
1411 /* best is datapath 2 */
1412 if (!test_and_set_bit(ISAR_DP2_USE
,
1413 &bcs
->hw
.isar
.reg
->Flags
))
1414 bcs
->hw
.isar
.dpath
= 2;
1415 else if (!test_and_set_bit(ISAR_DP1_USE
,
1416 &bcs
->hw
.isar
.reg
->Flags
))
1417 bcs
->hw
.isar
.dpath
= 1;
1419 printk(KERN_WARNING
"isar modeisar both pathes in use\n");
1425 /* only datapath 1 */
1426 if (!test_and_set_bit(ISAR_DP1_USE
,
1427 &bcs
->hw
.isar
.reg
->Flags
))
1428 bcs
->hw
.isar
.dpath
= 1;
1430 printk(KERN_WARNING
"isar modeisar analog funktions only with DP1\n");
1431 debugl1(cs
, "isar modeisar analog funktions only with DP1");
1437 if (cs
->debug
& L1_DEB_HSCX
)
1438 debugl1(cs
, "isar dp%d mode %d->%d ichan %d",
1439 bcs
->hw
.isar
.dpath
, bcs
->mode
, mode
, bc
);
1444 if (bcs
->mode
== L1_MODE_NULL
) {
1445 /* Clear resources */
1446 if (bcs
->hw
.isar
.dpath
== 1)
1447 test_and_clear_bit(ISAR_DP1_USE
, &bcs
->hw
.isar
.reg
->Flags
);
1448 else if (bcs
->hw
.isar
.dpath
== 2)
1449 test_and_clear_bit(ISAR_DP2_USE
, &bcs
->hw
.isar
.reg
->Flags
);
1450 bcs
->hw
.isar
.dpath
= 0;
1456 isar_pump_cmd(struct BCState
*bcs
, u_char cmd
, u_char para
)
1458 struct IsdnCardState
*cs
= bcs
->cs
;
1459 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1460 u_char ctrl
= 0, nom
= 0, p1
= 0;
1463 case ISDN_FAX_CLASS1_FTM
:
1464 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1465 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1467 ctrl
= PCTRL_CMD_FTM
;
1469 bcs
->hw
.isar
.state
= STFAX_LINE
;
1470 bcs
->hw
.isar
.cmd
= ctrl
;
1471 bcs
->hw
.isar
.mod
= para
;
1472 bcs
->hw
.isar
.newmod
= 0;
1473 bcs
->hw
.isar
.newcmd
= 0;
1474 bcs
->hw
.isar
.try_mod
= 3;
1475 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1476 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) &&
1477 (bcs
->hw
.isar
.mod
== para
)) {
1478 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1480 bcs
->hw
.isar
.newmod
= para
;
1481 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FTM
;
1483 ctrl
= PCTRL_CMD_ESC
;
1484 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1487 case ISDN_FAX_CLASS1_FTH
:
1488 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1489 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1491 ctrl
= PCTRL_CMD_FTH
;
1493 bcs
->hw
.isar
.state
= STFAX_LINE
;
1494 bcs
->hw
.isar
.cmd
= ctrl
;
1495 bcs
->hw
.isar
.mod
= para
;
1496 bcs
->hw
.isar
.newmod
= 0;
1497 bcs
->hw
.isar
.newcmd
= 0;
1498 bcs
->hw
.isar
.try_mod
= 3;
1499 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1500 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) &&
1501 (bcs
->hw
.isar
.mod
== para
)) {
1502 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1504 bcs
->hw
.isar
.newmod
= para
;
1505 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FTH
;
1507 ctrl
= PCTRL_CMD_ESC
;
1508 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1511 case ISDN_FAX_CLASS1_FRM
:
1512 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1513 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1515 ctrl
= PCTRL_CMD_FRM
;
1517 bcs
->hw
.isar
.state
= STFAX_LINE
;
1518 bcs
->hw
.isar
.cmd
= ctrl
;
1519 bcs
->hw
.isar
.mod
= para
;
1520 bcs
->hw
.isar
.newmod
= 0;
1521 bcs
->hw
.isar
.newcmd
= 0;
1522 bcs
->hw
.isar
.try_mod
= 3;
1523 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1524 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) &&
1525 (bcs
->hw
.isar
.mod
== para
)) {
1526 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1528 bcs
->hw
.isar
.newmod
= para
;
1529 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FRM
;
1531 ctrl
= PCTRL_CMD_ESC
;
1532 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1535 case ISDN_FAX_CLASS1_FRH
:
1536 test_and_set_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1537 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1539 ctrl
= PCTRL_CMD_FRH
;
1541 bcs
->hw
.isar
.state
= STFAX_LINE
;
1542 bcs
->hw
.isar
.cmd
= ctrl
;
1543 bcs
->hw
.isar
.mod
= para
;
1544 bcs
->hw
.isar
.newmod
= 0;
1545 bcs
->hw
.isar
.newcmd
= 0;
1546 bcs
->hw
.isar
.try_mod
= 3;
1547 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1548 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRH
) &&
1549 (bcs
->hw
.isar
.mod
== para
)) {
1550 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1552 bcs
->hw
.isar
.newmod
= para
;
1553 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FRH
;
1555 ctrl
= PCTRL_CMD_ESC
;
1556 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1559 case ISDN_FAXPUMP_HALT
:
1560 bcs
->hw
.isar
.state
= STFAX_NULL
;
1562 ctrl
= PCTRL_CMD_HALT
;
1566 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, ctrl
, nom
, &p1
);
1570 isar_setup(struct IsdnCardState
*cs
)
1577 for (i
=0; i
<2; i
++) {
1579 sendmsg(cs
, (i
? ISAR_HIS_DPS2
: ISAR_HIS_DPS1
) |
1580 ISAR_HIS_P12CFG
, 4, 1, &msg
);
1581 cs
->bcs
[i
].hw
.isar
.mml
= msg
;
1582 cs
->bcs
[i
].mode
= 0;
1583 cs
->bcs
[i
].hw
.isar
.dpath
= i
+ 1;
1584 modeisar(&cs
->bcs
[i
], 0, 0);
1585 INIT_WORK(&cs
->bcs
[i
].tqueue
, isar_bh
);
1590 isar_l2l1(struct PStack
*st
, int pr
, void *arg
)
1592 struct BCState
*bcs
= st
->l1
.bcs
;
1593 struct sk_buff
*skb
= arg
;
1598 case (PH_DATA
| REQUEST
):
1599 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1601 skb_queue_tail(&bcs
->squeue
, skb
);
1604 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1605 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1606 debugl1(bcs
->cs
, "DRQ set BC_FLG_BUSY");
1607 bcs
->hw
.isar
.txcnt
= 0;
1608 bcs
->cs
->BC_Send_Data(bcs
);
1610 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1612 case (PH_PULL
| INDICATION
):
1613 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1615 printk(KERN_WARNING
"isar_l2l1: this shouldn't happen\n");
1617 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1618 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1619 debugl1(bcs
->cs
, "PUI set BC_FLG_BUSY");
1621 bcs
->hw
.isar
.txcnt
= 0;
1622 bcs
->cs
->BC_Send_Data(bcs
);
1624 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1626 case (PH_PULL
| REQUEST
):
1628 test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1629 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1631 test_and_set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1633 case (PH_ACTIVATE
| REQUEST
):
1634 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1635 test_and_set_bit(BC_FLG_ACTIV
, &bcs
->Flag
);
1636 bcs
->hw
.isar
.conmsg
[0] = 0;
1637 if (test_bit(FLG_ORIG
, &st
->l2
.flag
))
1638 test_and_set_bit(BC_FLG_ORIG
, &bcs
->Flag
);
1640 test_and_clear_bit(BC_FLG_ORIG
, &bcs
->Flag
);
1641 switch(st
->l1
.mode
) {
1644 ret
= modeisar(bcs
, st
->l1
.mode
, st
->l1
.bc
);
1645 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1647 l1_msg_b(st
, PH_DEACTIVATE
| REQUEST
, arg
);
1649 l1_msg_b(st
, PH_ACTIVATE
| REQUEST
, arg
);
1653 ret
= modeisar(bcs
, st
->l1
.mode
, st
->l1
.bc
);
1654 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1656 l1_msg_b(st
, PH_DEACTIVATE
| REQUEST
, arg
);
1659 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1663 case (PH_DEACTIVATE
| REQUEST
):
1664 l1_msg_b(st
, pr
, arg
);
1666 case (PH_DEACTIVATE
| CONFIRM
):
1667 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1668 switch(st
->l1
.mode
) {
1674 isar_pump_cmd(bcs
, ISDN_FAXPUMP_HALT
, 0);
1677 test_and_clear_bit(BC_FLG_ACTIV
, &bcs
->Flag
);
1678 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1679 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1680 debugl1(bcs
->cs
, "PDAC clear BC_FLG_BUSY");
1681 modeisar(bcs
, 0, st
->l1
.bc
);
1682 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1683 st
->l1
.l1l2(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
1689 close_isarstate(struct BCState
*bcs
)
1691 modeisar(bcs
, 0, bcs
->channel
);
1692 if (test_and_clear_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1693 kfree(bcs
->hw
.isar
.rcvbuf
);
1694 bcs
->hw
.isar
.rcvbuf
= NULL
;
1695 skb_queue_purge(&bcs
->rqueue
);
1696 skb_queue_purge(&bcs
->squeue
);
1698 dev_kfree_skb_any(bcs
->tx_skb
);
1700 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1701 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1702 debugl1(bcs
->cs
, "closeisar clear BC_FLG_BUSY");
1705 del_timer(&bcs
->hw
.isar
.ftimer
);
1709 open_isarstate(struct IsdnCardState
*cs
, struct BCState
*bcs
)
1711 if (!test_and_set_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1712 if (!(bcs
->hw
.isar
.rcvbuf
= kmalloc(HSCX_BUFMAX
, GFP_ATOMIC
))) {
1714 "HiSax: No memory for isar.rcvbuf\n");
1717 skb_queue_head_init(&bcs
->rqueue
);
1718 skb_queue_head_init(&bcs
->squeue
);
1721 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1722 if (cs
->debug
& L1_DEB_HSCX
)
1723 debugl1(cs
, "openisar clear BC_FLG_BUSY");
1725 bcs
->hw
.isar
.rcvidx
= 0;
1731 setstack_isar(struct PStack
*st
, struct BCState
*bcs
)
1733 bcs
->channel
= st
->l1
.bc
;
1734 if (open_isarstate(st
->l1
.hardware
, bcs
))
1737 st
->l2
.l2l1
= isar_l2l1
;
1738 setstack_manager(st
);
1745 isar_auxcmd(struct IsdnCardState
*cs
, isdn_ctrl
*ic
) {
1748 struct BCState
*bcs
;
1750 if (cs
->debug
& L1_DEB_HSCX
)
1751 debugl1(cs
, "isar_auxcmd cmd/ch %x/%d", ic
->command
, ic
->arg
);
1752 switch (ic
->command
) {
1753 case (ISDN_CMD_FAXCMD
):
1754 bcs
= cs
->channel
[ic
->arg
].bcs
;
1755 if (cs
->debug
& L1_DEB_HSCX
)
1756 debugl1(cs
, "isar_auxcmd cmd/subcmd %d/%d",
1757 ic
->parm
.aux
.cmd
, ic
->parm
.aux
.subcmd
);
1758 switch(ic
->parm
.aux
.cmd
) {
1759 case ISDN_FAX_CLASS1_CTRL
:
1760 if (ic
->parm
.aux
.subcmd
== ETX
)
1761 test_and_set_bit(BC_FLG_DLEETX
,
1764 case ISDN_FAX_CLASS1_FTS
:
1765 if (ic
->parm
.aux
.subcmd
== AT_QUERY
) {
1766 ic
->command
= ISDN_STAT_FAXIND
;
1767 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_OK
;
1768 cs
->iif
.statcallb(ic
);
1770 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_QUERY
) {
1771 strcpy(ic
->parm
.aux
.para
, "0-255");
1772 ic
->command
= ISDN_STAT_FAXIND
;
1773 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1774 cs
->iif
.statcallb(ic
);
1776 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_VALUE
) {
1777 if (cs
->debug
& L1_DEB_HSCX
)
1778 debugl1(cs
, "isar_auxcmd %s=%d",
1779 FC1_CMD
[ic
->parm
.aux
.cmd
], ic
->parm
.aux
.para
[0]);
1780 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1781 if (! ic
->parm
.aux
.para
[0]) {
1782 ic
->command
= ISDN_STAT_FAXIND
;
1783 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_OK
;
1784 cs
->iif
.statcallb(ic
);
1787 if (! test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
)) {
1789 bcs
->hw
.isar
.ftimer
.expires
=
1790 jiffies
+ ((ic
->parm
.aux
.para
[0] * 10 * HZ
)/1000);
1791 test_and_set_bit(BC_FLG_FTI_FTS
, &bcs
->Flag
);
1792 add_timer(&bcs
->hw
.isar
.ftimer
);
1796 debugl1(cs
, "isar FTS=%d and FTI busy",
1797 ic
->parm
.aux
.para
[0]);
1801 debugl1(cs
, "isar FTS=%d and isar.state not ready(%x)",
1802 ic
->parm
.aux
.para
[0],bcs
->hw
.isar
.state
);
1804 ic
->command
= ISDN_STAT_FAXIND
;
1805 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_ERROR
;
1806 cs
->iif
.statcallb(ic
);
1809 case ISDN_FAX_CLASS1_FRM
:
1810 case ISDN_FAX_CLASS1_FRH
:
1811 case ISDN_FAX_CLASS1_FTM
:
1812 case ISDN_FAX_CLASS1_FTH
:
1813 if (ic
->parm
.aux
.subcmd
== AT_QUERY
) {
1814 sprintf(ic
->parm
.aux
.para
,
1815 "%d", bcs
->hw
.isar
.mod
);
1816 ic
->command
= ISDN_STAT_FAXIND
;
1817 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1818 cs
->iif
.statcallb(ic
);
1820 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_QUERY
) {
1821 char *p
= ic
->parm
.aux
.para
;
1822 for(i
=0;i
<FAXMODCNT
;i
++)
1823 if ((1<<i
) & modmask
)
1824 p
+= sprintf(p
, "%d,", faxmodulation
[i
]);
1827 ic
->command
= ISDN_STAT_FAXIND
;
1828 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1829 cs
->iif
.statcallb(ic
);
1831 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_VALUE
) {
1832 if (cs
->debug
& L1_DEB_HSCX
)
1833 debugl1(cs
, "isar_auxcmd %s=%d",
1834 FC1_CMD
[ic
->parm
.aux
.cmd
], ic
->parm
.aux
.para
[0]);
1835 for(i
=0;i
<FAXMODCNT
;i
++)
1836 if (faxmodulation
[i
]==ic
->parm
.aux
.para
[0])
1838 if ((i
< FAXMODCNT
) && ((1<<i
) & modmask
) &&
1839 test_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1842 ic
->parm
.aux
.para
[0]);
1846 /* wrong modulation or not activ */
1849 ic
->command
= ISDN_STAT_FAXIND
;
1850 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_ERROR
;
1851 cs
->iif
.statcallb(ic
);
1854 case (ISDN_CMD_IOCTL
):
1856 case 9: /* load firmware */
1857 features
= ISDN_FEATURE_L2_MODEM
|
1858 ISDN_FEATURE_L2_FAX
|
1859 ISDN_FEATURE_L3_FCLASS1
;
1860 memcpy(&adr
, ic
->parm
.num
, sizeof(ulong
));
1861 if (isar_load_firmware(cs
, (u_char __user
*)adr
))
1864 ll_run(cs
, features
);
1867 features
= *(unsigned int *) ic
->parm
.num
;
1868 printk(KERN_DEBUG
"HiSax: max modulation old(%04x) new(%04x)\n",
1873 features
= *(unsigned int *) ic
->parm
.num
;
1874 printk(KERN_DEBUG
"HiSax: FRM extra delay old(%d) new(%d) ms\n",
1875 frm_extra_delay
, features
);
1877 frm_extra_delay
= features
;
1880 features
= *(unsigned int *) ic
->parm
.num
;
1881 printk(KERN_DEBUG
"HiSax: TOA old(%d) new(%d) db\n",
1882 para_TOA
, features
);
1883 if (features
>= 0 && features
< 32)
1884 para_TOA
= features
;
1887 printk(KERN_DEBUG
"HiSax: invalid ioctl %d\n",
1898 void initisar(struct IsdnCardState
*cs
)
1900 cs
->bcs
[0].BC_SetStack
= setstack_isar
;
1901 cs
->bcs
[1].BC_SetStack
= setstack_isar
;
1902 cs
->bcs
[0].BC_Close
= close_isarstate
;
1903 cs
->bcs
[1].BC_Close
= close_isarstate
;
1904 cs
->bcs
[0].hw
.isar
.ftimer
.function
= (void *) ftimer_handler
;
1905 cs
->bcs
[0].hw
.isar
.ftimer
.data
= (long) &cs
->bcs
[0];
1906 init_timer(&cs
->bcs
[0].hw
.isar
.ftimer
);
1907 cs
->bcs
[1].hw
.isar
.ftimer
.function
= (void *) ftimer_handler
;
1908 cs
->bcs
[1].hw
.isar
.ftimer
.data
= (long) &cs
->bcs
[1];
1909 init_timer(&cs
->bcs
[1].hw
.isar
.ftimer
);