From be32d26e703a0a12a9cf948a29da4607ec94398b Mon Sep 17 00:00:00 2001
From: Victor Liu <victorliu@google.com>
Date: Mon, 25 Apr 2022 14:15:21 -0700
Subject: [PATCH] uwb: update calibrations

update default calibration
update japan specific calibration
use japan specific calibration

Bug: 229426438
Signed-off-by: Victor Liu <victorliu@google.com>
Change-Id: Ifabe90d0b1361c64b588e032baeec49cc2184e7e
---
 device-cheetah.mk           |  4 +-
 uwb/UWB-calibration-jp.conf | 34 +++++++++++++++
 uwb/UWB-calibration.conf    | 82 ++++++++++++++++++-------------------
 uwb/uwb_calibration.mk      |  1 +
 4 files changed, 79 insertions(+), 42 deletions(-)
 create mode 100644 uwb/UWB-calibration-jp.conf

diff --git a/device-cheetah.mk b/device-cheetah.mk
index f02cd87b..9fe0aec9 100644
--- a/device-cheetah.mk
+++ b/device-cheetah.mk
@@ -31,8 +31,10 @@ include hardware/google/pixel/vibrator/cs40l26/device.mk
 include device/google/gs101/bluetooth/bluetooth.mk
 
 ifeq ($(filter factory_cheetah, $(TARGET_PRODUCT)),)
-include device/google/gs101/uwb/uwb.mk
+# The ordering of the two uwb makefiles ensures device specific calibration files
+# are used instead of platform (gs101) specific calibration files - b/230787474.
 include device/google/pantah/uwb/uwb_calibration.mk
+include device/google/gs101/uwb/uwb.mk
 endif
 
 $(call soong_config_set,lyric,tuning_product,cheetah)
diff --git a/uwb/UWB-calibration-jp.conf b/uwb/UWB-calibration-jp.conf
new file mode 100644
index 00000000..fc6af1d3
--- /dev/null
+++ b/uwb/UWB-calibration-jp.conf
@@ -0,0 +1,34 @@
+ant0.ch5.prf16.tx_power=0
+ant0.ch5.prf16.pg_delay=0
+ant0.ch5.prf64.tx_power=0
+ant0.ch5.prf64.pg_delay=0
+ant0.ch9.prf16.tx_power=0x56564856
+ant0.ch9.prf16.pg_delay=0x26
+ant0.ch9.prf64.tx_power=0x56564856
+ant0.ch9.prf64.pg_delay=0x26
+ant1.ch5.prf16.tx_power=0
+ant1.ch5.prf16.pg_delay=0
+ant1.ch5.prf64.tx_power=0
+ant1.ch5.prf64.pg_delay=0
+ant1.ch9.prf16.tx_power=0x36362c36
+ant1.ch9.prf16.pg_delay=0x26
+ant1.ch9.prf64.tx_power=0x36362c36
+ant1.ch9.prf64.pg_delay=0x26
+ant2.ch5.prf16.tx_power=0
+ant2.ch5.prf16.pg_delay=0
+ant2.ch5.prf64.tx_power=0
+ant2.ch5.prf64.pg_delay=0
+ant2.ch9.prf16.tx_power=0
+ant2.ch9.prf16.pg_delay=0
+ant2.ch9.prf64.tx_power=0
+ant2.ch9.prf64.pg_delay=0
+ant3.ch5.prf16.tx_power=0
+ant3.ch5.prf16.pg_delay=0
+ant3.ch5.prf64.tx_power=0
+ant3.ch5.prf64.pg_delay=0
+ant3.ch9.prf16.tx_power=0
+ant3.ch9.prf16.pg_delay=0
+ant3.ch9.prf64.tx_power=0
+ant3.ch9.prf64.pg_delay=0
+alternate_pulse_shape=0x01
+restricted_channels=0x20
diff --git a/uwb/UWB-calibration.conf b/uwb/UWB-calibration.conf
index 52a528d0..bdf14261 100644
--- a/uwb/UWB-calibration.conf
+++ b/uwb/UWB-calibration.conf
@@ -12,21 +12,21 @@
 [CCC]ap_coop_mode=1
 [CCC]antenna_selection=4
 ant0.ch5.prf16.ant_delay=16450
