FreeCalypso > hg > fc-rfcal-tools
annotate cmu200/band.c @ 132:94e8a410d6bd
fc-rfcal-txcheck: pass PCL to tester (txpwr-cal-pcl)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 20 Dec 2021 03:52:01 +0000 |
parents | e2db512abbee |
children |
rev | line source |
---|---|
2
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Our band and ARFCN tables and lookup code live here. |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <string.h> |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <strings.h> |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "band.h" |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "secaddr.h" |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 struct arfcn_range band850_arfcn_range = {128, 251, 824200, 869200}; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 struct arfcn_range band900_arfcn_range = { 0, 124, 890000, 935000}; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 struct arfcn_range band900_arfcn_range_ext = {975, 1023, 880200, 925200}; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 struct arfcn_range band1800_arfcn_range = {512, 885, 1710200, 1805200}; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 struct arfcn_range band1900_arfcn_range = {512, 810, 1850200, 1930200}; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 struct band supported_bands[] = { |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 {"850", SECADDR_GSM850MS_NSIG, &band850_arfcn_range, 0}, |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 {"900", SECADDR_GSM900MS_NSIG, &band900_arfcn_range, |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 &band900_arfcn_range_ext}, |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 {"1800", SECADDR_GSM1800MS_NSIG, &band1800_arfcn_range, 0}, |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {"1900", SECADDR_GSM1900MS_NSIG, &band1900_arfcn_range, 0}, |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {0, 0, 0, 0} |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 }; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct band *current_band; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 find_named_band(srchname) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 char *srchname; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 struct band *band; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 for (band = supported_bands; band->name; band++) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 if (!strcmp(band->name, srchname)) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 break; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 if (!band->name) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return(-1); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 current_band = band; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return(0); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 check_arfcn_range(range, arfcn, ulp, dlp) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 struct arfcn_range *range; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 unsigned arfcn, *ulp, *dlp; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 { |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (arfcn < range->min) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(-1); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 if (arfcn > range->max) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 return(-1); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (ulp) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 *ulp = range->ul_khz + (arfcn - range->min) * 200; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (dlp) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 *dlp = range->dl_khz + (arfcn - range->min) * 200; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return(0); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 verify_arfcn(arfcn, ulp, dlp) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 unsigned arfcn, *ulp, *dlp; |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 { |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (!check_arfcn_range(current_band->arfcn_range, arfcn, ulp, dlp)) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 return(0); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 if (current_band->arfcn_range_ext && |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 !check_arfcn_range(current_band->arfcn_range_ext, arfcn, ulp, dlp)) |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 return(0); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 return(-1); |
e2db512abbee
fc-cmu200d: band and ARFCN tables implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |