diff options
author | Ikjoon Jang <ikjn@google.com> | 2023-10-26 10:43:00 +0000 |
---|---|---|
committer | Ikjoon Jang <ikjn@google.com> | 2023-11-14 02:02:17 +0000 |
commit | 684e80acf0e3761a501098cf14c0d740ca23a6d1 (patch) | |
tree | e977005d2a571c96271b0b1df4d54d8c1292305d | |
parent | ad5230a15fa1fceb86477af18fe158c2b121ef4c (diff) | |
download | uwb-684e80acf0e3761a501098cf14c0d740ca23a6d1.tar.gz |
extra calibrations: apply per-country restrictions
Apply `cal.restricted_channels` and `cal.uwb_disable` from
set-country-code handler. extra calibrations of `cal.xxx` are only
applied when COUNTRY_CODE_CAPS is not supplied.
Define restricted_channel_mask instead of two boolean values for channel
5 and 9 restrictions in phNxpUciHal_Runtime_Settings_t.
Bug: 277025402
Test: check logcat
Change-Id: I06ad38547cadf812f57d9705a9a5d1432cbbddd0
-rw-r--r-- | halimpl/hal/phNxpUciHal.cc | 4 | ||||
-rw-r--r-- | halimpl/hal/phNxpUciHal.h | 3 | ||||
-rw-r--r-- | halimpl/hal/phNxpUciHal_ext.cc | 71 |
3 files changed, 54 insertions, 24 deletions
diff --git a/halimpl/hal/phNxpUciHal.cc b/halimpl/hal/phNxpUciHal.cc index f2804d3..52226d7 100644 --- a/halimpl/hal/phNxpUciHal.cc +++ b/halimpl/hal/phNxpUciHal.cc @@ -325,8 +325,8 @@ bool phNxpUciHal_parse(uint16_t data_len, const uint8_t *p_data) if (tagId == UCI_PARAM_ID_CHANNEL_NUMBER) { ch = p_data[index]; - if (((ch == CHANNEL_NUM_5) && !rt_set->channel_5_support) || - ((ch == CHANNEL_NUM_9) && !rt_set->channel_9_support)) { + if (((ch == CHANNEL_NUM_5) && (rt_set->restricted_channel_mask & (1 << 5))) || + ((ch == CHANNEL_NUM_9) && (rt_set->restricted_channel_mask & (1 << 9)))) { NXPLOG_UCIHAL_D("Country code blocked channel %u", ch); // send setAppConfig response with COUNTRY_CODE_BLOCKED response diff --git a/halimpl/hal/phNxpUciHal.h b/halimpl/hal/phNxpUciHal.h index e103e93..7297032 100644 --- a/halimpl/hal/phNxpUciHal.h +++ b/halimpl/hal/phNxpUciHal.h @@ -156,8 +156,7 @@ typedef struct { } phNxpUciHal_FW_Version_t; typedef struct { - bool channel_5_support; - bool channel_9_support; + uint16_t restricted_channel_mask; bool uwb_enable; short tx_power_offset; // From UWB_COUNTRY_CODE_CAPS } phNxpUciHal_Runtime_Settings_t; diff --git a/halimpl/hal/phNxpUciHal_ext.cc b/halimpl/hal/phNxpUciHal_ext.cc index 8be6b20..5a312b3 100644 --- a/halimpl/hal/phNxpUciHal_ext.cc +++ b/halimpl/hal/phNxpUciHal_ext.cc @@ -331,6 +331,21 @@ tHAL_UWB_STATUS phNxpUciHal_process_ext_rsp(uint16_t rsp_len, uint8_t* p_buff){ static bool phNxpUciHal_setCalibParamTxPower(void); /******************************************************************************* + * Function phNxpUciHal_resetRuntimeSettings + * + * Description reset per-country code settigs to default + * + *******************************************************************************/ +static void phNxpUciHal_resetRuntimeSettings(void) +{ + phNxpUciHal_Runtime_Settings_t *rt_set = &nxpucihal_ctrl.rt_settings; + rt_set->uwb_enable = true; + rt_set->restricted_channel_mask = 0; + rt_set->tx_power_offset = 0; + +} + +/******************************************************************************* * Function phNxpUciHal_applyCountryCaps * * Description Creates supported channel's and Tx power TLV format for @@ -345,11 +360,7 @@ static void phNxpUciHal_applyCountryCaps(const char country_code[2], { phNxpUciHal_Runtime_Settings_t *rt_set = &nxpucihal_ctrl.rt_settings; - // reset country code config to default - rt_set->uwb_enable = true; - rt_set->channel_5_support = 1; - rt_set->channel_9_support = 1; - rt_set->tx_power_offset = 0; + phNxpUciHal_resetRuntimeSettings(); uint16_t idx = 1; // first byte = number countries bool country_code_found = false; @@ -367,14 +378,14 @@ static void phNxpUciHal_applyCountryCaps(const char country_code[2], } break; case CHANNEL_5_TAG: - if (len == 1) { - rt_set->channel_5_support = cc_resp[idx]; + if (len == 1 && !cc_resp[idx]) { + rt_set->restricted_channel_mask |= 1<< 5; NXPLOG_UCIHAL_D("CountryCaps channel 5 support = %u", cc_resp[idx]); } break; case CHANNEL_9_TAG: - if (len == 1) { - rt_set->channel_9_support = cc_resp[idx]; + if (len == 1 && !cc_resp[idx]) { + rt_set->restricted_channel_mask |= 1<< 9; NXPLOG_UCIHAL_D("CountryCaps channel 9 support = %u", cc_resp[idx]); } break; @@ -398,15 +409,15 @@ static void phNxpUciHal_applyCountryCaps(const char country_code[2], // consist up 'cc_data' TLVs uint8_t fira_channels = 0xff; - if (!rt_set->channel_5_support) + if (rt_set->restricted_channel_mask & (1 << 5)) fira_channels &= CHANNEL_5_MASK; - if (!rt_set->channel_9_support) + if (rt_set->restricted_channel_mask & (1 << 9)) fira_channels &= CHANNEL_9_MASK; uint8_t ccc_channels = 0; - if (rt_set->channel_5_support) + if (!(rt_set->restricted_channel_mask & (1 << 5))) ccc_channels |= 0x01; - if (rt_set->channel_9_support) + if (!(rt_set->restricted_channel_mask & (1 << 9))) ccc_channels |= 0x02; uint8_t index = 0; @@ -1226,6 +1237,25 @@ static void extcal_do_tx_base_band(void) } } +static void extcal_do_restrictions(void) +{ + phNxpUciHal_Runtime_Settings_t *rt_set = &nxpucihal_ctrl.rt_settings; + + phNxpUciHal_resetRuntimeSettings(); + + uint16_t mask= 0; + if (NxpConfig_GetNum("cal.restricted_channels", &mask, sizeof(mask))) { + NXPLOG_UCIHAL_D("Restriction flag, restricted channel mask=0x%x", mask); + rt_set->restricted_channel_mask = mask; + } + + uint8_t uwb_disable = 0; + if (NxpConfig_GetNum("cal.uwb_disable", &uwb_disable, sizeof(uwb_disable))) { + NXPLOG_UCIHAL_D("Restriction flag, uwb_disable=%u", uwb_disable); + rt_set->uwb_enable = !uwb_disable; + } +} + /****************************************************************************** * Function phNxpUciHal_extcal_handle_coreinit * @@ -1250,10 +1280,6 @@ void phNxpUciHal_extcal_handle_coreinit(void) extcal_do_xtal(); extcal_do_ant_delay(); - - extcal_do_tx_power(); - extcal_do_tx_pulse_shape(); - extcal_do_tx_base_band(); } extern bool isCountryCodeMapCreated; @@ -1295,8 +1321,13 @@ void phNxpUciHal_handle_set_country_code(const char country_code[2]) // per-country extra calibrations are only triggered when 'COUNTRY_CODE_CAPS' is not provided if (!isCountryCodeMapCreated) { NXPLOG_UCIHAL_D("Apply per-country extra calibrations"); - extcal_do_tx_power(); - extcal_do_tx_pulse_shape(); - extcal_do_tx_base_band(); + extcal_do_restrictions(); + + phNxpUciHal_Runtime_Settings_t *rt_set = &nxpucihal_ctrl.rt_settings; + if (rt_set->uwb_enable) { + extcal_do_tx_power(); + extcal_do_tx_pulse_shape(); + extcal_do_tx_base_band(); + } } } |