FreeCalypso > hg > fc-tourmaline
view src/condat/com/src/comlib/cl_user_spver.c @ 303:f76436d19a7a default tip
!GPRS config: fix long-standing AT+COPS chance hanging bug
There has been a long-standing bug in FreeCalypso going back years:
sometimes in the AT command bring-up sequence of an ACI-only MS,
the AT+COPS command would produce only a power scan followed by
cessation of protocol stack activity (only L1 ADC traces), instead
of the expected network search sequence. This behaviour was seen
in different FC firmware versions going back to Citrine, and seemed
to follow some law of chance, not reliably repeatable.
This bug has been tracked down and found to be specific to !GPRS
configuration, stemming from our TCS2/TCS3 hybrid and reconstruction
of !GPRS support that was bitrotten in TCS3.2/LoCosto version.
ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3
version and had to be pulled from TCS2 - but as it turns out,
there is a new field in the MMR_REG_REQ primitive that needs to be
set correctly, and that psa_mms.c module is the place where this
initialization needed to be added.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Jun 2023 08:23:37 +0000 |
parents | 4bb5772a05a3 |
children |
line wrap: on
line source
/* * This C module is a FreeCalypso addition; it is part of the mechanism * for setting a user-defined list of accepted speech versions in the Bearer * Capability IE for speech calls, with a user-defined order of preference, * overriding the standard SV list based on hw+fw platform capabilities * and the standard order of preference. */ #include <string.h> #include "typedefs.h" #include "vsi.h" #include "gsm.h" #include "cl_user_spver.h" #include "m_cc.val" /* * State variable: it is packed into a single 32-bit word so it can be * updated atomically; it is declared as volatile so that each set/reset/get * function will access it exactly once as written in the code, and it is * made global so it will appear in the linker map file for debugging - * so we can read it via fc-tmsh r32. * * Packing format: * * bits [31:24] = number of SVs in user-defined list * bits [23:20] = rad_chan_req * bits [19:16] = spver_list[0] * bits [15:12] = spver_list[1] * bits [11: 8] = spver_list[2] * bits [ 7: 4] = spver_list[3] * bits [ 3: 0] = spver_list[4] */ volatile U32 cl_user_spver_state_var; UBYTE cl_user_spver_set(const UBYTE *spver_list) { UBYTE n, sv; UBYTE pos_fr = 0, pos_hr = 0, pos_efr = 0; UBYTE pos_amr_fr = 0, pos_amr_hr = 0; UBYTE rad_chan_req; U32 new_word; for (n = 0; n < 5; n++) { sv = spver_list[n]; if (sv == NOT_PRESENT_8BIT) break; switch (sv) { case M_CC_SPEECH_VERS_FR: if (pos_fr) return CL_USER_SPVER_SET_ERROR; pos_fr = n + 1; break; case M_CC_SPEECH_VERS_HR: if (pos_hr) return CL_USER_SPVER_SET_ERROR; pos_hr = n + 1; break; case M_CC_SPEECH_VERS_EFR: if (pos_efr) return CL_USER_SPVER_SET_ERROR; pos_efr = n + 1; break; case M_CC_SPEECH_VERS_AMR_FR: if (pos_amr_fr) return CL_USER_SPVER_SET_ERROR; pos_amr_fr = n + 1; break; case M_CC_SPEECH_VERS_AMR_HR: if (pos_amr_hr) return CL_USER_SPVER_SET_ERROR; pos_amr_hr = n + 1; break; default: return CL_USER_SPVER_SET_ERROR; } } if (!n || !pos_fr) return CL_USER_SPVER_SET_ERROR; if (!pos_hr) rad_chan_req = M_CC_RCR_FULL_ONLY; else if (pos_hr < pos_fr) rad_chan_req = M_CC_RCR_HALF_PREF; else rad_chan_req = M_CC_RCR_FULL_PREF; new_word = n << 24; new_word |= rad_chan_req << 20; new_word |= (spver_list[0] & 0xF) << 16; new_word |= (spver_list[1] & 0xF) << 12; new_word |= (spver_list[2] & 0xF) << 8; new_word |= (spver_list[3] & 0xF) << 4; new_word |= (spver_list[4] & 0xF) << 0; cl_user_spver_state_var = new_word; return CL_USER_SPVER_SET_OK; } void cl_user_spver_reset(void) { cl_user_spver_state_var = 0; } UBYTE cl_user_spver_get(UBYTE *spver_list, UBYTE *rad_chan_req) { U32 conf; UBYTE num, n; conf = cl_user_spver_state_var; num = conf >> 24; if (num < 1 || num > 5) return CL_USER_SPVER_IS_NOT_SET; spver_list[0] = (conf >> 16) & 0xF; spver_list[1] = (conf >> 12) & 0xF; spver_list[2] = (conf >> 8) & 0xF; spver_list[3] = (conf >> 4) & 0xF; spver_list[4] = conf & 0xF; for (n = num; n < 5; n++) spver_list[n] = NOT_PRESENT_8BIT; *rad_chan_req = (conf >> 20) & 0xF; return CL_USER_SPVER_IS_SET; }