-ant0.ch5.prf16.tx_power=0
+ant0.ch5.prf16.tx_power=0x4F4F444F
 ant0.ch5.prf16.pg_count=0
-ant0.ch5.prf16.pg_delay=0
+ant0.ch5.prf16.pg_delay=0x26
 ant0.ch5.prf64.ant_delay=16450
-ant0.ch5.prf64.tx_power=0
+ant0.ch5.prf64.tx_power=0x4F4F444F
 ant0.ch5.prf64.pg_count=0
-ant0.ch5.prf64.pg_delay=0
+ant0.ch5.prf64.pg_delay=0x26
 ant0.ch9.prf16.ant_delay=16450
-ant0.ch9.prf16.tx_power=0
+ant0.ch9.prf16.tx_power=0x66665466
 ant0.ch9.prf16.pg_count=0
-ant0.ch9.prf16.pg_delay=0
+ant0.ch9.prf16.pg_delay=0x26
 ant0.ch9.prf64.ant_delay=16450
-ant0.ch9.prf64.tx_power=0
+ant0.ch9.prf64.tx_power=0x66665466
 ant0.ch9.prf64.pg_count=0
-ant0.ch9.prf64.pg_delay=0
+ant0.ch9.prf64.pg_delay=0x26
 ant0.port=0
 ant0.selector_gpio=7
 ant0.selector_gpio_value=0
@@ -39,13 +39,13 @@ ant1.ch5.prf64.tx_power=0
 ant1.ch5.prf64.pg_count=0
 ant1.ch5.prf64.pg_delay=0
 ant1.ch9.prf16.ant_delay=16450
-ant1.ch9.prf16.tx_power=0
+ant1.ch9.prf16.tx_power=0x62625062
 ant1.ch9.prf16.pg_count=0
-ant1.ch9.prf16.pg_delay=0
+ant1.ch9.prf16.pg_delay=0x26
 ant1.ch9.prf64.ant_delay=16450
-ant1.ch9.prf64.tx_power=0
+ant1.ch9.prf64.tx_power=0x62625062
 ant1.ch9.prf64.pg_count=0
-ant1.ch9.prf64.pg_delay=0
+ant1.ch9.prf64.pg_delay=0x26
 ant1.port=0
 ant1.selector_gpio=7
 ant1.selector_gpio_value=1
@@ -69,13 +69,13 @@ ant2.port=1
 ant2.selector_gpio=6
 ant2.selector_gpio_value=0
 ant3.ch5.prf16.ant_delay=16450
-ant3.ch5.prf16.tx_power=0
+ant3.ch5.prf16.tx_power=0x23231C23
 ant3.ch5.prf16.pg_count=0
-ant3.ch5.prf16.pg_delay=0
+ant3.ch5.prf16.pg_delay=0x20
 ant3.ch5.prf64.ant_delay=16450
-ant3.ch5.prf64.tx_power=0
+ant3.ch5.prf64.tx_power=0x23231C23
 ant3.ch5.prf64.pg_count=0
-ant3.ch5.prf64.pg_delay=0
+ant3.ch5.prf64.pg_delay=0x20
 ant3.ch9.prf16.ant_delay=16450
 ant3.ch9.prf16.tx_power=0
 ant3.ch9.prf16.pg_count=0
@@ -91,50 +91,50 @@ ant0.ant1.ch5.pdoa_offset=0
 ant0.ant1.ch9.pdoa_offset=0
 ant0.ant2.ch5.pdoa_offset=0
 ant0.ant2.ch9.pdoa_offset=0
-ant1.ant2.ch5.pdoa_offset=2173
-ant1.ant2.ch9.pdoa_offset=3555
+ant1.ant2.ch5.pdoa_offset=-2520
+ant1.ant2.ch9.pdoa_offset=1874
 ant0.ant3.ch5.pdoa_offset=0
 ant0.ant3.ch9.pdoa_offset=0
