14 #undef ISDN_TTY_FAX_STAT_DEBUG
15 #undef ISDN_TTY_FAX_CMD_DEBUG
17 #include <linux/isdn.h>
23 static char *isdn_tty_fax_revision =
"$Revision: 1.1.2.2 $";
25 #define PARSE_ERROR1 { isdn_tty_fax_modem_result(1, info); return 1; }
33 if ((p =
strchr(revision,
':'))) {
57 {
"OK",
"ERROR",
"+FCON",
"+FCSI:",
"+FDIS:",
58 "+FHNG:",
"+FDCS:",
"CONNECT",
"+FTSI:",
59 "+FCFR",
"+FPTS:",
"+FET:"};
65 #ifdef ISDN_TTY_FAX_CMD_DEBUG
67 msg[code], info->
line);
83 if (f->phase == ISDN_FAX_PHASE_A)
84 f->phase = ISDN_FAX_PHASE_B;
93 rp = &f->r_resolution;
94 for (i = 0; i < 8; i++) {
95 sprintf(rss,
"%c%s", rp[i] + 48,
100 #ifdef ISDN_TTY_FAX_CMD_DEBUG
112 rp = &f->r_resolution;
113 for (i = 0; i < 8; i++) {
114 sprintf(rss,
"%c%s", rp[i] + 48,
119 #ifdef ISDN_TTY_FAX_CMD_DEBUG
125 info->faxonline |= 2;
143 if (info->faxonline & 1) {
155 {
"OK",
"CONNECT",
"NO CARRIER",
"ERROR",
"FCERROR"};
157 #ifdef ISDN_TTY_FAX_CMD_DEBUG
193 T30_s *f = info->fax;
197 return (isdn_tty_fax_command1(info, c));
199 #ifdef ISDN_TTY_FAX_CMD_DEBUG
201 f->r_code, info->
line);
204 case ISDN_TTY_FAX_FCON:
206 isdn_tty_fax_modem_result(2, info);
208 case ISDN_TTY_FAX_FCON_I:
209 info->faxonline = 16;
210 isdn_tty_fax_modem_result(2, info);
212 case ISDN_TTY_FAX_RID:
213 if (info->faxonline & 1)
214 isdn_tty_fax_modem_result(3, info);
215 if (info->faxonline & 16)
216 isdn_tty_fax_modem_result(8, info);
218 case ISDN_TTY_FAX_DIS:
219 isdn_tty_fax_modem_result(4, info);
221 case ISDN_TTY_FAX_HNG:
222 if (f->phase == ISDN_FAX_PHASE_C) {
223 if (f->direction == ISDN_TTY_FAX_CONN_IN) {
230 info->faxonline &= ~2;
233 f->phase = ISDN_FAX_PHASE_E;
234 isdn_tty_fax_modem_result(5, info);
235 isdn_tty_fax_modem_result(0, info);
237 case ISDN_TTY_FAX_DCS:
238 isdn_tty_fax_modem_result(6, info);
239 isdn_tty_fax_modem_result(7, info);
240 f->phase = ISDN_FAX_PHASE_C;
242 case ISDN_TTY_FAX_TRAIN_OK:
243 isdn_tty_fax_modem_result(6, info);
244 isdn_tty_fax_modem_result(0, info);
246 case ISDN_TTY_FAX_SENT:
247 isdn_tty_fax_modem_result(0, info);
249 case ISDN_TTY_FAX_CFR:
250 isdn_tty_fax_modem_result(9, info);
252 case ISDN_TTY_FAX_ET:
255 isdn_tty_fax_modem_result(10, info);
256 isdn_tty_fax_modem_result(11, info);
257 isdn_tty_fax_modem_result(0, info);
258 info->faxonline &= ~2;
260 f->phase = ISDN_FAX_PHASE_D;
262 case ISDN_TTY_FAX_PTS:
263 isdn_tty_fax_modem_result(10, info);
264 if (f->direction == ISDN_TTY_FAX_CONN_OUT) {
266 f->phase = ISDN_FAX_PHASE_B;
268 isdn_tty_fax_modem_result(0, info);
271 case ISDN_TTY_FAX_EOP:
272 info->faxonline &= ~2;
274 f->phase = ISDN_FAX_PHASE_D;
291 if (!info->fax->bor) {
292 for (i = 0; i < skb->
len; i++) {
295 LeftMask = 0x80, RightMask = 0x01;
296 LeftMask > RightMask;
297 LeftMask >>= 1, RightMask <<= 1
299 fBit = (Data & LeftMask);
300 if (Data & RightMask)
323 {
"AE",
"TS",
"RS",
"TM",
"RM",
"TH",
"RH"};
332 #ifdef ISDN_TTY_FAX_CMD_DEBUG
351 if ((par < 0) || (par > 255))
364 #ifdef ISDN_TTY_FAX_CMD_DEBUG
378 spin_unlock_irqrestore(&
dev->lock, flags);
385 spin_unlock_irqrestore(&
dev->lock, flags);
398 spin_unlock_irqrestore(&
dev->lock, flags);
412 isdn_tty_cmd_FCLASS2(
char **p,
modem_info *info)
415 T30_s *f = info->fax;
421 {1, 5, 2, 2, 3, 2, 0, 7};
435 if ((par < 0) || (par > 255))
444 if (!
strncmp(p[0],
"BADLIN", 6)) {
449 sprintf(rs,
"\r\n%d", f->badlin);
460 if ((par < 0) || (par > 255))
463 #ifdef ISDN_TTY_FAX_STAT_DEBUG
474 if (!
strncmp(p[0],
"BADMUL", 6)) {
479 sprintf(rs,
"\r\n%d", f->badmul);
490 if ((par < 0) || (par > 255))
493 #ifdef ISDN_TTY_FAX_STAT_DEBUG
504 if (!
strncmp(p[0],
"BOR", 3)) {
520 if ((par < 0) || (par > 1))
523 #ifdef ISDN_TTY_FAX_STAT_DEBUG
534 if (!
strncmp(p[0],
"NBC", 3)) {
550 if ((par < 0) || (par > 1))
553 #ifdef ISDN_TTY_FAX_STAT_DEBUG
564 if (!
strncmp(p[0],
"BUF?", 4)) {
566 #ifdef ISDN_TTY_FAX_STAT_DEBUG
575 if (!
strncmp(p[0],
"CIG", 3)) {
581 sprintf(rs,
"\r\n\"%s\"", f->pollid);
593 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] !=
'"'); i++) {
594 f->pollid[
i] = *p[0]++;
598 for (r = i; r < FAXIDLEN; r++) {
601 f->pollid[FAXIDLEN - 1] = 0;
602 #ifdef ISDN_TTY_FAX_STAT_DEBUG
629 if ((par < 0) || (par > 2))
632 #ifdef ISDN_TTY_FAX_STAT_DEBUG
659 if ((par < 0) || (par > 1))
662 #ifdef ISDN_TTY_FAX_STAT_DEBUG
673 if (!
strncmp(p[0],
"CTCRTY", 6)) {
678 sprintf(rs,
"\r\n%d", f->ctcrty);
689 if ((par < 0) || (par > 255))
692 #ifdef ISDN_TTY_FAX_STAT_DEBUG
703 if (!
strncmp(p[0],
"DCC", 3)) {
704 char *rp = &f->resolution;
712 for (i = 0; i < 8; i++) {
713 sprintf(rss,
"%c%s", rp[i] + 48,
722 isdn_tty_at_cout(
"\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
725 for (i = 0; (((*p[0] >=
'0') && (*p[0] <=
'9')) || (*p[0] ==
',')) && (i < 8); i++) {
727 if ((*p[0] - 48) > maxdccval[
i]) {
737 #ifdef ISDN_TTY_FAX_STAT_DEBUG
738 printk(
KERN_DEBUG "isdn_tty: Fax FDCC capabilities DCE=%d,%d,%d,%d,%d,%d,%d,%d\n",
739 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]);
749 if (!
strncmp(p[0],
"DIS", 3)) {
750 char *rp = &f->resolution;
758 for (i = 0; i < 8; i++) {
759 sprintf(rss,
"%c%s", rp[i] + 48,
768 isdn_tty_at_cout(
"\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
771 for (i = 0; (((*p[0] >=
'0') && (*p[0] <=
'9')) || (*p[0] ==
',')) && (i < 8); i++) {
773 if ((*p[0] - 48) > maxdccval[
i]) {
783 #ifdef ISDN_TTY_FAX_STAT_DEBUG
784 printk(
KERN_DEBUG "isdn_tty: Fax FDIS session parms=%d,%d,%d,%d,%d,%d,%d,%d\n",
785 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]);
797 if ((info->faxonline & 16) &&
798 ((f->phase == ISDN_FAX_PHASE_B) || (f->phase == ISDN_FAX_PHASE_D))) {
799 #ifdef ISDN_TTY_FAX_STAT_DEBUG
802 f->code = ISDN_TTY_FAX_DR;
807 if (f->phase == ISDN_FAX_PHASE_B) {
808 f->phase = ISDN_FAX_PHASE_C;
809 }
else if (f->phase == ISDN_FAX_PHASE_D) {
812 f->phase = ISDN_FAX_PHASE_C;
813 isdn_tty_fax_modem_result(7, info);
816 f->phase = ISDN_FAX_PHASE_B;
819 f->phase = ISDN_FAX_PHASE_E;
834 char *rp = &f->resolution;
837 if (!(info->faxonline & 1))
840 for (i = 0; (((*p[0] >=
'0') && (*p[0] <=
'9')) || (*p[0] ==
',')) && (i < 4); i++) {
842 if ((*p[0] - 48) > maxdccval[val[
i]]) {
845 rp[val[
i]] = *p[0] - 48;
852 #ifdef ISDN_TTY_FAX_STAT_DEBUG
854 rp[4], rp[0], rp[2], rp[3]);
856 if ((f->phase == ISDN_FAX_PHASE_B) || (f->phase == ISDN_FAX_PHASE_D)) {
857 f->code = ISDN_TTY_FAX_DT;
862 if (f->phase == ISDN_FAX_PHASE_D) {
863 f->phase = ISDN_FAX_PHASE_C;
864 isdn_tty_fax_modem_result(7, info);
872 if (!
strncmp(p[0],
"ECM", 3)) {
888 if ((par != 0) && (par != 2))
891 #ifdef ISDN_TTY_FAX_STAT_DEBUG
902 if (!
strncmp(p[0],
"ET=", 3)) {
909 if ((f->phase != ISDN_FAX_PHASE_D) ||
910 (!(info->faxonline & 1)))
913 if ((par < 0) || (par > 2))
916 f->code = ISDN_TTY_FAX_ET;
921 #ifdef ISDN_TTY_FAX_STAT_DEBUG
931 if ((f->phase == ISDN_FAX_PHASE_IDLE) || (f->phase == ISDN_FAX_PHASE_E))
937 if (!
strncmp(p[0],
"LID", 3)) {
943 sprintf(rs,
"\r\n\"%s\"", f->id);
955 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] !=
'"'); i++) {
960 for (r = i; r < FAXIDLEN; r++) {
963 f->id[FAXIDLEN - 1] = 0;
964 #ifdef ISDN_TTY_FAX_STAT_DEBUG
976 if (!
strncmp(p[0],
"MDL?", 4)) {
978 #ifdef ISDN_TTY_FAX_STAT_DEBUG
985 if (!
strncmp(p[0],
"MFR?", 4)) {
987 #ifdef ISDN_TTY_FAX_STAT_DEBUG
994 if (!
strncmp(p[0],
"MINSP", 5)) {
999 sprintf(rs,
"\r\n%d", f->minsp);
1010 if ((par < 0) || (par > 5))
1013 #ifdef ISDN_TTY_FAX_STAT_DEBUG
1024 if (!
strncmp(p[0],
"PHCTO", 5)) {
1029 sprintf(rs,
"\r\n%d", f->phcto);
1040 if ((par < 0) || (par > 255))
1043 #ifdef ISDN_TTY_FAX_STAT_DEBUG
1055 if (!
strncmp(p[0],
"REL", 3)) {
1060 sprintf(rs,
"\r\n%d", f->rel);
1071 if ((par < 0) || (par > 1))
1074 #ifdef ISDN_TTY_FAX_STAT_DEBUG
1085 if (!
strncmp(p[0],
"REV?", 4)) {
1087 #ifdef ISDN_TTY_FAX_STAT_DEBUG
1090 strcpy(rss, isdn_tty_fax_revision);
1091 sprintf(rs,
"\r\nRev: %s", isdn_getrev(rss));
1097 if (!
strncmp(p[0],
"TBC=", 4)) {
1099 #ifdef ISDN_TTY_FAX_STAT_DEBUG
1119 return (isdn_tty_cmd_FCLASS2(p, info));
1121 return (isdn_tty_cmd_FCLASS1(p, info));