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]);
66 for (i
= 1; i
< len
; i
++)
67 cs
->BC_Write_Reg(cs
, 2, ISAR_MBOX
, msg
[i
]);
68 #if DUMP_MBOXFRAME > 1
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
);
77 debugl1(cs
, "%s", tmp
);
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
);
99 #if DUMP_MBOXFRAME > 1
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
);
108 debugl1(cs
, "%s", tmp
);
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 cfu_ret
, 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 cfu_ret
= copy_from_user(&size
, p
, sizeof(int));
217 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", cfu_ret
);
221 printk(KERN_DEBUG
"isar_load_firmware size: %d\n", size
);
223 /* disable ISAR IRQ */
224 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
225 if (!(msg
= kmalloc(256, GFP_KERNEL
))) {
226 printk(KERN_ERR
"isar_load_firmware no buffer\n");
229 if (!(tmpmsg
= kmalloc(256, GFP_KERNEL
))) {
230 printk(KERN_ERR
"isar_load_firmware no tmp buffer\n");
234 spin_lock_irqsave(&cs
->lock
, flags
);
235 /* disable ISAR IRQ */
236 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
237 spin_unlock_irqrestore(&cs
->lock
, flags
);
239 if ((ret
= copy_from_user(&blk_head
, p
, BLK_HEAD_SIZE
))) {
240 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", ret
);
244 sadr
= (blk_head
.sadr
& 0xff) * 256 + blk_head
.sadr
/ 256;
245 blk_head
.sadr
= sadr
;
246 sadr
= (blk_head
.len
& 0xff) * 256 + blk_head
.len
/ 256;
248 sadr
= (blk_head
.d_key
& 0xff) * 256 + blk_head
.d_key
/ 256;
249 blk_head
.d_key
= sadr
;
250 #endif /* __BIG_ENDIAN */
251 cnt
+= BLK_HEAD_SIZE
;
253 printk(KERN_DEBUG
"isar firmware block (%#x,%5d,%#x)\n",
254 blk_head
.sadr
, blk_head
.len
, blk_head
.d_key
& 0xff);
255 sadr
= blk_head
.sadr
;
257 spin_lock_irqsave(&cs
->lock
, flags
);
258 if (!sendmsg(cs
, ISAR_HIS_DKEY
, blk_head
.d_key
& 0xff, 0, NULL
)) {
259 printk(KERN_ERR
"isar sendmsg dkey failed\n");
260 ret
= 1; goto reterr_unlock
;
262 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
263 printk(KERN_ERR
"isar waitrecmsg dkey failed\n");
264 ret
= 1; goto reterr_unlock
;
266 if ((ireg
->iis
!= ISAR_IIS_DKEY
) || ireg
->cmsb
|| len
) {
267 printk(KERN_ERR
"isar wrong dkey response (%x,%x,%x)\n",
268 ireg
->iis
, ireg
->cmsb
, len
);
269 ret
= 1; goto reterr_unlock
;
271 spin_unlock_irqrestore(&cs
->lock
, flags
);
283 if ((ret
= copy_from_user(tmpmsg
, p
, nom
))) {
284 printk(KERN_ERR
"isar_load_firmware copy_from_user ret %d\n", ret
);
290 sp
= (u_short
*)tmpmsg
;
292 printk(KERN_DEBUG
"isar: load %3d words at %04x left %d\n",
303 #endif /* __BIG_ENDIAN */
307 spin_lock_irqsave(&cs
->lock
, flags
);
308 if (!sendmsg(cs
, ISAR_HIS_FIRM
, 0, nom
, msg
)) {
309 printk(KERN_ERR
"isar sendmsg prog failed\n");
310 ret
= 1; goto reterr_unlock
;
312 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
313 printk(KERN_ERR
"isar waitrecmsg prog failed\n");
314 ret
= 1; goto reterr_unlock
;
316 if ((ireg
->iis
!= ISAR_IIS_FIRM
) || ireg
->cmsb
|| len
) {
317 printk(KERN_ERR
"isar wrong prog response (%x,%x,%x)\n",
318 ireg
->iis
, ireg
->cmsb
, len
);
319 ret
= 1; goto reterr_unlock
;
321 spin_unlock_irqrestore(&cs
->lock
, flags
);
323 printk(KERN_DEBUG
"isar firmware block %5d words loaded\n",
333 spin_lock_irqsave(&cs
->lock
, flags
);
334 if (!sendmsg(cs
, ISAR_HIS_STDSP
, 0, 2, msg
)) {
335 printk(KERN_ERR
"isar sendmsg start dsp failed\n");
336 ret
= 1; goto reterr_unlock
;
338 if (!waitrecmsg(cs
, &len
, tmp
, 100000)) {
339 printk(KERN_ERR
"isar waitrecmsg start dsp failed\n");
340 ret
= 1; goto reterr_unlock
;
342 if ((ireg
->iis
!= ISAR_IIS_STDSP
) || ireg
->cmsb
|| len
) {
343 printk(KERN_ERR
"isar wrong start dsp response (%x,%x,%x)\n",
344 ireg
->iis
, ireg
->cmsb
, len
);
345 ret
= 1; goto reterr_unlock
;
347 printk(KERN_DEBUG
"isar start dsp success\n");
348 /* NORMAL mode entered */
349 /* Enable IRQs of ISAR */
350 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, ISAR_IRQSTA
);
351 spin_unlock_irqrestore(&cs
->lock
, flags
);
352 cnt
= 1000; /* max 1s */
353 while ((!ireg
->bstat
) && cnt
) {
358 printk(KERN_ERR
"isar no general status event received\n");
359 ret
= 1; goto reterror
;
361 printk(KERN_DEBUG
"isar general status event %x\n",
368 spin_lock_irqsave(&cs
->lock
, flags
);
370 if (!sendmsg(cs
, ISAR_HIS_DIAG
, ISAR_CTRL_STST
, 0, NULL
)) {
371 printk(KERN_ERR
"isar sendmsg self tst failed\n");
372 ret
= 1; goto reterr_unlock
;
374 cnt
= 10000; /* max 100 ms */
375 spin_unlock_irqrestore(&cs
->lock
, flags
);
376 while ((ireg
->iis
!= ISAR_IIS_DIAG
) && cnt
) {
382 printk(KERN_ERR
"isar no self tst response\n");
383 ret
= 1; goto reterror
;
385 if ((ireg
->cmsb
== ISAR_CTRL_STST
) && (ireg
->clsb
== 1)
386 && (ireg
->par
[0] == 0)) {
387 printk(KERN_DEBUG
"isar selftest OK\n");
389 printk(KERN_DEBUG
"isar selftest not OK %x/%x/%x\n",
390 ireg
->cmsb
, ireg
->clsb
, ireg
->par
[0]);
391 ret
= 1; goto reterror
;
393 spin_lock_irqsave(&cs
->lock
, flags
);
395 if (!sendmsg(cs
, ISAR_HIS_DIAG
, ISAR_CTRL_SWVER
, 0, NULL
)) {
396 printk(KERN_ERR
"isar RQST SVN failed\n");
397 ret
= 1; goto reterr_unlock
;
399 spin_unlock_irqrestore(&cs
->lock
, flags
);
400 cnt
= 30000; /* max 300 ms */
401 while ((ireg
->iis
!= ISAR_IIS_DIAG
) && cnt
) {
407 printk(KERN_ERR
"isar no SVN response\n");
408 ret
= 1; goto reterror
;
410 if ((ireg
->cmsb
== ISAR_CTRL_SWVER
) && (ireg
->clsb
== 1))
411 printk(KERN_DEBUG
"isar software version %#x\n",
414 printk(KERN_ERR
"isar wrong swver response (%x,%x) cnt(%d)\n",
415 ireg
->cmsb
, ireg
->clsb
, cnt
);
416 ret
= 1; goto reterror
;
419 spin_lock_irqsave(&cs
->lock
, flags
);
425 spin_unlock_irqrestore(&cs
->lock
, flags
);
429 /* disable ISAR IRQ */
430 cs
->BC_Write_Reg(cs
, 0, ISAR_IRQBIT
, 0);
436 #define B_LL_NOCARRIER 8
437 #define B_LL_CONNECT 9
441 isar_bh(struct work_struct
*work
)
443 struct BCState
*bcs
= container_of(work
, struct BCState
, tqueue
);
446 if (test_and_clear_bit(B_LL_NOCARRIER
, &bcs
->event
))
447 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_NOCARR
);
448 if (test_and_clear_bit(B_LL_CONNECT
, &bcs
->event
))
449 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
450 if (test_and_clear_bit(B_LL_OK
, &bcs
->event
))
451 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_OK
);
455 send_DLE_ETX(struct BCState
*bcs
)
457 u_char dleetx
[2] = {DLE
, ETX
};
460 if ((skb
= dev_alloc_skb(2))) {
461 skb_put_data(skb
, dleetx
, 2);
462 skb_queue_tail(&bcs
->rqueue
, skb
);
463 schedule_event(bcs
, B_RCVBUFREADY
);
465 printk(KERN_WARNING
"HiSax: skb out of memory\n");
470 dle_count(unsigned char *buf
, int len
)
481 insert_dle(unsigned char *dest
, unsigned char *src
, int count
) {
482 /* <DLE> in input stream have to be flagged as <DLE><DLE> */
491 isar_rcv_frame(struct IsdnCardState
*cs
, struct BCState
*bcs
)
495 struct isar_reg
*ireg
= bcs
->hw
.isar
.reg
;
498 debugl1(cs
, "isar zero len frame");
499 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
504 debugl1(cs
, "isar mode 0 spurious IIS_RDATA %x/%x/%x",
505 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
506 printk(KERN_WARNING
"isar mode 0 spurious IIS_RDATA %x/%x/%x\n",
507 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
508 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
512 if ((skb
= dev_alloc_skb(ireg
->clsb
))) {
513 rcv_mbox(cs
, ireg
, (u_char
*)skb_put(skb
, ireg
->clsb
));
514 skb_queue_tail(&bcs
->rqueue
, skb
);
515 schedule_event(bcs
, B_RCVBUFREADY
);
517 printk(KERN_WARNING
"HiSax: skb out of memory\n");
518 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
522 if ((bcs
->hw
.isar
.rcvidx
+ ireg
->clsb
) > HSCX_BUFMAX
) {
523 if (cs
->debug
& L1_DEB_WARN
)
524 debugl1(cs
, "isar_rcv_frame: incoming packet too large");
525 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
526 bcs
->hw
.isar
.rcvidx
= 0;
527 } else if (ireg
->cmsb
& HDLC_ERROR
) {
528 if (cs
->debug
& L1_DEB_WARN
)
529 debugl1(cs
, "isar frame error %x len %d",
530 ireg
->cmsb
, ireg
->clsb
);
531 #ifdef ERROR_STATISTIC
532 if (ireg
->cmsb
& HDLC_ERR_RER
)
534 if (ireg
->cmsb
& HDLC_ERR_CER
)
537 bcs
->hw
.isar
.rcvidx
= 0;
538 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
540 if (ireg
->cmsb
& HDLC_FSD
)
541 bcs
->hw
.isar
.rcvidx
= 0;
542 ptr
= bcs
->hw
.isar
.rcvbuf
+ bcs
->hw
.isar
.rcvidx
;
543 bcs
->hw
.isar
.rcvidx
+= ireg
->clsb
;
544 rcv_mbox(cs
, ireg
, ptr
);
545 if (ireg
->cmsb
& HDLC_FED
) {
546 if (bcs
->hw
.isar
.rcvidx
< 3) { /* last 2 bytes are the FCS */
547 if (cs
->debug
& L1_DEB_WARN
)
548 debugl1(cs
, "isar frame to short %d",
549 bcs
->hw
.isar
.rcvidx
);
550 } else if (!(skb
= dev_alloc_skb(bcs
->hw
.isar
.rcvidx
- 2))) {
551 printk(KERN_WARNING
"ISAR: receive out of memory\n");
553 skb_put_data(skb
, bcs
->hw
.isar
.rcvbuf
,
554 bcs
->hw
.isar
.rcvidx
- 2);
555 skb_queue_tail(&bcs
->rqueue
, skb
);
556 schedule_event(bcs
, B_RCVBUFREADY
);
558 bcs
->hw
.isar
.rcvidx
= 0;
563 if (bcs
->hw
.isar
.state
!= STFAX_ACTIV
) {
564 if (cs
->debug
& L1_DEB_WARN
)
565 debugl1(cs
, "isar_rcv_frame: not ACTIV");
566 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
567 bcs
->hw
.isar
.rcvidx
= 0;
570 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) {
571 rcv_mbox(cs
, ireg
, bcs
->hw
.isar
.rcvbuf
);
572 bcs
->hw
.isar
.rcvidx
= ireg
->clsb
+
573 dle_count(bcs
->hw
.isar
.rcvbuf
, ireg
->clsb
);
574 if (cs
->debug
& L1_DEB_HSCX
)
575 debugl1(cs
, "isar_rcv_frame: raw(%d) dle(%d)",
576 ireg
->clsb
, bcs
->hw
.isar
.rcvidx
);
577 if ((skb
= dev_alloc_skb(bcs
->hw
.isar
.rcvidx
))) {
578 insert_dle((u_char
*)skb_put(skb
, bcs
->hw
.isar
.rcvidx
),
579 bcs
->hw
.isar
.rcvbuf
, ireg
->clsb
);
580 skb_queue_tail(&bcs
->rqueue
, skb
);
581 schedule_event(bcs
, B_RCVBUFREADY
);
582 if (ireg
->cmsb
& SART_NMD
) { /* ABORT */
583 if (cs
->debug
& L1_DEB_WARN
)
584 debugl1(cs
, "isar_rcv_frame: no more data");
585 bcs
->hw
.isar
.rcvidx
= 0;
587 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
588 ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
,
590 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
591 schedule_event(bcs
, B_LL_NOCARRIER
);
594 printk(KERN_WARNING
"HiSax: skb out of memory\n");
598 if (bcs
->hw
.isar
.cmd
!= PCTRL_CMD_FRH
) {
599 if (cs
->debug
& L1_DEB_WARN
)
600 debugl1(cs
, "isar_rcv_frame: unknown fax mode %x",
602 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
603 bcs
->hw
.isar
.rcvidx
= 0;
607 if ((bcs
->hw
.isar
.rcvidx
+ ireg
->clsb
) > HSCX_BUFMAX
) {
608 if (cs
->debug
& L1_DEB_WARN
)
609 debugl1(cs
, "isar_rcv_frame: incoming packet too large");
610 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
611 bcs
->hw
.isar
.rcvidx
= 0;
612 } else if (ireg
->cmsb
& HDLC_ERROR
) {
613 if (cs
->debug
& L1_DEB_WARN
)
614 debugl1(cs
, "isar frame error %x len %d",
615 ireg
->cmsb
, ireg
->clsb
);
616 bcs
->hw
.isar
.rcvidx
= 0;
617 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
619 if (ireg
->cmsb
& HDLC_FSD
) {
620 bcs
->hw
.isar
.rcvidx
= 0;
622 ptr
= bcs
->hw
.isar
.rcvbuf
+ bcs
->hw
.isar
.rcvidx
;
623 bcs
->hw
.isar
.rcvidx
+= ireg
->clsb
;
624 rcv_mbox(cs
, ireg
, ptr
);
625 if (ireg
->cmsb
& HDLC_FED
) {
626 int len
= bcs
->hw
.isar
.rcvidx
+
627 dle_count(bcs
->hw
.isar
.rcvbuf
, bcs
->hw
.isar
.rcvidx
);
628 if (bcs
->hw
.isar
.rcvidx
< 3) { /* last 2 bytes are the FCS */
629 if (cs
->debug
& L1_DEB_WARN
)
630 debugl1(cs
, "isar frame to short %d",
631 bcs
->hw
.isar
.rcvidx
);
632 printk(KERN_WARNING
"ISAR: frame to short %d\n",
633 bcs
->hw
.isar
.rcvidx
);
634 } else if (!(skb
= dev_alloc_skb(len
))) {
635 printk(KERN_WARNING
"ISAR: receive out of memory\n");
637 insert_dle((u_char
*)skb_put(skb
, len
),
639 bcs
->hw
.isar
.rcvidx
);
640 skb_queue_tail(&bcs
->rqueue
, skb
);
641 schedule_event(bcs
, B_RCVBUFREADY
);
643 schedule_event(bcs
, B_LL_OK
);
644 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
646 bcs
->hw
.isar
.rcvidx
= 0;
649 if (ireg
->cmsb
& SART_NMD
) { /* ABORT */
650 if (cs
->debug
& L1_DEB_WARN
)
651 debugl1(cs
, "isar_rcv_frame: no more data");
652 bcs
->hw
.isar
.rcvidx
= 0;
653 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
654 ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
, 0, NULL
);
655 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
656 if (test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
)) {
658 schedule_event(bcs
, B_LL_NOCARRIER
);
663 printk(KERN_ERR
"isar_rcv_frame mode (%x)error\n", bcs
->mode
);
664 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
670 isar_fill_fifo(struct BCState
*bcs
)
672 struct IsdnCardState
*cs
= bcs
->cs
;
677 if ((cs
->debug
& L1_DEB_HSCX
) && !(cs
->debug
& L1_DEB_HSCX_FIFO
))
678 debugl1(cs
, "isar_fill_fifo");
681 if (bcs
->tx_skb
->len
<= 0)
683 if (!(bcs
->hw
.isar
.reg
->bstat
&
684 (bcs
->hw
.isar
.dpath
== 1 ? BSTAT_RDM1
: BSTAT_RDM2
)))
686 if (bcs
->tx_skb
->len
> bcs
->hw
.isar
.mml
) {
688 count
= bcs
->hw
.isar
.mml
;
690 count
= bcs
->tx_skb
->len
;
693 ptr
= bcs
->tx_skb
->data
;
694 if (!bcs
->hw
.isar
.txcnt
) {
696 if ((bcs
->mode
== L1_MODE_FAX
) &&
697 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
)) {
698 if (bcs
->tx_skb
->len
> 1) {
699 if ((ptr
[0] == 0xff) && (ptr
[1] == 0x13))
701 test_and_set_bit(BC_FLG_LASTDATA
,
706 skb_pull(bcs
->tx_skb
, count
);
707 bcs
->tx_cnt
-= count
;
708 bcs
->hw
.isar
.txcnt
+= count
;
711 printk(KERN_ERR
"isar_fill_fifo wrong mode 0\n");
715 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
719 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
723 if (bcs
->hw
.isar
.state
!= STFAX_ACTIV
) {
724 if (cs
->debug
& L1_DEB_WARN
)
725 debugl1(cs
, "isar_fill_fifo: not ACTIV");
726 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
727 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
729 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) {
730 sendmsg(cs
, SET_DPS(bcs
->hw
.isar
.dpath
) | ISAR_HIS_SDATA
,
733 if (cs
->debug
& L1_DEB_WARN
)
734 debugl1(cs
, "isar_fill_fifo: not FTH/FTM");
739 debugl1(cs
, "isar_fill_fifo mode(%x) error", bcs
->mode
);
740 printk(KERN_ERR
"isar_fill_fifo mode(%x) error\n", bcs
->mode
);
746 struct BCState
*sel_bcs_isar(struct IsdnCardState
*cs
, u_char dpath
)
748 if ((!dpath
) || (dpath
== 3))
750 if (cs
->bcs
[0].hw
.isar
.dpath
== dpath
)
751 return (&cs
->bcs
[0]);
752 if (cs
->bcs
[1].hw
.isar
.dpath
== dpath
)
753 return (&cs
->bcs
[1]);
758 send_frames(struct BCState
*bcs
)
761 if (bcs
->tx_skb
->len
) {
765 if (test_bit(FLG_LLI_L1WAKEUP
, &bcs
->st
->lli
.flag
) &&
766 (PACKET_NOACK
!= bcs
->tx_skb
->pkt_type
)) {
768 spin_lock_irqsave(&bcs
->aclock
, flags
);
769 bcs
->ackcnt
+= bcs
->hw
.isar
.txcnt
;
770 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
771 schedule_event(bcs
, B_ACKPENDING
);
773 if (bcs
->mode
== L1_MODE_FAX
) {
774 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
775 if (test_bit(BC_FLG_LASTDATA
, &bcs
->Flag
)) {
776 test_and_set_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
);
778 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) {
779 if (test_bit(BC_FLG_DLEETX
, &bcs
->Flag
)) {
780 test_and_set_bit(BC_FLG_LASTDATA
, &bcs
->Flag
);
781 test_and_set_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
);
785 dev_kfree_skb_any(bcs
->tx_skb
);
786 bcs
->hw
.isar
.txcnt
= 0;
790 if ((bcs
->tx_skb
= skb_dequeue(&bcs
->squeue
))) {
791 bcs
->hw
.isar
.txcnt
= 0;
792 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
795 if (test_and_clear_bit(BC_FLG_DLEETX
, &bcs
->Flag
)) {
796 if (test_and_clear_bit(BC_FLG_LASTDATA
, &bcs
->Flag
)) {
797 if (test_and_clear_bit(BC_FLG_NMD_DATA
, &bcs
->Flag
)) {
799 sendmsg(bcs
->cs
, SET_DPS(bcs
->hw
.isar
.dpath
) |
800 ISAR_HIS_SDATA
, 0x01, 1, &dummy
);
802 test_and_set_bit(BC_FLG_LL_OK
, &bcs
->Flag
);
804 schedule_event(bcs
, B_LL_CONNECT
);
807 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
808 schedule_event(bcs
, B_XMTBUFREADY
);
813 check_send(struct IsdnCardState
*cs
, u_char rdm
)
817 if (rdm
& BSTAT_RDM1
) {
818 if ((bcs
= sel_bcs_isar(cs
, 1))) {
824 if (rdm
& BSTAT_RDM2
) {
825 if ((bcs
= sel_bcs_isar(cs
, 2))) {
834 static const char *dmril
[] = {"NO SPEED", "1200/75", "NODEF2", "75/1200",
835 "NODEF4", "300", "600", "1200", "2400",
836 "4800", "7200", "9600nt", "9600t", "12000",
838 static const char *dmrim
[] = {"NO MOD", "NO DEF", "V32/V32b", "V22", "V21",
839 "Bell103", "V23", "Bell202", "V17", "V29",
843 isar_pump_status_rsp(struct BCState
*bcs
, struct isar_reg
*ireg
) {
844 struct IsdnCardState
*cs
= bcs
->cs
;
845 u_char ril
= ireg
->par
[0];
848 if (!test_and_clear_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
))
851 if (cs
->debug
& L1_DEB_WARN
)
852 debugl1(cs
, "wrong pstrsp ril=%d", ril
);
855 switch (ireg
->par
[1]) {
890 sprintf(bcs
->hw
.isar
.conmsg
, "%s %s", dmril
[ril
], dmrim
[rim
]);
891 bcs
->conmsg
= bcs
->hw
.isar
.conmsg
;
892 if (cs
->debug
& L1_DEB_HSCX
)
893 debugl1(cs
, "pump strsp %s", bcs
->conmsg
);
897 isar_pump_statev_modem(struct BCState
*bcs
, u_char devt
) {
898 struct IsdnCardState
*cs
= bcs
->cs
;
899 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
902 case PSEV_10MS_TIMER
:
903 if (cs
->debug
& L1_DEB_HSCX
)
904 debugl1(cs
, "pump stev TIMER");
907 if (cs
->debug
& L1_DEB_HSCX
)
908 debugl1(cs
, "pump stev CONNECT");
909 l1_msg_b(bcs
->st
, PH_ACTIVATE
| REQUEST
, NULL
);
912 if (cs
->debug
& L1_DEB_HSCX
)
913 debugl1(cs
, "pump stev NO CONNECT");
914 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
915 l1_msg_b(bcs
->st
, PH_DEACTIVATE
| REQUEST
, NULL
);
918 if (cs
->debug
& L1_DEB_HSCX
)
919 debugl1(cs
, "pump stev V24 OFF");
922 if (cs
->debug
& L1_DEB_HSCX
)
923 debugl1(cs
, "pump stev CTS ON");
926 if (cs
->debug
& L1_DEB_HSCX
)
927 debugl1(cs
, "pump stev CTS OFF");
930 if (cs
->debug
& L1_DEB_HSCX
)
931 debugl1(cs
, "pump stev CARRIER ON");
932 test_and_set_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
);
933 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
936 if (cs
->debug
& L1_DEB_HSCX
)
937 debugl1(cs
, "pump stev CARRIER OFF");
940 if (cs
->debug
& L1_DEB_HSCX
)
941 debugl1(cs
, "pump stev DSR ON");
944 if (cs
->debug
& L1_DEB_HSCX
)
945 debugl1(cs
, "pump stev DSR_OFF");
948 if (cs
->debug
& L1_DEB_HSCX
)
949 debugl1(cs
, "pump stev REMOTE RETRAIN");
952 if (cs
->debug
& L1_DEB_HSCX
)
953 debugl1(cs
, "pump stev REMOTE RENEGOTIATE");
956 if (cs
->debug
& L1_DEB_HSCX
)
957 debugl1(cs
, "pump stev GSTN CLEAR");
960 if (cs
->debug
& L1_DEB_HSCX
)
961 debugl1(cs
, "unknown pump stev %x", devt
);
967 ll_deliver_faxstat(struct BCState
*bcs
, u_char status
)
970 struct Channel
*chanp
= (struct Channel
*) bcs
->st
->lli
.userdata
;
972 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
973 debugl1(bcs
->cs
, "HL->LL FAXIND %x", status
);
974 ic
.driver
= bcs
->cs
->myid
;
975 ic
.command
= ISDN_STAT_FAXIND
;
976 ic
.arg
= chanp
->chan
;
977 ic
.parm
.aux
.cmd
= status
;
978 bcs
->cs
->iif
.statcallb(&ic
);
982 isar_pump_statev_fax(struct BCState
*bcs
, u_char devt
) {
983 struct IsdnCardState
*cs
= bcs
->cs
;
984 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
988 case PSEV_10MS_TIMER
:
989 if (cs
->debug
& L1_DEB_HSCX
)
990 debugl1(cs
, "pump stev TIMER");
993 if (cs
->debug
& L1_DEB_HSCX
)
994 debugl1(cs
, "pump stev RSP_READY");
995 bcs
->hw
.isar
.state
= STFAX_READY
;
996 l1_msg_b(bcs
->st
, PH_ACTIVATE
| REQUEST
, NULL
);
997 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
998 isar_pump_cmd(bcs
, ISDN_FAX_CLASS1_FRH
, 3);
1000 isar_pump_cmd(bcs
, ISDN_FAX_CLASS1_FTH
, 3);
1003 case PSEV_LINE_TX_H
:
1004 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1005 if (cs
->debug
& L1_DEB_HSCX
)
1006 debugl1(cs
, "pump stev LINE_TX_H");
1007 bcs
->hw
.isar
.state
= STFAX_CONT
;
1008 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1010 if (cs
->debug
& L1_DEB_WARN
)
1011 debugl1(cs
, "pump stev LINE_TX_H wrong st %x",
1012 bcs
->hw
.isar
.state
);
1015 case PSEV_LINE_RX_H
:
1016 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1017 if (cs
->debug
& L1_DEB_HSCX
)
1018 debugl1(cs
, "pump stev LINE_RX_H");
1019 bcs
->hw
.isar
.state
= STFAX_CONT
;
1020 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1022 if (cs
->debug
& L1_DEB_WARN
)
1023 debugl1(cs
, "pump stev LINE_RX_H wrong st %x",
1024 bcs
->hw
.isar
.state
);
1027 case PSEV_LINE_TX_B
:
1028 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1029 if (cs
->debug
& L1_DEB_HSCX
)
1030 debugl1(cs
, "pump stev LINE_TX_B");
1031 bcs
->hw
.isar
.state
= STFAX_CONT
;
1032 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1034 if (cs
->debug
& L1_DEB_WARN
)
1035 debugl1(cs
, "pump stev LINE_TX_B wrong st %x",
1036 bcs
->hw
.isar
.state
);
1039 case PSEV_LINE_RX_B
:
1040 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1041 if (cs
->debug
& L1_DEB_HSCX
)
1042 debugl1(cs
, "pump stev LINE_RX_B");
1043 bcs
->hw
.isar
.state
= STFAX_CONT
;
1044 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_CONT
, 0, NULL
);
1046 if (cs
->debug
& L1_DEB_WARN
)
1047 debugl1(cs
, "pump stev LINE_RX_B wrong st %x",
1048 bcs
->hw
.isar
.state
);
1052 if (bcs
->hw
.isar
.state
== STFAX_CONT
) {
1053 if (cs
->debug
& L1_DEB_HSCX
)
1054 debugl1(cs
, "pump stev RSP_CONN");
1055 bcs
->hw
.isar
.state
= STFAX_ACTIV
;
1056 test_and_set_bit(ISAR_RATE_REQ
, &bcs
->hw
.isar
.reg
->Flags
);
1057 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
1058 if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) {
1059 /* 1s Flags before data */
1060 if (test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
))
1061 del_timer(&bcs
->hw
.isar
.ftimer
);
1063 bcs
->hw
.isar
.ftimer
.expires
=
1064 jiffies
+ ((1000 * HZ
) / 1000);
1065 test_and_set_bit(BC_FLG_LL_CONN
,
1067 add_timer(&bcs
->hw
.isar
.ftimer
);
1069 schedule_event(bcs
, B_LL_CONNECT
);
1072 if (cs
->debug
& L1_DEB_WARN
)
1073 debugl1(cs
, "pump stev RSP_CONN wrong st %x",
1074 bcs
->hw
.isar
.state
);
1077 case PSEV_FLAGS_DET
:
1078 if (cs
->debug
& L1_DEB_HSCX
)
1079 debugl1(cs
, "pump stev FLAGS_DET");
1082 if (cs
->debug
& L1_DEB_HSCX
)
1083 debugl1(cs
, "pump stev RSP_DISC");
1084 if (bcs
->hw
.isar
.state
== STFAX_ESCAPE
) {
1086 switch (bcs
->hw
.isar
.newcmd
) {
1088 bcs
->hw
.isar
.state
= STFAX_READY
;
1094 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1095 PCTRL_CMD_SILON
, 1, &p1
);
1096 bcs
->hw
.isar
.state
= STFAX_SILDET
;
1099 if (frm_extra_delay
)
1100 mdelay(frm_extra_delay
);
1103 p1
= bcs
->hw
.isar
.mod
= bcs
->hw
.isar
.newmod
;
1104 bcs
->hw
.isar
.newmod
= 0;
1105 bcs
->hw
.isar
.cmd
= bcs
->hw
.isar
.newcmd
;
1106 bcs
->hw
.isar
.newcmd
= 0;
1107 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1108 bcs
->hw
.isar
.cmd
, 1, &p1
);
1109 bcs
->hw
.isar
.state
= STFAX_LINE
;
1110 bcs
->hw
.isar
.try_mod
= 3;
1113 if (cs
->debug
& L1_DEB_HSCX
)
1114 debugl1(cs
, "RSP_DISC unknown newcmd %x", bcs
->hw
.isar
.newcmd
);
1117 } else if (bcs
->hw
.isar
.state
== STFAX_ACTIV
) {
1118 if (test_and_clear_bit(BC_FLG_LL_OK
, &bcs
->Flag
)) {
1119 schedule_event(bcs
, B_LL_OK
);
1120 } else if (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) {
1122 schedule_event(bcs
, B_LL_NOCARRIER
);
1124 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1126 bcs
->hw
.isar
.state
= STFAX_READY
;
1128 bcs
->hw
.isar
.state
= STFAX_READY
;
1129 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1132 case PSEV_RSP_SILDET
:
1133 if (cs
->debug
& L1_DEB_HSCX
)
1134 debugl1(cs
, "pump stev RSP_SILDET");
1135 if (bcs
->hw
.isar
.state
== STFAX_SILDET
) {
1136 p1
= bcs
->hw
.isar
.mod
= bcs
->hw
.isar
.newmod
;
1137 bcs
->hw
.isar
.newmod
= 0;
1138 bcs
->hw
.isar
.cmd
= bcs
->hw
.isar
.newcmd
;
1139 bcs
->hw
.isar
.newcmd
= 0;
1140 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1141 bcs
->hw
.isar
.cmd
, 1, &p1
);
1142 bcs
->hw
.isar
.state
= STFAX_LINE
;
1143 bcs
->hw
.isar
.try_mod
= 3;
1146 case PSEV_RSP_SILOFF
:
1147 if (cs
->debug
& L1_DEB_HSCX
)
1148 debugl1(cs
, "pump stev RSP_SILOFF");
1150 case PSEV_RSP_FCERR
:
1151 if (bcs
->hw
.isar
.state
== STFAX_LINE
) {
1152 if (cs
->debug
& L1_DEB_HSCX
)
1153 debugl1(cs
, "pump stev RSP_FCERR try %d",
1154 bcs
->hw
.isar
.try_mod
);
1155 if (bcs
->hw
.isar
.try_mod
--) {
1156 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
,
1157 bcs
->hw
.isar
.cmd
, 1,
1162 if (cs
->debug
& L1_DEB_HSCX
)
1163 debugl1(cs
, "pump stev RSP_FCERR");
1164 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1165 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, PCTRL_CMD_ESC
, 0, NULL
);
1166 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_FCERROR
);
1173 static char debbuf
[128];
1176 isar_int_main(struct IsdnCardState
*cs
)
1178 struct isar_reg
*ireg
= cs
->bcs
[0].hw
.isar
.reg
;
1179 struct BCState
*bcs
;
1181 get_irq_infos(cs
, ireg
);
1182 switch (ireg
->iis
& ISAR_IIS_MSCMSD
) {
1183 case ISAR_IIS_RDATA
:
1184 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1185 isar_rcv_frame(cs
, bcs
);
1187 debugl1(cs
, "isar spurious IIS_RDATA %x/%x/%x",
1188 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1189 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1192 case ISAR_IIS_GSTEV
:
1193 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1194 ireg
->bstat
|= ireg
->cmsb
;
1195 check_send(cs
, ireg
->cmsb
);
1197 case ISAR_IIS_BSTEV
:
1198 #ifdef ERROR_STATISTIC
1199 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1200 if (ireg
->cmsb
== BSTEV_TBO
)
1202 if (ireg
->cmsb
== BSTEV_RBO
)
1206 if (cs
->debug
& L1_DEB_WARN
)
1207 debugl1(cs
, "Buffer STEV dpath%d msb(%x)",
1208 ireg
->iis
>> 6, ireg
->cmsb
);
1209 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1211 case ISAR_IIS_PSTEV
:
1212 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1213 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1214 if (bcs
->mode
== L1_MODE_V32
) {
1215 isar_pump_statev_modem(bcs
, ireg
->cmsb
);
1216 } else if (bcs
->mode
== L1_MODE_FAX
) {
1217 isar_pump_statev_fax(bcs
, ireg
->cmsb
);
1218 } else if (ireg
->cmsb
== PSEV_10MS_TIMER
) {
1219 if (cs
->debug
& L1_DEB_HSCX
)
1220 debugl1(cs
, "pump stev TIMER");
1222 if (cs
->debug
& L1_DEB_WARN
)
1223 debugl1(cs
, "isar IIS_PSTEV pmode %d stat %x",
1224 bcs
->mode
, ireg
->cmsb
);
1227 debugl1(cs
, "isar spurious IIS_PSTEV %x/%x/%x",
1228 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1229 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1232 case ISAR_IIS_PSTRSP
:
1233 if ((bcs
= sel_bcs_isar(cs
, ireg
->iis
>> 6))) {
1234 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1235 isar_pump_status_rsp(bcs
, ireg
);
1237 debugl1(cs
, "isar spurious IIS_PSTRSP %x/%x/%x",
1238 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1239 cs
->BC_Write_Reg(cs
, 1, ISAR_IIA
, 0);
1243 case ISAR_IIS_BSTRSP
:
1244 case ISAR_IIS_IOM2RSP
:
1245 rcv_mbox(cs
, ireg
, (u_char
*)ireg
->par
);
1246 if ((cs
->debug
& (L1_DEB_HSCX
| L1_DEB_HSCX_FIFO
))
1248 u_char
*tp
= debbuf
;
1250 tp
+= sprintf(debbuf
, "msg iis(%x) msb(%x)",
1251 ireg
->iis
, ireg
->cmsb
);
1252 QuickHex(tp
, (u_char
*)ireg
->par
, ireg
->clsb
);
1253 debugl1(cs
, "%s", debbuf
);
1256 case ISAR_IIS_INVMSG
:
1257 rcv_mbox(cs
, ireg
, debbuf
);
1258 if (cs
->debug
& L1_DEB_WARN
)
1259 debugl1(cs
, "invalid msg his:%x",
1263 rcv_mbox(cs
, ireg
, debbuf
);
1264 if (cs
->debug
& L1_DEB_WARN
)
1265 debugl1(cs
, "unhandled msg iis(%x) ctrl(%x/%x)",
1266 ireg
->iis
, ireg
->cmsb
, ireg
->clsb
);
1272 ftimer_handler(struct timer_list
*t
) {
1273 struct BCState
*bcs
= from_timer(bcs
, t
, hw
.isar
.ftimer
);
1275 debugl1(bcs
->cs
, "ftimer flags %04lx",
1277 test_and_clear_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
);
1278 if (test_and_clear_bit(BC_FLG_LL_CONN
, &bcs
->Flag
)) {
1279 schedule_event(bcs
, B_LL_CONNECT
);
1281 if (test_and_clear_bit(BC_FLG_FTI_FTS
, &bcs
->Flag
)) {
1282 schedule_event(bcs
, B_LL_OK
);
1287 setup_pump(struct BCState
*bcs
) {
1288 struct IsdnCardState
*cs
= bcs
->cs
;
1289 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1290 u_char ctrl
, param
[6];
1292 switch (bcs
->mode
) {
1296 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, PMOD_BYPASS
, 0, NULL
);
1299 ctrl
= PMOD_DATAMODEM
;
1300 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
1302 param
[5] = PV32P6_CTN
;
1304 param
[5] = PV32P6_ATN
;
1306 param
[0] = para_TOA
; /* 6 db */
1307 param
[1] = PV32P2_V23R
| PV32P2_V22A
| PV32P2_V22B
|
1308 PV32P2_V22C
| PV32P2_V21
| PV32P2_BEL
;
1309 param
[2] = PV32P3_AMOD
| PV32P3_V32B
| PV32P3_V23B
;
1310 param
[3] = PV32P4_UT144
;
1311 param
[4] = PV32P5_UT144
;
1312 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, ctrl
, 6, param
);
1316 if (test_bit(BC_FLG_ORIG
, &bcs
->Flag
)) {
1318 param
[1] = PFAXP2_CTN
;
1320 param
[1] = PFAXP2_ATN
;
1322 param
[0] = para_TOA
; /* 6 db */
1323 sendmsg(cs
, dps
| ISAR_HIS_PUMPCFG
, ctrl
, 2, param
);
1324 bcs
->hw
.isar
.state
= STFAX_NULL
;
1325 bcs
->hw
.isar
.newcmd
= 0;
1326 bcs
->hw
.isar
.newmod
= 0;
1327 test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
);
1331 sendmsg(cs
, dps
| ISAR_HIS_PSTREQ
, 0, 0, NULL
);
1336 setup_sart(struct BCState
*bcs
) {
1337 struct IsdnCardState
*cs
= bcs
->cs
;
1338 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1339 u_char ctrl
, param
[2];
1341 switch (bcs
->mode
) {
1343 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_DISABLE
, 0,
1347 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_BINARY
, 2,
1352 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, SMODE_HDLC
, 1,
1356 ctrl
= SMODE_V14
| SCTRL_HDMC_BOTH
;
1357 param
[0] = S_P1_CHS_8
;
1358 param
[1] = S_P2_BFT_DEF
;
1359 sendmsg(cs
, dps
| ISAR_HIS_SARTCFG
, ctrl
, 2,
1363 /* SART must not configured with FAX */
1367 sendmsg(cs
, dps
| ISAR_HIS_BSTREQ
, 0, 0, NULL
);
1372 setup_iom2(struct BCState
*bcs
) {
1373 struct IsdnCardState
*cs
= bcs
->cs
;
1374 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1375 u_char cmsb
= IOM_CTRL_ENA
, msg
[5] = {IOM_P1_TXD
, 0, 0, 0, 0};
1378 msg
[1] = msg
[3] = 1;
1379 switch (bcs
->mode
) {
1383 msg
[1] = msg
[3] = bcs
->hw
.isar
.dpath
+ 2;
1390 cmsb
|= IOM_CTRL_ALAW
| IOM_CTRL_RCV
;
1393 sendmsg(cs
, dps
| ISAR_HIS_IOM2CFG
, cmsb
, 5, msg
);
1395 sendmsg(cs
, dps
| ISAR_HIS_IOM2REQ
, 0, 0, NULL
);
1400 modeisar(struct BCState
*bcs
, int mode
, int bc
)
1402 struct IsdnCardState
*cs
= bcs
->cs
;
1404 /* Here we are selecting the best datapath for requested mode */
1405 if (bcs
->mode
== L1_MODE_NULL
) { /* New Setup */
1408 case L1_MODE_NULL
: /* init */
1409 if (!bcs
->hw
.isar
.dpath
)
1410 /* no init for dpath 0 */
1415 /* best is datapath 2 */
1416 if (!test_and_set_bit(ISAR_DP2_USE
,
1417 &bcs
->hw
.isar
.reg
->Flags
))
1418 bcs
->hw
.isar
.dpath
= 2;
1419 else if (!test_and_set_bit(ISAR_DP1_USE
,
1420 &bcs
->hw
.isar
.reg
->Flags
))
1421 bcs
->hw
.isar
.dpath
= 1;
1423 printk(KERN_WARNING
"isar modeisar both paths in use\n");
1429 /* only datapath 1 */
1430 if (!test_and_set_bit(ISAR_DP1_USE
,
1431 &bcs
->hw
.isar
.reg
->Flags
))
1432 bcs
->hw
.isar
.dpath
= 1;
1434 printk(KERN_WARNING
"isar modeisar analog functions only with DP1\n");
1435 debugl1(cs
, "isar modeisar analog functions only with DP1");
1441 if (cs
->debug
& L1_DEB_HSCX
)
1442 debugl1(cs
, "isar dp%d mode %d->%d ichan %d",
1443 bcs
->hw
.isar
.dpath
, bcs
->mode
, mode
, bc
);
1448 if (bcs
->mode
== L1_MODE_NULL
) {
1449 /* Clear resources */
1450 if (bcs
->hw
.isar
.dpath
== 1)
1451 test_and_clear_bit(ISAR_DP1_USE
, &bcs
->hw
.isar
.reg
->Flags
);
1452 else if (bcs
->hw
.isar
.dpath
== 2)
1453 test_and_clear_bit(ISAR_DP2_USE
, &bcs
->hw
.isar
.reg
->Flags
);
1454 bcs
->hw
.isar
.dpath
= 0;
1460 isar_pump_cmd(struct BCState
*bcs
, u_char cmd
, u_char para
)
1462 struct IsdnCardState
*cs
= bcs
->cs
;
1463 u_char dps
= SET_DPS(bcs
->hw
.isar
.dpath
);
1464 u_char ctrl
= 0, nom
= 0, p1
= 0;
1467 case ISDN_FAX_CLASS1_FTM
:
1468 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1469 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1471 ctrl
= PCTRL_CMD_FTM
;
1473 bcs
->hw
.isar
.state
= STFAX_LINE
;
1474 bcs
->hw
.isar
.cmd
= ctrl
;
1475 bcs
->hw
.isar
.mod
= para
;
1476 bcs
->hw
.isar
.newmod
= 0;
1477 bcs
->hw
.isar
.newcmd
= 0;
1478 bcs
->hw
.isar
.try_mod
= 3;
1479 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1480 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTM
) &&
1481 (bcs
->hw
.isar
.mod
== para
)) {
1482 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1484 bcs
->hw
.isar
.newmod
= para
;
1485 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FTM
;
1487 ctrl
= PCTRL_CMD_ESC
;
1488 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1491 case ISDN_FAX_CLASS1_FTH
:
1492 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1493 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1495 ctrl
= PCTRL_CMD_FTH
;
1497 bcs
->hw
.isar
.state
= STFAX_LINE
;
1498 bcs
->hw
.isar
.cmd
= ctrl
;
1499 bcs
->hw
.isar
.mod
= para
;
1500 bcs
->hw
.isar
.newmod
= 0;
1501 bcs
->hw
.isar
.newcmd
= 0;
1502 bcs
->hw
.isar
.try_mod
= 3;
1503 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1504 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FTH
) &&
1505 (bcs
->hw
.isar
.mod
== para
)) {
1506 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1508 bcs
->hw
.isar
.newmod
= para
;
1509 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FTH
;
1511 ctrl
= PCTRL_CMD_ESC
;
1512 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1515 case ISDN_FAX_CLASS1_FRM
:
1516 test_and_clear_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1517 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1519 ctrl
= PCTRL_CMD_FRM
;
1521 bcs
->hw
.isar
.state
= STFAX_LINE
;
1522 bcs
->hw
.isar
.cmd
= ctrl
;
1523 bcs
->hw
.isar
.mod
= para
;
1524 bcs
->hw
.isar
.newmod
= 0;
1525 bcs
->hw
.isar
.newcmd
= 0;
1526 bcs
->hw
.isar
.try_mod
= 3;
1527 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1528 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRM
) &&
1529 (bcs
->hw
.isar
.mod
== para
)) {
1530 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1532 bcs
->hw
.isar
.newmod
= para
;
1533 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FRM
;
1535 ctrl
= PCTRL_CMD_ESC
;
1536 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1539 case ISDN_FAX_CLASS1_FRH
:
1540 test_and_set_bit(BC_FLG_FRH_WAIT
, &bcs
->Flag
);
1541 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1543 ctrl
= PCTRL_CMD_FRH
;
1545 bcs
->hw
.isar
.state
= STFAX_LINE
;
1546 bcs
->hw
.isar
.cmd
= ctrl
;
1547 bcs
->hw
.isar
.mod
= para
;
1548 bcs
->hw
.isar
.newmod
= 0;
1549 bcs
->hw
.isar
.newcmd
= 0;
1550 bcs
->hw
.isar
.try_mod
= 3;
1551 } else if ((bcs
->hw
.isar
.state
== STFAX_ACTIV
) &&
1552 (bcs
->hw
.isar
.cmd
== PCTRL_CMD_FRH
) &&
1553 (bcs
->hw
.isar
.mod
== para
)) {
1554 ll_deliver_faxstat(bcs
, ISDN_FAX_CLASS1_CONNECT
);
1556 bcs
->hw
.isar
.newmod
= para
;
1557 bcs
->hw
.isar
.newcmd
= PCTRL_CMD_FRH
;
1559 ctrl
= PCTRL_CMD_ESC
;
1560 bcs
->hw
.isar
.state
= STFAX_ESCAPE
;
1563 case ISDN_FAXPUMP_HALT
:
1564 bcs
->hw
.isar
.state
= STFAX_NULL
;
1566 ctrl
= PCTRL_CMD_HALT
;
1570 sendmsg(cs
, dps
| ISAR_HIS_PUMPCTRL
, ctrl
, nom
, &p1
);
1574 isar_setup(struct IsdnCardState
*cs
)
1581 for (i
= 0; i
< 2; i
++) {
1583 sendmsg(cs
, (i
? ISAR_HIS_DPS2
: ISAR_HIS_DPS1
) |
1584 ISAR_HIS_P12CFG
, 4, 1, &msg
);
1585 cs
->bcs
[i
].hw
.isar
.mml
= msg
;
1586 cs
->bcs
[i
].mode
= 0;
1587 cs
->bcs
[i
].hw
.isar
.dpath
= i
+ 1;
1588 modeisar(&cs
->bcs
[i
], 0, 0);
1589 INIT_WORK(&cs
->bcs
[i
].tqueue
, isar_bh
);
1594 isar_l2l1(struct PStack
*st
, int pr
, void *arg
)
1596 struct BCState
*bcs
= st
->l1
.bcs
;
1597 struct sk_buff
*skb
= arg
;
1602 case (PH_DATA
| REQUEST
):
1603 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1605 skb_queue_tail(&bcs
->squeue
, skb
);
1608 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1609 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1610 debugl1(bcs
->cs
, "DRQ set BC_FLG_BUSY");
1611 bcs
->hw
.isar
.txcnt
= 0;
1612 bcs
->cs
->BC_Send_Data(bcs
);
1614 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1616 case (PH_PULL
| INDICATION
):
1617 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1619 printk(KERN_WARNING
"isar_l2l1: this shouldn't happen\n");
1621 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1622 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1623 debugl1(bcs
->cs
, "PUI set BC_FLG_BUSY");
1625 bcs
->hw
.isar
.txcnt
= 0;
1626 bcs
->cs
->BC_Send_Data(bcs
);
1628 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1630 case (PH_PULL
| REQUEST
):
1632 test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1633 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1635 test_and_set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1637 case (PH_ACTIVATE
| REQUEST
):
1638 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1639 test_and_set_bit(BC_FLG_ACTIV
, &bcs
->Flag
);
1640 bcs
->hw
.isar
.conmsg
[0] = 0;
1641 if (test_bit(FLG_ORIG
, &st
->l2
.flag
))
1642 test_and_set_bit(BC_FLG_ORIG
, &bcs
->Flag
);
1644 test_and_clear_bit(BC_FLG_ORIG
, &bcs
->Flag
);
1645 switch (st
->l1
.mode
) {
1648 ret
= modeisar(bcs
, st
->l1
.mode
, st
->l1
.bc
);
1649 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1651 l1_msg_b(st
, PH_DEACTIVATE
| REQUEST
, arg
);
1653 l1_msg_b(st
, PH_ACTIVATE
| REQUEST
, arg
);
1657 ret
= modeisar(bcs
, st
->l1
.mode
, st
->l1
.bc
);
1658 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1660 l1_msg_b(st
, PH_DEACTIVATE
| REQUEST
, arg
);
1663 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1667 case (PH_DEACTIVATE
| REQUEST
):
1668 l1_msg_b(st
, pr
, arg
);
1670 case (PH_DEACTIVATE
| CONFIRM
):
1671 spin_lock_irqsave(&bcs
->cs
->lock
, flags
);
1672 switch (st
->l1
.mode
) {
1678 isar_pump_cmd(bcs
, ISDN_FAXPUMP_HALT
, 0);
1681 test_and_clear_bit(BC_FLG_ACTIV
, &bcs
->Flag
);
1682 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1683 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1684 debugl1(bcs
->cs
, "PDAC clear BC_FLG_BUSY");
1685 modeisar(bcs
, 0, st
->l1
.bc
);
1686 spin_unlock_irqrestore(&bcs
->cs
->lock
, flags
);
1687 st
->l1
.l1l2(st
, PH_DEACTIVATE
| CONFIRM
, NULL
);
1693 close_isarstate(struct BCState
*bcs
)
1695 modeisar(bcs
, 0, bcs
->channel
);
1696 if (test_and_clear_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1697 kfree(bcs
->hw
.isar
.rcvbuf
);
1698 bcs
->hw
.isar
.rcvbuf
= NULL
;
1699 skb_queue_purge(&bcs
->rqueue
);
1700 skb_queue_purge(&bcs
->squeue
);
1702 dev_kfree_skb_any(bcs
->tx_skb
);
1704 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1705 if (bcs
->cs
->debug
& L1_DEB_HSCX
)
1706 debugl1(bcs
->cs
, "closeisar clear BC_FLG_BUSY");
1709 del_timer(&bcs
->hw
.isar
.ftimer
);
1713 open_isarstate(struct IsdnCardState
*cs
, struct BCState
*bcs
)
1715 if (!test_and_set_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1716 if (!(bcs
->hw
.isar
.rcvbuf
= kmalloc(HSCX_BUFMAX
, GFP_ATOMIC
))) {
1718 "HiSax: No memory for isar.rcvbuf\n");
1721 skb_queue_head_init(&bcs
->rqueue
);
1722 skb_queue_head_init(&bcs
->squeue
);
1725 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1726 if (cs
->debug
& L1_DEB_HSCX
)
1727 debugl1(cs
, "openisar clear BC_FLG_BUSY");
1729 bcs
->hw
.isar
.rcvidx
= 0;
1735 setstack_isar(struct PStack
*st
, struct BCState
*bcs
)
1737 bcs
->channel
= st
->l1
.bc
;
1738 if (open_isarstate(st
->l1
.hardware
, bcs
))
1741 st
->l2
.l2l1
= isar_l2l1
;
1742 setstack_manager(st
);
1749 isar_auxcmd(struct IsdnCardState
*cs
, isdn_ctrl
*ic
) {
1752 struct BCState
*bcs
;
1754 if (cs
->debug
& L1_DEB_HSCX
)
1755 debugl1(cs
, "isar_auxcmd cmd/ch %x/%ld", ic
->command
, ic
->arg
);
1756 switch (ic
->command
) {
1757 case (ISDN_CMD_FAXCMD
):
1758 bcs
= cs
->channel
[ic
->arg
].bcs
;
1759 if (cs
->debug
& L1_DEB_HSCX
)
1760 debugl1(cs
, "isar_auxcmd cmd/subcmd %d/%d",
1761 ic
->parm
.aux
.cmd
, ic
->parm
.aux
.subcmd
);
1762 switch (ic
->parm
.aux
.cmd
) {
1763 case ISDN_FAX_CLASS1_CTRL
:
1764 if (ic
->parm
.aux
.subcmd
== ETX
)
1765 test_and_set_bit(BC_FLG_DLEETX
,
1768 case ISDN_FAX_CLASS1_FTS
:
1769 if (ic
->parm
.aux
.subcmd
== AT_QUERY
) {
1770 ic
->command
= ISDN_STAT_FAXIND
;
1771 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_OK
;
1772 cs
->iif
.statcallb(ic
);
1774 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_QUERY
) {
1775 strcpy(ic
->parm
.aux
.para
, "0-255");
1776 ic
->command
= ISDN_STAT_FAXIND
;
1777 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1778 cs
->iif
.statcallb(ic
);
1780 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_VALUE
) {
1781 if (cs
->debug
& L1_DEB_HSCX
)
1782 debugl1(cs
, "isar_auxcmd %s=%d",
1783 FC1_CMD
[ic
->parm
.aux
.cmd
], ic
->parm
.aux
.para
[0]);
1784 if (bcs
->hw
.isar
.state
== STFAX_READY
) {
1785 if (!ic
->parm
.aux
.para
[0]) {
1786 ic
->command
= ISDN_STAT_FAXIND
;
1787 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_OK
;
1788 cs
->iif
.statcallb(ic
);
1791 if (!test_and_set_bit(BC_FLG_FTI_RUN
, &bcs
->Flag
)) {
1793 bcs
->hw
.isar
.ftimer
.expires
=
1794 jiffies
+ ((ic
->parm
.aux
.para
[0] * 10 * HZ
) / 1000);
1795 test_and_set_bit(BC_FLG_FTI_FTS
, &bcs
->Flag
);
1796 add_timer(&bcs
->hw
.isar
.ftimer
);
1800 debugl1(cs
, "isar FTS=%d and FTI busy",
1801 ic
->parm
.aux
.para
[0]);
1805 debugl1(cs
, "isar FTS=%d and isar.state not ready(%x)",
1806 ic
->parm
.aux
.para
[0], bcs
->hw
.isar
.state
);
1808 ic
->command
= ISDN_STAT_FAXIND
;
1809 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_ERROR
;
1810 cs
->iif
.statcallb(ic
);
1813 case ISDN_FAX_CLASS1_FRM
:
1814 case ISDN_FAX_CLASS1_FRH
:
1815 case ISDN_FAX_CLASS1_FTM
:
1816 case ISDN_FAX_CLASS1_FTH
:
1817 if (ic
->parm
.aux
.subcmd
== AT_QUERY
) {
1818 sprintf(ic
->parm
.aux
.para
,
1819 "%d", bcs
->hw
.isar
.mod
);
1820 ic
->command
= ISDN_STAT_FAXIND
;
1821 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1822 cs
->iif
.statcallb(ic
);
1824 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_QUERY
) {
1825 char *p
= ic
->parm
.aux
.para
;
1826 for (i
= 0; i
< FAXMODCNT
; i
++)
1827 if ((1 << i
) & modmask
)
1828 p
+= sprintf(p
, "%d,", faxmodulation
[i
]);
1831 ic
->command
= ISDN_STAT_FAXIND
;
1832 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_QUERY
;
1833 cs
->iif
.statcallb(ic
);
1835 } else if (ic
->parm
.aux
.subcmd
== AT_EQ_VALUE
) {
1836 if (cs
->debug
& L1_DEB_HSCX
)
1837 debugl1(cs
, "isar_auxcmd %s=%d",
1838 FC1_CMD
[ic
->parm
.aux
.cmd
], ic
->parm
.aux
.para
[0]);
1839 for (i
= 0; i
< FAXMODCNT
; i
++)
1840 if (faxmodulation
[i
] == ic
->parm
.aux
.para
[0])
1842 if ((i
< FAXMODCNT
) && ((1 << i
) & modmask
) &&
1843 test_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
1846 ic
->parm
.aux
.para
[0]);
1850 /* wrong modulation or not activ */
1853 ic
->command
= ISDN_STAT_FAXIND
;
1854 ic
->parm
.aux
.cmd
= ISDN_FAX_CLASS1_ERROR
;
1855 cs
->iif
.statcallb(ic
);
1858 case (ISDN_CMD_IOCTL
):
1860 case 9: /* load firmware */
1861 features
= ISDN_FEATURE_L2_MODEM
|
1862 ISDN_FEATURE_L2_FAX
|
1863 ISDN_FEATURE_L3_FCLASS1
;
1864 memcpy(&adr
, ic
->parm
.num
, sizeof(ulong
));
1865 if (isar_load_firmware(cs
, (u_char __user
*)adr
))
1868 ll_run(cs
, features
);
1871 features
= *(unsigned int *) ic
->parm
.num
;
1872 printk(KERN_DEBUG
"HiSax: max modulation old(%04x) new(%04x)\n",
1877 features
= *(unsigned int *) ic
->parm
.num
;
1878 printk(KERN_DEBUG
"HiSax: FRM extra delay old(%d) new(%d) ms\n",
1879 frm_extra_delay
, features
);
1881 frm_extra_delay
= features
;
1884 features
= *(unsigned int *) ic
->parm
.num
;
1885 printk(KERN_DEBUG
"HiSax: TOA old(%d) new(%d) db\n",
1886 para_TOA
, features
);
1887 if (features
>= 0 && features
< 32)
1888 para_TOA
= features
;
1891 printk(KERN_DEBUG
"HiSax: invalid ioctl %d\n",
1902 void initisar(struct IsdnCardState
*cs
)
1904 cs
->bcs
[0].BC_SetStack
= setstack_isar
;
1905 cs
->bcs
[1].BC_SetStack
= setstack_isar
;
1906 cs
->bcs
[0].BC_Close
= close_isarstate
;
1907 cs
->bcs
[1].BC_Close
= close_isarstate
;
1908 timer_setup(&cs
->bcs
[0].hw
.isar
.ftimer
, ftimer_handler
, 0);
1909 timer_setup(&cs
->bcs
[1].hw
.isar
.ftimer
, ftimer_handler
, 0);