mirror of https://gerrit.osmocom.org/libosmocore
gsm_utils: Define 4 upper bits as "flags" and mask them out in utility functions
This way those function don't care about the flags they don't know about Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
dab0287b3f
commit
2a471ee25d
|
@ -87,6 +87,7 @@ static inline int rach_max_trans_raw2val(int raw) {
|
||||||
|
|
||||||
#define ARFCN_PCS 0x8000
|
#define ARFCN_PCS 0x8000
|
||||||
#define ARFCN_UPLINK 0x4000
|
#define ARFCN_UPLINK 0x4000
|
||||||
|
#define ARFCN_FLAG_MASK 0xf000 /* Reserve the upper 5 bits for flags */
|
||||||
|
|
||||||
enum gsm_band gsm_arfcn2band(uint16_t arfcn);
|
enum gsm_band gsm_arfcn2band(uint16_t arfcn);
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,11 @@ void generate_backtrace()
|
||||||
|
|
||||||
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
|
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
|
||||||
{
|
{
|
||||||
if (arfcn & ARFCN_PCS)
|
int is_pcs = arfcn & ARFCN_PCS;
|
||||||
|
|
||||||
|
arfcn &= ~ARFCN_FLAG_MASK;
|
||||||
|
|
||||||
|
if (is_pcs)
|
||||||
return GSM_BAND_1900;
|
return GSM_BAND_1900;
|
||||||
else if (arfcn <= 124)
|
else if (arfcn <= 124)
|
||||||
return GSM_BAND_900;
|
return GSM_BAND_900;
|
||||||
|
@ -386,8 +390,11 @@ uint16_t gsm_arfcn2freq10(uint16_t arfcn, int uplink)
|
||||||
{
|
{
|
||||||
uint16_t freq10_ul;
|
uint16_t freq10_ul;
|
||||||
uint16_t freq10_dl;
|
uint16_t freq10_dl;
|
||||||
|
int is_pcs = arfcn & ARFCN_PCS;
|
||||||
|
|
||||||
if (arfcn & ARFCN_PCS) {
|
arfcn &= ~ARFCN_FLAG_MASK;
|
||||||
|
|
||||||
|
if (is_pcs) {
|
||||||
/* DCS 1900 */
|
/* DCS 1900 */
|
||||||
arfcn &= ~ARFCN_PCS;
|
arfcn &= ~ARFCN_PCS;
|
||||||
freq10_ul = 18502 + 2 * (arfcn-512);
|
freq10_ul = 18502 + 2 * (arfcn-512);
|
||||||
|
|
Loading…
Reference in New Issue