-ant1.ant3.ch5.pdoa_offset=3845
-ant1.ant3.ch9.pdoa_offset=647
+ant1.ant3.ch5.pdoa_offset=-3080
+ant1.ant3.ch9.pdoa_offset=3214
 ant2.ant3.ch5.pdoa_offset=0
 ant2.ant3.ch9.pdoa_offset=0
 ch5.pll_locking_code=0
 ch9.pll_locking_code=0
-ant1.ant2.ch5.pdoa_lut=3d:ea:7b:0a:66:ea:c3:09:a4:ea:0a:09:cd:ea:66:08:0a:eb:ae:07:33:eb:f6:06:48:eb:52:06:71:eb:9a:05:c3:eb:e1:04:e1:ec:29:04:c3:ef:85:03:a4:f4:cd:02:14:f8:14:02:b8:fa:5c:01:8f:fc:b8:00:e1:fe:00:00:48:01:48:ff:85:03:a4:fe:ae:05:ec:fd:00:08:33:fd:d7:09:7b:fc:85:0b:d7:fb:0a:0d:1f:fb:66:0e:66:fa:33:0f:ae:f9:00:10:0a:f9:a4:10:52:f8:1f:11:9a:f7:5c:11:f6:f6:9a:11:3d:f6:ae:11:85:f5
-ant1.ant2.ch9.pdoa_lut=c3:ed:7b:0a:29:ee:c3:09:3d:ee:0a:09:cd:ee:66:08:c3:ef:ae:07:f6:f0:f6:06:3d:f2:52:06:52:f2:9a:05:cd:f2:e1:04:5c:f3:29:04:c3:f3:85:03:b8:f4:cd:02:71:f7:14:02:52:fa:5c:01:85:fd:b8:00:00:00:00:00:0a:01:48:ff:5c:01:a4:fe:14:02:ec:fd:5c:03:33:fd:48:05:7b:fc:b8:06:d7:fb:14:08:1f:fb:33:09:66:fa:ec:09:ae:f9:3d:0a:0a:f9:0a:0b:52:f8:1f:0b:9a:f7:48:0b:f6:f6:85:0b:3d:f6:9a:0b:85:f5
-ant1.ant3.ch5.pdoa_lut=66:ec:7b:0a:e1:ec:c3:09:14:ee:0a:09:d7:ef:66:08:8f:f2:ae:07:00:f6:f6:06:cd:f6:52:06:33:f7:9a:05:d7:f7:e1:04:48:f9:29:04:33:fd:85:03:d7:fd:cd:02:3d:fe:14:02:ec:ff:5c:01:14:00:b8:00:3d:00:00:00:cd:02:48:ff:29:04:a4:fe:a4:04:ec:fd:85:05:33:fd:e1:06:7b:fc:b8:08:d7:fb:14:0a:1f:fb:e1:0a:66:fa:1f:0b:0a:f9:1f:0b:ae:f9:5c:0b:52:f8:c3:0b:9a:f7:52:0c:f6:f6:0a:0d:3d:f6:00:0e:85:f5
-ant1.ant3.ch9.pdoa_lut=0a:ef:7b:0a:c3:ef:c3:09:00:f0:0a:09:14:f0:66:08:7b:f0:ae:07:48:f1:f6:06:00:f2:52:06:c3:f3:9a:05:00:f6:e1:04:d7:f7:29:04:1f:f9:85:03:ae:f9:cd:02:e1:fa:14:02:e1:fc:5c:01:b8:fe:b8:00:c3:ff:00:00:00:02:48:ff:5c:05:a4:fe:52:08:ec:fd:14:0a:33:fd:e1:0a:7b:fc:14:0c:d7:fb:14:0e:1f:fb:1f:0f:66:fa:00:10:ae:f9:b8:10:0a:f9:29:12:52:f8:00:14:9a:f7:7b:16:f6:f6:d7:17:3d:f6:29:18:85:f5
+ant1.ant2.ch5.pdoa_lut=0a:f4:89:f5:d9:f4:3b:f6:c1:f5:ee:f6:df:f5:a0:f7:7f:f6:54:f8:dd:f6:06:f9:f2:f6:b8:f9:89:f7:6a:fa:d1:f7:1d:fb:54:f8:d1:fb:f0:f8:83:fc:46:fa:35:fd:b0:fb:e7:fd:23:fd:9c:fe:a2:fe:4e:ff:00:00:00:00:31:01:b2:00:a6:02:64:01:0a:04:19:02:52:05:cb:02:73:06:7d:03:cb:07:2f:04:be:08:e3:04:f8:09:96:05:39:0b:48:06:81:0c:fa:06:1b:0d:ac:07:87:0d:60:08:a0:0e:12:09:06:0f:c5:09:2d:0f:77:0a
+ant1.ant2.ch9.pdoa_lut=d7:ec:89:f5:d9:ed:3b:f6:73:ee:ee:f6:58:ef:a0:f7:73:f0:54:f8:f0:f1:06:f9:d7:f2:b8:f9:f6:f3:6a:fa:cf:f5:1d:fb:2d:f7:d1:fb:23:f8:83:fc:a4:f9:35:fd:4c:fb:e7:fd:cb:fc:9c:fe:33:fe:4e:ff:00:00:00:00:f6:01:b2:00:ba:03:64:01:83:05:19:02:21:07:cb:02:6d:08:7d:03:71:09:2f:04:ba:0a:e3:04:c3:0b:96:05:f0:0c:48:06:c7:0d:fa:06:77:0e:ac:07:42:0f:60:08:89:0f:12:09:87:10:c5:09:c7:10:77:0a
+ant1.ant3.ch5.pdoa_lut=89:f4:54:f8:a2:f4:a0:f7:ae:f4:89:f5:0a:f5:ee:f6:7d:f5:3b:f6:8d:f5:06:f9:0a:f7:b8:f9:9a:f7:6a:fa:fa:f7:1d:fb:68:f8:d1:fb:f0:f9:83:fc:fa:fb:35:fd:6d:fd:e7:fd:2f:fe:9c:fe:98:fe:4e:ff:00:00:00:00:1d:02:b2:00:2d:02:19:02:33:02:64:01:0a:03:cb:02:6f:04:7d:03:db:05:2f:04:85:07:e3:04:b0:08:96:05:06:09:48:06:71:09:fa:06:48:0a:ac:07:4e:0b:60:08:58:0c:c5:09:62:0c:12:09:c5:0c:77:0a
+ant1.ant3.ch9.pdoa_lut=4e:ec:89:f5:9c:ee:3b:f6:04:f0:ee:f6:44:f1:a0:f7:c3:f2:54:f8:54:f3:06:f9:4c:f4:b8:f9:12:f5:6a:fa:0a:f6:1d:fb:21:f7:d1:fb:19:f8:83:fc:79:f9:35:fd:ba:fa:e7:fd:73:fc:9c:fe:0e:fe:4e:ff:00:00:00:00:d7:00:b2:00:f6:01:64:01:21:04:19:02:60:04:cb:02:37:05:7d:03:0a:07:2f:04:c5:07:e3:04:fc:07:96:05:8f:08:48:06:b0:09:fa:06:39:0a:ac:07:c9:0a:60:08:58:0b:12:09:75:0b:77:0a:83:0b:c5:09
 xtal_trim=23
 temperature_reference=85
 smart_tx_power=1
 auto_sleep_margin=20000
 restricted_channels=0
