FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/com/src/driver/vmd.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS | |
4 | Modul : DRV_VMD | |
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 voice memo and recognition | |
18 | driver interface for the G23 protocol stack. | |
19 | | |
20 | This driver is used to control all voice memo and | |
21 | voice recognition related procedure. | |
22 +----------------------------------------------------------------------------- | |
23 */ | |
24 | |
25 #ifndef DRV_VMD_C | |
26 #define DRV_VMD_C | |
27 | |
28 #define ENTITY_CST | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "custom.h" | |
35 #include "prim.h" | |
36 #include "gsm.h" | |
37 #include "tok.h" | |
38 #include "cst/cst.h" | |
39 #include "gdi.h" | |
40 #include "vmd.h" | |
41 | |
42 | |
43 /*==== EXPORT =====================================================*/ | |
44 /*==== VARIABLES ==================================================*/ | |
45 | |
46 drv_SignalCB_Type vmd_signal_callback = NULL; | |
47 | |
48 #if defined (NEW_FRAME) | |
49 EXTERN T_HANDLE hCommL1; | |
50 #else | |
51 EXTERN T_VSI_CHANDLE hCommL1; | |
52 #endif | |
53 | |
54 /*==== FUNCTIONS ==================================================*/ | |
55 | |
56 /*==== TYPES ======================================================*/ | |
57 | |
58 typedef struct T_MMI_VM_RECORD_REQ_V | |
59 { | |
60 UBYTE dtx_used; | |
61 USHORT d_k_x1_t0; | |
62 USHORT d_k_x1_t1; | |
63 USHORT d_k_x1_t2; | |
64 USHORT d_pe_rep; | |
65 USHORT d_pe_off; | |
66 USHORT d_se_off; | |
67 USHORT d_bu_off; | |
68 USHORT d_t0_on; | |
69 USHORT d_t0_off; | |
70 USHORT d_t1_on; | |
71 USHORT d_t1_off; | |
72 USHORT d_t2_on; | |
73 USHORT d_t2_off; | |
74 USHORT * start_address; | |
75 USHORT * stop_address; | |
76 } T_MMI_VM_RECORD_REQ_V; | |
77 | |
78 typedef struct T_MMI_VM_PLAY_REQ_V | |
79 { | |
80 USHORT * start_address; | |
81 } T_MMI_VM_PLAY_REQ_V; | |
82 | |
83 typedef struct T_MMI_VM_END_PLAY_IND | |
84 { | |
85 USHORT * stop_address; | |
86 } T_MMI_VM_END_PLAY_IND; | |
87 | |
88 typedef struct T_MMI_VM_END_RECORD_IND | |
89 { | |
90 USHORT * stop_address; | |
91 } T_MMI_VM_END_RECORD_IND; | |
92 | |
93 typedef struct T_MMI_VM_END_PLAY_REQ | |
94 { | |
95 UBYTE dummy; | |
96 } T_MMI_VM_END_PLAY_REQ; | |
97 | |
98 typedef struct T_MMI_VM_END_RECORD_REQ | |
99 { | |
100 UBYTE dummy; | |
101 } T_MMI_VM_END_RECORD_REQ; | |
102 | |
103 typedef struct | |
104 { | |
105 USHORT param1; | |
106 USHORT param2; | |
107 USHORT param3; | |
108 USHORT param4; | |
109 USHORT param5; | |
110 } | |
111 T_MMI_SR_REQ_V; | |
112 | |
113 typedef struct | |
114 { | |
115 UBYTE error_code; | |
116 UBYTE index; | |
117 } T_MMI_SR_IND_V; | |
118 | |
119 #define MMI_VM_RECORD_REQ_V 8 | |
120 #define MMI_VM_PLAY_REQ_V 9 | |
121 #define MMI_VM_END_RECORD_REQ 10 | |
122 | |
123 #define MMI_SR_REQ_V 110 | |
124 #define MMI_SR_IND_V 119 | |
125 | |
126 #define MMI_VM_END_PLAY_REQ 114 | |
127 #define MMI_VM_END_PLAY_IND 115 | |
128 #define MMI_VM_END_RECORD_IND 116 | |
129 | |
130 LOCAL void vmd_mmi_vm_end_record_ind (T_MMI_VM_END_RECORD_IND * vmd_parameter); | |
131 LOCAL void vmd_mmi_vm_end_play_ind (T_MMI_VM_END_PLAY_IND * vmd_parameter); | |
132 LOCAL void vmd_mmi_sr_end_ind (T_MMI_SR_IND_V * vmd_parameter); | |
133 | |
134 /*==== CONSTANTS ==================================================*/ | |
135 /* | |
136 +--------------------------------------------------------------------+ | |
137 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
138 | STATE : code ROUTINE : vmd_init | | |
139 +--------------------------------------------------------------------+ | |
140 | |
141 PURPOSE : The function initializes the driverīs internal data. | |
142 The function returns DRV_OK in case of a successful | |
143 completition. The function returns DRV_INITIALIZED if | |
144 the driver has already been initialized and is ready to | |
145 be used or is already in use. In case of an initialization | |
146 failure, which means the that the driver cannot be used, | |
147 the function returns DRV_INITFAILURE. | |
148 | |
149 */ | |
150 | |
151 GLOBAL UBYTE vmd_init (drv_SignalCB_Type in_SignalCBPtr) | |
152 { | |
153 vmd_signal_callback = in_SignalCBPtr; /* store call-back function */ | |
154 | |
155 return DRV_OK; | |
156 } | |
157 | |
158 /* | |
159 +--------------------------------------------------------------------+ | |
160 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
161 | STATE : code ROUTINE : vmd_exit | | |
162 +--------------------------------------------------------------------+ | |
163 | |
164 PURPOSE : The function is called when the driver functionality is | |
165 not longer required. | |
166 */ | |
167 | |
168 GLOBAL void vmd_exit (void) | |
169 { | |
170 vmd_signal_callback = NULL; | |
171 } | |
172 | |
173 /* | |
174 +--------------------------------------------------------------------+ | |
175 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
176 | STATE : code ROUTINE : vmd_start_voice_memo_recording | | |
177 +--------------------------------------------------------------------+ | |
178 | |
179 PURPOSE : This function is used to start voice memo recording. | |
180 The needed parameters are defined in the structure | |
181 vmd_start_record_type. | |
182 | |
183 */ | |
184 | |
185 GLOBAL UBYTE vmd_start_voice_memo_recording (vmd_start_record_type * vmd_parameter) | |
186 { | |
187 PALLOC (mmi_vm_record_req, MMI_VM_RECORD_REQ_V); | |
188 | |
189 /* | |
190 * copy parameters to send to layer 1 | |
191 */ | |
192 mmi_vm_record_req->start_address = vmd_parameter->start_address; | |
193 mmi_vm_record_req->stop_address = vmd_parameter->stop_address; | |
194 mmi_vm_record_req->dtx_used = vmd_parameter->dtx_used; | |
195 | |
196 switch (vmd_parameter->tone_id) | |
197 { | |
198 /* case .... | |
199 add here the parameter to generate a | |
200 tone during dedicated mode. | |
201 break; | |
202 */ | |
203 case 0: /* no tone in idle mode */ | |
204 mmi_vm_record_req->d_k_x1_t0 = 0; | |
205 mmi_vm_record_req->d_k_x1_t1 = 0; | |
206 mmi_vm_record_req->d_k_x1_t2 = 0; | |
207 mmi_vm_record_req->d_pe_rep = 0; | |
208 mmi_vm_record_req->d_pe_off = 0; | |
209 mmi_vm_record_req->d_se_off = 0; | |
210 mmi_vm_record_req->d_bu_off = 0; | |
211 mmi_vm_record_req->d_t0_on = 0; | |
212 mmi_vm_record_req->d_t0_off = 0; | |
213 mmi_vm_record_req->d_t1_on = 0; | |
214 mmi_vm_record_req->d_t1_off = 0; | |
215 mmi_vm_record_req->d_t2_on = 0; | |
216 mmi_vm_record_req->d_t2_off = 0; | |
217 break; | |
218 } | |
219 | |
220 | |
221 PSENDX (L1, mmi_vm_record_req); | |
222 | |
223 return DRV_OK; | |
224 } | |
225 | |
226 /* | |
227 +--------------------------------------------------------------------+ | |
228 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
229 | STATE : code ROUTINE : vmd_stop_voice_memo_recording | | |
230 +--------------------------------------------------------------------+ | |
231 | |
232 PURPOSE : This function is used to stop voice memo recording. | |
233 | |
234 */ | |
235 | |
236 GLOBAL UBYTE vmd_stop_voice_memo_recording () | |
237 { | |
238 PALLOC (mmi_vm_end_record_req, MMI_VM_END_RECORD_REQ); | |
239 | |
240 PSENDX (L1, mmi_vm_end_record_req); | |
241 | |
242 return DRV_OK; | |
243 } | |
244 | |
245 /* | |
246 +--------------------------------------------------------------------+ | |
247 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
248 | STATE : code ROUTINE : vmd_start_voice_memo_playing | | |
249 +--------------------------------------------------------------------+ | |
250 | |
251 PURPOSE : This function is used to start voice memo playing. | |
252 The needed parameters are defined in the structure | |
253 vmd_start_play_type. | |
254 | |
255 */ | |
256 | |
257 GLOBAL UBYTE vmd_start_voice_memo_playing (vmd_start_play_type * vmd_parameter) | |
258 { | |
259 | |
260 PALLOC (mmi_vm_play_req, MMI_VM_PLAY_REQ_V); | |
261 | |
262 /* | |
263 * copy parameters to send to layer 1 | |
264 */ | |
265 mmi_vm_play_req->start_address = vmd_parameter->start_address; | |
266 | |
267 PSENDX (L1, mmi_vm_play_req); | |
268 | |
269 return DRV_OK; | |
270 } | |
271 | |
272 /* | |
273 +--------------------------------------------------------------------+ | |
274 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
275 | STATE : code ROUTINE : vmd_stop_voice_memo_playing | | |
276 +--------------------------------------------------------------------+ | |
277 | |
278 PURPOSE : This function is used to stop voice memo playing. | |
279 | |
280 */ | |
281 | |
282 GLOBAL UBYTE vmd_stop_voice_memo_playing () | |
283 { | |
284 PALLOC (mmi_vm_end_play_req, MMI_VM_END_PLAY_REQ); | |
285 | |
286 PSENDX (L1, mmi_vm_end_play_req); | |
287 | |
288 return DRV_OK; | |
289 } | |
290 | |
291 /* | |
292 +--------------------------------------------------------------------+ | |
293 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
294 | STATE : code ROUTINE : vmd_start_recognition | | |
295 +--------------------------------------------------------------------+ | |
296 | |
297 PURPOSE : This function is used to a speech recognition procedure. | |
298 The needed parameters are defined in the structure | |
299 vmd_start_recognition_req_type. | |
300 | |
301 */ | |
302 | |
303 GLOBAL UBYTE vmd_start_recognition (vmd_speech_recognition_req_type * vmd_parameter) | |
304 { | |
305 PALLOC (mmi_sr_req, MMI_SR_REQ_V); | |
306 | |
307 /* | |
308 * copy parameters to send to layer 1 | |
309 * | |
310 * NOTE: parameter usage is not clear (missing documents) | |
311 */ | |
312 mmi_sr_req->param1 = vmd_parameter->i_speaker; | |
313 mmi_sr_req->param2 = vmd_parameter->i_action; | |
314 mmi_sr_req->param3 = vmd_parameter->i_param1; | |
315 mmi_sr_req->param4 = vmd_parameter->i_param2; | |
316 | |
317 PSENDX (L1, mmi_sr_req); | |
318 | |
319 return DRV_OK; | |
320 } | |
321 | |
322 /* | |
323 +--------------------------------------------------------------------+ | |
324 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
325 | STATE : code ROUTINE : vmd_mmi_vm_end_record_ind | | |
326 +--------------------------------------------------------------------+ | |
327 | |
328 PURPOSE : This function is called after reception of the | |
329 MMI_VM_END_RECORD_IND primitive from layer 1. | |
330 | |
331 */ | |
332 | |
333 LOCAL void vmd_mmi_vm_end_record_ind (T_MMI_VM_END_RECORD_IND * vmd_parameter) | |
334 { | |
335 drv_SignalID_Type signal_params; | |
336 | |
337 signal_params.SignalType = VMD_END_RECORD; | |
338 | |
339 #if defined (NEW_FRAME) | |
340 | |
341 signal_params.SignalType = 0; | |
342 //nm | |
343 // signal_params.UserData = vmd_parameter; | |
344 | |
345 #else | |
346 signal_params.SignalValue = 0; | |
347 //nm | |
348 // signal_params.UserData = vmd_parameter; | |
349 #endif | |
350 | |
351 if (vmd_signal_callback NEQ NULL) | |
352 (*vmd_signal_callback)(&signal_params); | |
353 } | |
354 | |
355 /* | |
356 +--------------------------------------------------------------------+ | |
357 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
358 | STATE : code ROUTINE : vmd_mmi_vm_end_play_ind | | |
359 +--------------------------------------------------------------------+ | |
360 | |
361 PURPOSE : This function is called after reception of the | |
362 MMI_VM_END_PLAY_IND primitive from layer 1. | |
363 | |
364 */ | |
365 | |
366 LOCAL void vmd_mmi_vm_end_play_ind (T_MMI_VM_END_PLAY_IND * vmd_parameter) | |
367 { | |
368 drv_SignalID_Type signal_params; | |
369 | |
370 signal_params.SignalType = VMD_END_PLAY; | |
371 | |
372 #if defined (NEW_FRAME) | |
373 signal_params.SignalType = 0; | |
374 //nm | |
375 // signal_params.UserData = vmd_parameter; | |
376 | |
377 #else | |
378 signal_params.SignalValue = 0; | |
379 //nm | |
380 // signal_params.UserData = vmd_parameter; | |
381 #endif | |
382 | |
383 if (vmd_signal_callback NEQ NULL) | |
384 (*vmd_signal_callback)(&signal_params); | |
385 } | |
386 | |
387 /* | |
388 +--------------------------------------------------------------------+ | |
389 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
390 | STATE : code ROUTINE : vmd_mmi_sr_ind | | |
391 +--------------------------------------------------------------------+ | |
392 | |
393 PURPOSE : This function is called after reception of the | |
394 MMI_SR_IND primitive from layer 1. | |
395 | |
396 */ | |
397 | |
398 LOCAL void vmd_mmi_sr_end_ind (T_MMI_SR_IND_V * vmd_parameter) | |
399 { | |
400 drv_SignalID_Type signal_params; | |
401 | |
402 signal_params.SignalType = VMD_SPEECH_RECOGNITION; | |
403 | |
404 #if defined (NEW_FRAME) | |
405 signal_params.SignalType = 0; | |
406 //nm | |
407 // signal_params.UserData = vmd_parameter; | |
408 | |
409 #else | |
410 signal_params.SignalValue = 0; | |
411 //nm | |
412 // signal_params.UserData = vmd_parameter; | |
413 #endif | |
414 | |
415 if (vmd_signal_callback NEQ NULL) | |
416 (*vmd_signal_callback)(&signal_params); | |
417 } | |
418 | |
419 | |
420 /* | |
421 +--------------------------------------------------------------------+ | |
422 | PROJECT : GSM-PS (6103) MODULE : DRV_VMD | | |
423 | STATE : code ROUTINE : vmd_primitive | | |
424 +--------------------------------------------------------------------+ | |
425 | |
426 PURPOSE : This function is called from the CST pei module after | |
427 reception of a primitive from layer 1. If it is a | |
428 VMD primitive it is distributed and the primitive is | |
429 freed, else nothing happens. | |
430 | |
431 */ | |
432 | |
433 GLOBAL UBYTE vmd_primitive (USHORT opc, void * data) | |
434 { | |
435 switch (opc) | |
436 { | |
437 case MMI_VM_END_RECORD_IND: | |
438 vmd_mmi_vm_end_record_ind ((T_MMI_VM_END_RECORD_IND *)data); | |
439 PFREE (data); | |
440 return TRUE; | |
441 | |
442 case MMI_VM_END_PLAY_IND: | |
443 vmd_mmi_vm_end_play_ind ((T_MMI_VM_END_PLAY_IND *)data); | |
444 PFREE (data); | |
445 return TRUE; | |
446 | |
447 case MMI_SR_IND_V: | |
448 vmd_mmi_sr_end_ind ((T_MMI_SR_IND_V *)data); | |
449 PFREE (data); | |
450 return TRUE; | |
451 | |
452 } | |
453 return FALSE; | |
454 } | |
455 | |
456 #endif |