Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Stuff used by all variants of the driver |
| 3 | * |
Tilman Schmidt | 70440cf | 2006-04-10 22:55:14 -0700 | [diff] [blame] | 4 | * Copyright (c) 2001 by Stefan Eilers, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 5 | * Hansjoerg Lipp <hjlipp@web.de>, |
| 6 | * Tilman Schmidt <tilman@imap.cc>. |
| 7 | * |
| 8 | * ===================================================================== |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * ===================================================================== |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include "gigaset.h" |
| 17 | |
| 18 | /* ========================================================== */ |
| 19 | /* bit masks for pending commands */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 20 | #define PC_DIAL 0x001 |
| 21 | #define PC_HUP 0x002 |
| 22 | #define PC_INIT 0x004 |
| 23 | #define PC_DLE0 0x008 |
| 24 | #define PC_DLE1 0x010 |
| 25 | #define PC_SHUTDOWN 0x020 |
| 26 | #define PC_ACCEPT 0x040 |
| 27 | #define PC_CID 0x080 |
| 28 | #define PC_NOCID 0x100 |
| 29 | #define PC_CIDMODE 0x200 |
| 30 | #define PC_UMMODE 0x400 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 31 | |
| 32 | /* types of modem responses */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 33 | #define RT_NOTHING 0 |
| 34 | #define RT_ZSAU 1 |
| 35 | #define RT_RING 2 |
| 36 | #define RT_NUMBER 3 |
| 37 | #define RT_STRING 4 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 38 | #define RT_ZCAU 6 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 39 | |
| 40 | /* Possible ASCII responses */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 41 | #define RSP_OK 0 |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 42 | #define RSP_ERROR 1 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 43 | #define RSP_ZGCI 3 |
| 44 | #define RSP_RING 4 |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 45 | #define RSP_ZVLS 5 |
| 46 | #define RSP_ZCAU 6 |
| 47 | |
| 48 | /* responses with values to store in at_state */ |
| 49 | /* - numeric */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 50 | #define RSP_VAR 100 |
| 51 | #define RSP_ZSAU (RSP_VAR + VAR_ZSAU) |
| 52 | #define RSP_ZDLE (RSP_VAR + VAR_ZDLE) |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 53 | #define RSP_ZCTP (RSP_VAR + VAR_ZCTP) |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 54 | /* - string */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 55 | #define RSP_STR (RSP_VAR + VAR_NUM) |
| 56 | #define RSP_NMBR (RSP_STR + STR_NMBR) |
| 57 | #define RSP_ZCPN (RSP_STR + STR_ZCPN) |
| 58 | #define RSP_ZCON (RSP_STR + STR_ZCON) |
| 59 | #define RSP_ZBC (RSP_STR + STR_ZBC) |
| 60 | #define RSP_ZHLC (RSP_STR + STR_ZHLC) |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 61 | |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 62 | #define RSP_WRONG_CID -2 /* unknown cid in cmd */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 63 | #define RSP_INVAL -6 /* invalid response */ |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 64 | #define RSP_NODEV -9 /* device not connected */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 65 | |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 66 | #define RSP_NONE -19 |
| 67 | #define RSP_STRING -20 |
| 68 | #define RSP_NULL -21 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 69 | #define RSP_INIT -27 |
| 70 | #define RSP_ANY -26 |
| 71 | #define RSP_LAST -28 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 72 | |
| 73 | /* actions for process_response */ |
| 74 | #define ACT_NOTHING 0 |
| 75 | #define ACT_SETDLE1 1 |
| 76 | #define ACT_SETDLE0 2 |
| 77 | #define ACT_FAILINIT 3 |
| 78 | #define ACT_HUPMODEM 4 |
| 79 | #define ACT_CONFIGMODE 5 |
| 80 | #define ACT_INIT 6 |
| 81 | #define ACT_DLE0 7 |
| 82 | #define ACT_DLE1 8 |
| 83 | #define ACT_FAILDLE0 9 |
| 84 | #define ACT_FAILDLE1 10 |
| 85 | #define ACT_RING 11 |
| 86 | #define ACT_CID 12 |
| 87 | #define ACT_FAILCID 13 |
| 88 | #define ACT_SDOWN 14 |
| 89 | #define ACT_FAILSDOWN 15 |
| 90 | #define ACT_DEBUG 16 |
| 91 | #define ACT_WARN 17 |
| 92 | #define ACT_DIALING 18 |
| 93 | #define ACT_ABORTDIAL 19 |
| 94 | #define ACT_DISCONNECT 20 |
| 95 | #define ACT_CONNECT 21 |
| 96 | #define ACT_REMOTEREJECT 22 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 97 | #define ACT_CONNTIMEOUT 23 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 98 | #define ACT_REMOTEHUP 24 |
| 99 | #define ACT_ABORTHUP 25 |
| 100 | #define ACT_ICALL 26 |
| 101 | #define ACT_ACCEPTED 27 |
| 102 | #define ACT_ABORTACCEPT 28 |
| 103 | #define ACT_TIMEOUT 29 |
| 104 | #define ACT_GETSTRING 30 |
| 105 | #define ACT_SETVER 31 |
| 106 | #define ACT_FAILVER 32 |
| 107 | #define ACT_GOTVER 33 |
| 108 | #define ACT_TEST 34 |
| 109 | #define ACT_ERROR 35 |
| 110 | #define ACT_ABORTCID 36 |
| 111 | #define ACT_ZCAU 37 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 112 | #define ACT_NOTIFY_BC_DOWN 38 |
| 113 | #define ACT_NOTIFY_BC_UP 39 |
| 114 | #define ACT_DIAL 40 |
| 115 | #define ACT_ACCEPT 41 |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 116 | #define ACT_HUP 43 |
| 117 | #define ACT_IF_LOCK 44 |
| 118 | #define ACT_START 45 |
| 119 | #define ACT_STOP 46 |
| 120 | #define ACT_FAKEDLE0 47 |
| 121 | #define ACT_FAKEHUP 48 |
| 122 | #define ACT_FAKESDOWN 49 |
| 123 | #define ACT_SHUTDOWN 50 |
| 124 | #define ACT_PROC_CIDMODE 51 |
| 125 | #define ACT_UMODESET 52 |
| 126 | #define ACT_FAILUMODE 53 |
| 127 | #define ACT_CMODESET 54 |
| 128 | #define ACT_FAILCMODE 55 |
| 129 | #define ACT_IF_VER 56 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 130 | #define ACT_CMD 100 |
| 131 | |
| 132 | /* at command sequences */ |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 133 | #define SEQ_NONE 0 |
| 134 | #define SEQ_INIT 100 |
| 135 | #define SEQ_DLE0 200 |
| 136 | #define SEQ_DLE1 250 |
| 137 | #define SEQ_CID 300 |
| 138 | #define SEQ_NOCID 350 |
| 139 | #define SEQ_HUP 400 |
| 140 | #define SEQ_DIAL 600 |
| 141 | #define SEQ_ACCEPT 720 |
| 142 | #define SEQ_SHUTDOWN 500 |
| 143 | #define SEQ_CIDMODE 10 |
| 144 | #define SEQ_UMMODE 11 |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 145 | |
| 146 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 147 | /* 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid), |
| 148 | * 400: hup, 500: reset, 600: dial, 700: ring */ |
Tilman Schmidt | 528efc6 | 2009-05-13 12:44:17 +0000 | [diff] [blame] | 149 | struct reply_t gigaset_tab_nocid[] = |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 150 | { |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 151 | /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, |
| 152 | * action, command */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 153 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 154 | /* initialize device, set cid mode if possible */ |
| 155 | {RSP_INIT, -1, -1, SEQ_INIT, 100, 1, {ACT_TIMEOUT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 156 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 157 | {EV_TIMEOUT, 100, 100, -1, 101, 3, {0}, "Z\r"}, |
| 158 | {RSP_OK, 101, 103, -1, 120, 5, {ACT_GETSTRING}, |
| 159 | "+GMR\r"}, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 160 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 161 | {EV_TIMEOUT, 101, 101, -1, 102, 5, {0}, "Z\r"}, |
| 162 | {RSP_ERROR, 101, 101, -1, 102, 5, {0}, "Z\r"}, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 163 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 164 | {EV_TIMEOUT, 102, 102, -1, 108, 5, {ACT_SETDLE1}, |
| 165 | "^SDLE=0\r"}, |
| 166 | {RSP_OK, 108, 108, -1, 104, -1}, |
| 167 | {RSP_ZDLE, 104, 104, 0, 103, 5, {0}, "Z\r"}, |
| 168 | {EV_TIMEOUT, 104, 104, -1, 0, 0, {ACT_FAILINIT} }, |
| 169 | {RSP_ERROR, 108, 108, -1, 0, 0, {ACT_FAILINIT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 170 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 171 | {EV_TIMEOUT, 108, 108, -1, 105, 2, {ACT_SETDLE0, |
| 172 | ACT_HUPMODEM, |
| 173 | ACT_TIMEOUT} }, |
| 174 | {EV_TIMEOUT, 105, 105, -1, 103, 5, {0}, "Z\r"}, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 175 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 176 | {RSP_ERROR, 102, 102, -1, 107, 5, {0}, "^GETPRE\r"}, |
| 177 | {RSP_OK, 107, 107, -1, 0, 0, {ACT_CONFIGMODE} }, |
| 178 | {RSP_ERROR, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, |
| 179 | {EV_TIMEOUT, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 180 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 181 | {RSP_ERROR, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, |
| 182 | {EV_TIMEOUT, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 183 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 184 | {RSP_STRING, 120, 120, -1, 121, -1, {ACT_SETVER} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 185 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 186 | {EV_TIMEOUT, 120, 121, -1, 0, 0, {ACT_FAILVER, |
| 187 | ACT_INIT} }, |
| 188 | {RSP_ERROR, 120, 121, -1, 0, 0, {ACT_FAILVER, |
| 189 | ACT_INIT} }, |
| 190 | {RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER, |
| 191 | ACT_INIT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 192 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 193 | /* leave dle mode */ |
| 194 | {RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"}, |
| 195 | {RSP_OK, 201, 201, -1, 202, -1}, |
| 196 | {RSP_ZDLE, 202, 202, 0, 0, 0, {ACT_DLE0} }, |
| 197 | {RSP_NODEV, 200, 249, -1, 0, 0, {ACT_FAKEDLE0} }, |
| 198 | {RSP_ERROR, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, |
| 199 | {EV_TIMEOUT, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 200 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 201 | /* enter dle mode */ |
| 202 | {RSP_INIT, 0, 0, SEQ_DLE1, 251, 5, {0}, "^SDLE=1\r"}, |
| 203 | {RSP_OK, 251, 251, -1, 252, -1}, |
| 204 | {RSP_ZDLE, 252, 252, 1, 0, 0, {ACT_DLE1} }, |
| 205 | {RSP_ERROR, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, |
| 206 | {EV_TIMEOUT, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 207 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 208 | /* incoming call */ |
| 209 | {RSP_RING, -1, -1, -1, -1, -1, {ACT_RING} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 210 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 211 | /* get cid */ |
| 212 | {RSP_INIT, 0, 0, SEQ_CID, 301, 5, {0}, "^SGCI?\r"}, |
| 213 | {RSP_OK, 301, 301, -1, 302, -1}, |
| 214 | {RSP_ZGCI, 302, 302, -1, 0, 0, {ACT_CID} }, |
| 215 | {RSP_ERROR, 301, 349, -1, 0, 0, {ACT_FAILCID} }, |
| 216 | {EV_TIMEOUT, 301, 349, -1, 0, 0, {ACT_FAILCID} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 217 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 218 | /* enter cid mode */ |
| 219 | {RSP_INIT, 0, 0, SEQ_CIDMODE, 150, 5, {0}, "^SGCI=1\r"}, |
| 220 | {RSP_OK, 150, 150, -1, 0, 0, {ACT_CMODESET} }, |
| 221 | {RSP_ERROR, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, |
| 222 | {EV_TIMEOUT, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 223 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 224 | /* leave cid mode */ |
| 225 | {RSP_INIT, 0, 0, SEQ_UMMODE, 160, 5, {0}, "Z\r"}, |
| 226 | {RSP_OK, 160, 160, -1, 0, 0, {ACT_UMODESET} }, |
| 227 | {RSP_ERROR, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, |
| 228 | {EV_TIMEOUT, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 229 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 230 | /* abort getting cid */ |
| 231 | {RSP_INIT, 0, 0, SEQ_NOCID, 0, 0, {ACT_ABORTCID} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 232 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 233 | /* reset */ |
| 234 | {RSP_INIT, 0, 0, SEQ_SHUTDOWN, 504, 5, {0}, "Z\r"}, |
| 235 | {RSP_OK, 504, 504, -1, 0, 0, {ACT_SDOWN} }, |
| 236 | {RSP_ERROR, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, |
| 237 | {EV_TIMEOUT, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, |
| 238 | {RSP_NODEV, 501, 599, -1, 0, 0, {ACT_FAKESDOWN} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 239 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 240 | {EV_PROC_CIDMODE, -1, -1, -1, -1, -1, {ACT_PROC_CIDMODE} }, |
| 241 | {EV_IF_LOCK, -1, -1, -1, -1, -1, {ACT_IF_LOCK} }, |
| 242 | {EV_IF_VER, -1, -1, -1, -1, -1, {ACT_IF_VER} }, |
| 243 | {EV_START, -1, -1, -1, -1, -1, {ACT_START} }, |
| 244 | {EV_STOP, -1, -1, -1, -1, -1, {ACT_STOP} }, |
| 245 | {EV_SHUTDOWN, -1, -1, -1, -1, -1, {ACT_SHUTDOWN} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 246 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 247 | /* misc. */ |
| 248 | {RSP_ERROR, -1, -1, -1, -1, -1, {ACT_ERROR} }, |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 249 | {RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, |
| 250 | {RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, |
| 251 | {RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, |
| 252 | {RSP_LAST} |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 253 | }; |
| 254 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 255 | /* 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring, |
| 256 | * 400: hup, 750: accepted icall */ |
Tilman Schmidt | 528efc6 | 2009-05-13 12:44:17 +0000 | [diff] [blame] | 257 | struct reply_t gigaset_tab_cid[] = |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 258 | { |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 259 | /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, |
| 260 | * action, command */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 261 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 262 | /* dial */ |
| 263 | {EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} }, |
| 264 | {RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC} }, |
Tilman Schmidt | 1ce368f | 2010-06-21 13:55:05 +0000 | [diff] [blame] | 265 | {RSP_OK, 601, 601, -1, 603, 5, {ACT_CMD+AT_PROTO} }, |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 266 | {RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD+AT_TYPE} }, |
| 267 | {RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD+AT_MSN} }, |
| 268 | {RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} }, |
| 269 | {RSP_OK, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} }, |
| 270 | {RSP_NULL, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} }, |
| 271 | {RSP_OK, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} }, |
| 272 | {RSP_OK, 607, 607, -1, 608, 5, {0}, "+VLS=17\r"}, |
| 273 | {RSP_OK, 608, 608, -1, 609, -1}, |
| 274 | {RSP_ZSAU, 609, 609, ZSAU_PROCEEDING, 610, 5, {ACT_CMD+AT_DIAL} }, |
| 275 | {RSP_OK, 610, 610, -1, 650, 0, {ACT_DIALING} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 276 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 277 | {RSP_ERROR, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, |
| 278 | {EV_TIMEOUT, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 279 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 280 | /* optional dialing responses */ |
| 281 | {EV_BC_OPEN, 650, 650, -1, 651, -1}, |
| 282 | {RSP_ZVLS, 609, 651, 17, -1, -1, {ACT_DEBUG} }, |
| 283 | {RSP_ZCTP, 610, 651, -1, -1, -1, {ACT_DEBUG} }, |
| 284 | {RSP_ZCPN, 610, 651, -1, -1, -1, {ACT_DEBUG} }, |
| 285 | {RSP_ZSAU, 650, 651, ZSAU_CALL_DELIVERED, -1, -1, {ACT_DEBUG} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 286 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 287 | /* connect */ |
| 288 | {RSP_ZSAU, 650, 650, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, |
| 289 | {RSP_ZSAU, 651, 651, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, |
| 290 | ACT_NOTIFY_BC_UP} }, |
| 291 | {RSP_ZSAU, 750, 750, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, |
| 292 | {RSP_ZSAU, 751, 751, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, |
| 293 | ACT_NOTIFY_BC_UP} }, |
| 294 | {EV_BC_OPEN, 800, 800, -1, 800, -1, {ACT_NOTIFY_BC_UP} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 295 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 296 | /* remote hangup */ |
| 297 | {RSP_ZSAU, 650, 651, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT} }, |
| 298 | {RSP_ZSAU, 750, 751, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, |
| 299 | {RSP_ZSAU, 800, 800, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 300 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 301 | /* hangup */ |
| 302 | {EV_HUP, -1, -1, -1, -1, -1, {ACT_HUP} }, |
| 303 | {RSP_INIT, -1, -1, SEQ_HUP, 401, 5, {0}, "+VLS=0\r"}, |
| 304 | {RSP_OK, 401, 401, -1, 402, 5}, |
| 305 | {RSP_ZVLS, 402, 402, 0, 403, 5}, |
| 306 | {RSP_ZSAU, 403, 403, ZSAU_DISCONNECT_REQ, -1, -1, {ACT_DEBUG} }, |
| 307 | {RSP_ZSAU, 403, 403, ZSAU_NULL, 0, 0, {ACT_DISCONNECT} }, |
| 308 | {RSP_NODEV, 401, 403, -1, 0, 0, {ACT_FAKEHUP} }, |
| 309 | {RSP_ERROR, 401, 401, -1, 0, 0, {ACT_ABORTHUP} }, |
| 310 | {EV_TIMEOUT, 401, 403, -1, 0, 0, {ACT_ABORTHUP} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 311 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 312 | {EV_BC_CLOSED, 0, 0, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 313 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 314 | /* ring */ |
| 315 | {RSP_ZBC, 700, 700, -1, -1, -1, {0} }, |
| 316 | {RSP_ZHLC, 700, 700, -1, -1, -1, {0} }, |
| 317 | {RSP_NMBR, 700, 700, -1, -1, -1, {0} }, |
| 318 | {RSP_ZCPN, 700, 700, -1, -1, -1, {0} }, |
| 319 | {RSP_ZCTP, 700, 700, -1, -1, -1, {0} }, |
| 320 | {EV_TIMEOUT, 700, 700, -1, 720, 720, {ACT_ICALL} }, |
| 321 | {EV_BC_CLOSED, 720, 720, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 322 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 323 | /*accept icall*/ |
| 324 | {EV_ACCEPT, -1, -1, -1, -1, -1, {ACT_ACCEPT} }, |
| 325 | {RSP_INIT, 720, 720, SEQ_ACCEPT, 721, 5, {ACT_CMD+AT_PROTO} }, |
| 326 | {RSP_OK, 721, 721, -1, 722, 5, {ACT_CMD+AT_ISO} }, |
| 327 | {RSP_OK, 722, 722, -1, 723, 5, {0}, "+VLS=17\r"}, |
| 328 | {RSP_OK, 723, 723, -1, 724, 5, {0} }, |
| 329 | {RSP_ZVLS, 724, 724, 17, 750, 50, {ACT_ACCEPTED} }, |
| 330 | {RSP_ERROR, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, |
| 331 | {EV_TIMEOUT, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, |
| 332 | {RSP_ZSAU, 700, 729, ZSAU_NULL, 0, 0, {ACT_ABORTACCEPT} }, |
| 333 | {RSP_ZSAU, 700, 729, ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT} }, |
| 334 | {RSP_ZSAU, 700, 729, ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 335 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 336 | {EV_BC_OPEN, 750, 750, -1, 751, -1}, |
| 337 | {EV_TIMEOUT, 750, 751, -1, 0, 0, {ACT_CONNTIMEOUT} }, |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 338 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 339 | /* B channel closed (general case) */ |
| 340 | {EV_BC_CLOSED, -1, -1, -1, -1, -1, {ACT_NOTIFY_BC_DOWN} }, |
Tilman Schmidt | 73a8881 | 2006-04-22 02:35:30 -0700 | [diff] [blame] | 341 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 342 | /* misc. */ |
| 343 | {RSP_ZCON, -1, -1, -1, -1, -1, {ACT_DEBUG} }, |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 344 | {RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, |
| 345 | {RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, |
| 346 | {RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, |
| 347 | {RSP_LAST} |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 348 | }; |
| 349 | |
| 350 | |
Tilman Schmidt | 50e4fe9 | 2009-10-25 09:30:57 +0000 | [diff] [blame] | 351 | static const struct resp_type_t { |
| 352 | unsigned char *response; |
| 353 | int resp_code; |
| 354 | int type; |
| 355 | } resp_type[] = |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 356 | { |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 357 | {"OK", RSP_OK, RT_NOTHING}, |
| 358 | {"ERROR", RSP_ERROR, RT_NOTHING}, |
| 359 | {"ZSAU", RSP_ZSAU, RT_ZSAU}, |
| 360 | {"ZCAU", RSP_ZCAU, RT_ZCAU}, |
| 361 | {"RING", RSP_RING, RT_RING}, |
| 362 | {"ZGCI", RSP_ZGCI, RT_NUMBER}, |
| 363 | {"ZVLS", RSP_ZVLS, RT_NUMBER}, |
| 364 | {"ZCTP", RSP_ZCTP, RT_NUMBER}, |
| 365 | {"ZDLE", RSP_ZDLE, RT_NUMBER}, |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 366 | {"ZHLC", RSP_ZHLC, RT_STRING}, |
| 367 | {"ZBC", RSP_ZBC, RT_STRING}, |
| 368 | {"NMBR", RSP_NMBR, RT_STRING}, |
| 369 | {"ZCPN", RSP_ZCPN, RT_STRING}, |
| 370 | {"ZCON", RSP_ZCON, RT_STRING}, |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 371 | {NULL, 0, 0} |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 372 | }; |
| 373 | |
Tilman Schmidt | 50e4fe9 | 2009-10-25 09:30:57 +0000 | [diff] [blame] | 374 | static const struct zsau_resp_t { |
| 375 | unsigned char *str; |
| 376 | int code; |
| 377 | } zsau_resp[] = |
| 378 | { |
| 379 | {"OUTGOING_CALL_PROCEEDING", ZSAU_OUTGOING_CALL_PROCEEDING}, |
| 380 | {"CALL_DELIVERED", ZSAU_CALL_DELIVERED}, |
| 381 | {"ACTIVE", ZSAU_ACTIVE}, |
| 382 | {"DISCONNECT_IND", ZSAU_DISCONNECT_IND}, |
| 383 | {"NULL", ZSAU_NULL}, |
| 384 | {"DISCONNECT_REQ", ZSAU_DISCONNECT_REQ}, |
| 385 | {NULL, ZSAU_UNKNOWN} |
| 386 | }; |
| 387 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 388 | /* retrieve CID from parsed response |
| 389 | * returns 0 if no CID, -1 if invalid CID, or CID value 1..65535 |
| 390 | */ |
| 391 | static int cid_of_response(char *s) |
| 392 | { |
Alexey Dobriyan | 19eccc2 | 2011-03-27 02:58:35 +0000 | [diff] [blame] | 393 | int cid; |
Andy Shevchenko | c974138 | 2010-07-15 02:37:20 +0000 | [diff] [blame] | 394 | int rc; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 395 | |
| 396 | if (s[-1] != ';') |
| 397 | return 0; /* no CID separator */ |
Alexey Dobriyan | 19eccc2 | 2011-03-27 02:58:35 +0000 | [diff] [blame] | 398 | rc = kstrtoint(s, 10, &cid); |
Andy Shevchenko | c974138 | 2010-07-15 02:37:20 +0000 | [diff] [blame] | 399 | if (rc) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 400 | return 0; /* CID not numeric */ |
| 401 | if (cid < 1 || cid > 65535) |
| 402 | return -1; /* CID out of range */ |
| 403 | return cid; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Tilman Schmidt | 1cec972 | 2009-10-06 12:19:01 +0000 | [diff] [blame] | 406 | /** |
| 407 | * gigaset_handle_modem_response() - process received modem response |
| 408 | * @cs: device descriptor structure. |
| 409 | * |
| 410 | * Called by asyncdata/isocdata if a block of data received from the |
| 411 | * device must be processed as a modem command response. The data is |
| 412 | * already in the cs structure. |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 413 | */ |
| 414 | void gigaset_handle_modem_response(struct cardstate *cs) |
| 415 | { |
| 416 | unsigned char *argv[MAX_REC_PARAMS + 1]; |
| 417 | int params; |
| 418 | int i, j; |
Tilman Schmidt | 35dc845 | 2007-03-29 01:20:34 -0700 | [diff] [blame] | 419 | const struct resp_type_t *rt; |
Tilman Schmidt | 50e4fe9 | 2009-10-25 09:30:57 +0000 | [diff] [blame] | 420 | const struct zsau_resp_t *zr; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 421 | int curarg; |
| 422 | unsigned long flags; |
| 423 | unsigned next, tail, head; |
| 424 | struct event_t *event; |
| 425 | int resp_code; |
| 426 | int param_type; |
| 427 | int abort; |
| 428 | size_t len; |
| 429 | int cid; |
| 430 | int rawstring; |
| 431 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 432 | len = cs->cbytes; |
| 433 | if (!len) { |
| 434 | /* ignore additional LFs/CRs (M10x config mode or cx100) */ |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 435 | gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 436 | return; |
| 437 | } |
| 438 | cs->respdata[len] = 0; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 439 | argv[0] = cs->respdata; |
| 440 | params = 1; |
| 441 | if (cs->at_state.getstring) { |
| 442 | /* getstring only allowed without cid at the moment */ |
| 443 | cs->at_state.getstring = 0; |
| 444 | rawstring = 1; |
| 445 | cid = 0; |
| 446 | } else { |
| 447 | /* parse line */ |
| 448 | for (i = 0; i < len; i++) |
| 449 | switch (cs->respdata[i]) { |
| 450 | case ';': |
| 451 | case ',': |
| 452 | case '=': |
| 453 | if (params > MAX_REC_PARAMS) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 454 | dev_warn(cs->dev, |
| 455 | "too many parameters in response\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 456 | /* need last parameter (might be CID) */ |
| 457 | params--; |
| 458 | } |
| 459 | argv[params++] = cs->respdata + i + 1; |
| 460 | } |
| 461 | |
| 462 | rawstring = 0; |
| 463 | cid = params > 1 ? cid_of_response(argv[params-1]) : 0; |
| 464 | if (cid < 0) { |
| 465 | gigaset_add_event(cs, &cs->at_state, RSP_INVAL, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 466 | NULL, 0, NULL); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 467 | return; |
| 468 | } |
| 469 | |
| 470 | for (j = 1; j < params; ++j) |
| 471 | argv[j][-1] = 0; |
| 472 | |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 473 | gig_dbg(DEBUG_EVENT, "CMD received: %s", argv[0]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 474 | if (cid) { |
| 475 | --params; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 476 | gig_dbg(DEBUG_EVENT, "CID: %s", argv[params]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 477 | } |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 478 | gig_dbg(DEBUG_EVENT, "available params: %d", params - 1); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 479 | for (j = 1; j < params; j++) |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 480 | gig_dbg(DEBUG_EVENT, "param %d: %s", j, argv[j]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | spin_lock_irqsave(&cs->ev_lock, flags); |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 484 | head = cs->ev_head; |
| 485 | tail = cs->ev_tail; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 486 | |
| 487 | abort = 1; |
| 488 | curarg = 0; |
| 489 | while (curarg < params) { |
| 490 | next = (tail + 1) % MAX_EVENTS; |
| 491 | if (unlikely(next == head)) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 492 | dev_err(cs->dev, "event queue full\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 493 | break; |
| 494 | } |
| 495 | |
| 496 | event = cs->events + tail; |
| 497 | event->at_state = NULL; |
| 498 | event->cid = cid; |
| 499 | event->ptr = NULL; |
| 500 | event->arg = NULL; |
| 501 | tail = next; |
| 502 | |
| 503 | if (rawstring) { |
| 504 | resp_code = RSP_STRING; |
| 505 | param_type = RT_STRING; |
| 506 | } else { |
| 507 | for (rt = resp_type; rt->response; ++rt) |
| 508 | if (!strcmp(argv[curarg], rt->response)) |
| 509 | break; |
| 510 | |
| 511 | if (!rt->response) { |
Tilman Schmidt | 2ed5e4f | 2010-07-05 14:18:48 +0000 | [diff] [blame] | 512 | event->type = RSP_NONE; |
| 513 | gig_dbg(DEBUG_EVENT, |
| 514 | "unknown modem response: '%s'\n", |
| 515 | argv[curarg]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 516 | break; |
| 517 | } |
| 518 | |
| 519 | resp_code = rt->resp_code; |
| 520 | param_type = rt->type; |
| 521 | ++curarg; |
| 522 | } |
| 523 | |
| 524 | event->type = resp_code; |
| 525 | |
| 526 | switch (param_type) { |
| 527 | case RT_NOTHING: |
| 528 | break; |
| 529 | case RT_RING: |
| 530 | if (!cid) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 531 | dev_err(cs->dev, |
| 532 | "received RING without CID!\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 533 | event->type = RSP_INVAL; |
| 534 | abort = 1; |
| 535 | } else { |
| 536 | event->cid = 0; |
| 537 | event->parameter = cid; |
| 538 | abort = 0; |
| 539 | } |
| 540 | break; |
| 541 | case RT_ZSAU: |
| 542 | if (curarg >= params) { |
| 543 | event->parameter = ZSAU_NONE; |
| 544 | break; |
| 545 | } |
Tilman Schmidt | 50e4fe9 | 2009-10-25 09:30:57 +0000 | [diff] [blame] | 546 | for (zr = zsau_resp; zr->str; ++zr) |
| 547 | if (!strcmp(argv[curarg], zr->str)) |
| 548 | break; |
| 549 | event->parameter = zr->code; |
| 550 | if (!zr->str) |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 551 | dev_warn(cs->dev, |
| 552 | "%s: unknown parameter %s after ZSAU\n", |
| 553 | __func__, argv[curarg]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 554 | ++curarg; |
| 555 | break; |
| 556 | case RT_STRING: |
| 557 | if (curarg < params) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 558 | event->ptr = kstrdup(argv[curarg], GFP_ATOMIC); |
| 559 | if (!event->ptr) |
| 560 | dev_err(cs->dev, "out of memory\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 561 | ++curarg; |
| 562 | } |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 563 | gig_dbg(DEBUG_EVENT, "string==%s", |
Tilman Schmidt | 236b87c | 2008-12-26 01:22:03 -0800 | [diff] [blame] | 564 | event->ptr ? (char *) event->ptr : "NULL"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 565 | break; |
| 566 | case RT_ZCAU: |
| 567 | event->parameter = -1; |
| 568 | if (curarg + 1 < params) { |
Alexey Dobriyan | 19eccc2 | 2011-03-27 02:58:35 +0000 | [diff] [blame] | 569 | u8 type, value; |
Andy Shevchenko | c974138 | 2010-07-15 02:37:20 +0000 | [diff] [blame] | 570 | |
Alexey Dobriyan | 19eccc2 | 2011-03-27 02:58:35 +0000 | [diff] [blame] | 571 | i = kstrtou8(argv[curarg++], 16, &type); |
| 572 | j = kstrtou8(argv[curarg++], 16, &value); |
| 573 | if (i == 0 && j == 0) |
Andy Shevchenko | c974138 | 2010-07-15 02:37:20 +0000 | [diff] [blame] | 574 | event->parameter = (type << 8) | value; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 575 | } else |
| 576 | curarg = params - 1; |
| 577 | break; |
| 578 | case RT_NUMBER: |
Alexey Dobriyan | 19eccc2 | 2011-03-27 02:58:35 +0000 | [diff] [blame] | 579 | if (curarg >= params || |
| 580 | kstrtoint(argv[curarg++], 10, &event->parameter)) |
| 581 | event->parameter = -1; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 582 | gig_dbg(DEBUG_EVENT, "parameter==%d", event->parameter); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 583 | break; |
| 584 | } |
| 585 | |
| 586 | if (resp_code == RSP_ZDLE) |
| 587 | cs->dle = event->parameter; |
| 588 | |
| 589 | if (abort) |
| 590 | break; |
| 591 | } |
| 592 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 593 | cs->ev_tail = tail; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 594 | spin_unlock_irqrestore(&cs->ev_lock, flags); |
| 595 | |
| 596 | if (curarg != params) |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 597 | gig_dbg(DEBUG_EVENT, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 598 | "invalid number of processed parameters: %d/%d", |
| 599 | curarg, params); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 600 | } |
| 601 | EXPORT_SYMBOL_GPL(gigaset_handle_modem_response); |
| 602 | |
| 603 | /* disconnect |
| 604 | * process closing of connection associated with given AT state structure |
| 605 | */ |
| 606 | static void disconnect(struct at_state_t **at_state_p) |
| 607 | { |
| 608 | unsigned long flags; |
Tilman Schmidt | d48c778 | 2006-04-10 22:55:08 -0700 | [diff] [blame] | 609 | struct bc_state *bcs = (*at_state_p)->bcs; |
| 610 | struct cardstate *cs = (*at_state_p)->cs; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 611 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 612 | spin_lock_irqsave(&cs->lock, flags); |
| 613 | ++(*at_state_p)->seq_index; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 614 | |
| 615 | /* revert to selected idle mode */ |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 616 | if (!cs->cidmode) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 617 | cs->at_state.pending_commands |= PC_UMMODE; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 618 | gig_dbg(DEBUG_EVENT, "Scheduling PC_UMMODE"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 619 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 620 | } |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 621 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 622 | |
| 623 | if (bcs) { |
| 624 | /* B channel assigned: invoke hardware specific handler */ |
| 625 | cs->ops->close_bchannel(bcs); |
Tilman Schmidt | 3305adf | 2009-10-06 12:18:26 +0000 | [diff] [blame] | 626 | /* notify LL */ |
| 627 | if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { |
| 628 | bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 629 | gigaset_isdn_hupD(bcs); |
Tilman Schmidt | 3305adf | 2009-10-06 12:18:26 +0000 | [diff] [blame] | 630 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 631 | } else { |
| 632 | /* no B channel assigned: just deallocate */ |
| 633 | spin_lock_irqsave(&cs->lock, flags); |
| 634 | list_del(&(*at_state_p)->list); |
| 635 | kfree(*at_state_p); |
| 636 | *at_state_p = NULL; |
| 637 | spin_unlock_irqrestore(&cs->lock, flags); |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | /* get_free_channel |
| 642 | * get a free AT state structure: either one of those associated with the |
| 643 | * B channels of the Gigaset device, or if none of those is available, |
| 644 | * a newly allocated one with bcs=NULL |
| 645 | * The structure should be freed by calling disconnect() after use. |
| 646 | */ |
| 647 | static inline struct at_state_t *get_free_channel(struct cardstate *cs, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 648 | int cid) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 649 | /* cids: >0: siemens-cid |
| 650 | 0: without cid |
| 651 | -1: no cid assigned yet |
| 652 | */ |
| 653 | { |
| 654 | unsigned long flags; |
| 655 | int i; |
| 656 | struct at_state_t *ret; |
| 657 | |
| 658 | for (i = 0; i < cs->channels; ++i) |
| 659 | if (gigaset_get_channel(cs->bcs + i)) { |
| 660 | ret = &cs->bcs[i].at_state; |
| 661 | ret->cid = cid; |
| 662 | return ret; |
| 663 | } |
| 664 | |
| 665 | spin_lock_irqsave(&cs->lock, flags); |
| 666 | ret = kmalloc(sizeof(struct at_state_t), GFP_ATOMIC); |
| 667 | if (ret) { |
| 668 | gigaset_at_init(ret, NULL, cs, cid); |
| 669 | list_add(&ret->list, &cs->temp_at_states); |
| 670 | } |
| 671 | spin_unlock_irqrestore(&cs->lock, flags); |
| 672 | return ret; |
| 673 | } |
| 674 | |
| 675 | static void init_failed(struct cardstate *cs, int mode) |
| 676 | { |
| 677 | int i; |
| 678 | struct at_state_t *at_state; |
| 679 | |
| 680 | cs->at_state.pending_commands &= ~PC_INIT; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 681 | cs->mode = mode; |
| 682 | cs->mstate = MS_UNINITIALIZED; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 683 | gigaset_free_channels(cs); |
| 684 | for (i = 0; i < cs->channels; ++i) { |
| 685 | at_state = &cs->bcs[i].at_state; |
| 686 | if (at_state->pending_commands & PC_CID) { |
| 687 | at_state->pending_commands &= ~PC_CID; |
| 688 | at_state->pending_commands |= PC_NOCID; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 689 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 690 | } |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | static void schedule_init(struct cardstate *cs, int state) |
| 695 | { |
| 696 | if (cs->at_state.pending_commands & PC_INIT) { |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 697 | gig_dbg(DEBUG_EVENT, "not scheduling PC_INIT again"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 698 | return; |
| 699 | } |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 700 | cs->mstate = state; |
| 701 | cs->mode = M_UNKNOWN; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 702 | gigaset_block_channels(cs); |
| 703 | cs->at_state.pending_commands |= PC_INIT; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 704 | gig_dbg(DEBUG_EVENT, "Scheduling PC_INIT"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 705 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 706 | } |
| 707 | |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 708 | /* Add "AT" to a command, add the cid, dle encode it, send the result to the |
| 709 | hardware. */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 710 | static void send_command(struct cardstate *cs, const char *cmd, int cid, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 711 | int dle, gfp_t kmallocflags) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 712 | { |
Tilman Schmidt | e3628dd | 2010-07-05 14:18:43 +0000 | [diff] [blame] | 713 | struct cmdbuf_t *cb; |
| 714 | size_t buflen; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 715 | |
Tilman Schmidt | e3628dd | 2010-07-05 14:18:43 +0000 | [diff] [blame] | 716 | buflen = strlen(cmd) + 12; /* DLE ( A T 1 2 3 4 5 <cmd> DLE ) \0 */ |
| 717 | cb = kmalloc(sizeof(struct cmdbuf_t) + buflen, kmallocflags); |
| 718 | if (!cb) { |
| 719 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 720 | return; |
| 721 | } |
Tilman Schmidt | e3628dd | 2010-07-05 14:18:43 +0000 | [diff] [blame] | 722 | if (cid > 0 && cid <= 65535) |
| 723 | cb->len = snprintf(cb->buf, buflen, |
| 724 | dle ? "\020(AT%d%s\020)" : "AT%d%s", |
| 725 | cid, cmd); |
| 726 | else |
| 727 | cb->len = snprintf(cb->buf, buflen, |
| 728 | dle ? "\020(AT%s\020)" : "AT%s", |
| 729 | cmd); |
| 730 | cb->offset = 0; |
| 731 | cb->next = NULL; |
| 732 | cb->wake_tasklet = NULL; |
| 733 | cs->ops->write_cmd(cs, cb); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid) |
| 737 | { |
| 738 | struct at_state_t *at_state; |
| 739 | int i; |
| 740 | unsigned long flags; |
| 741 | |
| 742 | if (cid == 0) |
| 743 | return &cs->at_state; |
| 744 | |
| 745 | for (i = 0; i < cs->channels; ++i) |
| 746 | if (cid == cs->bcs[i].at_state.cid) |
| 747 | return &cs->bcs[i].at_state; |
| 748 | |
| 749 | spin_lock_irqsave(&cs->lock, flags); |
| 750 | |
| 751 | list_for_each_entry(at_state, &cs->temp_at_states, list) |
| 752 | if (cid == at_state->cid) { |
| 753 | spin_unlock_irqrestore(&cs->lock, flags); |
| 754 | return at_state; |
| 755 | } |
| 756 | |
| 757 | spin_unlock_irqrestore(&cs->lock, flags); |
| 758 | |
| 759 | return NULL; |
| 760 | } |
| 761 | |
| 762 | static void bchannel_down(struct bc_state *bcs) |
| 763 | { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 764 | if (bcs->chstate & CHS_B_UP) { |
| 765 | bcs->chstate &= ~CHS_B_UP; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 766 | gigaset_isdn_hupB(bcs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { |
| 770 | bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 771 | gigaset_isdn_hupD(bcs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | gigaset_free_channel(bcs); |
| 775 | |
| 776 | gigaset_bcs_reinit(bcs); |
| 777 | } |
| 778 | |
| 779 | static void bchannel_up(struct bc_state *bcs) |
| 780 | { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 781 | if (bcs->chstate & CHS_B_UP) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 782 | dev_notice(bcs->cs->dev, "%s: B channel already up\n", |
| 783 | __func__); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 784 | return; |
| 785 | } |
| 786 | |
| 787 | bcs->chstate |= CHS_B_UP; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 788 | gigaset_isdn_connB(bcs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 789 | } |
| 790 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 791 | static void start_dial(struct at_state_t *at_state, void *data, |
| 792 | unsigned seq_index) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 793 | { |
| 794 | struct bc_state *bcs = at_state->bcs; |
| 795 | struct cardstate *cs = at_state->cs; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 796 | char **commands = data; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 797 | unsigned long flags; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 798 | int i; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 799 | |
| 800 | bcs->chstate |= CHS_NOTIFY_LL; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 801 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 802 | spin_lock_irqsave(&cs->lock, flags); |
| 803 | if (at_state->seq_index != seq_index) { |
| 804 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 805 | goto error; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 806 | } |
| 807 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 808 | |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 809 | for (i = 0; i < AT_NUM; ++i) { |
| 810 | kfree(bcs->commands[i]); |
| 811 | bcs->commands[i] = commands[i]; |
| 812 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 813 | |
| 814 | at_state->pending_commands |= PC_CID; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 815 | gig_dbg(DEBUG_EVENT, "Scheduling PC_CID"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 816 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 817 | return; |
| 818 | |
| 819 | error: |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 820 | for (i = 0; i < AT_NUM; ++i) { |
| 821 | kfree(commands[i]); |
| 822 | commands[i] = NULL; |
| 823 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 824 | at_state->pending_commands |= PC_NOCID; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 825 | gig_dbg(DEBUG_EVENT, "Scheduling PC_NOCID"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 826 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 827 | return; |
| 828 | } |
| 829 | |
| 830 | static void start_accept(struct at_state_t *at_state) |
| 831 | { |
| 832 | struct cardstate *cs = at_state->cs; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 833 | struct bc_state *bcs = at_state->bcs; |
| 834 | int i; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 835 | |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 836 | for (i = 0; i < AT_NUM; ++i) { |
| 837 | kfree(bcs->commands[i]); |
| 838 | bcs->commands[i] = NULL; |
| 839 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 840 | |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 841 | bcs->commands[AT_PROTO] = kmalloc(9, GFP_ATOMIC); |
| 842 | bcs->commands[AT_ISO] = kmalloc(9, GFP_ATOMIC); |
| 843 | if (!bcs->commands[AT_PROTO] || !bcs->commands[AT_ISO]) { |
| 844 | dev_err(at_state->cs->dev, "out of memory\n"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 845 | /* error reset */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 846 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 847 | gig_dbg(DEBUG_EVENT, "Scheduling PC_HUP"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 848 | cs->commands_pending = 1; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 849 | return; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 850 | } |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 851 | |
| 852 | snprintf(bcs->commands[AT_PROTO], 9, "^SBPR=%u\r", bcs->proto2); |
| 853 | snprintf(bcs->commands[AT_ISO], 9, "^SISO=%u\r", bcs->channel + 1); |
| 854 | |
| 855 | at_state->pending_commands |= PC_ACCEPT; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 856 | gig_dbg(DEBUG_EVENT, "Scheduling PC_ACCEPT"); |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 857 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | static void do_start(struct cardstate *cs) |
| 861 | { |
| 862 | gigaset_free_channels(cs); |
| 863 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 864 | if (cs->mstate != MS_LOCKED) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 865 | schedule_init(cs, MS_INIT); |
| 866 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 867 | cs->isdn_up = 1; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 868 | gigaset_isdn_start(cs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 869 | |
| 870 | cs->waiting = 0; |
| 871 | wake_up(&cs->waitqueue); |
| 872 | } |
| 873 | |
| 874 | static void finish_shutdown(struct cardstate *cs) |
| 875 | { |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 876 | if (cs->mstate != MS_LOCKED) { |
| 877 | cs->mstate = MS_UNINITIALIZED; |
| 878 | cs->mode = M_UNKNOWN; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 879 | } |
| 880 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 881 | /* Tell the LL that the device is not available .. */ |
| 882 | if (cs->isdn_up) { |
| 883 | cs->isdn_up = 0; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 884 | gigaset_isdn_stop(cs); |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 885 | } |
| 886 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 887 | /* The rest is done by cleanup_cs () in user mode. */ |
| 888 | |
| 889 | cs->cmd_result = -ENODEV; |
| 890 | cs->waiting = 0; |
Tilman Schmidt | 2869b23 | 2007-02-12 00:52:34 -0800 | [diff] [blame] | 891 | wake_up(&cs->waitqueue); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | static void do_shutdown(struct cardstate *cs) |
| 895 | { |
| 896 | gigaset_block_channels(cs); |
| 897 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 898 | if (cs->mstate == MS_READY) { |
| 899 | cs->mstate = MS_SHUTDOWN; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 900 | cs->at_state.pending_commands |= PC_SHUTDOWN; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 901 | gig_dbg(DEBUG_EVENT, "Scheduling PC_SHUTDOWN"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 902 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 903 | } else |
| 904 | finish_shutdown(cs); |
| 905 | } |
| 906 | |
| 907 | static void do_stop(struct cardstate *cs) |
| 908 | { |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 909 | unsigned long flags; |
| 910 | |
| 911 | spin_lock_irqsave(&cs->lock, flags); |
| 912 | cs->connected = 0; |
| 913 | spin_unlock_irqrestore(&cs->lock, flags); |
| 914 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 915 | do_shutdown(cs); |
| 916 | } |
| 917 | |
| 918 | /* Entering cid mode or getting a cid failed: |
| 919 | * try to initialize the device and try again. |
| 920 | * |
| 921 | * channel >= 0: getting cid for the channel failed |
| 922 | * channel < 0: entering cid mode failed |
| 923 | * |
| 924 | * returns 0 on failure |
| 925 | */ |
| 926 | static int reinit_and_retry(struct cardstate *cs, int channel) |
| 927 | { |
| 928 | int i; |
| 929 | |
| 930 | if (--cs->retry_count <= 0) |
| 931 | return 0; |
| 932 | |
| 933 | for (i = 0; i < cs->channels; ++i) |
| 934 | if (cs->bcs[i].at_state.cid > 0) |
| 935 | return 0; |
| 936 | |
| 937 | if (channel < 0) |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 938 | dev_warn(cs->dev, |
| 939 | "Could not enter cid mode. Reinit device and try again.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 940 | else { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 941 | dev_warn(cs->dev, |
| 942 | "Could not get a call id. Reinit device and try again.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 943 | cs->bcs[channel].at_state.pending_commands |= PC_CID; |
| 944 | } |
| 945 | schedule_init(cs, MS_INIT); |
| 946 | return 1; |
| 947 | } |
| 948 | |
| 949 | static int at_state_invalid(struct cardstate *cs, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 950 | struct at_state_t *test_ptr) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 951 | { |
| 952 | unsigned long flags; |
| 953 | unsigned channel; |
| 954 | struct at_state_t *at_state; |
| 955 | int retval = 0; |
| 956 | |
| 957 | spin_lock_irqsave(&cs->lock, flags); |
| 958 | |
| 959 | if (test_ptr == &cs->at_state) |
| 960 | goto exit; |
| 961 | |
| 962 | list_for_each_entry(at_state, &cs->temp_at_states, list) |
| 963 | if (at_state == test_ptr) |
| 964 | goto exit; |
| 965 | |
| 966 | for (channel = 0; channel < cs->channels; ++channel) |
| 967 | if (&cs->bcs[channel].at_state == test_ptr) |
| 968 | goto exit; |
| 969 | |
| 970 | retval = 1; |
| 971 | exit: |
| 972 | spin_unlock_irqrestore(&cs->lock, flags); |
| 973 | return retval; |
| 974 | } |
| 975 | |
| 976 | static void handle_icall(struct cardstate *cs, struct bc_state *bcs, |
| 977 | struct at_state_t **p_at_state) |
| 978 | { |
| 979 | int retval; |
| 980 | struct at_state_t *at_state = *p_at_state; |
| 981 | |
| 982 | retval = gigaset_isdn_icall(at_state); |
| 983 | switch (retval) { |
| 984 | case ICALL_ACCEPT: |
| 985 | break; |
| 986 | default: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 987 | dev_err(cs->dev, "internal error: disposition=%d\n", retval); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 988 | /* --v-- fall through --v-- */ |
| 989 | case ICALL_IGNORE: |
| 990 | case ICALL_REJECT: |
| 991 | /* hang up actively |
| 992 | * Device doc says that would reject the call. |
| 993 | * In fact it doesn't. |
| 994 | */ |
| 995 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 996 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 997 | break; |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | static int do_lock(struct cardstate *cs) |
| 1002 | { |
| 1003 | int mode; |
| 1004 | int i; |
| 1005 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1006 | switch (cs->mstate) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1007 | case MS_UNINITIALIZED: |
| 1008 | case MS_READY: |
| 1009 | if (cs->cur_at_seq || !list_empty(&cs->temp_at_states) || |
| 1010 | cs->at_state.pending_commands) |
| 1011 | return -EBUSY; |
| 1012 | |
| 1013 | for (i = 0; i < cs->channels; ++i) |
| 1014 | if (cs->bcs[i].at_state.pending_commands) |
| 1015 | return -EBUSY; |
| 1016 | |
| 1017 | if (!gigaset_get_channels(cs)) |
| 1018 | return -EBUSY; |
| 1019 | |
| 1020 | break; |
| 1021 | case MS_LOCKED: |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1022 | break; |
| 1023 | default: |
| 1024 | return -EBUSY; |
| 1025 | } |
| 1026 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1027 | mode = cs->mode; |
| 1028 | cs->mstate = MS_LOCKED; |
| 1029 | cs->mode = M_UNKNOWN; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1030 | |
| 1031 | return mode; |
| 1032 | } |
| 1033 | |
| 1034 | static int do_unlock(struct cardstate *cs) |
| 1035 | { |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1036 | if (cs->mstate != MS_LOCKED) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1037 | return -EINVAL; |
| 1038 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1039 | cs->mstate = MS_UNINITIALIZED; |
| 1040 | cs->mode = M_UNKNOWN; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1041 | gigaset_free_channels(cs); |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1042 | if (cs->connected) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1043 | schedule_init(cs, MS_INIT); |
| 1044 | |
| 1045 | return 0; |
| 1046 | } |
| 1047 | |
| 1048 | static void do_action(int action, struct cardstate *cs, |
| 1049 | struct bc_state *bcs, |
| 1050 | struct at_state_t **p_at_state, char **pp_command, |
| 1051 | int *p_genresp, int *p_resp_code, |
| 1052 | struct event_t *ev) |
| 1053 | { |
| 1054 | struct at_state_t *at_state = *p_at_state; |
| 1055 | struct at_state_t *at_state2; |
| 1056 | unsigned long flags; |
| 1057 | |
| 1058 | int channel; |
| 1059 | |
| 1060 | unsigned char *s, *e; |
| 1061 | int i; |
| 1062 | unsigned long val; |
| 1063 | |
| 1064 | switch (action) { |
| 1065 | case ACT_NOTHING: |
| 1066 | break; |
| 1067 | case ACT_TIMEOUT: |
| 1068 | at_state->waiting = 1; |
| 1069 | break; |
| 1070 | case ACT_INIT: |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1071 | cs->at_state.pending_commands &= ~PC_INIT; |
| 1072 | cs->cur_at_seq = SEQ_NONE; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1073 | cs->mode = M_UNIMODEM; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1074 | spin_lock_irqsave(&cs->lock, flags); |
| 1075 | if (!cs->cidmode) { |
| 1076 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1077 | gigaset_free_channels(cs); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1078 | cs->mstate = MS_READY; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1079 | break; |
| 1080 | } |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1081 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1082 | cs->at_state.pending_commands |= PC_CIDMODE; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1083 | gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1084 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1085 | break; |
| 1086 | case ACT_FAILINIT: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1087 | dev_warn(cs->dev, "Could not initialize the device.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1088 | cs->dle = 0; |
| 1089 | init_failed(cs, M_UNKNOWN); |
| 1090 | cs->cur_at_seq = SEQ_NONE; |
| 1091 | break; |
| 1092 | case ACT_CONFIGMODE: |
| 1093 | init_failed(cs, M_CONFIG); |
| 1094 | cs->cur_at_seq = SEQ_NONE; |
| 1095 | break; |
| 1096 | case ACT_SETDLE1: |
| 1097 | cs->dle = 1; |
| 1098 | /* cs->inbuf[0].inputstate |= INS_command | INS_DLE_command; */ |
| 1099 | cs->inbuf[0].inputstate &= |
| 1100 | ~(INS_command | INS_DLE_command); |
| 1101 | break; |
| 1102 | case ACT_SETDLE0: |
| 1103 | cs->dle = 0; |
| 1104 | cs->inbuf[0].inputstate = |
| 1105 | (cs->inbuf[0].inputstate & ~INS_DLE_command) |
| 1106 | | INS_command; |
| 1107 | break; |
| 1108 | case ACT_CMODESET: |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1109 | if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1110 | gigaset_free_channels(cs); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1111 | cs->mstate = MS_READY; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1112 | } |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1113 | cs->mode = M_CID; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1114 | cs->cur_at_seq = SEQ_NONE; |
| 1115 | break; |
| 1116 | case ACT_UMODESET: |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1117 | cs->mode = M_UNIMODEM; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1118 | cs->cur_at_seq = SEQ_NONE; |
| 1119 | break; |
| 1120 | case ACT_FAILCMODE: |
| 1121 | cs->cur_at_seq = SEQ_NONE; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1122 | if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1123 | init_failed(cs, M_UNKNOWN); |
| 1124 | break; |
| 1125 | } |
| 1126 | if (!reinit_and_retry(cs, -1)) |
| 1127 | schedule_init(cs, MS_RECOVER); |
| 1128 | break; |
| 1129 | case ACT_FAILUMODE: |
| 1130 | cs->cur_at_seq = SEQ_NONE; |
| 1131 | schedule_init(cs, MS_RECOVER); |
| 1132 | break; |
| 1133 | case ACT_HUPMODEM: |
| 1134 | /* send "+++" (hangup in unimodem mode) */ |
Tilman Schmidt | e3628dd | 2010-07-05 14:18:43 +0000 | [diff] [blame] | 1135 | if (cs->connected) { |
| 1136 | struct cmdbuf_t *cb; |
| 1137 | |
| 1138 | cb = kmalloc(sizeof(struct cmdbuf_t) + 3, GFP_ATOMIC); |
| 1139 | if (!cb) { |
| 1140 | dev_err(cs->dev, "%s: out of memory\n", |
| 1141 | __func__); |
| 1142 | return; |
| 1143 | } |
| 1144 | memcpy(cb->buf, "+++", 3); |
| 1145 | cb->len = 3; |
| 1146 | cb->offset = 0; |
| 1147 | cb->next = NULL; |
| 1148 | cb->wake_tasklet = NULL; |
| 1149 | cs->ops->write_cmd(cs, cb); |
| 1150 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1151 | break; |
| 1152 | case ACT_RING: |
| 1153 | /* get fresh AT state structure for new CID */ |
| 1154 | at_state2 = get_free_channel(cs, ev->parameter); |
| 1155 | if (!at_state2) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1156 | dev_warn(cs->dev, |
| 1157 | "RING ignored: could not allocate channel structure\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1158 | break; |
| 1159 | } |
| 1160 | |
| 1161 | /* initialize AT state structure |
| 1162 | * note that bcs may be NULL if no B channel is free |
| 1163 | */ |
| 1164 | at_state2->ConState = 700; |
Tilman Schmidt | 3a0a3a6 | 2010-03-14 12:58:05 +0000 | [diff] [blame] | 1165 | for (i = 0; i < STR_NUM; ++i) { |
| 1166 | kfree(at_state2->str_var[i]); |
| 1167 | at_state2->str_var[i] = NULL; |
| 1168 | } |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1169 | at_state2->int_var[VAR_ZCTP] = -1; |
| 1170 | |
| 1171 | spin_lock_irqsave(&cs->lock, flags); |
| 1172 | at_state2->timer_expires = RING_TIMEOUT; |
| 1173 | at_state2->timer_active = 1; |
| 1174 | spin_unlock_irqrestore(&cs->lock, flags); |
| 1175 | break; |
| 1176 | case ACT_ICALL: |
| 1177 | handle_icall(cs, bcs, p_at_state); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1178 | break; |
| 1179 | case ACT_FAILSDOWN: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1180 | dev_warn(cs->dev, "Could not shut down the device.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1181 | /* fall through */ |
| 1182 | case ACT_FAKESDOWN: |
| 1183 | case ACT_SDOWN: |
| 1184 | cs->cur_at_seq = SEQ_NONE; |
| 1185 | finish_shutdown(cs); |
| 1186 | break; |
| 1187 | case ACT_CONNECT: |
| 1188 | if (cs->onechannel) { |
| 1189 | at_state->pending_commands |= PC_DLE1; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1190 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1191 | break; |
| 1192 | } |
| 1193 | bcs->chstate |= CHS_D_UP; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 1194 | gigaset_isdn_connD(bcs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1195 | cs->ops->init_bchannel(bcs); |
| 1196 | break; |
| 1197 | case ACT_DLE1: |
| 1198 | cs->cur_at_seq = SEQ_NONE; |
| 1199 | bcs = cs->bcs + cs->curchannel; |
| 1200 | |
| 1201 | bcs->chstate |= CHS_D_UP; |
Tilman Schmidt | 088ec0c | 2009-10-06 12:19:07 +0000 | [diff] [blame] | 1202 | gigaset_isdn_connD(bcs); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1203 | cs->ops->init_bchannel(bcs); |
| 1204 | break; |
| 1205 | case ACT_FAKEHUP: |
| 1206 | at_state->int_var[VAR_ZSAU] = ZSAU_NULL; |
| 1207 | /* fall through */ |
| 1208 | case ACT_DISCONNECT: |
| 1209 | cs->cur_at_seq = SEQ_NONE; |
| 1210 | at_state->cid = -1; |
| 1211 | if (bcs && cs->onechannel && cs->dle) { |
| 1212 | /* Check for other open channels not needed: |
| 1213 | * DLE only used for M10x with one B channel. |
| 1214 | */ |
| 1215 | at_state->pending_commands |= PC_DLE0; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1216 | cs->commands_pending = 1; |
Tilman Schmidt | 698e3ed | 2006-06-26 00:25:34 -0700 | [diff] [blame] | 1217 | } else |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1218 | disconnect(p_at_state); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1219 | break; |
| 1220 | case ACT_FAKEDLE0: |
| 1221 | at_state->int_var[VAR_ZDLE] = 0; |
| 1222 | cs->dle = 0; |
| 1223 | /* fall through */ |
| 1224 | case ACT_DLE0: |
| 1225 | cs->cur_at_seq = SEQ_NONE; |
| 1226 | at_state2 = &cs->bcs[cs->curchannel].at_state; |
| 1227 | disconnect(&at_state2); |
| 1228 | break; |
| 1229 | case ACT_ABORTHUP: |
| 1230 | cs->cur_at_seq = SEQ_NONE; |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1231 | dev_warn(cs->dev, "Could not hang up.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1232 | at_state->cid = -1; |
| 1233 | if (bcs && cs->onechannel) |
| 1234 | at_state->pending_commands |= PC_DLE0; |
Tilman Schmidt | 698e3ed | 2006-06-26 00:25:34 -0700 | [diff] [blame] | 1235 | else |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1236 | disconnect(p_at_state); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1237 | schedule_init(cs, MS_RECOVER); |
| 1238 | break; |
| 1239 | case ACT_FAILDLE0: |
| 1240 | cs->cur_at_seq = SEQ_NONE; |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1241 | dev_warn(cs->dev, "Could not leave DLE mode.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1242 | at_state2 = &cs->bcs[cs->curchannel].at_state; |
| 1243 | disconnect(&at_state2); |
| 1244 | schedule_init(cs, MS_RECOVER); |
| 1245 | break; |
| 1246 | case ACT_FAILDLE1: |
| 1247 | cs->cur_at_seq = SEQ_NONE; |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1248 | dev_warn(cs->dev, |
| 1249 | "Could not enter DLE mode. Trying to hang up.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1250 | channel = cs->curchannel; |
| 1251 | cs->bcs[channel].at_state.pending_commands |= PC_HUP; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1252 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1253 | break; |
| 1254 | |
| 1255 | case ACT_CID: /* got cid; start dialing */ |
| 1256 | cs->cur_at_seq = SEQ_NONE; |
| 1257 | channel = cs->curchannel; |
| 1258 | if (ev->parameter > 0 && ev->parameter <= 65535) { |
| 1259 | cs->bcs[channel].at_state.cid = ev->parameter; |
| 1260 | cs->bcs[channel].at_state.pending_commands |= |
| 1261 | PC_DIAL; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1262 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1263 | break; |
| 1264 | } |
| 1265 | /* fall through */ |
| 1266 | case ACT_FAILCID: |
| 1267 | cs->cur_at_seq = SEQ_NONE; |
| 1268 | channel = cs->curchannel; |
| 1269 | if (!reinit_and_retry(cs, channel)) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1270 | dev_warn(cs->dev, |
| 1271 | "Could not get a call ID. Cannot dial.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1272 | at_state2 = &cs->bcs[channel].at_state; |
| 1273 | disconnect(&at_state2); |
| 1274 | } |
| 1275 | break; |
| 1276 | case ACT_ABORTCID: |
| 1277 | cs->cur_at_seq = SEQ_NONE; |
| 1278 | at_state2 = &cs->bcs[cs->curchannel].at_state; |
| 1279 | disconnect(&at_state2); |
| 1280 | break; |
| 1281 | |
| 1282 | case ACT_DIALING: |
| 1283 | case ACT_ACCEPTED: |
| 1284 | cs->cur_at_seq = SEQ_NONE; |
| 1285 | break; |
| 1286 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1287 | case ACT_ABORTACCEPT: /* hangup/error/timeout during ICALL procssng */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1288 | disconnect(p_at_state); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1289 | break; |
| 1290 | |
| 1291 | case ACT_ABORTDIAL: /* error/timeout during dial preparation */ |
| 1292 | cs->cur_at_seq = SEQ_NONE; |
| 1293 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1294 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1295 | break; |
| 1296 | |
| 1297 | case ACT_REMOTEREJECT: /* DISCONNECT_IND after dialling */ |
| 1298 | case ACT_CONNTIMEOUT: /* timeout waiting for ZSAU=ACTIVE */ |
| 1299 | case ACT_REMOTEHUP: /* DISCONNECT_IND with established connection */ |
| 1300 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1301 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1302 | break; |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 1303 | case ACT_GETSTRING: /* warning: RING, ZDLE, ... |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1304 | are not handled properly anymore */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1305 | at_state->getstring = 1; |
| 1306 | break; |
| 1307 | case ACT_SETVER: |
| 1308 | if (!ev->ptr) { |
| 1309 | *p_genresp = 1; |
| 1310 | *p_resp_code = RSP_ERROR; |
| 1311 | break; |
| 1312 | } |
| 1313 | s = ev->ptr; |
| 1314 | |
| 1315 | if (!strcmp(s, "OK")) { |
| 1316 | *p_genresp = 1; |
| 1317 | *p_resp_code = RSP_ERROR; |
| 1318 | break; |
| 1319 | } |
| 1320 | |
| 1321 | for (i = 0; i < 4; ++i) { |
| 1322 | val = simple_strtoul(s, (char **) &e, 10); |
| 1323 | if (val > INT_MAX || e == s) |
| 1324 | break; |
| 1325 | if (i == 3) { |
| 1326 | if (*e) |
| 1327 | break; |
| 1328 | } else if (*e != '.') |
| 1329 | break; |
| 1330 | else |
| 1331 | s = e + 1; |
| 1332 | cs->fwver[i] = val; |
| 1333 | } |
| 1334 | if (i != 4) { |
| 1335 | *p_genresp = 1; |
| 1336 | *p_resp_code = RSP_ERROR; |
| 1337 | break; |
| 1338 | } |
| 1339 | /*at_state->getstring = 1;*/ |
| 1340 | cs->gotfwver = 0; |
| 1341 | break; |
| 1342 | case ACT_GOTVER: |
| 1343 | if (cs->gotfwver == 0) { |
| 1344 | cs->gotfwver = 1; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1345 | gig_dbg(DEBUG_EVENT, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1346 | "firmware version %02d.%03d.%02d.%02d", |
| 1347 | cs->fwver[0], cs->fwver[1], |
| 1348 | cs->fwver[2], cs->fwver[3]); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1349 | break; |
| 1350 | } |
| 1351 | /* fall through */ |
| 1352 | case ACT_FAILVER: |
| 1353 | cs->gotfwver = -1; |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1354 | dev_err(cs->dev, "could not read firmware version.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1355 | break; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1356 | case ACT_ERROR: |
Tilman Schmidt | 05eae94 | 2009-10-06 12:18:46 +0000 | [diff] [blame] | 1357 | gig_dbg(DEBUG_ANY, "%s: ERROR response in ConState %d", |
| 1358 | __func__, at_state->ConState); |
| 1359 | cs->cur_at_seq = SEQ_NONE; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1360 | break; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1361 | case ACT_DEBUG: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1362 | gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d", |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1363 | __func__, ev->type, at_state->ConState); |
| 1364 | break; |
| 1365 | case ACT_WARN: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1366 | dev_warn(cs->dev, "%s: resp_code %d in ConState %d!\n", |
| 1367 | __func__, ev->type, at_state->ConState); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1368 | break; |
| 1369 | case ACT_ZCAU: |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1370 | dev_warn(cs->dev, "cause code %04x in connection state %d.\n", |
| 1371 | ev->parameter, at_state->ConState); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1372 | break; |
| 1373 | |
| 1374 | /* events from the LL */ |
| 1375 | case ACT_DIAL: |
| 1376 | start_dial(at_state, ev->ptr, ev->parameter); |
| 1377 | break; |
| 1378 | case ACT_ACCEPT: |
| 1379 | start_accept(at_state); |
| 1380 | break; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1381 | case ACT_HUP: |
| 1382 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1383 | gig_dbg(DEBUG_EVENT, "Scheduling PC_HUP"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1384 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1385 | break; |
| 1386 | |
| 1387 | /* hotplug events */ |
| 1388 | case ACT_STOP: |
| 1389 | do_stop(cs); |
| 1390 | break; |
| 1391 | case ACT_START: |
| 1392 | do_start(cs); |
| 1393 | break; |
| 1394 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1395 | /* events from the interface */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1396 | case ACT_IF_LOCK: |
| 1397 | cs->cmd_result = ev->parameter ? do_lock(cs) : do_unlock(cs); |
| 1398 | cs->waiting = 0; |
| 1399 | wake_up(&cs->waitqueue); |
| 1400 | break; |
| 1401 | case ACT_IF_VER: |
| 1402 | if (ev->parameter != 0) |
| 1403 | cs->cmd_result = -EINVAL; |
| 1404 | else if (cs->gotfwver != 1) { |
| 1405 | cs->cmd_result = -ENOENT; |
| 1406 | } else { |
| 1407 | memcpy(ev->arg, cs->fwver, sizeof cs->fwver); |
| 1408 | cs->cmd_result = 0; |
| 1409 | } |
| 1410 | cs->waiting = 0; |
| 1411 | wake_up(&cs->waitqueue); |
| 1412 | break; |
| 1413 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1414 | /* events from the proc file system */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1415 | case ACT_PROC_CIDMODE: |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1416 | spin_lock_irqsave(&cs->lock, flags); |
| 1417 | if (ev->parameter != cs->cidmode) { |
| 1418 | cs->cidmode = ev->parameter; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1419 | if (ev->parameter) { |
| 1420 | cs->at_state.pending_commands |= PC_CIDMODE; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1421 | gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1422 | } else { |
| 1423 | cs->at_state.pending_commands |= PC_UMMODE; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1424 | gig_dbg(DEBUG_EVENT, "Scheduling PC_UMMODE"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1425 | } |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1426 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1427 | } |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1428 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1429 | cs->waiting = 0; |
| 1430 | wake_up(&cs->waitqueue); |
| 1431 | break; |
| 1432 | |
| 1433 | /* events from the hardware drivers */ |
| 1434 | case ACT_NOTIFY_BC_DOWN: |
| 1435 | bchannel_down(bcs); |
| 1436 | break; |
| 1437 | case ACT_NOTIFY_BC_UP: |
| 1438 | bchannel_up(bcs); |
| 1439 | break; |
| 1440 | case ACT_SHUTDOWN: |
| 1441 | do_shutdown(cs); |
| 1442 | break; |
| 1443 | |
| 1444 | |
| 1445 | default: |
| 1446 | if (action >= ACT_CMD && action < ACT_CMD + AT_NUM) { |
| 1447 | *pp_command = at_state->bcs->commands[action - ACT_CMD]; |
| 1448 | if (!*pp_command) { |
| 1449 | *p_genresp = 1; |
| 1450 | *p_resp_code = RSP_NULL; |
| 1451 | } |
| 1452 | } else |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1453 | dev_err(cs->dev, "%s: action==%d!\n", __func__, action); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1454 | } |
| 1455 | } |
| 1456 | |
| 1457 | /* State machine to do the calling and hangup procedure */ |
| 1458 | static void process_event(struct cardstate *cs, struct event_t *ev) |
| 1459 | { |
| 1460 | struct bc_state *bcs; |
| 1461 | char *p_command = NULL; |
| 1462 | struct reply_t *rep; |
| 1463 | int rcode; |
| 1464 | int genresp = 0; |
| 1465 | int resp_code = RSP_ERROR; |
| 1466 | int sendcid; |
| 1467 | struct at_state_t *at_state; |
| 1468 | int index; |
| 1469 | int curact; |
| 1470 | unsigned long flags; |
| 1471 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1472 | if (ev->cid >= 0) { |
| 1473 | at_state = at_state_from_cid(cs, ev->cid); |
| 1474 | if (!at_state) { |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1475 | gig_dbg(DEBUG_EVENT, "event %d for invalid cid %d", |
| 1476 | ev->type, ev->cid); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1477 | gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1478 | NULL, 0, NULL); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1479 | return; |
| 1480 | } |
| 1481 | } else { |
| 1482 | at_state = ev->at_state; |
| 1483 | if (at_state_invalid(cs, at_state)) { |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1484 | gig_dbg(DEBUG_EVENT, "event for invalid at_state %p", |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1485 | at_state); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1486 | return; |
| 1487 | } |
| 1488 | } |
| 1489 | |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1490 | gig_dbg(DEBUG_EVENT, "connection state %d, event %d", |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1491 | at_state->ConState, ev->type); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1492 | |
| 1493 | bcs = at_state->bcs; |
| 1494 | sendcid = at_state->cid; |
| 1495 | |
| 1496 | /* Setting the pointer to the dial array */ |
| 1497 | rep = at_state->replystruct; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1498 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1499 | spin_lock_irqsave(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1500 | if (ev->type == EV_TIMEOUT) { |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1501 | if (ev->parameter != at_state->timer_index |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1502 | || !at_state->timer_active) { |
| 1503 | ev->type = RSP_NONE; /* old timeout */ |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1504 | gig_dbg(DEBUG_EVENT, "old timeout"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1505 | } else if (!at_state->waiting) |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1506 | gig_dbg(DEBUG_EVENT, "timeout occurred"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1507 | else |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1508 | gig_dbg(DEBUG_EVENT, "stopped waiting"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1509 | } |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1510 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1511 | |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 1512 | /* if the response belongs to a variable in at_state->int_var[VAR_XXXX] |
| 1513 | or at_state->str_var[STR_XXXX], set it */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1514 | if (ev->type >= RSP_VAR && ev->type < RSP_VAR + VAR_NUM) { |
| 1515 | index = ev->type - RSP_VAR; |
| 1516 | at_state->int_var[index] = ev->parameter; |
| 1517 | } else if (ev->type >= RSP_STR && ev->type < RSP_STR + STR_NUM) { |
| 1518 | index = ev->type - RSP_STR; |
| 1519 | kfree(at_state->str_var[index]); |
| 1520 | at_state->str_var[index] = ev->ptr; |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 1521 | ev->ptr = NULL; /* prevent process_events() from |
| 1522 | deallocating ptr */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1523 | } |
| 1524 | |
| 1525 | if (ev->type == EV_TIMEOUT || ev->type == RSP_STRING) |
| 1526 | at_state->getstring = 0; |
| 1527 | |
Tilman Schmidt | 917f508 | 2006-04-10 22:55:00 -0700 | [diff] [blame] | 1528 | /* Search row in dial array which matches modem response and current |
| 1529 | constate */ |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1530 | for (;; rep++) { |
| 1531 | rcode = rep->resp_code; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1532 | if (rcode == RSP_LAST) { |
| 1533 | /* found nothing...*/ |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1534 | dev_warn(cs->dev, "%s: rcode=RSP_LAST: " |
| 1535 | "resp_code %d in ConState %d!\n", |
| 1536 | __func__, ev->type, at_state->ConState); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1537 | return; |
| 1538 | } |
| 1539 | if ((rcode == RSP_ANY || rcode == ev->type) |
| 1540 | && ((int) at_state->ConState >= rep->min_ConState) |
| 1541 | && (rep->max_ConState < 0 |
| 1542 | || (int) at_state->ConState <= rep->max_ConState) |
| 1543 | && (rep->parameter < 0 || rep->parameter == ev->parameter)) |
| 1544 | break; |
| 1545 | } |
| 1546 | |
| 1547 | p_command = rep->command; |
| 1548 | |
| 1549 | at_state->waiting = 0; |
| 1550 | for (curact = 0; curact < MAXACT; ++curact) { |
| 1551 | /* The row tells us what we should do .. |
| 1552 | */ |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1553 | do_action(rep->action[curact], cs, bcs, &at_state, &p_command, |
| 1554 | &genresp, &resp_code, ev); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1555 | if (!at_state) |
| 1556 | break; /* may be freed after disconnect */ |
| 1557 | } |
| 1558 | |
| 1559 | if (at_state) { |
| 1560 | /* Jump to the next con-state regarding the array */ |
| 1561 | if (rep->new_ConState >= 0) |
| 1562 | at_state->ConState = rep->new_ConState; |
| 1563 | |
| 1564 | if (genresp) { |
| 1565 | spin_lock_irqsave(&cs->lock, flags); |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1566 | at_state->timer_expires = 0; |
| 1567 | at_state->timer_active = 0; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1568 | spin_unlock_irqrestore(&cs->lock, flags); |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1569 | gigaset_add_event(cs, at_state, resp_code, |
| 1570 | NULL, 0, NULL); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1571 | } else { |
| 1572 | /* Send command to modem if not NULL... */ |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1573 | if (p_command) { |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1574 | if (cs->connected) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1575 | send_command(cs, p_command, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1576 | sendcid, cs->dle, |
| 1577 | GFP_ATOMIC); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1578 | else |
| 1579 | gigaset_add_event(cs, at_state, |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1580 | RSP_NODEV, |
| 1581 | NULL, 0, NULL); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | spin_lock_irqsave(&cs->lock, flags); |
| 1585 | if (!rep->timeout) { |
| 1586 | at_state->timer_expires = 0; |
| 1587 | at_state->timer_active = 0; |
| 1588 | } else if (rep->timeout > 0) { /* new timeout */ |
| 1589 | at_state->timer_expires = rep->timeout * 10; |
| 1590 | at_state->timer_active = 1; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1591 | ++at_state->timer_index; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1592 | } |
| 1593 | spin_unlock_irqrestore(&cs->lock, flags); |
| 1594 | } |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | static void schedule_sequence(struct cardstate *cs, |
| 1599 | struct at_state_t *at_state, int sequence) |
| 1600 | { |
| 1601 | cs->cur_at_seq = sequence; |
| 1602 | gigaset_add_event(cs, at_state, RSP_INIT, NULL, sequence, NULL); |
| 1603 | } |
| 1604 | |
| 1605 | static void process_command_flags(struct cardstate *cs) |
| 1606 | { |
| 1607 | struct at_state_t *at_state = NULL; |
| 1608 | struct bc_state *bcs; |
| 1609 | int i; |
| 1610 | int sequence; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1611 | unsigned long flags; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1612 | |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1613 | cs->commands_pending = 0; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1614 | |
| 1615 | if (cs->cur_at_seq) { |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1616 | gig_dbg(DEBUG_EVENT, "not searching scheduled commands: busy"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1617 | return; |
| 1618 | } |
| 1619 | |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1620 | gig_dbg(DEBUG_EVENT, "searching scheduled commands"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1621 | |
| 1622 | sequence = SEQ_NONE; |
| 1623 | |
| 1624 | /* clear pending_commands and hangup channels on shutdown */ |
| 1625 | if (cs->at_state.pending_commands & PC_SHUTDOWN) { |
| 1626 | cs->at_state.pending_commands &= ~PC_CIDMODE; |
| 1627 | for (i = 0; i < cs->channels; ++i) { |
| 1628 | bcs = cs->bcs + i; |
| 1629 | at_state = &bcs->at_state; |
| 1630 | at_state->pending_commands &= |
| 1631 | ~(PC_DLE1 | PC_ACCEPT | PC_DIAL); |
| 1632 | if (at_state->cid > 0) |
| 1633 | at_state->pending_commands |= PC_HUP; |
| 1634 | if (at_state->pending_commands & PC_CID) { |
| 1635 | at_state->pending_commands |= PC_NOCID; |
| 1636 | at_state->pending_commands &= ~PC_CID; |
| 1637 | } |
| 1638 | } |
| 1639 | } |
| 1640 | |
| 1641 | /* clear pending_commands and hangup channels on reset */ |
| 1642 | if (cs->at_state.pending_commands & PC_INIT) { |
| 1643 | cs->at_state.pending_commands &= ~PC_CIDMODE; |
| 1644 | for (i = 0; i < cs->channels; ++i) { |
| 1645 | bcs = cs->bcs + i; |
| 1646 | at_state = &bcs->at_state; |
| 1647 | at_state->pending_commands &= |
| 1648 | ~(PC_DLE1 | PC_ACCEPT | PC_DIAL); |
| 1649 | if (at_state->cid > 0) |
| 1650 | at_state->pending_commands |= PC_HUP; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1651 | if (cs->mstate == MS_RECOVER) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1652 | if (at_state->pending_commands & PC_CID) { |
| 1653 | at_state->pending_commands |= PC_NOCID; |
| 1654 | at_state->pending_commands &= ~PC_CID; |
| 1655 | } |
| 1656 | } |
| 1657 | } |
| 1658 | } |
| 1659 | |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1660 | /* only switch back to unimodem mode if no commands are pending and |
| 1661 | * no channels are up */ |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1662 | spin_lock_irqsave(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1663 | if (cs->at_state.pending_commands == PC_UMMODE |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1664 | && !cs->cidmode |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1665 | && list_empty(&cs->temp_at_states) |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1666 | && cs->mode == M_CID) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1667 | sequence = SEQ_UMMODE; |
| 1668 | at_state = &cs->at_state; |
| 1669 | for (i = 0; i < cs->channels; ++i) { |
| 1670 | bcs = cs->bcs + i; |
| 1671 | if (bcs->at_state.pending_commands || |
| 1672 | bcs->at_state.cid > 0) { |
| 1673 | sequence = SEQ_NONE; |
| 1674 | break; |
| 1675 | } |
| 1676 | } |
| 1677 | } |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1678 | spin_unlock_irqrestore(&cs->lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1679 | cs->at_state.pending_commands &= ~PC_UMMODE; |
| 1680 | if (sequence != SEQ_NONE) { |
| 1681 | schedule_sequence(cs, at_state, sequence); |
| 1682 | return; |
| 1683 | } |
| 1684 | |
| 1685 | for (i = 0; i < cs->channels; ++i) { |
| 1686 | bcs = cs->bcs + i; |
| 1687 | if (bcs->at_state.pending_commands & PC_HUP) { |
| 1688 | bcs->at_state.pending_commands &= ~PC_HUP; |
| 1689 | if (bcs->at_state.pending_commands & PC_CID) { |
| 1690 | /* not yet dialing: PC_NOCID is sufficient */ |
| 1691 | bcs->at_state.pending_commands |= PC_NOCID; |
| 1692 | bcs->at_state.pending_commands &= ~PC_CID; |
| 1693 | } else { |
| 1694 | schedule_sequence(cs, &bcs->at_state, SEQ_HUP); |
| 1695 | return; |
| 1696 | } |
| 1697 | } |
| 1698 | if (bcs->at_state.pending_commands & PC_NOCID) { |
| 1699 | bcs->at_state.pending_commands &= ~PC_NOCID; |
| 1700 | cs->curchannel = bcs->channel; |
| 1701 | schedule_sequence(cs, &cs->at_state, SEQ_NOCID); |
| 1702 | return; |
| 1703 | } else if (bcs->at_state.pending_commands & PC_DLE0) { |
| 1704 | bcs->at_state.pending_commands &= ~PC_DLE0; |
| 1705 | cs->curchannel = bcs->channel; |
| 1706 | schedule_sequence(cs, &cs->at_state, SEQ_DLE0); |
| 1707 | return; |
| 1708 | } |
| 1709 | } |
| 1710 | |
| 1711 | list_for_each_entry(at_state, &cs->temp_at_states, list) |
| 1712 | if (at_state->pending_commands & PC_HUP) { |
| 1713 | at_state->pending_commands &= ~PC_HUP; |
| 1714 | schedule_sequence(cs, at_state, SEQ_HUP); |
| 1715 | return; |
| 1716 | } |
| 1717 | |
| 1718 | if (cs->at_state.pending_commands & PC_INIT) { |
| 1719 | cs->at_state.pending_commands &= ~PC_INIT; |
Tilman Schmidt | c35a87f | 2009-10-25 09:30:47 +0000 | [diff] [blame] | 1720 | cs->dle = 0; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1721 | cs->inbuf->inputstate = INS_command; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1722 | schedule_sequence(cs, &cs->at_state, SEQ_INIT); |
| 1723 | return; |
| 1724 | } |
| 1725 | if (cs->at_state.pending_commands & PC_SHUTDOWN) { |
| 1726 | cs->at_state.pending_commands &= ~PC_SHUTDOWN; |
| 1727 | schedule_sequence(cs, &cs->at_state, SEQ_SHUTDOWN); |
| 1728 | return; |
| 1729 | } |
| 1730 | if (cs->at_state.pending_commands & PC_CIDMODE) { |
| 1731 | cs->at_state.pending_commands &= ~PC_CIDMODE; |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1732 | if (cs->mode == M_UNIMODEM) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1733 | cs->retry_count = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1734 | schedule_sequence(cs, &cs->at_state, SEQ_CIDMODE); |
| 1735 | return; |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | for (i = 0; i < cs->channels; ++i) { |
| 1740 | bcs = cs->bcs + i; |
| 1741 | if (bcs->at_state.pending_commands & PC_DLE1) { |
| 1742 | bcs->at_state.pending_commands &= ~PC_DLE1; |
| 1743 | cs->curchannel = bcs->channel; |
| 1744 | schedule_sequence(cs, &cs->at_state, SEQ_DLE1); |
| 1745 | return; |
| 1746 | } |
| 1747 | if (bcs->at_state.pending_commands & PC_ACCEPT) { |
| 1748 | bcs->at_state.pending_commands &= ~PC_ACCEPT; |
| 1749 | schedule_sequence(cs, &bcs->at_state, SEQ_ACCEPT); |
| 1750 | return; |
| 1751 | } |
| 1752 | if (bcs->at_state.pending_commands & PC_DIAL) { |
| 1753 | bcs->at_state.pending_commands &= ~PC_DIAL; |
| 1754 | schedule_sequence(cs, &bcs->at_state, SEQ_DIAL); |
| 1755 | return; |
| 1756 | } |
| 1757 | if (bcs->at_state.pending_commands & PC_CID) { |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1758 | switch (cs->mode) { |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1759 | case M_UNIMODEM: |
| 1760 | cs->at_state.pending_commands |= PC_CIDMODE; |
Tilman Schmidt | 1528b18 | 2010-02-22 13:09:52 +0000 | [diff] [blame] | 1761 | gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE"); |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1762 | cs->commands_pending = 1; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1763 | return; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1764 | case M_UNKNOWN: |
| 1765 | schedule_init(cs, MS_INIT); |
| 1766 | return; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1767 | } |
| 1768 | bcs->at_state.pending_commands &= ~PC_CID; |
| 1769 | cs->curchannel = bcs->channel; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1770 | cs->retry_count = 2; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1771 | schedule_sequence(cs, &cs->at_state, SEQ_CID); |
| 1772 | return; |
| 1773 | } |
| 1774 | } |
| 1775 | } |
| 1776 | |
| 1777 | static void process_events(struct cardstate *cs) |
| 1778 | { |
| 1779 | struct event_t *ev; |
| 1780 | unsigned head, tail; |
| 1781 | int i; |
| 1782 | int check_flags = 0; |
| 1783 | int was_busy; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1784 | unsigned long flags; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1785 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1786 | spin_lock_irqsave(&cs->ev_lock, flags); |
| 1787 | head = cs->ev_head; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1788 | |
| 1789 | for (i = 0; i < 2 * MAX_EVENTS; ++i) { |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1790 | tail = cs->ev_tail; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1791 | if (tail == head) { |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1792 | if (!check_flags && !cs->commands_pending) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1793 | break; |
| 1794 | check_flags = 0; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1795 | spin_unlock_irqrestore(&cs->ev_lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1796 | process_command_flags(cs); |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1797 | spin_lock_irqsave(&cs->ev_lock, flags); |
| 1798 | tail = cs->ev_tail; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1799 | if (tail == head) { |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1800 | if (!cs->commands_pending) |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1801 | break; |
| 1802 | continue; |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | ev = cs->events + head; |
| 1807 | was_busy = cs->cur_at_seq != SEQ_NONE; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1808 | spin_unlock_irqrestore(&cs->ev_lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1809 | process_event(cs, ev); |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1810 | spin_lock_irqsave(&cs->ev_lock, flags); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1811 | kfree(ev->ptr); |
| 1812 | ev->ptr = NULL; |
| 1813 | if (was_busy && cs->cur_at_seq == SEQ_NONE) |
| 1814 | check_flags = 1; |
| 1815 | |
| 1816 | head = (head + 1) % MAX_EVENTS; |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1817 | cs->ev_head = head; |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1818 | } |
| 1819 | |
Tilman Schmidt | 69049cc | 2006-04-10 22:55:16 -0700 | [diff] [blame] | 1820 | spin_unlock_irqrestore(&cs->ev_lock, flags); |
| 1821 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1822 | if (i == 2 * MAX_EVENTS) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1823 | dev_err(cs->dev, |
| 1824 | "infinite loop in process_events; aborting.\n"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1825 | } |
| 1826 | } |
| 1827 | |
| 1828 | /* tasklet scheduled on any event received from the Gigaset device |
| 1829 | * parameter: |
| 1830 | * data ISDN controller state structure |
| 1831 | */ |
| 1832 | void gigaset_handle_event(unsigned long data) |
| 1833 | { |
| 1834 | struct cardstate *cs = (struct cardstate *) data; |
| 1835 | |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1836 | /* handle incoming data on control/common channel */ |
Tilman Schmidt | 9d4bee2 | 2008-02-06 01:38:28 -0800 | [diff] [blame] | 1837 | if (cs->inbuf->head != cs->inbuf->tail) { |
Tilman Schmidt | 784d585 | 2006-04-10 22:55:04 -0700 | [diff] [blame] | 1838 | gig_dbg(DEBUG_INTR, "processing new data"); |
Hansjoerg Lipp | 14fa73a | 2006-03-26 01:38:30 -0800 | [diff] [blame] | 1839 | cs->ops->handle_input(cs->inbuf); |
| 1840 | } |
| 1841 | |
| 1842 | process_events(cs); |
| 1843 | } |