-[HAL]aoa_capability=1
+[HAL]aoa_capability=2
 [HAL]ant_sets.ch5.range.rx_ant_set_nonranging = 6
-[HAL]ant_sets.ch5.range.rx_ant_set_ranging = 3
-[HAL]ant_sets.ch5.range.tx_ant_set_nonranging = 0
-[HAL]ant_sets.ch5.range.tx_ant_set_ranging = 0
-[HAL]ant_sets.ch5.azimuth.rx_ant_set_nonranging = 6
+[HAL]ant_sets.ch5.range.rx_ant_set_ranging = 6
+[HAL]ant_sets.ch5.range.tx_ant_set_nonranging = 6
+[HAL]ant_sets.ch5.range.tx_ant_set_ranging = 6
+[HAL]ant_sets.ch5.azimuth.rx_ant_set_nonranging = 3
 [HAL]ant_sets.ch5.azimuth.rx_ant_set_ranging = 3
 [HAL]ant_sets.ch5.azimuth.tx_ant_set_nonranging = 0
 [HAL]ant_sets.ch5.azimuth.tx_ant_set_ranging = 0
 [HAL]ant_sets.ch9.range.rx_ant_set_nonranging = 6
-[HAL]ant_sets.ch9.range.rx_ant_set_ranging = 3
-[HAL]ant_sets.ch9.range.tx_ant_set_nonranging = 0
-[HAL]ant_sets.ch9.range.tx_ant_set_ranging = 0
-[HAL]ant_sets.ch5.elevation.rx_ant_set_nonranging = 6
-[HAL]ant_sets.ch5.elevation.rx_ant_set_ranging = 1
+[HAL]ant_sets.ch9.range.rx_ant_set_ranging = 6
+[HAL]ant_sets.ch9.range.tx_ant_set_nonranging = 6
+[HAL]ant_sets.ch9.range.tx_ant_set_ranging = 6
+[HAL]ant_sets.ch5.elevation.rx_ant_set_nonranging = 4
+[HAL]ant_sets.ch5.elevation.rx_ant_set_ranging = 4
 [HAL]ant_sets.ch5.elevation.tx_ant_set_nonranging = 0
 [HAL]ant_sets.ch5.elevation.tx_ant_set_ranging = 0
