aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/ev-layer.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/isdn/gigaset/ev-layer.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/isdn/gigaset/ev-layer.c')
-rw-r--r--drivers/isdn/gigaset/ev-layer.c651
1 files changed, 325 insertions, 326 deletions
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index cc768caa38f5..206c380c5235 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -40,8 +40,8 @@
40 40
41/* Possible ASCII responses */ 41/* Possible ASCII responses */
42#define RSP_OK 0 42#define RSP_OK 0
43//#define RSP_BUSY 1 43#define RSP_BUSY 1
44//#define RSP_CONNECT 2 44#define RSP_CONNECT 2
45#define RSP_ZGCI 3 45#define RSP_ZGCI 3
46#define RSP_RING 4 46#define RSP_RING 4
47#define RSP_ZAOC 5 47#define RSP_ZAOC 5
@@ -68,7 +68,6 @@
68#define RSP_ZHLC (RSP_STR + STR_ZHLC) 68#define RSP_ZHLC (RSP_STR + STR_ZHLC)
69#define RSP_ERROR -1 /* ERROR */ 69#define RSP_ERROR -1 /* ERROR */
70#define RSP_WRONG_CID -2 /* unknown cid in cmd */ 70#define RSP_WRONG_CID -2 /* unknown cid in cmd */
71//#define RSP_EMPTY -3
72#define RSP_UNKNOWN -4 /* unknown response */ 71#define RSP_UNKNOWN -4 /* unknown response */
73#define RSP_FAIL -5 /* internal error */ 72#define RSP_FAIL -5 /* internal error */
74#define RSP_INVAL -6 /* invalid response */ 73#define RSP_INVAL -6 /* invalid response */
@@ -76,9 +75,9 @@
76#define RSP_NONE -19 75#define RSP_NONE -19
77#define RSP_STRING -20 76#define RSP_STRING -20
78#define RSP_NULL -21 77#define RSP_NULL -21
79//#define RSP_RETRYFAIL -22 78#define RSP_RETRYFAIL -22
80//#define RSP_RETRY -23 79#define RSP_RETRY -23
81//#define RSP_SKIP -24 80#define RSP_SKIP -24
82#define RSP_INIT -27 81#define RSP_INIT -27
83#define RSP_ANY -26 82#define RSP_ANY -26
84#define RSP_LAST -28 83#define RSP_LAST -28
@@ -127,7 +126,6 @@
127#define ACT_NOTIFY_BC_UP 39 126#define ACT_NOTIFY_BC_UP 39
128#define ACT_DIAL 40 127#define ACT_DIAL 40
129#define ACT_ACCEPT 41 128#define ACT_ACCEPT 41
130#define ACT_PROTO_L2 42
131#define ACT_HUP 43 129#define ACT_HUP 43
132#define ACT_IF_LOCK 44 130#define ACT_IF_LOCK 44
133#define ACT_START 45 131#define ACT_START 45
@@ -159,229 +157,229 @@
159#define SEQ_UMMODE 11 157#define SEQ_UMMODE 11
160 158
161 159
162// 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid), 400: hup, 500: reset, 600: dial, 700: ring 160/* 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid),
161 * 400: hup, 500: reset, 600: dial, 700: ring */
163struct reply_t gigaset_tab_nocid[] = 162struct reply_t gigaset_tab_nocid[] =
164{ 163{
165 /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */ 164/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout,
166 165 * action, command */
167 /* initialize device, set cid mode if possible */ 166
168 //{RSP_INIT, -1, -1,100, 900, 0, {ACT_TEST}}, 167/* initialize device, set cid mode if possible */
169 //{RSP_ERROR, 900,900, -1, 0, 0, {ACT_FAILINIT}}, 168{RSP_INIT, -1, -1, SEQ_INIT, 100, 1, {ACT_TIMEOUT} },
170 //{RSP_OK, 900,900, -1, 100, INIT_TIMEOUT, 169
171 // {ACT_TIMEOUT}}, 170{EV_TIMEOUT, 100, 100, -1, 101, 3, {0}, "Z\r"},
172 171{RSP_OK, 101, 103, -1, 120, 5, {ACT_GETSTRING},
173 {RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT, 172 "+GMR\r"},
174 {ACT_TIMEOUT}}, /* wait until device is ready */ 173
175 174{EV_TIMEOUT, 101, 101, -1, 102, 5, {0}, "Z\r"},
176 {EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */ 175{RSP_ERROR, 101, 101, -1, 102, 5, {0}, "Z\r"},
177 {RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */ 176
178 177{EV_TIMEOUT, 102, 102, -1, 108, 5, {ACT_SETDLE1},
179 {EV_TIMEOUT, 101,101, -1, 102, 5, {0}, "Z\r"}, /* timeout => try once again. */ 178 "^SDLE=0\r"},
180 {RSP_ERROR, 101,101, -1, 102, 5, {0}, "Z\r"}, /* error => try once again. */ 179{RSP_OK, 108, 108, -1, 104, -1},
181 180{RSP_ZDLE, 104, 104, 0, 103, 5, {0}, "Z\r"},
182 {EV_TIMEOUT, 102,102, -1, 108, 5, {ACT_SETDLE1}, "^SDLE=0\r"}, /* timeout => try again in DLE mode. */ 181{EV_TIMEOUT, 104, 104, -1, 0, 0, {ACT_FAILINIT} },
183 {RSP_OK, 108,108, -1, 104,-1}, 182{RSP_ERROR, 108, 108, -1, 0, 0, {ACT_FAILINIT} },
184 {RSP_ZDLE, 104,104, 0, 103, 5, {0}, "Z\r"}, 183
185 {EV_TIMEOUT, 104,104, -1, 0, 0, {ACT_FAILINIT}}, 184{EV_TIMEOUT, 108, 108, -1, 105, 2, {ACT_SETDLE0,
186 {RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}}, 185 ACT_HUPMODEM,
187 186 ACT_TIMEOUT} },
188 {EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0, 187{EV_TIMEOUT, 105, 105, -1, 103, 5, {0}, "Z\r"},
189 ACT_HUPMODEM, 188
190 ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */ 189{RSP_ERROR, 102, 102, -1, 107, 5, {0}, "^GETPRE\r"},
191 {EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"}, 190{RSP_OK, 107, 107, -1, 0, 0, {ACT_CONFIGMODE} },
192 191{RSP_ERROR, 107, 107, -1, 0, 0, {ACT_FAILINIT} },
193 {RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */ 192{EV_TIMEOUT, 107, 107, -1, 0, 0, {ACT_FAILINIT} },
194 {RSP_OK, 107,107, -1, 0, 0, {ACT_CONFIGMODE}}, 193
195 {RSP_ERROR, 107,107, -1, 0, 0, {ACT_FAILINIT}}, 194{RSP_ERROR, 103, 103, -1, 0, 0, {ACT_FAILINIT} },
196 {EV_TIMEOUT, 107,107, -1, 0, 0, {ACT_FAILINIT}}, 195{EV_TIMEOUT, 103, 103, -1, 0, 0, {ACT_FAILINIT} },
197 196
198 {RSP_ERROR, 103,103, -1, 0, 0, {ACT_FAILINIT}}, 197{RSP_STRING, 120, 120, -1, 121, -1, {ACT_SETVER} },
199 {EV_TIMEOUT, 103,103, -1, 0, 0, {ACT_FAILINIT}}, 198
200 199{EV_TIMEOUT, 120, 121, -1, 0, 0, {ACT_FAILVER,
201 {RSP_STRING, 120,120, -1, 121,-1, {ACT_SETVER}}, 200 ACT_INIT} },
202 201{RSP_ERROR, 120, 121, -1, 0, 0, {ACT_FAILVER,
203 {EV_TIMEOUT, 120,121, -1, 0, 0, {ACT_FAILVER, ACT_INIT}}, 202 ACT_INIT} },
204 {RSP_ERROR, 120,121, -1, 0, 0, {ACT_FAILVER, ACT_INIT}}, 203{RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER,
205 {RSP_OK, 121,121, -1, 0, 0, {ACT_GOTVER, ACT_INIT}}, 204 ACT_INIT} },
206 205
207 /* leave dle mode */ 206/* leave dle mode */
208 {RSP_INIT, 0, 0,SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"}, 207{RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"},
209 {RSP_OK, 201,201, -1, 202,-1}, 208{RSP_OK, 201, 201, -1, 202, -1},
210 {RSP_ZDLE, 202,202, 0, 0, 0, {ACT_DLE0}}, 209{RSP_ZDLE, 202, 202, 0, 0, 0, {ACT_DLE0} },
211 {RSP_NODEV, 200,249, -1, 0, 0, {ACT_FAKEDLE0}}, 210{RSP_NODEV, 200, 249, -1, 0, 0, {ACT_FAKEDLE0} },
212 {RSP_ERROR, 200,249, -1, 0, 0, {ACT_FAILDLE0}}, 211{RSP_ERROR, 200, 249, -1, 0, 0, {ACT_FAILDLE0} },
213 {EV_TIMEOUT, 200,249, -1, 0, 0, {ACT_FAILDLE0}}, 212{EV_TIMEOUT, 200, 249, -1, 0, 0, {ACT_FAILDLE0} },
214 213
215 /* enter dle mode */ 214/* enter dle mode */
216 {RSP_INIT, 0, 0,SEQ_DLE1, 251, 5, {0}, "^SDLE=1\r"}, 215{RSP_INIT, 0, 0, SEQ_DLE1, 251, 5, {0}, "^SDLE=1\r"},
217 {RSP_OK, 251,251, -1, 252,-1}, 216{RSP_OK, 251, 251, -1, 252, -1},
218 {RSP_ZDLE, 252,252, 1, 0, 0, {ACT_DLE1}}, 217{RSP_ZDLE, 252, 252, 1, 0, 0, {ACT_DLE1} },
219 {RSP_ERROR, 250,299, -1, 0, 0, {ACT_FAILDLE1}}, 218{RSP_ERROR, 250, 299, -1, 0, 0, {ACT_FAILDLE1} },
220 {EV_TIMEOUT, 250,299, -1, 0, 0, {ACT_FAILDLE1}}, 219{EV_TIMEOUT, 250, 299, -1, 0, 0, {ACT_FAILDLE1} },
221 220
222 /* incoming call */ 221/* incoming call */
223 {RSP_RING, -1, -1, -1, -1,-1, {ACT_RING}}, 222{RSP_RING, -1, -1, -1, -1, -1, {ACT_RING} },
224 223
225 /* get cid */ 224/* get cid */
226 //{RSP_INIT, 0, 0,300, 901, 0, {ACT_TEST}}, 225{RSP_INIT, 0, 0, SEQ_CID, 301, 5, {0}, "^SGCI?\r"},
227 //{RSP_ERROR, 901,901, -1, 0, 0, {ACT_FAILCID}}, 226{RSP_OK, 301, 301, -1, 302, -1},
228 //{RSP_OK, 901,901, -1, 301, 5, {0}, "^SGCI?\r"}, 227{RSP_ZGCI, 302, 302, -1, 0, 0, {ACT_CID} },
229 228{RSP_ERROR, 301, 349, -1, 0, 0, {ACT_FAILCID} },
230 {RSP_INIT, 0, 0,SEQ_CID, 301, 5, {0}, "^SGCI?\r"}, 229{EV_TIMEOUT, 301, 349, -1, 0, 0, {ACT_FAILCID} },
231 {RSP_OK, 301,301, -1, 302,-1}, 230
232 {RSP_ZGCI, 302,302, -1, 0, 0, {ACT_CID}}, 231/* enter cid mode */
233 {RSP_ERROR, 301,349, -1, 0, 0, {ACT_FAILCID}}, 232{RSP_INIT, 0, 0, SEQ_CIDMODE, 150, 5, {0}, "^SGCI=1\r"},
234 {EV_TIMEOUT, 301,349, -1, 0, 0, {ACT_FAILCID}}, 233{RSP_OK, 150, 150, -1, 0, 0, {ACT_CMODESET} },
235 234{RSP_ERROR, 150, 150, -1, 0, 0, {ACT_FAILCMODE} },
236 /* enter cid mode */ 235{EV_TIMEOUT, 150, 150, -1, 0, 0, {ACT_FAILCMODE} },
237 {RSP_INIT, 0, 0,SEQ_CIDMODE, 150, 5, {0}, "^SGCI=1\r"}, 236
238 {RSP_OK, 150,150, -1, 0, 0, {ACT_CMODESET}}, 237/* leave cid mode */
239 {RSP_ERROR, 150,150, -1, 0, 0, {ACT_FAILCMODE}}, 238{RSP_INIT, 0, 0, SEQ_UMMODE, 160, 5, {0}, "Z\r"},
240 {EV_TIMEOUT, 150,150, -1, 0, 0, {ACT_FAILCMODE}}, 239{RSP_OK, 160, 160, -1, 0, 0, {ACT_UMODESET} },
241 240{RSP_ERROR, 160, 160, -1, 0, 0, {ACT_FAILUMODE} },
242 /* leave cid mode */ 241{EV_TIMEOUT, 160, 160, -1, 0, 0, {ACT_FAILUMODE} },
243 //{RSP_INIT, 0, 0,SEQ_UMMODE, 160, 5, {0}, "^SGCI=0\r"}, 242
244 {RSP_INIT, 0, 0,SEQ_UMMODE, 160, 5, {0}, "Z\r"}, 243/* abort getting cid */
245 {RSP_OK, 160,160, -1, 0, 0, {ACT_UMODESET}}, 244{RSP_INIT, 0, 0, SEQ_NOCID, 0, 0, {ACT_ABORTCID} },
246 {RSP_ERROR, 160,160, -1, 0, 0, {ACT_FAILUMODE}}, 245
247 {EV_TIMEOUT, 160,160, -1, 0, 0, {ACT_FAILUMODE}}, 246/* reset */
248 247{RSP_INIT, 0, 0, SEQ_SHUTDOWN, 504, 5, {0}, "Z\r"},
249 /* abort getting cid */ 248{RSP_OK, 504, 504, -1, 0, 0, {ACT_SDOWN} },
250 {RSP_INIT, 0, 0,SEQ_NOCID, 0, 0, {ACT_ABORTCID}}, 249{RSP_ERROR, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} },
251 250{EV_TIMEOUT, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} },
252 /* reset */ 251{RSP_NODEV, 501, 599, -1, 0, 0, {ACT_FAKESDOWN} },
253 {RSP_INIT, 0, 0,SEQ_SHUTDOWN, 504, 5, {0}, "Z\r"}, 252
254 {RSP_OK, 504,504, -1, 0, 0, {ACT_SDOWN}}, 253{EV_PROC_CIDMODE, -1, -1, -1, -1, -1, {ACT_PROC_CIDMODE} },
255 {RSP_ERROR, 501,599, -1, 0, 0, {ACT_FAILSDOWN}}, 254{EV_IF_LOCK, -1, -1, -1, -1, -1, {ACT_IF_LOCK} },
256 {EV_TIMEOUT, 501,599, -1, 0, 0, {ACT_FAILSDOWN}}, 255{EV_IF_VER, -1, -1, -1, -1, -1, {ACT_IF_VER} },
257 {RSP_NODEV, 501,599, -1, 0, 0, {ACT_FAKESDOWN}}, 256{EV_START, -1, -1, -1, -1, -1, {ACT_START} },
258 257{EV_STOP, -1, -1, -1, -1, -1, {ACT_STOP} },
259 {EV_PROC_CIDMODE,-1, -1, -1, -1,-1, {ACT_PROC_CIDMODE}}, //FIXME 258{EV_SHUTDOWN, -1, -1, -1, -1, -1, {ACT_SHUTDOWN} },
260 {EV_IF_LOCK, -1, -1, -1, -1,-1, {ACT_IF_LOCK}}, //FIXME 259
261 {EV_IF_VER, -1, -1, -1, -1,-1, {ACT_IF_VER}}, //FIXME 260/* misc. */
262 {EV_START, -1, -1, -1, -1,-1, {ACT_START}}, //FIXME 261{RSP_ERROR, -1, -1, -1, -1, -1, {ACT_ERROR} },
263 {EV_STOP, -1, -1, -1, -1,-1, {ACT_STOP}}, //FIXME 262{RSP_ZCFGT, -1, -1, -1, -1, -1, {ACT_DEBUG} },
264 {EV_SHUTDOWN, -1, -1, -1, -1,-1, {ACT_SHUTDOWN}}, //FIXME 263{RSP_ZCFG, -1, -1, -1, -1, -1, {ACT_DEBUG} },
265 264{RSP_ZLOG, -1, -1, -1, -1, -1, {ACT_DEBUG} },
266 /* misc. */ 265{RSP_ZMWI, -1, -1, -1, -1, -1, {ACT_DEBUG} },
267 {RSP_ERROR, -1, -1, -1, -1, -1, {ACT_ERROR} }, 266{RSP_ZABINFO, -1, -1, -1, -1, -1, {ACT_DEBUG} },
268 {RSP_EMPTY, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 267{RSP_ZSMLSTCHG, -1, -1, -1, -1, -1, {ACT_DEBUG} },
269 {RSP_ZCFGT, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 268
270 {RSP_ZCFG, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 269{RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} },
271 {RSP_ZLOG, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 270{RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} },
272 {RSP_ZMWI, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 271{RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} },
273 {RSP_ZABINFO, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 272{RSP_LAST}
274 {RSP_ZSMLSTCHG,-1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME
275
276 {RSP_ZCAU, -1, -1, -1, -1,-1, {ACT_ZCAU}},
277 {RSP_NONE, -1, -1, -1, -1,-1, {ACT_DEBUG}},
278 {RSP_ANY, -1, -1, -1, -1,-1, {ACT_WARN}},
279 {RSP_LAST}
280}; 273};
281 274
282// 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring, 400: hup, 750: accepted icall 275/* 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring,
276 * 400: hup, 750: accepted icall */
283struct reply_t gigaset_tab_cid[] = 277struct reply_t gigaset_tab_cid[] =
284{ 278{
285 /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */ 279/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout,
286 280 * action, command */
287 /* dial */ 281
288 {EV_DIAL, -1, -1, -1, -1,-1, {ACT_DIAL}}, //FIXME 282/* dial */
289 {RSP_INIT, 0, 0,SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC}}, 283{EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} },
290 {RSP_OK, 601,601, -1, 602, 5, {ACT_CMD+AT_HLC}}, 284{RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC} },
291 {RSP_NULL, 602,602, -1, 603, 5, {ACT_CMD+AT_PROTO}}, 285{RSP_OK, 601, 601, -1, 602, 5, {ACT_CMD+AT_HLC} },
292 {RSP_OK, 602,602, -1, 603, 5, {ACT_CMD+AT_PROTO}}, 286{RSP_NULL, 602, 602, -1, 603, 5, {ACT_CMD+AT_PROTO} },
293 {RSP_OK, 603,603, -1, 604, 5, {ACT_CMD+AT_TYPE}}, 287{RSP_OK, 602, 602, -1, 603, 5, {ACT_CMD+AT_PROTO} },
294 {RSP_OK, 604,604, -1, 605, 5, {ACT_CMD+AT_MSN}}, 288{RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD+AT_TYPE} },
295 {RSP_OK, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 289{RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD+AT_MSN} },
296 {RSP_NULL, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 290{RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} },
297 {RSP_OK, 606,606, -1, 607, 5, {0}, "+VLS=17\r"}, 291{RSP_OK, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} },
298 {RSP_OK, 607,607, -1, 608,-1}, 292{RSP_NULL, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} },
299 {RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 609, 5, {ACT_CMD+AT_DIAL}}, 293{RSP_OK, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} },
300 {RSP_OK, 609,609, -1, 650, 0, {ACT_DIALING}}, 294{RSP_OK, 607, 607, -1, 608, 5, {0}, "+VLS=17\r"},
301 295{RSP_OK, 608, 608, -1, 609, -1},
302 {RSP_ERROR, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 296{RSP_ZSAU, 609, 609, ZSAU_PROCEEDING, 610, 5, {ACT_CMD+AT_DIAL} },
303 {EV_TIMEOUT, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 297{RSP_OK, 610, 610, -1, 650, 0, {ACT_DIALING} },
304 298
305 /* optional dialing responses */ 299{RSP_ERROR, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} },
306 {EV_BC_OPEN, 650,650, -1, 651,-1}, 300{EV_TIMEOUT, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} },
307 {RSP_ZVLS, 608,651, 17, -1,-1, {ACT_DEBUG}}, 301
308 {RSP_ZCTP, 609,651, -1, -1,-1, {ACT_DEBUG}}, 302/* optional dialing responses */
309 {RSP_ZCPN, 609,651, -1, -1,-1, {ACT_DEBUG}}, 303{EV_BC_OPEN, 650, 650, -1, 651, -1},
310 {RSP_ZSAU, 650,651,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}}, 304{RSP_ZVLS, 609, 651, 17, -1, -1, {ACT_DEBUG} },
311 305{RSP_ZCTP, 610, 651, -1, -1, -1, {ACT_DEBUG} },
312 /* connect */ 306{RSP_ZCPN, 610, 651, -1, -1, -1, {ACT_DEBUG} },
313 {RSP_ZSAU, 650,650,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, 307{RSP_ZSAU, 650, 651, ZSAU_CALL_DELIVERED, -1, -1, {ACT_DEBUG} },
314 {RSP_ZSAU, 651,651,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT, 308
315 ACT_NOTIFY_BC_UP}}, 309/* connect */
316 {RSP_ZSAU, 750,750,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, 310{RSP_ZSAU, 650, 650, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} },
317 {RSP_ZSAU, 751,751,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT, 311{RSP_ZSAU, 651, 651, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT,
318 ACT_NOTIFY_BC_UP}}, 312 ACT_NOTIFY_BC_UP} },
319 {EV_BC_OPEN, 800,800, -1, 800,-1, {ACT_NOTIFY_BC_UP}}, 313{RSP_ZSAU, 750, 750, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} },
320 314{RSP_ZSAU, 751, 751, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT,
321 /* remote hangup */ 315 ACT_NOTIFY_BC_UP} },
322 {RSP_ZSAU, 650,651,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT}}, 316{EV_BC_OPEN, 800, 800, -1, 800, -1, {ACT_NOTIFY_BC_UP} },
323 {RSP_ZSAU, 750,751,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 317
324 {RSP_ZSAU, 800,800,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 318/* remote hangup */
325 319{RSP_ZSAU, 650, 651, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT} },
326 /* hangup */ 320{RSP_ZSAU, 750, 751, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} },
327 {EV_HUP, -1, -1, -1, -1,-1, {ACT_HUP}}, //FIXME 321{RSP_ZSAU, 800, 800, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} },
328 {RSP_INIT, -1, -1,SEQ_HUP, 401, 5, {0}, "+VLS=0\r"}, /* hang up */ //-1,-1? 322
329 {RSP_OK, 401,401, -1, 402, 5}, 323/* hangup */
330 {RSP_ZVLS, 402,402, 0, 403, 5}, 324{EV_HUP, -1, -1, -1, -1, -1, {ACT_HUP} },
331 {RSP_ZSAU, 403, 403, ZSAU_DISCONNECT_REQ, -1, -1, {ACT_DEBUG} }, 325{RSP_INIT, -1, -1, SEQ_HUP, 401, 5, {0}, "+VLS=0\r"},
332 {RSP_ZSAU, 403, 403, ZSAU_NULL, 0, 0, {ACT_DISCONNECT} }, 326{RSP_OK, 401, 401, -1, 402, 5},
333 {RSP_NODEV, 401, 403, -1, 0, 0, {ACT_FAKEHUP} }, 327{RSP_ZVLS, 402, 402, 0, 403, 5},
334 {RSP_ERROR, 401,401, -1, 0, 0, {ACT_ABORTHUP}}, 328{RSP_ZSAU, 403, 403, ZSAU_DISCONNECT_REQ, -1, -1, {ACT_DEBUG} },
335 {EV_TIMEOUT, 401,403, -1, 0, 0, {ACT_ABORTHUP}}, 329{RSP_ZSAU, 403, 403, ZSAU_NULL, 0, 0, {ACT_DISCONNECT} },
336 330{RSP_NODEV, 401, 403, -1, 0, 0, {ACT_FAKEHUP} },
337 {EV_BC_CLOSED, 0, 0, -1, 0,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME new constate + timeout 331{RSP_ERROR, 401, 401, -1, 0, 0, {ACT_ABORTHUP} },
338 332{EV_TIMEOUT, 401, 403, -1, 0, 0, {ACT_ABORTHUP} },
339 /* ring */ 333
340 {RSP_ZBC, 700,700, -1, -1,-1, {0}}, 334{EV_BC_CLOSED, 0, 0, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} },
341 {RSP_ZHLC, 700,700, -1, -1,-1, {0}}, 335
342 {RSP_NMBR, 700,700, -1, -1,-1, {0}}, 336/* ring */
343 {RSP_ZCPN, 700,700, -1, -1,-1, {0}}, 337{RSP_ZBC, 700, 700, -1, -1, -1, {0} },
344 {RSP_ZCTP, 700,700, -1, -1,-1, {0}}, 338{RSP_ZHLC, 700, 700, -1, -1, -1, {0} },
345 {EV_TIMEOUT, 700,700, -1, 720,720, {ACT_ICALL}}, 339{RSP_NMBR, 700, 700, -1, -1, -1, {0} },
346 {EV_BC_CLOSED,720,720, -1, 0,-1, {ACT_NOTIFY_BC_DOWN}}, 340{RSP_ZCPN, 700, 700, -1, -1, -1, {0} },
347 341{RSP_ZCTP, 700, 700, -1, -1, -1, {0} },
348 /*accept icall*/ 342{EV_TIMEOUT, 700, 700, -1, 720, 720, {ACT_ICALL} },
349 {EV_ACCEPT, -1, -1, -1, -1,-1, {ACT_ACCEPT}}, //FIXME 343{EV_BC_CLOSED, 720, 720, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} },
350 {RSP_INIT, 720,720,SEQ_ACCEPT, 721, 5, {ACT_CMD+AT_PROTO}}, 344
351 {RSP_OK, 721,721, -1, 722, 5, {ACT_CMD+AT_ISO}}, 345/*accept icall*/
352 {RSP_OK, 722,722, -1, 723, 5, {0}, "+VLS=17\r"}, /* set "Endgeraetemodus" */ 346{EV_ACCEPT, -1, -1, -1, -1, -1, {ACT_ACCEPT} },
353 {RSP_OK, 723,723, -1, 724, 5, {0}}, 347{RSP_INIT, 720, 720, SEQ_ACCEPT, 721, 5, {ACT_CMD+AT_PROTO} },
354 {RSP_ZVLS, 724,724, 17, 750,50, {ACT_ACCEPTED}}, 348{RSP_OK, 721, 721, -1, 722, 5, {ACT_CMD+AT_ISO} },
355 {RSP_ERROR, 721,729, -1, 0, 0, {ACT_ABORTACCEPT}}, 349{RSP_OK, 722, 722, -1, 723, 5, {0}, "+VLS=17\r"},
356 {EV_TIMEOUT, 721,729, -1, 0, 0, {ACT_ABORTACCEPT}}, 350{RSP_OK, 723, 723, -1, 724, 5, {0} },
357 {RSP_ZSAU, 700,729,ZSAU_NULL, 0, 0, {ACT_ABORTACCEPT}}, 351{RSP_ZVLS, 724, 724, 17, 750, 50, {ACT_ACCEPTED} },
358 {RSP_ZSAU, 700,729,ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT}}, 352{RSP_ERROR, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} },
359 {RSP_ZSAU, 700,729,ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT}}, 353{EV_TIMEOUT, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} },
360 354{RSP_ZSAU, 700, 729, ZSAU_NULL, 0, 0, {ACT_ABORTACCEPT} },
361 {EV_BC_OPEN, 750,750, -1, 751,-1}, 355{RSP_ZSAU, 700, 729, ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT} },
362 {EV_TIMEOUT, 750,751, -1, 0, 0, {ACT_CONNTIMEOUT}}, 356{RSP_ZSAU, 700, 729, ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT} },
363 357
364 /* B channel closed (general case) */ 358{EV_BC_OPEN, 750, 750, -1, 751, -1},
365 {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME 359{EV_TIMEOUT, 750, 751, -1, 0, 0, {ACT_CONNTIMEOUT} },
366 360
367 /* misc. */ 361/* B channel closed (general case) */
368 {EV_PROTO_L2, -1, -1, -1, -1,-1, {ACT_PROTO_L2}}, //FIXME 362{EV_BC_CLOSED, -1, -1, -1, -1, -1, {ACT_NOTIFY_BC_DOWN} },
369 363
370 {RSP_ZCON, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 364/* misc. */
371 {RSP_ZCCR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 365{RSP_ZCON, -1, -1, -1, -1, -1, {ACT_DEBUG} },
372 {RSP_ZAOC, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 366{RSP_ZCCR, -1, -1, -1, -1, -1, {ACT_DEBUG} },
373 {RSP_ZCSTR, -1, -1, -1, -1,-1, {ACT_DEBUG}}, //FIXME 367{RSP_ZAOC, -1, -1, -1, -1, -1, {ACT_DEBUG} },
374 368{RSP_ZCSTR, -1, -1, -1, -1, -1, {ACT_DEBUG} },
375 {RSP_ZCAU, -1, -1, -1, -1,-1, {ACT_ZCAU}}, 369
376 {RSP_NONE, -1, -1, -1, -1,-1, {ACT_DEBUG}}, 370{RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} },
377 {RSP_ANY, -1, -1, -1, -1,-1, {ACT_WARN}}, 371{RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} },
378 {RSP_LAST} 372{RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} },
373{RSP_LAST}
379}; 374};
380 375
381 376
382static const struct resp_type_t resp_type[] = 377static const struct resp_type_t {
378 unsigned char *response;
379 int resp_code;
380 int type;
381} resp_type[] =
383{ 382{
384 /*{"", RSP_EMPTY, RT_NOTHING},*/
385 {"OK", RSP_OK, RT_NOTHING}, 383 {"OK", RSP_OK, RT_NOTHING},
386 {"ERROR", RSP_ERROR, RT_NOTHING}, 384 {"ERROR", RSP_ERROR, RT_NOTHING},
387 {"ZSAU", RSP_ZSAU, RT_ZSAU}, 385 {"ZSAU", RSP_ZSAU, RT_ZSAU},
@@ -405,7 +403,21 @@ static const struct resp_type_t resp_type[] =
405 {"ZLOG", RSP_ZLOG, RT_NOTHING}, 403 {"ZLOG", RSP_ZLOG, RT_NOTHING},
406 {"ZABINFO", RSP_ZABINFO, RT_NOTHING}, 404 {"ZABINFO", RSP_ZABINFO, RT_NOTHING},
407 {"ZSMLSTCHG", RSP_ZSMLSTCHG, RT_NOTHING}, 405 {"ZSMLSTCHG", RSP_ZSMLSTCHG, RT_NOTHING},
408 {NULL,0,0} 406 {NULL, 0, 0}
407};
408
409static const struct zsau_resp_t {
410 unsigned char *str;
411 int code;
412} zsau_resp[] =
413{
414 {"OUTGOING_CALL_PROCEEDING", ZSAU_OUTGOING_CALL_PROCEEDING},
415 {"CALL_DELIVERED", ZSAU_CALL_DELIVERED},
416 {"ACTIVE", ZSAU_ACTIVE},
417 {"DISCONNECT_IND", ZSAU_DISCONNECT_IND},
418 {"NULL", ZSAU_NULL},
419 {"DISCONNECT_REQ", ZSAU_DISCONNECT_REQ},
420 {NULL, ZSAU_UNKNOWN}
409}; 421};
410 422
411/* 423/*
@@ -415,7 +427,7 @@ static int isdn_getnum(char *p)
415{ 427{
416 int v = -1; 428 int v = -1;
417 429
418 gig_dbg(DEBUG_TRANSCMD, "string: %s", p); 430 gig_dbg(DEBUG_EVENT, "string: %s", p);
419 431
420 while (*p >= '0' && *p <= '9') 432 while (*p >= '0' && *p <= '9')
421 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0'); 433 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
@@ -432,7 +444,7 @@ static int isdn_gethex(char *p)
432 int v = 0; 444 int v = 0;
433 int c; 445 int c;
434 446
435 gig_dbg(DEBUG_TRANSCMD, "string: %s", p); 447 gig_dbg(DEBUG_EVENT, "string: %s", p);
436 448
437 if (!*p) 449 if (!*p)
438 return -1; 450 return -1;
@@ -470,7 +482,6 @@ static int cid_of_response(char *s)
470 if (cid < 1 || cid > 65535) 482 if (cid < 1 || cid > 65535)
471 return -1; /* CID out of range */ 483 return -1; /* CID out of range */
472 return cid; 484 return cid;
473 //FIXME is ;<digit>+ at end of non-CID response really impossible?
474} 485}
475 486
476/** 487/**
@@ -487,6 +498,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
487 int params; 498 int params;
488 int i, j; 499 int i, j;
489 const struct resp_type_t *rt; 500 const struct resp_type_t *rt;
501 const struct zsau_resp_t *zr;
490 int curarg; 502 int curarg;
491 unsigned long flags; 503 unsigned long flags;
492 unsigned next, tail, head; 504 unsigned next, tail, head;
@@ -505,7 +517,6 @@ void gigaset_handle_modem_response(struct cardstate *cs)
505 return; 517 return;
506 } 518 }
507 cs->respdata[len] = 0; 519 cs->respdata[len] = 0;
508 gig_dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
509 argv[0] = cs->respdata; 520 argv[0] = cs->respdata;
510 params = 1; 521 params = 1;
511 if (cs->at_state.getstring) { 522 if (cs->at_state.getstring) {
@@ -540,14 +551,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
540 for (j = 1; j < params; ++j) 551 for (j = 1; j < params; ++j)
541 argv[j][-1] = 0; 552 argv[j][-1] = 0;
542 553
543 gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]); 554 gig_dbg(DEBUG_EVENT, "CMD received: %s", argv[0]);
544 if (cid) { 555 if (cid) {
545 --params; 556 --params;
546 gig_dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]); 557 gig_dbg(DEBUG_EVENT, "CID: %s", argv[params]);
547 } 558 }
548 gig_dbg(DEBUG_TRANSCMD, "available params: %d", params - 1); 559 gig_dbg(DEBUG_EVENT, "available params: %d", params - 1);
549 for (j = 1; j < params; j++) 560 for (j = 1; j < params; j++)
550 gig_dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]); 561 gig_dbg(DEBUG_EVENT, "param %d: %s", j, argv[j]);
551 } 562 }
552 563
553 spin_lock_irqsave(&cs->ev_lock, flags); 564 spin_lock_irqsave(&cs->ev_lock, flags);
@@ -613,24 +624,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
613 event->parameter = ZSAU_NONE; 624 event->parameter = ZSAU_NONE;
614 break; 625 break;
615 } 626 }
616 if (!strcmp(argv[curarg], "OUTGOING_CALL_PROCEEDING")) 627 for (zr = zsau_resp; zr->str; ++zr)
617 event->parameter = ZSAU_OUTGOING_CALL_PROCEEDING; 628 if (!strcmp(argv[curarg], zr->str))
618 else if (!strcmp(argv[curarg], "CALL_DELIVERED")) 629 break;
619 event->parameter = ZSAU_CALL_DELIVERED; 630 event->parameter = zr->code;
620 else if (!strcmp(argv[curarg], "ACTIVE")) 631 if (!zr->str)
621 event->parameter = ZSAU_ACTIVE;
622 else if (!strcmp(argv[curarg], "DISCONNECT_IND"))
623 event->parameter = ZSAU_DISCONNECT_IND;
624 else if (!strcmp(argv[curarg], "NULL"))
625 event->parameter = ZSAU_NULL;
626 else if (!strcmp(argv[curarg], "DISCONNECT_REQ"))
627 event->parameter = ZSAU_DISCONNECT_REQ;
628 else {
629 event->parameter = ZSAU_UNKNOWN;
630 dev_warn(cs->dev, 632 dev_warn(cs->dev,
631 "%s: unknown parameter %s after ZSAU\n", 633 "%s: unknown parameter %s after ZSAU\n",
632 __func__, argv[curarg]); 634 __func__, argv[curarg]);
633 }
634 ++curarg; 635 ++curarg;
635 break; 636 break;
636 case RT_STRING: 637 case RT_STRING:
@@ -640,7 +641,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
640 dev_err(cs->dev, "out of memory\n"); 641 dev_err(cs->dev, "out of memory\n");
641 ++curarg; 642 ++curarg;
642 } 643 }
643 gig_dbg(DEBUG_CMD, "string==%s", 644 gig_dbg(DEBUG_EVENT, "string==%s",
644 event->ptr ? (char *) event->ptr : "NULL"); 645 event->ptr ? (char *) event->ptr : "NULL");
645 break; 646 break;
646 case RT_ZCAU: 647 case RT_ZCAU:
@@ -667,7 +668,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
667 ++curarg; 668 ++curarg;
668 } else 669 } else
669 event->parameter = -1; 670 event->parameter = -1;
670 gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter); 671 gig_dbg(DEBUG_EVENT, "parameter==%d", event->parameter);
671 break; 672 break;
672 } 673 }
673 674
@@ -682,7 +683,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
682 spin_unlock_irqrestore(&cs->ev_lock, flags); 683 spin_unlock_irqrestore(&cs->ev_lock, flags);
683 684
684 if (curarg != params) 685 if (curarg != params)
685 gig_dbg(DEBUG_ANY, 686 gig_dbg(DEBUG_EVENT,
686 "invalid number of processed parameters: %d/%d", 687 "invalid number of processed parameters: %d/%d",
687 curarg, params); 688 curarg, params);
688} 689}
@@ -703,8 +704,8 @@ static void disconnect(struct at_state_t **at_state_p)
703 /* revert to selected idle mode */ 704 /* revert to selected idle mode */
704 if (!cs->cidmode) { 705 if (!cs->cidmode) {
705 cs->at_state.pending_commands |= PC_UMMODE; 706 cs->at_state.pending_commands |= PC_UMMODE;
707 gig_dbg(DEBUG_EVENT, "Scheduling PC_UMMODE");
706 cs->commands_pending = 1; 708 cs->commands_pending = 1;
707 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
708 } 709 }
709 spin_unlock_irqrestore(&cs->lock, flags); 710 spin_unlock_irqrestore(&cs->lock, flags);
710 711
@@ -714,7 +715,7 @@ static void disconnect(struct at_state_t **at_state_p)
714 /* notify LL */ 715 /* notify LL */
715 if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { 716 if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
716 bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); 717 bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
717 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); 718 gigaset_isdn_hupD(bcs);
718 } 719 }
719 } else { 720 } else {
720 /* no B channel assigned: just deallocate */ 721 /* no B channel assigned: just deallocate */
@@ -782,15 +783,15 @@ static void init_failed(struct cardstate *cs, int mode)
782static void schedule_init(struct cardstate *cs, int state) 783static void schedule_init(struct cardstate *cs, int state)
783{ 784{
784 if (cs->at_state.pending_commands & PC_INIT) { 785 if (cs->at_state.pending_commands & PC_INIT) {
785 gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again"); 786 gig_dbg(DEBUG_EVENT, "not scheduling PC_INIT again");
786 return; 787 return;
787 } 788 }
788 cs->mstate = state; 789 cs->mstate = state;
789 cs->mode = M_UNKNOWN; 790 cs->mode = M_UNKNOWN;
790 gigaset_block_channels(cs); 791 gigaset_block_channels(cs);
791 cs->at_state.pending_commands |= PC_INIT; 792 cs->at_state.pending_commands |= PC_INIT;
793 gig_dbg(DEBUG_EVENT, "Scheduling PC_INIT");
792 cs->commands_pending = 1; 794 cs->commands_pending = 1;
793 gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
794} 795}
795 796
796/* Add "AT" to a command, add the cid, dle encode it, send the result to the 797/* Add "AT" to a command, add the cid, dle encode it, send the result to the
@@ -872,12 +873,12 @@ static void bchannel_down(struct bc_state *bcs)
872{ 873{
873 if (bcs->chstate & CHS_B_UP) { 874 if (bcs->chstate & CHS_B_UP) {
874 bcs->chstate &= ~CHS_B_UP; 875 bcs->chstate &= ~CHS_B_UP;
875 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BHUP); 876 gigaset_isdn_hupB(bcs);
876 } 877 }
877 878
878 if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) { 879 if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
879 bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL); 880 bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
880 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP); 881 gigaset_isdn_hupD(bcs);
881 } 882 }
882 883
883 gigaset_free_channel(bcs); 884 gigaset_free_channel(bcs);
@@ -894,15 +895,17 @@ static void bchannel_up(struct bc_state *bcs)
894 } 895 }
895 896
896 bcs->chstate |= CHS_B_UP; 897 bcs->chstate |= CHS_B_UP;
897 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BCONN); 898 gigaset_isdn_connB(bcs);
898} 899}
899 900
900static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index) 901static void start_dial(struct at_state_t *at_state, void *data,
902 unsigned seq_index)
901{ 903{
902 struct bc_state *bcs = at_state->bcs; 904 struct bc_state *bcs = at_state->bcs;
903 struct cardstate *cs = at_state->cs; 905 struct cardstate *cs = at_state->cs;
904 int retval; 906 char **commands = data;
905 unsigned long flags; 907 unsigned long flags;
908 int i;
906 909
907 bcs->chstate |= CHS_NOTIFY_LL; 910 bcs->chstate |= CHS_NOTIFY_LL;
908 911
@@ -913,19 +916,23 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
913 } 916 }
914 spin_unlock_irqrestore(&cs->lock, flags); 917 spin_unlock_irqrestore(&cs->lock, flags);
915 918
916 retval = gigaset_isdn_setup_dial(at_state, data); 919 for (i = 0; i < AT_NUM; ++i) {
917 if (retval != 0) 920 kfree(bcs->commands[i]);
918 goto error; 921 bcs->commands[i] = commands[i];
919 922 }
920 923
921 at_state->pending_commands |= PC_CID; 924 at_state->pending_commands |= PC_CID;
922 gig_dbg(DEBUG_CMD, "Scheduling PC_CID"); 925 gig_dbg(DEBUG_EVENT, "Scheduling PC_CID");
923 cs->commands_pending = 1; 926 cs->commands_pending = 1;
924 return; 927 return;
925 928
926error: 929error:
930 for (i = 0; i < AT_NUM; ++i) {
931 kfree(commands[i]);
932 commands[i] = NULL;
933 }
927 at_state->pending_commands |= PC_NOCID; 934 at_state->pending_commands |= PC_NOCID;
928 gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID"); 935 gig_dbg(DEBUG_EVENT, "Scheduling PC_NOCID");
929 cs->commands_pending = 1; 936 cs->commands_pending = 1;
930 return; 937 return;
931} 938}
@@ -933,20 +940,31 @@ error:
933static void start_accept(struct at_state_t *at_state) 940static void start_accept(struct at_state_t *at_state)
934{ 941{
935 struct cardstate *cs = at_state->cs; 942 struct cardstate *cs = at_state->cs;
936 int retval; 943 struct bc_state *bcs = at_state->bcs;
944 int i;
937 945
938 retval = gigaset_isdn_setup_accept(at_state); 946 for (i = 0; i < AT_NUM; ++i) {
947 kfree(bcs->commands[i]);
948 bcs->commands[i] = NULL;
949 }
939 950
940 if (retval == 0) { 951 bcs->commands[AT_PROTO] = kmalloc(9, GFP_ATOMIC);
941 at_state->pending_commands |= PC_ACCEPT; 952 bcs->commands[AT_ISO] = kmalloc(9, GFP_ATOMIC);
942 gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); 953 if (!bcs->commands[AT_PROTO] || !bcs->commands[AT_ISO]) {
943 cs->commands_pending = 1; 954 dev_err(at_state->cs->dev, "out of memory\n");
944 } else {
945 /* error reset */ 955 /* error reset */
946 at_state->pending_commands |= PC_HUP; 956 at_state->pending_commands |= PC_HUP;
947 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP"); 957 gig_dbg(DEBUG_EVENT, "Scheduling PC_HUP");
948 cs->commands_pending = 1; 958 cs->commands_pending = 1;
959 return;
949 } 960 }
961
962 snprintf(bcs->commands[AT_PROTO], 9, "^SBPR=%u\r", bcs->proto2);
963 snprintf(bcs->commands[AT_ISO], 9, "^SISO=%u\r", bcs->channel + 1);
964
965 at_state->pending_commands |= PC_ACCEPT;
966 gig_dbg(DEBUG_EVENT, "Scheduling PC_ACCEPT");
967 cs->commands_pending = 1;
950} 968}
951 969
952static void do_start(struct cardstate *cs) 970static void do_start(struct cardstate *cs)
@@ -957,9 +975,7 @@ static void do_start(struct cardstate *cs)
957 schedule_init(cs, MS_INIT); 975 schedule_init(cs, MS_INIT);
958 976
959 cs->isdn_up = 1; 977 cs->isdn_up = 1;
960 gigaset_i4l_cmd(cs, ISDN_STAT_RUN); 978 gigaset_isdn_start(cs);
961 // FIXME: not in locked mode
962 // FIXME 2: only after init sequence
963 979
964 cs->waiting = 0; 980 cs->waiting = 0;
965 wake_up(&cs->waitqueue); 981 wake_up(&cs->waitqueue);
@@ -975,7 +991,7 @@ static void finish_shutdown(struct cardstate *cs)
975 /* Tell the LL that the device is not available .. */ 991 /* Tell the LL that the device is not available .. */
976 if (cs->isdn_up) { 992 if (cs->isdn_up) {
977 cs->isdn_up = 0; 993 cs->isdn_up = 0;
978 gigaset_i4l_cmd(cs, ISDN_STAT_STOP); 994 gigaset_isdn_stop(cs);
979 } 995 }
980 996
981 /* The rest is done by cleanup_cs () in user mode. */ 997 /* The rest is done by cleanup_cs () in user mode. */
@@ -992,8 +1008,8 @@ static void do_shutdown(struct cardstate *cs)
992 if (cs->mstate == MS_READY) { 1008 if (cs->mstate == MS_READY) {
993 cs->mstate = MS_SHUTDOWN; 1009 cs->mstate = MS_SHUTDOWN;
994 cs->at_state.pending_commands |= PC_SHUTDOWN; 1010 cs->at_state.pending_commands |= PC_SHUTDOWN;
1011 gig_dbg(DEBUG_EVENT, "Scheduling PC_SHUTDOWN");
995 cs->commands_pending = 1; 1012 cs->commands_pending = 1;
996 gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
997 } else 1013 } else
998 finish_shutdown(cs); 1014 finish_shutdown(cs);
999} 1015}
@@ -1113,7 +1129,6 @@ static int do_lock(struct cardstate *cs)
1113 1129
1114 break; 1130 break;
1115 case MS_LOCKED: 1131 case MS_LOCKED:
1116 //retval = -EACCES;
1117 break; 1132 break;
1118 default: 1133 default:
1119 return -EBUSY; 1134 return -EBUSY;
@@ -1175,8 +1190,8 @@ static void do_action(int action, struct cardstate *cs,
1175 } 1190 }
1176 spin_unlock_irqrestore(&cs->lock, flags); 1191 spin_unlock_irqrestore(&cs->lock, flags);
1177 cs->at_state.pending_commands |= PC_CIDMODE; 1192 cs->at_state.pending_commands |= PC_CIDMODE;
1193 gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE");
1178 cs->commands_pending = 1; 1194 cs->commands_pending = 1;
1179 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1180 break; 1195 break;
1181 case ACT_FAILINIT: 1196 case ACT_FAILINIT:
1182 dev_warn(cs->dev, "Could not initialize the device.\n"); 1197 dev_warn(cs->dev, "Could not initialize the device.\n");
@@ -1243,14 +1258,10 @@ static void do_action(int action, struct cardstate *cs,
1243 * note that bcs may be NULL if no B channel is free 1258 * note that bcs may be NULL if no B channel is free
1244 */ 1259 */
1245 at_state2->ConState = 700; 1260 at_state2->ConState = 700;
1246 kfree(at_state2->str_var[STR_NMBR]); 1261 for (i = 0; i < STR_NUM; ++i) {
1247 at_state2->str_var[STR_NMBR] = NULL; 1262 kfree(at_state2->str_var[i]);
1248 kfree(at_state2->str_var[STR_ZCPN]); 1263 at_state2->str_var[i] = NULL;
1249 at_state2->str_var[STR_ZCPN] = NULL; 1264 }
1250 kfree(at_state2->str_var[STR_ZBC]);
1251 at_state2->str_var[STR_ZBC] = NULL;
1252 kfree(at_state2->str_var[STR_ZHLC]);
1253 at_state2->str_var[STR_ZHLC] = NULL;
1254 at_state2->int_var[VAR_ZCTP] = -1; 1265 at_state2->int_var[VAR_ZCTP] = -1;
1255 1266
1256 spin_lock_irqsave(&cs->lock, flags); 1267 spin_lock_irqsave(&cs->lock, flags);
@@ -1276,7 +1287,7 @@ static void do_action(int action, struct cardstate *cs,
1276 break; 1287 break;
1277 } 1288 }
1278 bcs->chstate |= CHS_D_UP; 1289 bcs->chstate |= CHS_D_UP;
1279 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); 1290 gigaset_isdn_connD(bcs);
1280 cs->ops->init_bchannel(bcs); 1291 cs->ops->init_bchannel(bcs);
1281 break; 1292 break;
1282 case ACT_DLE1: 1293 case ACT_DLE1:
@@ -1284,7 +1295,7 @@ static void do_action(int action, struct cardstate *cs,
1284 bcs = cs->bcs + cs->curchannel; 1295 bcs = cs->bcs + cs->curchannel;
1285 1296
1286 bcs->chstate |= CHS_D_UP; 1297 bcs->chstate |= CHS_D_UP;
1287 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); 1298 gigaset_isdn_connD(bcs);
1288 cs->ops->init_bchannel(bcs); 1299 cs->ops->init_bchannel(bcs);
1289 break; 1300 break;
1290 case ACT_FAKEHUP: 1301 case ACT_FAKEHUP:
@@ -1369,7 +1380,7 @@ static void do_action(int action, struct cardstate *cs,
1369 cs->cur_at_seq = SEQ_NONE; 1380 cs->cur_at_seq = SEQ_NONE;
1370 break; 1381 break;
1371 1382
1372 case ACT_ABORTACCEPT: /* hangup/error/timeout during ICALL processing */ 1383 case ACT_ABORTACCEPT: /* hangup/error/timeout during ICALL procssng */
1373 disconnect(p_at_state); 1384 disconnect(p_at_state);
1374 break; 1385 break;
1375 1386
@@ -1427,7 +1438,7 @@ static void do_action(int action, struct cardstate *cs,
1427 case ACT_GOTVER: 1438 case ACT_GOTVER:
1428 if (cs->gotfwver == 0) { 1439 if (cs->gotfwver == 0) {
1429 cs->gotfwver = 1; 1440 cs->gotfwver = 1;
1430 gig_dbg(DEBUG_ANY, 1441 gig_dbg(DEBUG_EVENT,
1431 "firmware version %02d.%03d.%02d.%02d", 1442 "firmware version %02d.%03d.%02d.%02d",
1432 cs->fwver[0], cs->fwver[1], 1443 cs->fwver[0], cs->fwver[1],
1433 cs->fwver[2], cs->fwver[3]); 1444 cs->fwver[2], cs->fwver[3]);
@@ -1443,17 +1454,6 @@ static void do_action(int action, struct cardstate *cs,
1443 __func__, at_state->ConState); 1454 __func__, at_state->ConState);
1444 cs->cur_at_seq = SEQ_NONE; 1455 cs->cur_at_seq = SEQ_NONE;
1445 break; 1456 break;
1446#ifdef CONFIG_GIGASET_DEBUG
1447 case ACT_TEST:
1448 {
1449 static int count = 3; //2; //1;
1450 *p_genresp = 1;
1451 *p_resp_code = count ? RSP_ERROR : RSP_OK;
1452 if (count > 0)
1453 --count;
1454 }
1455 break;
1456#endif
1457 case ACT_DEBUG: 1457 case ACT_DEBUG:
1458 gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d", 1458 gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
1459 __func__, ev->type, at_state->ConState); 1459 __func__, ev->type, at_state->ConState);
@@ -1474,15 +1474,10 @@ static void do_action(int action, struct cardstate *cs,
1474 case ACT_ACCEPT: 1474 case ACT_ACCEPT:
1475 start_accept(at_state); 1475 start_accept(at_state);
1476 break; 1476 break;
1477 case ACT_PROTO_L2:
1478 gig_dbg(DEBUG_CMD, "set protocol to %u",
1479 (unsigned) ev->parameter);
1480 at_state->bcs->proto2 = ev->parameter;
1481 break;
1482 case ACT_HUP: 1477 case ACT_HUP:
1483 at_state->pending_commands |= PC_HUP; 1478 at_state->pending_commands |= PC_HUP;
1479 gig_dbg(DEBUG_EVENT, "Scheduling PC_HUP");
1484 cs->commands_pending = 1; 1480 cs->commands_pending = 1;
1485 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
1486 break; 1481 break;
1487 1482
1488 /* hotplug events */ 1483 /* hotplug events */
@@ -1493,7 +1488,7 @@ static void do_action(int action, struct cardstate *cs,
1493 do_start(cs); 1488 do_start(cs);
1494 break; 1489 break;
1495 1490
1496 /* events from the interface */ // FIXME without ACT_xxxx? 1491 /* events from the interface */
1497 case ACT_IF_LOCK: 1492 case ACT_IF_LOCK:
1498 cs->cmd_result = ev->parameter ? do_lock(cs) : do_unlock(cs); 1493 cs->cmd_result = ev->parameter ? do_lock(cs) : do_unlock(cs);
1499 cs->waiting = 0; 1494 cs->waiting = 0;
@@ -1512,17 +1507,17 @@ static void do_action(int action, struct cardstate *cs,
1512 wake_up(&cs->waitqueue); 1507 wake_up(&cs->waitqueue);
1513 break; 1508 break;
1514 1509
1515 /* events from the proc file system */ // FIXME without ACT_xxxx? 1510 /* events from the proc file system */
1516 case ACT_PROC_CIDMODE: 1511 case ACT_PROC_CIDMODE:
1517 spin_lock_irqsave(&cs->lock, flags); 1512 spin_lock_irqsave(&cs->lock, flags);
1518 if (ev->parameter != cs->cidmode) { 1513 if (ev->parameter != cs->cidmode) {
1519 cs->cidmode = ev->parameter; 1514 cs->cidmode = ev->parameter;
1520 if (ev->parameter) { 1515 if (ev->parameter) {
1521 cs->at_state.pending_commands |= PC_CIDMODE; 1516 cs->at_state.pending_commands |= PC_CIDMODE;
1522 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1517 gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE");
1523 } else { 1518 } else {
1524 cs->at_state.pending_commands |= PC_UMMODE; 1519 cs->at_state.pending_commands |= PC_UMMODE;
1525 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 1520 gig_dbg(DEBUG_EVENT, "Scheduling PC_UMMODE");
1526 } 1521 }
1527 cs->commands_pending = 1; 1522 cs->commands_pending = 1;
1528 } 1523 }
@@ -1573,6 +1568,8 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1573 if (ev->cid >= 0) { 1568 if (ev->cid >= 0) {
1574 at_state = at_state_from_cid(cs, ev->cid); 1569 at_state = at_state_from_cid(cs, ev->cid);
1575 if (!at_state) { 1570 if (!at_state) {
1571 gig_dbg(DEBUG_EVENT, "event %d for invalid cid %d",
1572 ev->type, ev->cid);
1576 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID, 1573 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID,
1577 NULL, 0, NULL); 1574 NULL, 0, NULL);
1578 return; 1575 return;
@@ -1580,13 +1577,13 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1580 } else { 1577 } else {
1581 at_state = ev->at_state; 1578 at_state = ev->at_state;
1582 if (at_state_invalid(cs, at_state)) { 1579 if (at_state_invalid(cs, at_state)) {
1583 gig_dbg(DEBUG_ANY, "event for invalid at_state %p", 1580 gig_dbg(DEBUG_EVENT, "event for invalid at_state %p",
1584 at_state); 1581 at_state);
1585 return; 1582 return;
1586 } 1583 }
1587 } 1584 }
1588 1585
1589 gig_dbg(DEBUG_CMD, "connection state %d, event %d", 1586 gig_dbg(DEBUG_EVENT, "connection state %d, event %d",
1590 at_state->ConState, ev->type); 1587 at_state->ConState, ev->type);
1591 1588
1592 bcs = at_state->bcs; 1589 bcs = at_state->bcs;
@@ -1600,11 +1597,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1600 if (ev->parameter != at_state->timer_index 1597 if (ev->parameter != at_state->timer_index
1601 || !at_state->timer_active) { 1598 || !at_state->timer_active) {
1602 ev->type = RSP_NONE; /* old timeout */ 1599 ev->type = RSP_NONE; /* old timeout */
1603 gig_dbg(DEBUG_ANY, "old timeout"); 1600 gig_dbg(DEBUG_EVENT, "old timeout");
1604 } else if (!at_state->waiting) 1601 } else if (!at_state->waiting)
1605 gig_dbg(DEBUG_ANY, "timeout occurred"); 1602 gig_dbg(DEBUG_EVENT, "timeout occurred");
1606 else 1603 else
1607 gig_dbg(DEBUG_ANY, "stopped waiting"); 1604 gig_dbg(DEBUG_EVENT, "stopped waiting");
1608 } 1605 }
1609 spin_unlock_irqrestore(&cs->lock, flags); 1606 spin_unlock_irqrestore(&cs->lock, flags);
1610 1607
@@ -1649,7 +1646,8 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1649 for (curact = 0; curact < MAXACT; ++curact) { 1646 for (curact = 0; curact < MAXACT; ++curact) {
1650 /* The row tells us what we should do .. 1647 /* The row tells us what we should do ..
1651 */ 1648 */
1652 do_action(rep->action[curact], cs, bcs, &at_state, &p_command, &genresp, &resp_code, ev); 1649 do_action(rep->action[curact], cs, bcs, &at_state, &p_command,
1650 &genresp, &resp_code, ev);
1653 if (!at_state) 1651 if (!at_state)
1654 break; /* may be freed after disconnect */ 1652 break; /* may be freed after disconnect */
1655 } 1653 }
@@ -1661,13 +1659,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1661 1659
1662 if (genresp) { 1660 if (genresp) {
1663 spin_lock_irqsave(&cs->lock, flags); 1661 spin_lock_irqsave(&cs->lock, flags);
1664 at_state->timer_expires = 0; //FIXME 1662 at_state->timer_expires = 0;
1665 at_state->timer_active = 0; //FIXME 1663 at_state->timer_active = 0;
1666 spin_unlock_irqrestore(&cs->lock, flags); 1664 spin_unlock_irqrestore(&cs->lock, flags);
1667 gigaset_add_event(cs, at_state, resp_code, NULL, 0, NULL); 1665 gigaset_add_event(cs, at_state, resp_code,
1666 NULL, 0, NULL);
1668 } else { 1667 } else {
1669 /* Send command to modem if not NULL... */ 1668 /* Send command to modem if not NULL... */
1670 if (p_command/*rep->command*/) { 1669 if (p_command) {
1671 if (cs->connected) 1670 if (cs->connected)
1672 send_command(cs, p_command, 1671 send_command(cs, p_command,
1673 sendcid, cs->dle, 1672 sendcid, cs->dle,
@@ -1710,11 +1709,11 @@ static void process_command_flags(struct cardstate *cs)
1710 cs->commands_pending = 0; 1709 cs->commands_pending = 0;
1711 1710
1712 if (cs->cur_at_seq) { 1711 if (cs->cur_at_seq) {
1713 gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy"); 1712 gig_dbg(DEBUG_EVENT, "not searching scheduled commands: busy");
1714 return; 1713 return;
1715 } 1714 }
1716 1715
1717 gig_dbg(DEBUG_CMD, "searching scheduled commands"); 1716 gig_dbg(DEBUG_EVENT, "searching scheduled commands");
1718 1717
1719 sequence = SEQ_NONE; 1718 sequence = SEQ_NONE;
1720 1719
@@ -1754,7 +1753,8 @@ static void process_command_flags(struct cardstate *cs)
1754 } 1753 }
1755 } 1754 }
1756 1755
1757 /* only switch back to unimodem mode, if no commands are pending and no channels are up */ 1756 /* only switch back to unimodem mode if no commands are pending and
1757 * no channels are up */
1758 spin_lock_irqsave(&cs->lock, flags); 1758 spin_lock_irqsave(&cs->lock, flags);
1759 if (cs->at_state.pending_commands == PC_UMMODE 1759 if (cs->at_state.pending_commands == PC_UMMODE
1760 && !cs->cidmode 1760 && !cs->cidmode
@@ -1813,9 +1813,8 @@ static void process_command_flags(struct cardstate *cs)
1813 1813
1814 if (cs->at_state.pending_commands & PC_INIT) { 1814 if (cs->at_state.pending_commands & PC_INIT) {
1815 cs->at_state.pending_commands &= ~PC_INIT; 1815 cs->at_state.pending_commands &= ~PC_INIT;
1816 cs->dle = 0; //FIXME 1816 cs->dle = 0;
1817 cs->inbuf->inputstate = INS_command; 1817 cs->inbuf->inputstate = INS_command;
1818 //FIXME reset card state (or -> LOCK0)?
1819 schedule_sequence(cs, &cs->at_state, SEQ_INIT); 1818 schedule_sequence(cs, &cs->at_state, SEQ_INIT);
1820 return; 1819 return;
1821 } 1820 }
@@ -1855,7 +1854,7 @@ static void process_command_flags(struct cardstate *cs)
1855 switch (cs->mode) { 1854 switch (cs->mode) {
1856 case M_UNIMODEM: 1855 case M_UNIMODEM:
1857 cs->at_state.pending_commands |= PC_CIDMODE; 1856 cs->at_state.pending_commands |= PC_CIDMODE;
1858 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1857 gig_dbg(DEBUG_EVENT, "Scheduling PC_CIDMODE");
1859 cs->commands_pending = 1; 1858 cs->commands_pending = 1;
1860 return; 1859 return;
1861#ifdef GIG_MAYINITONDIAL 1860#ifdef GIG_MAYINITONDIAL