FreeCalypso > hg > fc-tourmaline
view src/condat/com/src/comlib/cl_user_spver.c @ 301:4bb5772a05a3
AT%SPVER: new command for setting custom speech version lists
The speech version list in the Bearer Capability IE tells the network
which speech codecs are supported by the MS, and in which order of
preference. The standard behaviour is to list all codecs that are
supported by the hw+fw platform, and the standard preference order
is newer over older, FR over HR. But sometimes it is desirable
(for network testing) to artificially restrict which codecs the test MS
will declare as supported, and/or to list them in some peculiar
non-standard order of preference. Add a new private AT command,
AT%SPVER, allowing the user to set and clear custom speech version
lists for the Bearer Capability IE composer in CC.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 May 2023 21:43:10 +0000 |
parents | |
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; }