-[HAL]ant_sets.ch9.elevation.rx_ant_set_nonranging = 6
-[HAL]ant_sets.ch9.elevation.rx_ant_set_ranging = 1
-[HAL]ant_sets.ch9.elevation.tx_ant_set_nonranging = 0
-[HAL]ant_sets.ch9.elevation.tx_ant_set_ranging = 0
-[HAL]ant_sets.ch9.azimuth.rx_ant_set_nonranging = 6
+[HAL]ant_sets.ch9.elevation.rx_ant_set_nonranging = 4
+[HAL]ant_sets.ch9.elevation.rx_ant_set_ranging = 4
+[HAL]ant_sets.ch9.elevation.tx_ant_set_nonranging = 4
+[HAL]ant_sets.ch9.elevation.tx_ant_set_ranging = 4
+[HAL]ant_sets.ch9.azimuth.rx_ant_set_nonranging = 3
 [HAL]ant_sets.ch9.azimuth.rx_ant_set_ranging = 3
-[HAL]ant_sets.ch9.azimuth.tx_ant_set_nonranging = 0
-[HAL]ant_sets.ch9.azimuth.tx_ant_set_ranging = 0
+[HAL]ant_sets.ch9.azimuth.tx_ant_set_nonranging = 3
+[HAL]ant_sets.ch9.azimuth.tx_ant_set_ranging = 3
 [HAL]minimum_system_offset_uwbtime0=500
 coex_gpio=4
 coex_delay_us=1000
diff --git a/uwb/uwb_calibration.mk b/uwb/uwb_calibration.mk
index dcc44c15..866a89a9 100644
--- a/uwb/uwb_calibration.mk
+++ b/uwb/uwb_calibration.mk
@@ -19,3 +19,4 @@ PRODUCT_COPY_FILES += \
     $(LOCAL_UWB_CAL_DIR)/UWB-calibration.conf:$(TARGET_COPY_OUT_VENDOR)/etc/UWB-calibration.conf \
     $(LOCAL_UWB_CAL_DIR)/UWB-calibration.conf:$(TARGET_COPY_OUT_VENDOR)/etc/UWB-calibration-unknown.conf \
     $(LOCAL_UWB_CAL_DIR)/UWB-calibration.conf:$(TARGET_COPY_OUT_VENDOR)/etc/UWB-calibration-default.conf \
+    $(LOCAL_UWB_CAL_DIR)/UWB-calibration-jp.conf:$(TARGET_COPY_OUT_VENDOR)/etc/UWB-calibration-jp.conf \
-- 
GitLab