Make new L1CTL_FBSB_REQ work reliably
[osmocom-bb.git] / src / host / layer23 / src / support.c
1 /*
2  * (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
3  *
4  * All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  */
21
22 #include <stdio.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #include <osmocom/osmocom_data.h>
27
28 void gsm_support_init(struct osmocom_ms *ms)
29 {
30         struct gsm_support *sup = &ms->support;
31         int i;
32
33         memset(sup, 0, sizeof(*sup));
34         sup->ms = ms;
35
36         /* rf power capability */
37         sup->pwr_lev_900 = 3; /* CLASS 4: Handheld 2W */
38         sup->pwr_lev_1800 = 0; /* CLASS 1: Handheld 1W */
39         /* controlled early classmark sending */
40         sup->es_ind = 0; /* no */
41         /* revision level */
42         sup->rev_lev = 1; /* phase 2 mobile station */
43         /* support of VGCS */
44         sup->vgcs = 0; /* no */
45         /* support of VBS */
46         sup->vbs = 0; /* no */
47         /* support of SMS */
48         sup->sms_ptp = 1; /* yes */
49         /* screening indicator */
50         sup->ss_ind = 1; /* phase 2 error handling */
51         /* pseudo synchronised capability */
52         sup->ps_cap = 0; /* no */
53         /* CM service prompt */
54         sup->cmsp = 0; /* no */
55         /* solsa support */
56         sup->solsa = 0; /* no */
57         /* location service support */
58         sup->lcsva = 0; /* no */
59         sup->loc_serv = 0; /* no */
60         /* codec supprot */
61         sup->a5_1 = 0; /* currently not */
62         sup->a5_2 = 0;
63         sup->a5_3 = 0;
64         sup->a5_4 = 0;
65         sup->a5_5 = 0;
66         sup->a5_6 = 0;
67         sup->a5_7 = 0;
68         /* radio support */
69         sup->p_gsm = 1; /* P-GSM only */
70         sup->e_gsm = 0; /* E-GSM */
71         sup->r_gsm = 0; /* R-GSM */
72         sup->r_capa = 0;
73         sup->low_capa = 4; /* p,e,r power class */
74         sup->dcs_1800 = 1;
75         /* set supported frequencies */
76         if (sup->e_gsm || sup->r_gsm)
77                 sup->freq_map[0] |= 1;
78         if (sup->p_gsm || sup->e_gsm || sup->r_gsm)
79                 for(i = 1; i <= 124; i++)
80                         sup->freq_map[i >> 3] |= (1 << (i & 7));
81         if (sup->dcs_1800)
82                 for(i = 512; i <= 885; i++)
83                         sup->freq_map[i >> 3] |= (1 << (i & 7));
84         if (sup->e_gsm)
85                 for(i = 975; i <= 1023; i++)
86                         sup->freq_map[i >> 3] |= (1 << (i & 7));
87 //              for(i = 978; i <= 978; i++)
88 //                      sup->freq_map[i >> 3] |= (1 << (i & 7));
89         if (sup->r_gsm)
90                 for(i = 955; i <= 1023; i++)
91                         sup->freq_map[i >> 3] |= (1 << (i & 7));
92         sup->dcs_capa = 1; /* dcs power class */
93         /* multi slot support */
94         sup->ms_sup = 0; /* no */
95         /* ucs2 treatment */
96         sup->ucs2_treat = 0; /* default */
97         /* support extended measurements */
98         sup->ext_meas = 0; /* no */
99         /* support switched measurement capability */
100         sup->meas_cap = 0; /* no */
101         //sup->sms_val = ;
102         //sup->sm_val = ;
103
104         /* IMEI */
105         sprintf(sup->imei, "000000000000000");
106         sprintf(sup->imeisv, "0000000000000000");
107
108         /* radio */
109         sup->min_rxlev_db = -80; // TODO
110         sup->sync_to = 6; /* how long to wait sync (0.9 s) */
111         sup->scan_to = 4; /* how long to wait for all sysinfos (>=4 s) */
112 }
113
114 /* (3.2.1) maximum channels to scan within each band */
115 struct gsm_support_scan_max gsm_sup_smax[] = {
116         { 259, 293, 15, 0 },
117         { 360, 340, 15, 0 },
118         { 438, 511, 25, 0 },
119         { 128, 251, 30, 0 },
120         { 955, 124, 30, 0 },
121         { 512, 885, 40, 0 },
122         { 0, 0, 0, 0 }
123 };
124
125 int gsm_support_random_imei(struct gsm_support *sup)
126 {
127 }
128
129
130 /* dump support */
131 void gsm_support_dump(struct gsm_support *sup,
132                         void (*print)(void *, const char *, ...), void *priv)
133 {
134         print(priv, "Supported features of MS '%s':\n", sup->ms->name);
135         if (sup->r_gsm)
136                 print(priv, " R-GSM");
137         if (sup->e_gsm || sup->r_gsm)
138                 print(priv, " E-GSM");
139         if (sup->p_gsm || sup->p_gsm || sup->r_gsm)
140                 print(priv, " P-GSM");
141         if (sup->dcs_1800)
142                 print(priv, " DCS1800");
143         print(priv, "  (Phase %d mobile station)\n", sup->rev_lev + 1);
144         print(priv, " CECS     : %s\n", (sup->es_ind) ? "yes" : "no");
145         print(priv, " VGCS     : %s\n", (sup->vgcs) ? "yes" : "no");
146         print(priv, " VBS      : %s\n", (sup->vbs) ? "yes" : "no");
147         print(priv, " SMS      : %s\n", (sup->sms_ptp) ? "yes" : "no");
148         print(priv, " SS_IND   : %s\n", (sup->ss_ind) ? "yes" : "no");
149         print(priv, " PS_CAP   : %s\n", (sup->ps_cap) ? "yes" : "no");
150         print(priv, " CMSP     : %s\n", (sup->cmsp) ? "yes" : "no");
151         print(priv, " SoLSA    : %s\n", (sup->solsa) ? "yes" : "no");
152         print(priv, " LCSVA    : %s\n", (sup->lcsva) ? "yes" : "no");
153         print(priv, " LOC_SERV : %s\n", (sup->loc_serv) ? "yes" : "no");
154         print(priv, " A5/1     : %s\n", (sup->a5_1) ? "yes" : "no");
155         print(priv, " A5/2     : %s\n", (sup->a5_2) ? "yes" : "no");
156         print(priv, " A5/3     : %s\n", (sup->a5_3) ? "yes" : "no");
157         print(priv, " A5/4     : %s\n", (sup->a5_4) ? "yes" : "no");
158         print(priv, " A5/5     : %s\n", (sup->a5_5) ? "yes" : "no");
159         print(priv, " A5/6     : %s\n", (sup->a5_6) ? "yes" : "no");
160         print(priv, " A5/7     : %s\n", (sup->a5_7) ? "yes" : "no");
161         print(priv, " A5/1     : %s\n", (sup->a5_1) ? "yes" : "no");
162         print(priv, " Min RXLEV: %d\n", sup->min_rxlev_db);
163 }
164