FreeCalypso > hg > ffs-editor
comparison src/cs/services/tty/tty_api.c @ 0:92470e5d0b9e
src: partial import from FC Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 15 May 2020 01:28:16 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92470e5d0b9e |
---|---|
1 /** | |
2 * @file tut_api.c | |
3 * | |
4 * API for TTY SWE. | |
5 * | |
6 * @author Frederic Turgis (f-turgis@ti.com) & Gerard Cauvy (g-cauvy@ti.com) | |
7 * @version 0.1 | |
8 */ | |
9 | |
10 /* | |
11 * History: | |
12 * | |
13 * Date Modification | |
14 * ------------------------------------ | |
15 * 01/27/2003 Create | |
16 * | |
17 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved | |
18 */ | |
19 | |
20 #ifndef _WINDOWS | |
21 #include "config/l1sw.cfg" | |
22 #endif | |
23 | |
24 #include "tty/tty_i.h" | |
25 | |
26 #include "tty/tty_api.h" | |
27 #include "audio/audio_structs_i.h" | |
28 #include "audio/audio_const_i.h" | |
29 | |
30 /* External declaration */ | |
31 extern T_AUDIO_ENV_CTRL_BLK* p_audio_gbl_var; | |
32 | |
33 /********************************************************************************/ | |
34 /* */ | |
35 /* Function Name: audio_tty_set_config */ | |
36 /* */ | |
37 /* Purpose: This function is called to configure TTY. Currently, only */ | |
38 /* supports start and stop */ | |
39 /* */ | |
40 /* Input Parameters: */ | |
41 /* TTY configuration */ | |
42 /* Return path. */ | |
43 /* */ | |
44 /* Output Parameters: */ | |
45 /* Validation of the parameters. */ | |
46 /* */ | |
47 /* Note: */ | |
48 /* None. */ | |
49 /* */ | |
50 /* Revision History: */ | |
51 /* None. */ | |
52 /* */ | |
53 /********************************************************************************/ | |
54 T_AUDIO_RET audio_tty_set_config (T_AUDIO_TTY_CONFIG_PARAMETER *parameter, T_RV_RETURN *return_path) | |
55 { | |
56 #if (L1_GTT == 1) | |
57 /* Declare local variables. */ | |
58 T_RVF_MB_STATUS mb_status = RVF_GREEN; | |
59 T_RV_HDR *p_msg = NULL; | |
60 | |
61 /************************ audio_tty_set_config function begins ******************/ | |
62 if (p_audio_gbl_var == NULL ) | |
63 { | |
64 TTY_SEND_TRACE("TTY: Error Audio SWE not started ",RV_TRACE_LEVEL_ERROR); | |
65 return(AUDIO_ERROR); | |
66 } | |
67 | |
68 /* If bad parameters, then report an error and abort.*/ | |
69 if ( (parameter->Mode != TTY_STOP)&& | |
70 (parameter->Mode != TTY_EXT_START)) | |
71 { | |
72 TTY_SEND_TRACE("TTY: Error bad parameters ",RV_TRACE_LEVEL_ERROR); | |
73 return (AUDIO_ERROR); | |
74 } | |
75 | |
76 switch (parameter->Mode) | |
77 { | |
78 case TTY_EXT_START: | |
79 { | |
80 /* allocate the memory for the message to send */ | |
81 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external, | |
82 sizeof (T_TTY_START), | |
83 (T_RVF_BUFFER **) (&p_msg)); | |
84 } | |
85 break; | |
86 case TTY_STOP: | |
87 { | |
88 /* allocate the memory for the message to send */ | |
89 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external, | |
90 sizeof (T_TTY_STOP), | |
91 (T_RVF_BUFFER **) (&p_msg)); | |
92 } | |
93 break; | |
94 } | |
95 | |
96 /* If insufficient resources, then report a memory error and abort. */ | |
97 if (mb_status == RVF_YELLOW) | |
98 { | |
99 /* deallocate the memory */ | |
100 rvf_free_buf((T_RVF_BUFFER *)p_msg); | |
101 TTY_SEND_TRACE("TTY: Not Enough Memory (Yellow!) ",RV_TRACE_LEVEL_ERROR); | |
102 return (AUDIO_ERROR); | |
103 } | |
104 else | |
105 if (mb_status == RVF_RED) | |
106 { | |
107 TTY_SEND_TRACE("TTY: Not Enough Memory (Red!) ",RV_TRACE_LEVEL_ERROR); | |
108 return (AUDIO_ERROR); | |
109 } | |
110 | |
111 /* fill the message id + parameters */ | |
112 switch (parameter->Mode) | |
113 { | |
114 case TTY_EXT_START: | |
115 p_msg->msg_id = TTY_START_REQ; | |
116 | |
117 if (return_path->callback_func == NULL) | |
118 { | |
119 ((T_TTY_START *)p_msg)->return_path.addr_id = return_path->addr_id; | |
120 ((T_TTY_START *)p_msg)->return_path.callback_func = NULL; | |
121 } | |
122 else | |
123 { | |
124 ((T_TTY_START *)p_msg)->return_path.callback_func = return_path->callback_func; | |
125 } | |
126 break; | |
127 case TTY_STOP: | |
128 p_msg->msg_id = TTY_STOP_REQ; | |
129 break; | |
130 } | |
131 | |
132 /* fill the address source id */ | |
133 p_msg->src_addr_id = rvf_get_taskid(); | |
134 p_msg->dest_addr_id = p_audio_gbl_var->addrId; | |
135 | |
136 /* send the messsage to the audio entity */ | |
137 rvf_send_msg (p_audio_gbl_var->addrId, p_msg); | |
138 | |
139 return (AUDIO_OK); | |
140 | |
141 #else // L1_GTT | |
142 | |
143 TTY_SEND_TRACE("TTY API not available ", RV_TRACE_LEVEL_ERROR); | |
144 return (AUDIO_ERROR); | |
145 | |
146 #endif | |
147 } |