comparison src/cs/layer1/cfile/l1_afunc.c @ 0:4e78acac3d88

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