comparison 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
comparison
equal deleted inserted replaced
300:edcb8364d45b 301:4bb5772a05a3
1 /*
2 * This C module is a FreeCalypso addition; it is part of the mechanism
3 * for setting a user-defined list of accepted speech versions in the Bearer
4 * Capability IE for speech calls, with a user-defined order of preference,
5 * overriding the standard SV list based on hw+fw platform capabilities
6 * and the standard order of preference.
7 */
8
9 #include <string.h>
10 #include "typedefs.h"
11 #include "vsi.h"
12 #include "gsm.h"
13 #include "cl_user_spver.h"
14 #include "m_cc.val"
15
16 /*
17 * State variable: it is packed into a single 32-bit word so it can be
18 * updated atomically; it is declared as volatile so that each set/reset/get
19 * function will access it exactly once as written in the code, and it is
20 * made global so it will appear in the linker map file for debugging -
21 * so we can read it via fc-tmsh r32.
22 *
23 * Packing format:
24 *
25 * bits [31:24] = number of SVs in user-defined list
26 * bits [23:20] = rad_chan_req
27 * bits [19:16] = spver_list[0]
28 * bits [15:12] = spver_list[1]
29 * bits [11: 8] = spver_list[2]
30 * bits [ 7: 4] = spver_list[3]
31 * bits [ 3: 0] = spver_list[4]
32 */
33 volatile U32 cl_user_spver_state_var;
34
35 UBYTE cl_user_spver_set(const UBYTE *spver_list)
36 {
37 UBYTE n, sv;
38 UBYTE pos_fr = 0, pos_hr = 0, pos_efr = 0;
39 UBYTE pos_amr_fr = 0, pos_amr_hr = 0;
40 UBYTE rad_chan_req;
41 U32 new_word;
42
43 for (n = 0; n < 5; n++) {
44 sv = spver_list[n];
45 if (sv == NOT_PRESENT_8BIT)
46 break;
47 switch (sv) {
48 case M_CC_SPEECH_VERS_FR:
49 if (pos_fr)
50 return CL_USER_SPVER_SET_ERROR;
51 pos_fr = n + 1;
52 break;
53 case M_CC_SPEECH_VERS_HR:
54 if (pos_hr)
55 return CL_USER_SPVER_SET_ERROR;
56 pos_hr = n + 1;
57 break;
58 case M_CC_SPEECH_VERS_EFR:
59 if (pos_efr)
60 return CL_USER_SPVER_SET_ERROR;
61 pos_efr = n + 1;
62 break;
63 case M_CC_SPEECH_VERS_AMR_FR:
64 if (pos_amr_fr)
65 return CL_USER_SPVER_SET_ERROR;
66 pos_amr_fr = n + 1;
67 break;
68 case M_CC_SPEECH_VERS_AMR_HR:
69 if (pos_amr_hr)
70 return CL_USER_SPVER_SET_ERROR;
71 pos_amr_hr = n + 1;
72 break;
73 default:
74 return CL_USER_SPVER_SET_ERROR;
75 }
76 }
77 if (!n || !pos_fr)
78 return CL_USER_SPVER_SET_ERROR;
79 if (!pos_hr)
80 rad_chan_req = M_CC_RCR_FULL_ONLY;
81 else if (pos_hr < pos_fr)
82 rad_chan_req = M_CC_RCR_HALF_PREF;
83 else
84 rad_chan_req = M_CC_RCR_FULL_PREF;
85 new_word = n << 24;
86 new_word |= rad_chan_req << 20;
87 new_word |= (spver_list[0] & 0xF) << 16;
88 new_word |= (spver_list[1] & 0xF) << 12;
89 new_word |= (spver_list[2] & 0xF) << 8;
90 new_word |= (spver_list[3] & 0xF) << 4;
91 new_word |= (spver_list[4] & 0xF) << 0;
92 cl_user_spver_state_var = new_word;
93 return CL_USER_SPVER_SET_OK;
94 }
95
96 void cl_user_spver_reset(void)
97 {
98 cl_user_spver_state_var = 0;
99 }
100
101 UBYTE cl_user_spver_get(UBYTE *spver_list, UBYTE *rad_chan_req)
102 {
103 U32 conf;
104 UBYTE num, n;
105
106 conf = cl_user_spver_state_var;
107 num = conf >> 24;
108 if (num < 1 || num > 5)
109 return CL_USER_SPVER_IS_NOT_SET;
110 spver_list[0] = (conf >> 16) & 0xF;
111 spver_list[1] = (conf >> 12) & 0xF;
112 spver_list[2] = (conf >> 8) & 0xF;
113 spver_list[3] = (conf >> 4) & 0xF;
114 spver_list[4] = conf & 0xF;
115 for (n = num; n < 5; n++)
116 spver_list[n] = NOT_PRESENT_8BIT;
117 *rad_chan_req = (conf >> 20) & 0xF;
118 return CL_USER_SPVER_IS_SET;
119 }