FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-aci/aci/psa_t30p.c @ 775:eedbf248bac0
gsm-fw/g23m-aci subtree: initial import from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 12 Oct 2014 01:45:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
774:40a721fd9854 | 775:eedbf248bac0 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : PSA_T30P | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the processing functions for the | |
18 | primitives send to the protocol stack adapter by T30. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #if defined (DTI) || defined (FF_FAX) | |
23 | |
24 #ifndef PSA_T30P_C | |
25 #define PSA_T30P_C | |
26 #endif | |
27 | |
28 #include "aci_all.h" | |
29 | |
30 /*==== INCLUDES ===================================================*/ | |
31 #include "aci_cmh.h" | |
32 #include "ati_cmd.h" | |
33 #include "aci_cmd.h" | |
34 #include "dti.h" /* functionality of the dti library */ | |
35 | |
36 #include "dti_conn_mng.h" | |
37 #include "dti_cntrl_mng.h" | |
38 | |
39 #include "aci_fd.h" | |
40 #include "aci_io.h" | |
41 #include "aci.h" | |
42 #include "psa.h" | |
43 #include "psa_t30.h" | |
44 #include "cmh.h" | |
45 #include "cmh_t30.h" | |
46 | |
47 #include "aci_lst.h" | |
48 #include "psa_uart.h" | |
49 #include "cmh_uart.h" | |
50 #ifdef FF_PSI | |
51 #include "psa_psi.h" | |
52 #include "cmh_psi.h" | |
53 #include "ati_src_psi.h" | |
54 #endif /*FF_PSI*/ | |
55 | |
56 #include "psa_cc.h" | |
57 | |
58 /*==== CONSTANTS ==================================================*/ | |
59 | |
60 | |
61 /*==== TYPES ======================================================*/ | |
62 | |
63 | |
64 /*==== EXPORT =====================================================*/ | |
65 | |
66 | |
67 /*==== VARIABLES ==================================================*/ | |
68 | |
69 | |
70 /*==== FUNCTIONS ==================================================*/ | |
71 | |
72 /* | |
73 +-------------------------------------------------------------------+ | |
74 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
75 | ROUTINE : psa_t30_activate_cnf | | |
76 +-------------------------------------------------------------------+ | |
77 | |
78 PURPOSE : processes the T30_ACTIVATE_CNF primitive send by T30. | |
79 | |
80 */ | |
81 | |
82 GLOBAL void psa_t30_activate_cnf | |
83 (T_T30_ACTIVATE_CNF *t30_activate_cnf) | |
84 { | |
85 TRACE_FUNCTION ("psa_t30_activate_cnf()"); | |
86 | |
87 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
88 { | |
89 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
90 PFREE (t30_activate_cnf); | |
91 return; | |
92 } | |
93 | |
94 t30ShrdPrm.tbs = t30_activate_cnf->buf_size_tx; | |
95 t30ShrdPrm.rbs = t30_activate_cnf->buf_size_rx; | |
96 t30ShrdPrm.T30_is_activated = TRUE; | |
97 | |
98 PFREE (t30_activate_cnf); | |
99 | |
100 cmhT30_Activated( ); | |
101 } | |
102 | |
103 /* | |
104 +-------------------------------------------------------------------+ | |
105 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
106 | ROUTINE : psa_t30_cap_ind | | |
107 +-------------------------------------------------------------------+ | |
108 | |
109 PURPOSE : processes the T30_CAP_IND primitive send by T30. | |
110 | |
111 */ | |
112 | |
113 GLOBAL void psa_t30_cap_ind (T_T30_CAP_IND *t30_cap_ind) | |
114 { | |
115 TRACE_FUNCTION ("psa_t30_cap_ind()"); | |
116 | |
117 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
118 { | |
119 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
120 PFREE (t30_cap_ind); | |
121 return; | |
122 } | |
123 | |
124 memcpy (&t30ShrdPrm.hdlc_rcv, &t30_cap_ind->hdlc_info, | |
125 sizeof (T_hdlc_info)); | |
126 | |
127 PFREE (t30_cap_ind); | |
128 | |
129 cmhT30_CapRmtSite( ); | |
130 } | |
131 | |
132 /* | |
133 +-------------------------------------------------------------------+ | |
134 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
135 | ROUTINE : psa_t30_dti_cnf | | |
136 +-------------------------------------------------------------------+ | |
137 | |
138 PURPOSE : processes the T30_DTI_CNF primitive sent by T30. | |
139 | |
140 */ | |
141 | |
142 GLOBAL void psa_t30_dti_cnf (T_T30_DTI_CNF *t30_dti_cnf) | |
143 { | |
144 T_ACI_DTI_PRC *src_infos; | |
145 T_DTI_CONN_LINK_ID link_id = dti_cntrl_get_link_id( DTI_ENTITY_T30, DTI_INSTANCE_NOTPRESENT, DTI_SUB_NO_NOTPRESENT ); | |
146 | |
147 TRACE_FUNCTION ("psa_t30_dti_cnf()"); | |
148 | |
149 | |
150 switch( t30_dti_cnf->dti_conn ) | |
151 { | |
152 case( T30_CONNECT_DTI ): | |
153 /* by now, T30 is connected with UART. It should take care of | |
154 * disactivating flow control */ | |
155 src_infos = find_element ( uart_src_params, | |
156 (UBYTE)t30EntStat.entOwn, | |
157 cmhUARTtest_srcId ); | |
158 if (src_infos EQ NULL) | |
159 { | |
160 TRACE_EVENT_P1("[ERR] psa_t30_dti_cnf: t30EntStat.entOwn=%d not found", | |
161 t30EntStat.entOwn) ; | |
162 return ; | |
163 } | |
164 BITFIELD_CLEAR (src_infos->data_cntr, UART_DTI_FLOW_OFF); | |
165 dti_cntrl_entity_connected( link_id, DTI_ENTITY_T30, DTI_OK ); | |
166 | |
167 break; | |
168 | |
169 case( T30_DISCONNECT_DTI ): | |
170 /* it depends here on the context: | |
171 if network is disconnecting the call: */ | |
172 if (!psaCC_ctbIsValid (t30ShrdPrm.cId) OR | |
173 (psaCC_ctb(t30ShrdPrm.cId)->calStat EQ CS_DSC_REQ)) | |
174 { | |
175 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_T30 ); | |
176 } | |
177 else /* other cases */ | |
178 { | |
179 t30EntStat.isTempDisconnected = TRUE; | |
180 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_T30 ); | |
181 } | |
182 break; | |
183 } | |
184 | |
185 PFREE (t30_dti_cnf); | |
186 } | |
187 | |
188 /* | |
189 +-------------------------------------------------------------------+ | |
190 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
191 | ROUTINE : psa_t30_dti_ind | | |
192 +-------------------------------------------------------------------+ | |
193 | |
194 PURPOSE : processes the T30_DTI_IND primitive sent by T30. | |
195 | |
196 */ | |
197 | |
198 GLOBAL void psa_t30_dti_ind (T_T30_DTI_IND *t30_dti_ind) | |
199 { | |
200 TRACE_FUNCTION ("psa_t30_dti_ind()"); | |
201 | |
202 PFREE (t30_dti_ind); | |
203 } | |
204 | |
205 /* | |
206 +-------------------------------------------------------------------+ | |
207 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
208 | ROUTINE : psa_t30_phase_ind | | |
209 +-------------------------------------------------------------------+ | |
210 | |
211 PURPOSE : processes the T30_PHASE_IND primitive sent by T30. | |
212 | |
213 */ | |
214 | |
215 GLOBAL void psa_t30_phase_ind (T_T30_PHASE_IND *t30_phase_ind) | |
216 { | |
217 #ifdef FF_PSI | |
218 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params, | |
219 (UBYTE)t30EntStat.entOwn, cmhPSItest_srcId); | |
220 #endif /*FF_PSI*/ | |
221 TRACE_FUNCTION ("psa_t30_phase_ind()"); | |
222 | |
223 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
224 { | |
225 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
226 PFREE (t30_phase_ind); | |
227 return; | |
228 } | |
229 | |
230 switch ( t30_phase_ind->phase ) | |
231 { | |
232 case MSG_PHASE: | |
233 /* send connect message with flow control */ | |
234 | |
235 R_AT( RAT_CONNECT, t30EntStat.entOwn ) | |
236 ( t30EntStat.curCmd, cmhT30_GetDataRate(), t30ShrdPrm.cId+1, TRUE ); | |
237 if (IS_SRC_BT(t30EntStat.entOwn)) | |
238 { | |
239 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_BLUETOOTH, DTI_ENTITY_T30}; | |
240 dti_cntrl_est_dpath((UBYTE)t30EntStat.entOwn, entity_list, 2, SPLIT, T30_connect_dti_cb); | |
241 } | |
242 else | |
243 { | |
244 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_T30}; | |
245 dti_cntrl_est_dpath_indirect ( (UBYTE)t30EntStat.entOwn, | |
246 entity_list, | |
247 1, | |
248 SPLIT, | |
249 T30_connect_dti_cb, | |
250 DTI_CPBLTY_SER, | |
251 DTI_CID_NOTPRESENT); | |
252 } | |
253 break; | |
254 | |
255 case BCS_PHASE: | |
256 { | |
257 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI}; | |
258 #ifdef FF_PSI | |
259 if (src_infos NEQ NULL) | |
260 dti_cntrl_est_dpath_indirect ( (UBYTE)t30EntStat.entOwn, | |
261 entity_list, | |
262 1, | |
263 SPLIT, | |
264 atiPSI_dti_cb, | |
265 DTI_CPBLTY_CMD, | |
266 DTI_CID_NOTPRESENT); | |
267 else | |
268 #endif /*FF_PSI*/ | |
269 dti_cntrl_est_dpath_indirect ( (UBYTE)t30EntStat.entOwn, | |
270 entity_list, | |
271 1, | |
272 SPLIT, | |
273 atiUART_dti_cb, | |
274 DTI_CPBLTY_CMD, | |
275 DTI_CID_NOTPRESENT); | |
276 } | |
277 break; | |
278 | |
279 default: | |
280 break; | |
281 } | |
282 PFREE (t30_phase_ind); | |
283 } | |
284 | |
285 /* | |
286 +-------------------------------------------------------------------+ | |
287 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
288 | ROUTINE : psa_t30_cmpl_ind | | |
289 +-------------------------------------------------------------------+ | |
290 | |
291 PURPOSE : processes the T30_CMPL_IND primitive send by T30. | |
292 | |
293 */ | |
294 | |
295 GLOBAL void psa_t30_cmpl_ind (T_T30_CMPL_IND *t30_cmpl_ind) | |
296 { | |
297 UBYTE cmpl; | |
298 | |
299 TRACE_FUNCTION ("psa_t30_cmpl_ind()"); | |
300 | |
301 cmpl = t30_cmpl_ind->cmpl; | |
302 | |
303 PFREE (t30_cmpl_ind); | |
304 | |
305 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
306 { | |
307 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
308 return; | |
309 } | |
310 | |
311 switch (cmpl) | |
312 { | |
313 case CMPL_DCN: | |
314 { | |
315 cmhT30_Disconnected( ); | |
316 break; | |
317 } | |
318 | |
319 case CMPL_EOM: | |
320 { | |
321 cmhT30_NextDoc( ); | |
322 break; | |
323 } | |
324 | |
325 case CMPL_EOP: | |
326 { | |
327 cmhT30_TransCmpl( ); | |
328 break; | |
329 } | |
330 | |
331 case CMPL_PI: | |
332 { | |
333 cmhT30_ProcIntInst( ); | |
334 break; | |
335 } | |
336 | |
337 default: | |
338 { | |
339 break; | |
340 } | |
341 } | |
342 } | |
343 | |
344 /* | |
345 +-------------------------------------------------------------------+ | |
346 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
347 | ROUTINE : psa_t30_deactivate_cnf | | |
348 +-------------------------------------------------------------------+ | |
349 | |
350 PURPOSE : processes the T30_DEACTIVATE_CNF primitive send by T30. | |
351 | |
352 */ | |
353 | |
354 GLOBAL void psa_t30_deactivate_cnf | |
355 (T_T30_DEACTIVATE_CNF *t30_deactivate_cnf) | |
356 { | |
357 TRACE_FUNCTION ("psa_t30_deactivate_cnf()"); | |
358 | |
359 PFREE (t30_deactivate_cnf); | |
360 | |
361 cmhT30_Deactivated( ); | |
362 } | |
363 | |
364 /* | |
365 +-------------------------------------------------------------------+ | |
366 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
367 | ROUTINE : psa_t30_eol_ind | | |
368 +-------------------------------------------------------------------+ | |
369 | |
370 PURPOSE : processes the T30_EOL_IND primitive send by T30. | |
371 | |
372 */ | |
373 | |
374 GLOBAL void psa_t30_eol_ind (T_T30_EOL_IND *t30_eol_ind) | |
375 { | |
376 TRACE_FUNCTION ("psa_t30_eol_ind()"); | |
377 | |
378 t30ShrdPrm.eol = t30_eol_ind->eol; | |
379 | |
380 PFREE (t30_eol_ind); | |
381 } | |
382 | |
383 /* | |
384 +-------------------------------------------------------------------+ | |
385 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
386 | ROUTINE : psa_t30_error_ind | | |
387 +-------------------------------------------------------------------+ | |
388 | |
389 PURPOSE : processes the T30_ERROR_IND primitive send by T30. | |
390 | |
391 */ | |
392 | |
393 GLOBAL void psa_t30_error_ind (T_T30_ERROR_IND *t30_error_ind) | |
394 { | |
395 T_DTI_CONN_LINK_ID link_id = dti_cntrl_get_link_id( DTI_ENTITY_T30, DTI_INSTANCE_NOTPRESENT, DTI_SUB_NO_NOTPRESENT ); | |
396 | |
397 TRACE_FUNCTION ("psa_t30_error_ind()"); | |
398 | |
399 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
400 { | |
401 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
402 PFREE (t30_error_ind); | |
403 return; | |
404 } | |
405 | |
406 t30ShrdPrm.err_cause = t30_error_ind->cause; | |
407 | |
408 PFREE (t30_error_ind); | |
409 | |
410 /* tell dti_mng that an error occured: not connected anymore */ | |
411 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_T30 ); | |
412 | |
413 cmhT30_Failure(); | |
414 } | |
415 | |
416 /* | |
417 +-------------------------------------------------------------------+ | |
418 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
419 | ROUTINE : psa_t30_preamble_ind | | |
420 +-------------------------------------------------------------------+ | |
421 | |
422 PURPOSE : processes the T30_PREAMBLE_IND primitive send by T30. | |
423 | |
424 */ | |
425 | |
426 GLOBAL void psa_t30_preamble_ind | |
427 (T_T30_PREAMBLE_IND *t30_preamble_ind) | |
428 { | |
429 TRACE_FUNCTION ("psa_t30_preamble_ind()"); | |
430 | |
431 PFREE (t30_preamble_ind); | |
432 | |
433 cmhT30_PreambleRcvd( ); | |
434 } | |
435 | |
436 | |
437 /* | |
438 +-------------------------------------------------------------------+ | |
439 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
440 | ROUTINE : psa_t30_report_ind | | |
441 +-------------------------------------------------------------------+ | |
442 | |
443 PURPOSE : processes the T30_REPORT_IND primitive send by T30. | |
444 | |
445 */ | |
446 | |
447 GLOBAL void psa_t30_report_ind (T_T30_REPORT_IND *t30_report_ind) | |
448 { | |
449 TRACE_FUNCTION ("psa_t30_report_ind()"); | |
450 | |
451 t30ShrdPrm.report.dir = t30_report_ind->dir; | |
452 t30ShrdPrm.report.l_buf = t30_report_ind->sdu.l_buf; | |
453 | |
454 memcpy (t30ShrdPrm.report.buf, | |
455 t30_report_ind->sdu.buf, | |
456 t30_report_ind->sdu.l_buf >> 3); | |
457 | |
458 PFREE (t30_report_ind); | |
459 | |
460 cmhT30_HDLCRpt( ); | |
461 } | |
462 | |
463 /* | |
464 +-------------------------------------------------------------------+ | |
465 | PROJECT : GSM-PS (6147) MODULE : PSA_T30 | | |
466 | ROUTINE : psa_t30_sgn_ind | | |
467 +-------------------------------------------------------------------+ | |
468 | |
469 PURPOSE : processes the T30_SGN_IND primitive send by T30. | |
470 | |
471 */ | |
472 | |
473 GLOBAL void psa_t30_sgn_ind (T_T30_SGN_IND *t30_sgn_ind) | |
474 { | |
475 TRACE_FUNCTION ("psa_t30_sgn_ind()"); | |
476 | |
477 if (!psaCC_ctbIsValid (t30ShrdPrm.cId)) | |
478 { | |
479 TRACE_ERROR ("t30ShrdPrm.cId invalid"); | |
480 PFREE (t30_sgn_ind); | |
481 return; | |
482 } | |
483 | |
484 t30ShrdPrm.sgn_snd = t30_sgn_ind->sgn; | |
485 | |
486 PFREE (t30_sgn_ind); | |
487 | |
488 switch (t30ShrdPrm.sgn_snd) | |
489 { | |
490 case SGN_CRP: | |
491 case SGN_FCS_ERR: | |
492 case SGN_NO_RES: | |
493 { | |
494 psaT30_Capabilities(); | |
495 break; | |
496 } | |
497 | |
498 case SGN_FTT: | |
499 { | |
500 cmhT30_FTT( ); | |
501 break ; | |
502 } | |
503 | |
504 case SGN_DCN: | |
505 { | |
506 cmhT30_Disconnect( ); | |
507 break; | |
508 } | |
509 | |
510 case SGN_EOM: | |
511 { | |
512 cmhT30_DocReceived( ); | |
513 break; | |
514 } | |
515 | |
516 case SGN_EOP: | |
517 { | |
518 switch (t30ShrdPrm.faxStat) | |
519 { | |
520 case FS_RCV_DOC: | |
521 cmhT30_ProcEnd( ); | |
522 break; | |
523 case FS_SND_DOC: | |
524 ppmPendFlg = TRUE; | |
525 if( psaT30_Ppm() < 0 ) /* T30 PPM request */ | |
526 { | |
527 TRACE_EVENT( "FATAL RETURN psaT30 in cmhT30_PPMRcvd" ); | |
528 } | |
529 ppmPendFlg = FALSE; | |
530 t30ShrdPrm.sgn_snd = SGN_NOT_USED; | |
531 break; | |
532 default: | |
533 TRACE_FUNCTION ("psa_t30_sgn_ind() - SGN_EOP ERROR"); | |
534 break; | |
535 } | |
536 break; | |
537 } | |
538 | |
539 case SGN_MPS: | |
540 { | |
541 switch (t30ShrdPrm.faxStat) | |
542 { | |
543 case FS_RCV_DOC: | |
544 cmhT30_PageReceived( ); | |
545 break; | |
546 case FS_SND_DOC: | |
547 pageSentFlg = TRUE; | |
548 ppmPendFlg = TRUE; | |
549 if( psaT30_Ppm() < 0 ) /* T30 PPM request */ | |
550 { | |
551 TRACE_EVENT( "FATAL RETURN psaT30 in cmhT30_PPMRcvd" ); | |
552 } | |
553 ppmPendFlg = FALSE; | |
554 t30ShrdPrm.sgn_snd = SGN_NOT_USED; | |
555 cmhT30_NextPage( ); | |
556 break; | |
557 default: | |
558 TRACE_FUNCTION ("psa_t30_sgn_ind() - SGN_MPS ERROR"); | |
559 break; | |
560 } | |
561 break; | |
562 } | |
563 | |
564 case SGN_PIP: | |
565 { | |
566 cmhT30_ProcInt( ); | |
567 break; | |
568 } | |
569 | |
570 case SGN_PIN: | |
571 { | |
572 cmhT30_ProcInt( ); | |
573 break; | |
574 } | |
575 | |
576 case SGN_PRI_EOM: | |
577 { | |
578 cmhT30_DocReceivedPRI( ); | |
579 break; | |
580 } | |
581 | |
582 case SGN_PRI_EOP: | |
583 { | |
584 cmhT30_ProcEndPRI( ); | |
585 break; | |
586 } | |
587 | |
588 case SGN_PRI_MPS: | |
589 { | |
590 cmhT30_PageReceivedPRI( ); | |
591 break; | |
592 } | |
593 | |
594 case SGN_RTN: | |
595 { | |
596 cmhT30_RTN(); | |
597 break; | |
598 } | |
599 | |
600 case SGN_RTP: | |
601 { | |
602 cmhT30_RTP(); | |
603 break; | |
604 } | |
605 | |
606 case SGN_NOT_USED: | |
607 default: | |
608 { | |
609 break; | |
610 } | |
611 } | |
612 } | |
613 #endif /* DTI OR FF_FAX */ | |
614 | |
615 /*==== EOF =========================================================*/ | |
616 |