comparison L1/cfile/l1_afunc.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children b36540edb046
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1_AFUNC.C
4 *
5 * Filename l1_afunc.c
6 * Copyright 2003 (C) Texas Instruments
7 *
8 ************* Revision Controle System Header *************/
9
10 #define L1_AFUNC_C
11
12 #include "config.h"
13 #include "l1_confg.h"
14 #include "l1_macro.h"
15
16 #if (CODE_VERSION == SIMULATION)
17 #include <string.h>
18 #include "l1_types.h"
19 #include "sys_types.h"
20 #include "l1_const.h"
21 #include "l1_signa.h"
22 #if TESTMODE
23 #include "l1tm_defty.h"
24 #endif
25 #if (AUDIO_TASK == 1)
26 #include "l1audio_const.h"
27 #include "l1audio_cust.h"
28 #include "l1audio_defty.h"
29 #endif
30 #if (L1_GTT == 1)
31 #include "l1gtt_const.h"
32 #include "l1gtt_defty.h"
33 #endif
34 #if (L1_MIDI == 1)
35 #include "l1midi_defty.h"
36 #endif
37 #if (L1_MP3 == 1)
38 #include "l1mp3_defty.h"
39 #endif
40 //ADDED FOR AAC
41 #if (L1_AAC == 1)
42 #include "l1aac_defty.h"
43 #endif
44 #include "l1_defty.h"
45 #include "cust_os.h"
46 #include "l1_msgty.h"
47 #include "l1_varex.h"
48 #include "l1_proto.h"
49 #include "l1_tabs.h"
50 #include "l1_time.h"
51 #if L1_GPRS
52 #include "l1p_cons.h"
53 #include "l1p_msgt.h"
54 #include "l1p_deft.h"
55 #include "l1p_vare.h"
56 #endif
57 #else
58 #include <string.h>
59 #include "l1_types.h"
60 #include "sys_types.h"
61 #include "l1_const.h"
62 #include "l1_signa.h"
63 #include "l1_time.h"
64
65 #if TESTMODE
66 #include "l1tm_defty.h"
67 #endif
68 #if (AUDIO_TASK == 1)
69 #include "l1audio_const.h"
70 #include "l1audio_cust.h"
71 #include "l1audio_defty.h"
72 #endif
73 #if (L1_GTT == 1)
74 #include "l1gtt_const.h"
75 #include "l1gtt_defty.h"
76 #endif
77 #if (L1_MP3 == 1)
78 #include "l1mp3_defty.h"
79 #endif
80 #if (L1_MIDI == 1)
81 #include "l1midi_defty.h"
82 #endif
83 //ADDED FOR AAC
84 #if (L1_AAC == 1)
85 #include "l1aac_defty.h"
86 #endif
87 #include "l1_defty.h"
88 #include "../../gpf/inc/cust_os.h"
89 #include "l1_msgty.h"
90 #include "l1_varex.h"
91 #include "l1_proto.h"
92 #include "l1_tabs.h"
93 #if L1_GPRS
94 #include "l1p_cons.h"
95 #include "l1p_msgt.h"
96 #include "l1p_deft.h"
97 #include "l1p_vare.h"
98 #endif
99 #if (GSM_IDLE_RAM > 1)
100 #if (OP_L1_STANDALONE == 1)
101 #include "csmi_simul.h"
102 #else
103 #include "csmi/csmi.h"
104 #endif
105 #endif
106 #endif
107
108
109 #if (OP_L1_STANDALONE == 1)
110 #if (ANALOG == 11)
111 #include "bspTwl3029_Madc.h"
112 #endif
113 #endif
114
115 #if (L1_MADC_ON == 1)
116 #if (OP_L1_STANDALONE == 1)
117 #if (RF_FAM == 61)
118 #include "drp_api.h"
119 #include "l1_rf61.h"
120 #include <string.h>
121 extern T_DRP_SRM_API* drp_srm_api;
122 #endif
123 #if (ANALOG == 11)
124 BspTwl3029_MadcResults l1_madc_results;
125 void l1a_madc_callback(void);
126 #endif
127 #endif
128 #endif //L1_MADC_ON
129
130
131
132 /*-------------------------------------------------------*/
133 /* l1a_reset_ba_list() */
134 /*-------------------------------------------------------*/
135 /* */
136 /* Description: */
137 /* ------------ */
138 /* This function resets the BA list content. */
139 /* */
140 /*-------------------------------------------------------*/
141 void l1a_reset_ba_list()
142 {
143 UWORD8 i;
144
145 // Rem: this reset function do not touch the "ba_id", "nbr_carrier" and
146 // "radio_freq" fields.
147
148 //!!! remove this initialization when BA list handling changed for dedic mode
149 if(l1a_l1s_com.mode != I_MODE)
150 {
151 l1a_l1s_com.ba_list.next_to_ctrl = 0; // Carrier for next power measurement control.
152 l1a_l1s_com.ba_list.next_to_read = 0; // Carrier for next power measurement result.
153 l1a_l1s_com.ba_list.first_index = 0; // First BA index measured in current session.
154 }
155
156 // Reset of "ms_ctrl, ms_ctrl_d, msctrl_dd" is done at L1 startup
157 // and when SYNCHRO task is executed.
158
159 l1a_l1s_com.ba_list.np_ctrl = 0; // PCH burst number.
160
161
162 for(i=0; i<C_BA_PM_MEAS; i++) // 2 measurements / PCH frame...
163 {
164 l1a_l1s_com.ba_list.used_il [i] = l1_config.params.il_min; // IL used in CTRL phase for AGC setting.
165 l1a_l1s_com.ba_list.used_il_d [i] = l1_config.params.il_min; // ... 1 frame delay.
166 l1a_l1s_com.ba_list.used_il_dd[i] = l1_config.params.il_min; // ... 2 frames delay, used in READ phase.
167
168 l1a_l1s_com.ba_list.used_lna [i] = FALSE; // LNA used in CTRL phase for AGC setting.
169 l1a_l1s_com.ba_list.used_lna_d [i] = FALSE; // ... 1 frame delay.
170 l1a_l1s_com.ba_list.used_lna_dd[i] = FALSE; // ... 2 frames delay, used in READ phase.
171 }
172
173 for(i=0; i<32+1; i++)
174 {
175 l1a_l1s_com.ba_list.A[i].acc = 0; // Reset IL accumulation.
176 }
177 }
178
179 /*-------------------------------------------------------*/
180 /* l1a_reset_full_list() */
181 /*-------------------------------------------------------*/
182 /* */
183 /* Description: */
184 /* ------------ */
185 /* This function resets the FULL list content. */
186 /* */
187 /*-------------------------------------------------------*/
188 void l1a_reset_full_list()
189 {
190 UWORD16 i;
191
192 // Init power measurement multi_session process
193 l1a_l1s_com.full_list.meas_1st_pass_ctrl = 1; // Set 1st pass flag for power measurement session in ctrl.
194 l1a_l1s_com.full_list.meas_1st_pass_read = 1; // Set 1st pass flag for power measurement session in read.
195 l1a_l1s_com.full_list.nbr_sat_carrier_ctrl = 0; // Clear number of saturated carrier in ctrl.
196 l1a_l1s_com.full_list.nbr_sat_carrier_read = 0; // Clear number of saturated carrier in read.
197
198 // Set global parameters for full list measurement.
199 l1a_l1s_com.full_list.next_to_ctrl = 0; // Set next carrier to control to 1st one.
200 l1a_l1s_com.full_list.next_to_read = 0; // Set next carrier to control to 1st one.
201
202 // Reset Pipeline
203 // Note: l1a_l1s_com.full_list.ms_ctrl_d is reset at the end of l1_meas_manager()
204 l1a_l1s_com.full_list.ms_ctrl_dd = 0;
205 l1a_l1s_com.full_list.ms_ctrl_d = 0;
206
207 // Reset the FULL LIST.
208 #if (L1_FF_MULTIBAND == 0)
209 for(i=0; i<l1_config.std.nbmax_carrier; i++)
210 #else
211 for(i=0; i< NBMAX_CARRIER; i++)
212 #endif
213 {
214 l1a_l1s_com.full_list.sat_flag[i] = 0; // Reset sat_flag
215 }
216
217 #if L1_GPRS
218 // Reset PPCH burst ctrl indication
219 l1pa_l1ps_com.cr_freq_list.pnp_ctrl = 0;
220 #endif
221 }
222
223 #if ((L1_EOTD == 1) && (L1_EOTD_QBIT_ACC == 1))
224 /*-------------------------------------------------------*/
225 /* l1a_add_time_delta() */
226 /*-------------------------------------------------------*/
227 /* */
228 /* Description: */
229 /* ------------ */
230 /* This function shifts a given cell timing (given as a */
231 /* couple [time_alignmt, fn_offset]) by adding */
232 /* a specified new time_alignmt offset (+ve or -ve */
233 /* between -4999 and +4999 qb) */
234 /* to that timing. */
235 /* */
236 /*-------------------------------------------------------*/
237 void l1a_add_time_delta(UWORD32 * time_alignmt, UWORD32 * fn_offset, WORD32 delta)
238 {
239 WORD32 new_time_alignmt = *time_alignmt + delta;
240 UWORD32 new_fn_offset = *fn_offset;
241
242 if(new_time_alignmt < 0)
243 {
244 new_time_alignmt += TPU_CLOCK_RANGE;
245 new_fn_offset = (new_fn_offset + 1) % MAX_FN;
246 }
247 else if(new_time_alignmt >= TPU_CLOCK_RANGE)
248 {
249 new_time_alignmt -= TPU_CLOCK_RANGE;
250 new_fn_offset = (new_fn_offset - 1 + MAX_FN) % MAX_FN;
251 }
252
253 *time_alignmt = new_time_alignmt;
254 *fn_offset = new_fn_offset;
255 }
256
257 /*-------------------------------------------------------*/
258 /* l1a_compensate_sync_ind() */
259 /*-------------------------------------------------------*/
260 /* */
261 /* Description: */
262 /* ------------ */
263 /* Attempts to modify the time_alignmt and fn_offset */
264 /* fields of an MPHC_NCELL_SYNC_IND message based on */
265 /* E-OTD cross-correlation information in order to */
266 /* post-correct the result. This can be used to form a */
267 /* quater-bit alignment with slow drifting neighbours */
268 /* */
269 /*-------------------------------------------------------*/
270 void l1a_compensate_sync_ind(T_MPHC_NCELL_SYNC_IND * msg)
271 {
272
273 // This process can only be applied to SBCONF messages
274 // with good SCH decodes and valid EOTD results.
275 //
276 // a_eotd_crosscor [0] [1] [2] [3] [4] [5] [6] [7] [8]
277 //
278 // <------ Peak Range ----->
279 //
280 // As long as the cross-correlation peak lies in the range
281 // [1] to [7] then we can examine the slope of the correlation
282 // points on either side of the peak in order to perform a
283 // positive or negative QB shift.
284
285 if((msg->sb_flag) && (msg->eotd_data_valid))
286 {
287 WORD16 peak_index = msg->d_eotd_max - msg->d_eotd_first;
288
289 if((peak_index >= 1) && (peak_index <= 7))
290 {
291 UWORD32 a_power[9];
292 UWORD32 pre_power, post_power, thresh_power;
293 UWORD32 i;
294 WORD32 shift = 0;
295
296 // Calculate the normalised power of the cross-correlation samples
297 // in a_eotd_crosscor. This could be improved to only calculate
298 // the terms for [peak_index-1] [peak_index] [peak_index+1] if
299 // the algorithm proves viable in the long term.
300
301 // Normalised power[i] = real[i]^2 + imag[i]^2
302
303 for(i=0; i<9; ++i)
304 {
305 //
306 // Awkward looking code to square values as our compiler / assembler
307 // gets the following construct wrong. Very strange...
308 //
309 // UWORD32 real = ...
310 // real *= real; <-- Assembler allocates registers incorrectly here
311 //
312
313 UWORD32 real = msg->a_eotd_crosscor[2*i] * msg->a_eotd_crosscor[2*i];
314 UWORD32 imag = msg->a_eotd_crosscor[(2*i)+1] * msg->a_eotd_crosscor[(2*i)+1];
315
316 // Sum of the squares...
317
318 a_power[i] = real + imag;
319 }
320
321 // By inspection of practical examples, it appears that (peak power/3)
322 // is a good threshold on which to compare the shape of the slope.
323
324 thresh_power = a_power[peak_index] / 3;
325 pre_power = a_power[peak_index-1];
326 post_power = a_power[peak_index+1];
327
328 // Decision on whether the gradient of the slope of the crosscor points
329 // on either side of the peak is large enough to cause a (max) +/- 1QB shift
330 // to the time_alignmt field.
331
332 if( (pre_power < thresh_power) && (post_power > thresh_power) )
333 {
334 // Right skew on the cross corrrelation - shift time_alignmt
335 // to be one greater
336
337 shift = 1;
338 }
339 else if ( (pre_power > thresh_power) && (post_power < thresh_power) )
340 {
341 // Left skew on the cross correlation - shift time_alignmt
342 // to be one less
343
344 shift = -1;
345 }
346
347 l1a_add_time_delta( &(msg->time_alignmt),
348 &(msg->fn_offset),
349 shift );
350
351 }
352 }
353 }
354 #endif
355
356 /*-------------------------------------------------------*/
357 /* l1a_add_time_for_nb() */
358 /*-------------------------------------------------------*/
359 /* */
360 /* Description: */
361 /* ------------ */
362 /* This function shift a given cell timing (given as a */
363 /* couple [time_alignmt, fn_offset]) by adding */
364 /* "SB_MARGIN - NB_MARGIN" */
365 /* to that timing. */
366 /* */
367 /*-------------------------------------------------------*/
368 void l1a_add_time_for_nb(UWORD32 *time_alignmt, UWORD32 *fn_offset)
369 {
370 // Add "SB_MARGIN - NB_MARGIN" qbit to "fn_offset" and "time_alignmt".
371 // Pay attention to the modulos.
372
373 *time_alignmt += (SB_MARGIN - NB_MARGIN);
374 if(*time_alignmt >= TPU_CLOCK_RANGE)
375 {
376 *time_alignmt -= TPU_CLOCK_RANGE;
377 *fn_offset = (*fn_offset + MAX_FN - 1) % MAX_FN;
378 }
379 }
380
381 /*-------------------------------------------------------*/
382 /* l1a_add_timeslot() */
383 /*-------------------------------------------------------*/
384 /* */
385 /* Description: */
386 /* ------------ */
387 /* This function shift a given cell timing (given as a */
388 /* couple [time_alignmt, fn_offset]) by adding a number */
389 /* of TIMESLOT (given as "tn") to that timing. */
390 /* */
391 /*-------------------------------------------------------*/
392 void l1a_add_timeslot(UWORD32 *time_alignmt, UWORD32 *fn_offset, UWORD8 tn)
393 {
394 // Add "tn" timeslot to "fn_offset" and "time_alignmt".
395 // Pay attention to the modulos.
396
397 *time_alignmt += tn * BP_DURATION;
398 if(*time_alignmt >= TPU_CLOCK_RANGE)
399 {
400 *time_alignmt -= TPU_CLOCK_RANGE;
401 *fn_offset = (*fn_offset + MAX_FN - 1) % MAX_FN;
402 }
403 }
404
405 /*-------------------------------------------------------*/
406 /* l1a_sub_time_for_nb() */
407 /*-------------------------------------------------------*/
408 /* */
409 /* Description: */
410 /* ------------ */
411 /* This function shift a given cell timing (given as a */
412 /* couple [time_alignmt, fn_offset]) by substacting */
413 /* "SB_MARGIN - NB_MARGIN" */
414 /* to that timing. */
415 /* */
416 /*-------------------------------------------------------*/
417 void l1a_sub_time_for_nb(UWORD32 *time_alignmt, UWORD32 *fn_offset)
418 {
419 WORD32 new_time_alignmt;
420
421 // Sub "SB_MARGIN - NB_MARGIN" qbit to "fn_offset" and "time_alignmt".
422 // Pay attention to the modulos.
423
424 new_time_alignmt = *time_alignmt - (SB_MARGIN - NB_MARGIN);
425 if(new_time_alignmt < 0)
426 {
427 new_time_alignmt += TPU_CLOCK_RANGE;
428 *fn_offset = (*fn_offset + 1) % MAX_FN;
429 }
430 *time_alignmt = new_time_alignmt;
431 }
432
433 /*-------------------------------------------------------*/
434 /* l1a_sub_timeslot() */
435 /*-------------------------------------------------------*/
436 /* */
437 /* Description: */
438 /* ------------ */
439 /* This function shift a given cell timing (given as a */
440 /* couple [time_alignmt, fn_offset]) by substracting a */
441 /* number of TIMESLOT (given as "tn") to that timing. */
442 /* */
443 /*-------------------------------------------------------*/
444 void l1a_sub_timeslot(UWORD32 *time_alignmt, UWORD32 *fn_offset, UWORD8 tn)
445 {
446 WORD32 new_time_alignmt;
447
448 // Sub "tn" timeslot to "fn_offset" and "time_alignmt".
449 // Pay attention to the modulos.
450 new_time_alignmt = *time_alignmt - (tn * BP_DURATION);
451 if(new_time_alignmt < 0)
452 {
453 new_time_alignmt += TPU_CLOCK_RANGE;
454 *fn_offset = (*fn_offset + 1) % MAX_FN;
455 }
456 *time_alignmt = new_time_alignmt;
457 }
458
459 /*-------------------------------------------------------*/
460 /* l1a_correct_timing() */
461 /*-------------------------------------------------------*/
462 /* */
463 /* Description: */
464 /* ------------ */
465 /* */
466 /*-------------------------------------------------------*/
467 #if (L1_12NEIGH == 1)
468 void l1a_correct_timing (UWORD8 neigh_id,UWORD32 time_alignmt,UWORD32 fn_offset)
469 {
470 // Save timing information in case of future handovers.
471 l1a_l1s_com.nsync.list[neigh_id].time_alignmt_mem = time_alignmt;
472 l1a_l1s_com.nsync.list[neigh_id].fn_offset_mem = fn_offset;
473
474 // Sub the serving cell timeslot number to the Neigh./Serving timing
475 // difference to format it for L1S use.
476 l1a_sub_timeslot(&time_alignmt, &fn_offset, l1a_l1s_com.dl_tn);
477 l1a_sub_time_for_nb(&time_alignmt, &fn_offset);
478
479 // Save neighbor information in the neighbor confirmation cell structure.
480 l1a_l1s_com.nsync.list[neigh_id].time_alignmt = time_alignmt;
481 l1a_l1s_com.nsync.list[neigh_id].fn_offset = fn_offset;
482 }
483 #endif
484
485 /*-------------------------------------------------------*/
486 /* l1a_compute_Eotd_data() */
487 /*-------------------------------------------------------*/
488 /* */
489 /* Description: */
490 /* ------------ */
491 /* */
492 /*-------------------------------------------------------*/
493 #if ((L1_12NEIGH ==1) && (L1_EOTD == 1))
494 void l1a_compute_Eotd_data( UWORD8 *first_scell, UWORD8 neigh_id, UWORD32 SignalCode, xSignalHeaderRec *msg)
495 {
496 WORD32 ta_sb_neigh;
497 UWORD32 fn_sb_neigh;
498 WORD16 d_eotd_first;
499 WORD32 toa_correction;
500 UWORD32 timetag;
501
502 // SB case .....
503 if (SignalCode == L1C_SB_INFO)
504 {
505 fn_sb_neigh = ((T_L1C_SB_INFO *)(msg->SigP))->fn_sb_neigh;
506 d_eotd_first= ((T_L1C_SB_INFO *)(msg->SigP))->d_eotd_first;
507 toa_correction = ((T_L1C_SB_INFO *)(msg->SigP))->toa_correction;
508 }
509 // SBCONF case .....
510 else
511 {
512 fn_sb_neigh = ((T_L1C_SBCONF_INFO *)(msg->SigP))->fn_sb_neigh;
513 d_eotd_first= ((T_L1C_SBCONF_INFO *)(msg->SigP))->d_eotd_first;
514 toa_correction = ((T_L1C_SBCONF_INFO *)(msg->SigP))->toa_correction;
515 }
516
517 // compute the true Serving/Neighbor time difference.
518 // 1) update time_alignmt with (23bit - d_eotd_first) delta
519 // 2) Add the serving cell timeslot number to the Serving/Neighbor time difference.
520 ta_sb_neigh = l1a_l1s_com.nsync.list[neigh_id].time_alignmt;
521 ta_sb_neigh += (d_eotd_first - (23))*4 +
522 (l1a_l1s_com.dl_tn * 625);
523
524 // for Serving cell, timetag reference is 0
525 if (*first_scell == TRUE)
526 {
527 l1a_l1s_com.nsync.fn_sb_serv = fn_sb_neigh;
528 l1a_l1s_com.nsync.ta_sb_serv = ta_sb_neigh;
529
530 timetag = 0;
531 }
532 else
533 {
534 UWORD32 delta_fn;
535 WORD32 delta_qbit;
536
537 delta_fn = (fn_sb_neigh - l1a_l1s_com.nsync.fn_sb_serv + MAX_FN)%MAX_FN;
538 delta_qbit = ta_sb_neigh - l1a_l1s_com.nsync.ta_sb_serv;
539
540 // Set timetag
541 timetag = (delta_fn*5000) + (WORD32)(delta_qbit) + toa_correction;
542
543 #if (CODE_VERSION == SIMULATION)
544 #if (TRACE_TYPE==5)
545 ((T_MPHC_NCELL_SYNC_IND *)(msg->SigP))->delta_fn = delta_fn;
546 ((T_MPHC_NCELL_SYNC_IND *)(msg->SigP))->delta_qbit = delta_qbit;
547 #endif
548 #endif
549 }
550 // Set timetag
551 ((T_MPHC_NCELL_SYNC_IND *)(msg->SigP))->timetag = timetag;
552
553 }
554 #endif
555
556 /*-------------------------------------------------------*/
557 /* l1a_get_free_dedic_set() */
558 /*-------------------------------------------------------*/
559 /* Parameters : */
560 /* Return : */
561 /* Functionality : */
562 /*-------------------------------------------------------*/
563 T_DEDIC_SET *l1a_get_free_dedic_set()
564 {
565 T_DEDIC_SET *fset;
566 UWORD8 i;
567
568 // Get free set pointer.
569 if(l1a_l1s_com.dedic_set.aset == &(l1a_l1s_com.dedic_set.set[0]))
570 fset = &(l1a_l1s_com.dedic_set.set[1]);
571 else
572 fset = &(l1a_l1s_com.dedic_set.set[0]);
573
574 // Clear free set.
575 fset->achan_ptr = NULL;
576 fset->chan1.desc.channel_type = INVALID_CHANNEL;
577 fset->chan1.desc_bef_sti.channel_type = INVALID_CHANNEL;
578 fset->chan2.desc.channel_type = INVALID_CHANNEL;
579 fset->chan2.desc_bef_sti.channel_type = INVALID_CHANNEL;
580
581 fset->ma.alist_ptr = NULL;
582 fset->ma.freq_list.rf_chan_cnt = 0;
583 fset->ma.freq_list_bef_sti.rf_chan_cnt = 0;
584
585 // Starting time.
586 fset->serv_sti_fn = -1;
587 fset->neig_sti_fn = -1;
588
589 // Frequency redefinition flag.
590 fset->freq_redef_flag = FALSE;
591
592 // Timing Advance
593 fset->timing_advance = 0;
594 fset->new_timing_advance = 0;
595
596 // TXPWR
597 fset->new_target_txpwr = NO_TXPWR;
598
599 // Cell Information
600 l1a_reset_cell_info(&(fset->cell_desc));
601
602 // Cipering.
603 fset->a5mode = 0; // Ciphering OFF.
604
605 // Clear O&M test variables.
606 fset->dai_mode = 0; // No DAI test.
607 fset->chan1.tch_loop = 0; // No TCH loop on chan1.
608 fset->chan2.tch_loop = 0; // No TCH loop on chan2.
609
610 // For handover...
611 fset->ho_acc = 0;
612 fset->ho_acc_to_send = 0;
613 fset->t3124 = 0;
614
615 #if ((REL99 == 1) && (FF_BHO == 1))
616 // For blind handover...
617 fset->report_time_diff = FALSE;
618 fset->nci = FALSE;
619 fset->report_time_diff = FALSE;
620 fset->real_time_difference = 0;
621 fset->HO_SignalCode = 0;
622 #endif
623
624 // Reset DPAGC fifo
625 for(i=0;i<DPAGC_FIFO_LEN;i++)
626 {
627 fset->G_all[i] = 200;
628 fset->G_DTX[i] = 200;
629 }
630
631 // Reset DTX_ALLOWED field.
632 fset->dtx_allowed = FALSE;
633
634 #if IDS
635 // clear ids_mode: default value = speech mode
636 fset->ids_mode = 0;
637 #endif
638
639 #if (AMR == 1)
640 // Clear the AMR ver 1.0 network settings
641 fset->amr_configuration.noise_suppression_bit = FALSE;
642 fset->amr_configuration.initial_codec_mode_indicator = FALSE;
643 fset->amr_configuration.initial_codec_mode = 0;
644 fset->amr_configuration.active_codec_set = 0;
645 fset->amr_configuration.threshold[0] = 0;
646 fset->amr_configuration.threshold[1] = 0;
647 fset->amr_configuration.threshold[2] = 0;
648 fset->amr_configuration.hysteresis[0] = 0;
649 fset->amr_configuration.hysteresis[1] = 0;
650 fset->amr_configuration.hysteresis[2] = 0;
651 fset->cmip = C_AMR_CMIP_DEFAULT;
652 #endif
653 return(fset);
654 }
655
656 /*-------------------------------------------------------*/
657 /* l1a_fill_bef_sti_param() */
658 /*-------------------------------------------------------*/
659 /* Parameters : */
660 /* Return : */
661 /* Functionality : */
662 /*-------------------------------------------------------*/
663 void l1a_fill_bef_sti_param(T_DEDIC_SET *set_ptr, BOOL start_time_present)
664 {
665 if(start_time_present == TRUE)
666 // There is a STARTING TIME field...
667 {
668 if((set_ptr->ma.freq_list_bef_sti.rf_chan_cnt != 0) ||
669 (set_ptr->chan1.desc_bef_sti.channel_type != INVALID_CHANNEL) ||
670 (set_ptr->chan2.desc_bef_sti.channel_type != INVALID_CHANNEL))
671 // There is at least one "bef_sti" parameter given for this channel.
672 // Other empty parameters must be filled with the according "AFTER STARTING TIME" parameters.
673 {
674 // Fill "chan1.desc_bef_sti"
675 if(set_ptr->chan1.desc_bef_sti.channel_type == INVALID_CHANNEL)
676 set_ptr->chan1.desc_bef_sti = set_ptr->chan1.desc;
677
678 // Fill "chan2.desc_bef_sti"
679 if(set_ptr->chan2.desc_bef_sti.channel_type == INVALID_CHANNEL)
680 set_ptr->chan2.desc_bef_sti = set_ptr->chan2.desc;
681
682 // Fill "freq_list_bef_sti"
683 if(set_ptr->ma.freq_list_bef_sti.rf_chan_cnt == 0)
684 set_ptr->ma.freq_list_bef_sti = set_ptr->ma.freq_list;
685 }
686 }
687 }
688
689 /*-------------------------------------------------------*/
690 /* l1a_decode_starting_time() */
691 /*-------------------------------------------------------*/
692 /* Parameters : */
693 /* Return : */
694 /* Functionality : */
695 /*-------------------------------------------------------*/
696 WORD32 l1a_decode_starting_time(T_STARTING_TIME coded_starting_time)
697 {
698 WORD32 starting_time;
699
700 if(coded_starting_time.start_time_present == TRUE )
701 // A starting time is present.
702 // ---------------------------
703 {
704 WORD32 tp1 = coded_starting_time.start_time.n32;
705 WORD32 t2 = coded_starting_time.start_time.n26;
706 WORD32 t3 = coded_starting_time.start_time.n51;
707
708 // Compute STI.
709 starting_time = 51*((26 + t3 - t2) % 26) + t3 + (51*26*tp1) ;
710 }
711 else
712 {
713 starting_time = -1;
714 }
715
716 return(starting_time);
717 }
718
719 /*-------------------------------------------------------*/
720 /* l1a_reset_cell_info() */
721 /*-------------------------------------------------------*/
722 /* Parameters : */
723 /* Return : */
724 /* Functionality : */
725 /*-------------------------------------------------------*/
726 void l1a_reset_cell_info(T_CELL_INFO *cell_info)
727 {
728 cell_info->bsic = 0;
729 cell_info->fn_offset = 0;
730 cell_info->time_alignmt = 0;
731 cell_info->meas.acc = 0;
732 cell_info->meas.nbr_meas = 0;
733 cell_info->attempt_count = 0;
734 cell_info->si_bit_map = 0;
735
736 cell_info->traffic_meas.input_level = l1_config.params.il_min;
737 cell_info->traffic_meas_beacon.input_level = l1_config.params.il_min;
738 cell_info->traffic_meas.lna_off = FALSE;
739 cell_info->traffic_meas_beacon.lna_off = FALSE;
740
741 cell_info->buff_beacon[0] = cell_info->buff_beacon[1] = cell_info->buff_beacon[2] =
742 cell_info->buff_beacon[3] = l1_config.params.il_min;
743
744 #if L1_GPRS
745 cell_info->transfer_meas.input_level = l1_config.params.il_min;
746 cell_info->transfer_meas.lna_off = FALSE;
747 cell_info->pb = 0;
748 #endif
749 }
750
751 /*-------------------------------------------------------*/
752 /* l1a_send_confirmation() */
753 /*-------------------------------------------------------*/
754 /* Parameters : */
755 /* Return : */
756 /* Functionality : */
757 /*-------------------------------------------------------*/
758 void l1a_send_confirmation(UWORD32 SignalCode, UWORD8 queue_type)
759 {
760 xSignalHeaderRec *msg;
761
762 msg = os_alloc_sig(0);
763 DEBUGMSG(status,NU_ALLOC_ERR)
764 msg->SignalCode = (int)SignalCode;
765
766 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
767 l1_trace_message(msg);
768 #endif
769
770
771 #if (OP_L1_STANDALONE == 1)
772 os_send_sig(msg, queue_type);
773 #else
774 os_send_sig(msg, ((T_ENUM_OS_QUEUE)queue_type)); //omaps00090550
775 #endif
776
777
778 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
779 }
780
781 /*-------------------------------------------------------*/
782 /* l1a_send_result() */
783 /*-------------------------------------------------------*/
784 /* Parameters : */
785 /* Return : */
786 /* Functionality : */
787 /*-------------------------------------------------------*/
788 void l1a_send_result(UWORD32 SignalCode, xSignalHeaderRec *msg, UWORD8 queue)
789 {
790 // Set flag to avoid the FREE(msg) in L1ASYNC.
791 l1a.l1_msg_forwarded = TRUE;
792
793 msg->SignalCode = (int)SignalCode;
794
795 // May not be necessary -> to check
796
797 #if (GSM_IDLE_RAM > 1)
798 if (!READ_TRAFFIC_CONT_STATE)
799 {
800 CSMI_TrafficControllerOn();
801 }
802 #endif
803
804 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
805 l1_trace_message(msg);
806 #endif
807
808 #if (OP_L1_STANDALONE == 1)
809 os_send_sig(msg, queue);
810 #else
811 os_send_sig(msg, ((T_ENUM_OS_QUEUE)queue)); //omaps00090550
812 #endif
813
814
815 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
816 }
817
818 /*-------------------------------------------------------*/
819 /* l1a_encode_rxqual() */
820 /*-------------------------------------------------------*/
821 /* Parameters : */
822 /* Return : */
823 /* Functionality : */
824 /*-------------------------------------------------------*/
825 UWORD8 l1a_encode_rxqual (UWORD32 inlevel)
826 {
827 enum qual_thr
828 {
829 thr_0_2 = 4,
830 thr_0_4 = 8,
831 thr_0_8 = 16,
832 thr_1_6 = 32,
833 thr_3_2 = 64,
834 thr_6_4 = 128,
835 thr_12_8 = 256
836 };
837
838 UWORD8 rxqual;
839
840 if (inlevel < thr_0_2) rxqual = 0;
841 else
842 if (inlevel < thr_0_4) rxqual = 1;
843 else
844 if (inlevel < thr_0_8) rxqual = 2;
845 else
846 if (inlevel < thr_1_6) rxqual = 3;
847 else
848 if (inlevel < thr_3_2) rxqual = 4;
849 else
850 if (inlevel < thr_6_4) rxqual = 5;
851 else
852 if (inlevel < thr_12_8) rxqual = 6;
853 else rxqual = 7;
854
855 return((UWORD8) rxqual);
856 }
857
858 /*-------------------------------------------------------*/
859 /* l1a_report_failling_ncell_sync() */
860 /*-------------------------------------------------------*/
861 /* Parameters : */
862 /* Return : */
863 /* Functionality : */
864 /*-------------------------------------------------------*/
865 void l1a_report_failling_ncell_sync(UWORD32 SignalCode, UWORD8 neigh_id)
866 {
867 xSignalHeaderRec *msg;
868
869 // Send MPHC_NCELL_SYNC_IND message to L3 with a FAILLURE indication.
870 msg = os_alloc_sig(sizeof(T_MPHC_NCELL_SYNC_IND));
871 DEBUGMSG(status,NU_ALLOC_ERR)
872
873 msg->SignalCode = SignalCode;
874 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->sb_flag = FALSE;
875 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->radio_freq = l1a_l1s_com.nsync.list[neigh_id].radio_freq;
876 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->bsic = 0;
877 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->fn_offset = 0;
878 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->time_alignmt = 0;
879
880 // For trace/debug only
881 ((T_MPHC_NCELL_SYNC_IND*)(msg->SigP))->neigh_id = neigh_id;
882
883 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
884 l1_trace_message(msg);
885 #endif
886
887 os_send_sig(msg, RRM1_QUEUE);
888 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
889 }
890
891
892 /*-------------------------------------------------------*/
893 /* l1a_clip_txpwr() */
894 /*-------------------------------------------------------*/
895 /* Parameters : */
896 /* Return : */
897 /* Functionality : */
898 /*-------------------------------------------------------*/
899 #if (L1_FF_MULTIBAND == 0)
900
901 UWORD8 l1a_clip_txpwr (UWORD8 supplied_txpwr, UWORD16 radio_freq)
902 {
903 #define txpwr_to_compare(pwr) ((pwr<=l1_config.std.txpwr_turning_point)? pwr+32:pwr)
904
905 switch(l1_config.std.id)
906 {
907 case GSM:
908 case GSM_E:
909 {
910 // Clip LOW according to powerclass_band1.
911 if ( supplied_txpwr < MIN_TXPWR_GSM[l1a_l1s_com.powerclass_band1])
912 return(MIN_TXPWR_GSM[l1a_l1s_com.powerclass_band1]);
913
914 // Clip HIGH according to GSM spec. 05.05.
915 if ( supplied_txpwr > l1_config.std.max_txpwr_band1)
916 return(l1_config.std.max_txpwr_band1);
917 }
918 break;
919
920 case PCS1900:
921 {
922 // Clip LOW according to powerclass_band1.
923 if ( txpwr_to_compare(supplied_txpwr) <
924 txpwr_to_compare(MIN_TXPWR_PCS[l1a_l1s_com.powerclass_band1]) )
925 return(MIN_TXPWR_PCS[l1a_l1s_com.powerclass_band1]);
926
927 // Clip HIGH according to GSM spec. 05.05.
928 if ( txpwr_to_compare(supplied_txpwr) >
929 txpwr_to_compare(l1_config.std.max_txpwr_band1) )
930 return(l1_config.std.max_txpwr_band1);
931 }
932 break;
933
934 case DCS1800:
935 {
936 // Clip LOW according to powerclass_band1.
937 if ( txpwr_to_compare(supplied_txpwr) <
938 txpwr_to_compare(MIN_TXPWR_DCS[l1a_l1s_com.powerclass_band1]) )
939 return(MIN_TXPWR_DCS[l1a_l1s_com.powerclass_band1]);
940
941 // Clip HIGH according to GSM spec. 05.05.
942 if ( txpwr_to_compare(supplied_txpwr) >
943 txpwr_to_compare(l1_config.std.max_txpwr_band1) )
944 return(l1_config.std.max_txpwr_band1);
945 }
946 break;
947
948 case GSM850:
949 {
950 // Clip LOW according to powerclass_band1.
951 if ( txpwr_to_compare(supplied_txpwr) <
952 txpwr_to_compare(MIN_TXPWR_GSM850[l1a_l1s_com.powerclass_band1]) )
953 return(MIN_TXPWR_GSM850[l1a_l1s_com.powerclass_band1]);
954
955 // Clip HIGH according to GSM spec. 05.05.
956 if ( txpwr_to_compare(supplied_txpwr) >
957 txpwr_to_compare(l1_config.std.max_txpwr_band1) )
958 return(l1_config.std.max_txpwr_band1);
959 }
960 break;
961
962 case DUAL:
963 case DUALEXT:
964 {
965 // Test which Band is used: GSM or DCS 1800
966 if (radio_freq >= l1_config.std.first_radio_freq_band2)
967 {
968 // Clip LOW according to powerclass_band1.
969 if ( txpwr_to_compare(supplied_txpwr) <
970 txpwr_to_compare(MIN_TXPWR_DCS[l1a_l1s_com.powerclass_band2]) )
971 return(MIN_TXPWR_DCS[l1a_l1s_com.powerclass_band2]);
972
973 // Clip HIGH according to GSM spec. 05.05.
974 if ( txpwr_to_compare(supplied_txpwr) >
975 txpwr_to_compare(l1_config.std.max_txpwr_band2) )
976 return(l1_config.std.max_txpwr_band2);
977 }
978 else
979 {
980 // Clip LOW according to powerclass_band1.
981 if ( supplied_txpwr < MIN_TXPWR_GSM[l1a_l1s_com.powerclass_band1])
982 return(MIN_TXPWR_GSM[l1a_l1s_com.powerclass_band1]);
983
984 // Clip HIGH according to GSM spec. 05.05.
985 if ( supplied_txpwr > l1_config.std.max_txpwr_band1)
986 return(l1_config.std.max_txpwr_band1);
987 }
988 }
989 break;
990
991
992 case DUAL_US:
993 {
994 // Test which Band is used: GSM 850 or PCS1900
995 if (radio_freq >= l1_config.std.first_radio_freq_band2)
996 {
997 // Clip LOW according to powerclass_band1.
998 if ( txpwr_to_compare(supplied_txpwr) <
999 txpwr_to_compare(MIN_TXPWR_PCS[l1a_l1s_com.powerclass_band2]) )
1000 return(MIN_TXPWR_PCS[l1a_l1s_com.powerclass_band2]);
1001
1002 // Clip HIGH according to GSM spec. 05.05.
1003 if ( txpwr_to_compare(supplied_txpwr) >
1004 txpwr_to_compare(l1_config.std.max_txpwr_band2) )
1005 return(l1_config.std.max_txpwr_band2);
1006 }
1007 else
1008 {
1009 // Clip LOW according to powerclass_band1.
1010 if ( supplied_txpwr < MIN_TXPWR_GSM850[l1a_l1s_com.powerclass_band1])
1011 return(MIN_TXPWR_GSM850[l1a_l1s_com.powerclass_band1]);
1012
1013 // Clip HIGH according to GSM spec. 05.05.
1014 if ( supplied_txpwr > l1_config.std.max_txpwr_band1)
1015 return(l1_config.std.max_txpwr_band1);
1016 }
1017 }
1018 break;
1019
1020
1021 default: // should never occur
1022 {
1023 return(supplied_txpwr);
1024 }
1025 // omaps00090550 break;
1026 }
1027 return(supplied_txpwr);
1028 }
1029
1030 #else /*L1_FF_MULTIBAND = 1 below */
1031
1032 UWORD8 l1a_clip_txpwr (UWORD8 supplied_txpwr, UWORD16 radio_freq)
1033 {
1034
1035
1036 UWORD8 physical_band_id = 0;
1037 physical_band_id = l1_multiband_radio_freq_convert_into_physical_band_id(radio_freq);
1038 #define txpwr_to_compare(pwr) ((pwr<= multiband_rf[physical_band_id].tx_turning_point)? pwr+32:pwr)
1039 switch(multiband_rf[physical_band_id].gsm_band_identifier)
1040 {
1041 case RF_GSM900:
1042 {
1043
1044 // Clip LOW according to powerclass_band1.
1045 if ( supplied_txpwr < MIN_TXPWR_GSM[l1a_l1s_com.powerclass[physical_band_id]])
1046 return(MIN_TXPWR_GSM[l1a_l1s_com.powerclass[physical_band_id]]);
1047
1048 // Clip HIGH according to GSM spec. 05.05.
1049 if ( supplied_txpwr > multiband_rf[physical_band_id].max_txpwr)
1050 return(multiband_rf[physical_band_id].max_txpwr);
1051 break;
1052 }/*case GSM900*/
1053
1054 case RF_PCS1900:
1055 {
1056 // Clip LOW according to powerclass_band1.
1057 if ( txpwr_to_compare(supplied_txpwr) <
1058 txpwr_to_compare(MIN_TXPWR_PCS[l1a_l1s_com.powerclass[physical_band_id]]) )
1059 return(MIN_TXPWR_PCS[l1a_l1s_com.powerclass[physical_band_id]]);
1060
1061 // Clip HIGH according to GSM spec. 05.05.
1062 if ( txpwr_to_compare(supplied_txpwr) >
1063 txpwr_to_compare(multiband_rf[physical_band_id].max_txpwr) )
1064 return(multiband_rf[physical_band_id].max_txpwr);
1065 break;
1066 }/*case PCS1900*/
1067
1068 case RF_DCS1800:
1069 {
1070 // Clip LOW according to powerclass_band1.
1071 if ( txpwr_to_compare(supplied_txpwr) <
1072 txpwr_to_compare(MIN_TXPWR_DCS[l1a_l1s_com.powerclass[physical_band_id]]) )
1073 return(MIN_TXPWR_DCS[l1a_l1s_com.powerclass[physical_band_id]]);
1074
1075 // Clip HIGH according to GSM spec. 05.05.
1076 if ( txpwr_to_compare(supplied_txpwr) >
1077 txpwr_to_compare(multiband_rf[physical_band_id].max_txpwr) )
1078 return(multiband_rf[physical_band_id].max_txpwr);
1079 break;
1080 }/*case DCS1800*/
1081
1082 case RF_GSM850:
1083 {
1084 // Clip LOW according to powerclass_band1.
1085 if ( txpwr_to_compare(supplied_txpwr) <
1086 txpwr_to_compare(MIN_TXPWR_GSM850[l1a_l1s_com.powerclass[physical_band_id]]) )
1087 return(MIN_TXPWR_GSM850[l1a_l1s_com.powerclass[physical_band_id]]);
1088
1089 // Clip HIGH according to GSM spec. 05.05.
1090 if ( txpwr_to_compare(supplied_txpwr) >
1091 txpwr_to_compare(multiband_rf[physical_band_id].max_txpwr) )
1092 return(multiband_rf[physical_band_id].max_txpwr);
1093 break;
1094 }/*case GSM850*/
1095
1096 default: // should never occur
1097 {
1098 l1_multiband_error_handler();
1099 return(supplied_txpwr);
1100 break;
1101 } /*default*/
1102
1103 }/*switch(multiband_rfphysical_band_id].gsm_band_identifier)*/
1104 return(supplied_txpwr);
1105
1106 }
1107
1108 #endif /*L1_FF_MULTIBAND */
1109
1110
1111 //MADC
1112
1113 #if (L1_MADC_ON == 1)
1114 #if (OP_L1_STANDALONE == 1)
1115 #if (ANALOG == 11)
1116 void l1a_madc_callback(void)
1117 {
1118 char str[40];
1119
1120
1121
1122 xSignalHeaderRec *adc_msg;
1123 UWORD16 *adc_result;
1124 UWORD16 *madc_results;
1125 volatile UWORD16 *drp_temp_results;
1126
1127 #if (RF_FAM == 61)
1128 drp_temp_results =(volatile UWORD16 *) (&drp_srm_api->inout.temperature.output); //omaps00090550
1129 #endif
1130
1131 #if 0
1132 sprintf(str, "Temp Measure %x ", drp_temp_results);
1133
1134 //L1_trace_string ("Temp Meas\n");
1135 L1_trace_string(str);
1136 #endif
1137
1138 #if 0
1139 int i;
1140
1141 adc_msg = os_alloc_sig(sizeof(BspTwl3029_MadcResults) + sizeof(UWORD16));
1142 adc_result = &((BspTwl3029_MadcResults*)(adc_msg->SigP))->adc1;
1143 madc_results =& l1_madc_results.adc1;
1144
1145 //TEMP_MEAS: DRP
1146 #if (RF_FAM == 61)
1147 drp_temp_results =& (drp_srm_api->inout.temperature.output);
1148 #endif
1149
1150 //copy the measured values into the the message structure.
1151 memcpy(adc_result,madc_results,11*sizeof(UWORD16));//11 madc
1152 adc_result[11] = *drp_temp_results; // 1 temp meas
1153 /*
1154 for (i=0;i<11;i++)
1155 adc_result[i] = madc_results[i];
1156 */
1157 //Send the message
1158 adc_msg->SignalCode = CST_ADC_RESULT;
1159 os_send_sig(adc_msg, RRM1_QUEUE);
1160 #endif
1161 }
1162 #endif // ANALOG == 11
1163 #endif //OP_L1_STANDALONE
1164 #endif // L1_MADC_ON
1165
1166 //==============================================================================================
1167