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