summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPurnank H. G. <purnank@google.com>2024-04-10 20:26:35 +0800
committerPurnank G <purnank@google.com>2024-04-11 03:55:18 +0000
commit58a6841e6e5da23e761254585774f126f87ecc1a (patch)
treefc22e5a95805245a9cbfcb91a598931a8e2efce6
parentfa016935fc9953f24b14c9a6a690aae2d3acfcb6 (diff)
downloaduwb-58a6841e6e5da23e761254585774f126f87ecc1a.tar.gz
Handle Group Delay calibrated by D48/D49 in D50
D50 introduces a backward incompatibility for group delay. This patch implements work around for device calibrated with D48/49 and used with D48/49/50/on-wards. Bug: 330671454 Test: Range across fixed distance with D49/D50 Change-Id: I2d4573e305cb25aaef5f6fe6981b8bf154a4a689 Merged-In: I2d4573e305cb25aaef5f6fe6981b8bf154a4a689
-rw-r--r--halimpl/hal/phNxpUciHal_ext.cc8
-rw-r--r--halimpl/hal/sr1xx/NxpUwbChipSr1xx.cc47
-rw-r--r--halimpl/inc/NxpUwbChip.h5
3 files changed, 60 insertions, 0 deletions
diff --git a/halimpl/hal/phNxpUciHal_ext.cc b/halimpl/hal/phNxpUciHal_ext.cc
index e84f977..4c56a74 100644
--- a/halimpl/hal/phNxpUciHal_ext.cc
+++ b/halimpl/hal/phNxpUciHal_ext.cc
@@ -560,6 +560,13 @@ static void extcal_do_ant_delay(void)
// parameter: cal.ant<N>.ch<N>.ant_delay=X
// N(1) + N * {AntennaID(1), Rxdelay(Q14.2)}
if (n_rx_antennas) {
+
+ const int16_t extra_delay = nxpucihal_ctrl.uwb_chip->extra_group_delay();
+
+ if (extra_delay) {
+ NXPLOG_UCIHAL_D("RX_ANT_DELAY_CALIB: Extra compensation '%d'", extra_delay);
+ }
+
for (auto ch : cal_channels) {
std::vector<uint8_t> entries;
uint8_t n_entries = 0;
@@ -576,6 +583,7 @@ static void extcal_do_ant_delay(void)
if (!NxpConfig_GetNum(key, &delay_value, 2))
continue;
+ delay_value = delay_value + extra_delay;
NXPLOG_UCIHAL_D("Apply RX_ANT_DELAY_CALIB: %s = %u", key, delay_value);
entries.push_back(ant_id);
// Little Endian
diff --git a/halimpl/hal/sr1xx/NxpUwbChipSr1xx.cc b/halimpl/hal/sr1xx/NxpUwbChipSr1xx.cc
index 3dd0955..32c65b0 100644
--- a/halimpl/hal/sr1xx/NxpUwbChipSr1xx.cc
+++ b/halimpl/hal/sr1xx/NxpUwbChipSr1xx.cc
@@ -421,6 +421,7 @@ public:
device_type_t get_device_type(const uint8_t *param, size_t param_len);
tHAL_UWB_STATUS read_otp(extcal_param_id_t id, uint8_t *data, size_t data_len, size_t *retlen);
tHAL_UWB_STATUS apply_calibration(extcal_param_id_t id, const uint8_t ch, const uint8_t *data, size_t data_len);
+ int16_t extra_group_delay(void);
private:
tHAL_UWB_STATUS check_binding();
@@ -629,6 +630,52 @@ tHAL_UWB_STATUS NxpUwbChipSr1xx::apply_calibration(extcal_param_id_t id, const u
return sr1xx_apply_calibration(id, ch, data, data_len);
}
+int16_t NxpUwbChipSr1xx::extra_group_delay(void) {
+ bool need_7cm_offset = FALSE;
+ // + Compensation for D48/D49 calibration
+ // If calibration was done with D48 / D49
+ char calibrated_with_fw[15] = {0};
+
+ int has_calibrated_with_fw_config = NxpConfig_GetStr(
+ "cal.fw_version", calibrated_with_fw, sizeof(calibrated_with_fw) - 1);
+
+ if ( has_calibrated_with_fw_config ) {
+ // Conf file has entry of `cal.fw_version`
+ if (
+ ( 0 == memcmp("48.", calibrated_with_fw, 3)) ||
+ ( 0 == memcmp("49.", calibrated_with_fw, 3))) {
+ // Calibrated with D48 / D49.
+ if (nxpucihal_ctrl.fw_version.major_version == 0xFF) {
+ // Current FW seems to be Test FW
+ NXPLOG_UCIHAL_W("For Test FW, D49 -> D50+ 7cm Compensation is applied");
+ need_7cm_offset = TRUE;
+ }
+ else if (nxpucihal_ctrl.fw_version.major_version >= 0x50) {
+ // D50 and later fix is needed.
+ need_7cm_offset = TRUE;
+ }
+ }
+ else
+ {
+ // Not calibrated with D48/D49
+ }
+ }
+ else
+ {
+ // Missing Entry cal.fw_version
+ NXPLOG_UCIHAL_W("Could not get cal.fw_version. Assuming D48 used for calibration.");
+ need_7cm_offset = TRUE;
+ }
+ if (need_7cm_offset) {
+ /* Its Q14.2 format, hence << 2 */
+ return (7 << 2);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
std::unique_ptr<NxpUwbChip> GetUwbChip()
{
return std::make_unique<NxpUwbChipSr1xx>();
diff --git a/halimpl/inc/NxpUwbChip.h b/halimpl/inc/NxpUwbChip.h
index 25ac505..52979a5 100644
--- a/halimpl/inc/NxpUwbChip.h
+++ b/halimpl/inc/NxpUwbChip.h
@@ -71,6 +71,11 @@ public:
const uint8_t ch,
const uint8_t *data,
size_t data_len) = 0;
+
+ // Group Delay Compensation, if any
+ // SR1XX needs this, because it has
+ // different handling during calibration with D48/D49 vs D50
+ virtual int16_t extra_group_delay() = 0;
};
std::unique_ptr<NxpUwbChip> GetUwbChip();