summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIkjoon Jang <ikjn@google.com>2023-11-15 03:01:31 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-11-15 03:01:31 +0000
commit8dff6a9849fccf303a503c85c0a31417d372b2eb (patch)
tree24f0e2788522e2bc3cbb379b2730d18b03a5af94
parent8ef5cfd7df2dcc74e5e87e0aeccd6429a97096e1 (diff)
parent0aa6fa0d7048682d16357721b2b67a5e0745f7ec (diff)
downloaduwb-8dff6a9849fccf303a503c85c0a31417d372b2eb.tar.gz
extra calibrations: apply per-country calibrations on set-country-code am: 0aa6fa0d70
Original change: https://android-review.googlesource.com/c/platform/hardware/nxp/uwb/+/2807276 Change-Id: Ic94834e7ad6cfb45f3a63eefabeb29c7a16b911b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--halimpl/hal/phNxpUciHal.cc2
-rw-r--r--halimpl/hal/phNxpUciHal_ext.cc29
-rw-r--r--halimpl/hal/phNxpUciHal_ext.h4
-rw-r--r--halimpl/utils/phNxpConfig.cc13
4 files changed, 30 insertions, 18 deletions
diff --git a/halimpl/hal/phNxpUciHal.cc b/halimpl/hal/phNxpUciHal.cc
index b8f6390..212fdd0 100644
--- a/halimpl/hal/phNxpUciHal.cc
+++ b/halimpl/hal/phNxpUciHal.cc
@@ -298,7 +298,7 @@ bool phNxpUciHal_parse(uint16_t data_len, const uint8_t *p_data) {
if ((country_code[0] == '0') && (country_code[1] == '0')) {
NXPLOG_UCIHAL_D("Country code %c%c is Invalid!", country_code[0], country_code[1]);
} else {
- NxpConfig_SetCountryCode(country_code);
+ phNxpUciHal_handle_set_country_code(country_code);
}
// send country code response to upper layer
diff --git a/halimpl/hal/phNxpUciHal_ext.cc b/halimpl/hal/phNxpUciHal_ext.cc
index eb79bdf..3e18438 100644
--- a/halimpl/hal/phNxpUciHal_ext.cc
+++ b/halimpl/hal/phNxpUciHal_ext.cc
@@ -353,7 +353,7 @@ void phNxpUciHal_reset_country_code_config() {
* Returns void
*
*******************************************************************************/
-void phNxpUciHal_getCountryCaps(const uint8_t *cc_resp, const char country_code[2],
+static void phNxpUciHal_getCountryCaps(const uint8_t *cc_resp, const char country_code[2],
uint8_t *cc_data, uint32_t *retlen) {
uint16_t idx = 0;
uint16_t index = 0;
@@ -1277,11 +1277,14 @@ 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;
+
/******************************************************************************
* Function phNxpUciHal_handle_set_country_code
*
@@ -1295,4 +1298,28 @@ void phNxpUciHal_handle_set_country_code(const char country_code[2])
NXPLOG_UCIHAL_D("Apply country code %c%c", country_code[0], country_code[1]);
NxpConfig_SetCountryCode(country_code);
+
+ // Load 'COUNTRY_CODE_CAPS' and apply it to 'conf_map'
+ uint8_t cc_caps[UCI_MAX_DATA_LEN];
+ auto cc_data = std::make_unique<uint8_t[]>(UCI_MAX_DATA_LEN);
+ long retlen = 0;
+ if (NxpConfig_GetByteArray(NAME_NXP_UWB_COUNTRY_CODE_CAPS, cc_caps, sizeof(cc_caps), &retlen) && retlen) {
+ isCountryCodeMapCreated = false;
+
+ uint32_t cc_caps_len = retlen;
+ phNxpUciHal_getCountryCaps(cc_caps, country_code, cc_data.get(), &cc_caps_len);
+
+ if (get_conf_map(cc_data.get(), cc_caps_len)) {
+ isCountryCodeMapCreated = true;
+ NXPLOG_UCIHAL_D("Country code caps loaded");
+ }
+ }
+
+ // 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();
+ }
}
diff --git a/halimpl/hal/phNxpUciHal_ext.h b/halimpl/hal/phNxpUciHal_ext.h
index 7a753ce..d6b437c 100644
--- a/halimpl/hal/phNxpUciHal_ext.h
+++ b/halimpl/hal/phNxpUciHal_ext.h
@@ -66,8 +66,6 @@ typedef struct {
tHAL_UWB_STATUS phNxpUciHal_send_ext_cmd(uint16_t cmd_len, const uint8_t* p_cmd);
tHAL_UWB_STATUS phNxpUciHal_process_ext_rsp(uint16_t cmd_len, uint8_t* p_buff);
tHAL_UWB_STATUS phNxpUciHal_set_board_config();
-void phNxpUciHal_getCountryCaps(const uint8_t *cc_resp, const char country_code[2],
- uint8_t *cc_data, uint32_t *retlen);
void phNxpUciHal_processCalibParamTxPowerPerAntenna(const short conf_tx_power,
const uint8_t *p_data,
uint16_t data_len);
@@ -75,5 +73,5 @@ void phNxpUciHal_extcal_handle_coreinit(void);
bool phNxpUciHal_updateTxPower(short conf_tx_power);
bool phNxpUciHal_setCalibParamTxPower(short conf_tx_power);
void phNxpUciHal_process_response();
-
+void phNxpUciHal_handle_set_country_code(const char country_code[2]);
#endif /* _PHNXPNICHAL_EXT_H_ */
diff --git a/halimpl/utils/phNxpConfig.cc b/halimpl/utils/phNxpConfig.cc
index 9f32438..99f9d71 100644
--- a/halimpl/utils/phNxpConfig.cc
+++ b/halimpl/utils/phNxpConfig.cc
@@ -774,7 +774,6 @@ void CascadeConfig::init(const char *main_config)
}
}
-extern bool isCountryCodeMapCreated;
void CascadeConfig::setCountryCode(const char country_code[2])
{
string strCountry = mRegionMap.xlateCountryCode(country_code);
@@ -786,18 +785,6 @@ void CascadeConfig::setCountryCode(const char country_code[2])
x.dump();
}
}
-
- // Load 'COUNTRY_CODE_CAPS' and apply it to 'conf_map'
- auto cc_data = make_unique<uint8_t[]>(UCI_MAX_DATA_LEN);
- const uwbParam *param = mCapsConfig.find(NAME_NXP_UWB_COUNTRY_CODE_CAPS);
- if (param) {
- uint32_t retlen = param->arr_len();
- phNxpUciHal_getCountryCaps(param->arr_value(), country_code, cc_data.get(), &retlen);
- if (get_conf_map(cc_data.get(), retlen)) {
- isCountryCodeMapCreated = true;
- NXPLOG_UCIHAL_D("Country code caps loaded");
- }
- }
}
const uwbParam* CascadeConfig::find(const char *name) const