Support setting BT controller Low Latency mode
Support set acl priority and latency by sending vendor vsc.
Bug: 274551249
Bug: 257406628
Tag: #feature
Test: test on sink device support dynamic spatial audio
Change-Id: I6de957383e88df946fe65b5e7b6e77bd1fb5d521
diff --git a/system/stack/include/hcidefs.h b/system/stack/include/hcidefs.h
index dffa4c5..704f3b8 100644
--- a/system/stack/include/hcidefs.h
+++ b/system/stack/include/hcidefs.h
@@ -914,8 +914,9 @@
/* Parameter information for HCI_SYNA_SET_ACL_PRIORITY */
#define HCI_SYNA_ACL_PRIORITY_PARAM_SIZE 3
-#define HCI_SYNA_ACL_PRIORITY_LOW 0x00
-#define HCI_SYNA_ACL_PRIORITY_HIGH 0xFF
+#define HCI_SYNA_ACL_NORMAL_PRIORITY 0xF0
+#define HCI_SYNA_ACL_HIGH_PRIORITY 0xF2
+#define HCI_SYNA_ACL_HIGH_PRIORITY_LOW_LATENCY 0xF3
#define HCI_SYNA_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)
/*
diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc
index dc0e4a6..90926a7 100644
--- a/system/stack/l2cap/l2c_utils.cc
+++ b/system/stack/l2cap/l2c_utils.cc
@@ -2274,24 +2274,39 @@
/*******************************************************************************
*
- * Function l2cu_set_acl_priority_syna
+ * Function l2cu_set_acl_priority_latency_syna
*
- * Description Sends a VSC to set the ACL priority on Synaptics chip.
+ * Description Sends a VSC to set the ACL priority and recorded latency on
+ * Synaptics chip.
*
* Returns void
*
******************************************************************************/
-static void l2cu_set_acl_priority_syna(uint16_t handle,
- tL2CAP_PRIORITY priority) {
- uint8_t* pp;
- uint8_t command[HCI_SYNA_ACL_PRIORITY_PARAM_SIZE];
+static void l2cu_set_acl_priority_latency_syna(tL2C_LCB* p_lcb,
+ tL2CAP_PRIORITY priority) {
uint8_t vs_param;
+ if (priority == L2CAP_PRIORITY_HIGH) {
+ // priority to high, if using latency mode check preset latency
+ if (p_lcb->use_latency_mode &&
+ p_lcb->preset_acl_latency == L2CAP_LATENCY_LOW) {
+ LOG_INFO("Set ACL priority: High Priority and Low Latency Mode");
+ vs_param = HCI_SYNA_ACL_HIGH_PRIORITY_LOW_LATENCY;
+ p_lcb->set_latency(L2CAP_LATENCY_LOW);
+ } else {
+ LOG_INFO("Set ACL priority: High Priority Mode");
+ vs_param = HCI_SYNA_ACL_HIGH_PRIORITY;
+ }
+ } else {
+ // priority to normal
+ LOG_INFO("Set ACL priority: Normal Mode");
+ vs_param = HCI_SYNA_ACL_NORMAL_PRIORITY;
+ p_lcb->set_latency(L2CAP_LATENCY_NORMAL);
+ }
- pp = command;
- vs_param = (priority == L2CAP_PRIORITY_HIGH) ? HCI_SYNA_ACL_PRIORITY_HIGH
- : HCI_SYNA_ACL_PRIORITY_LOW;
- UINT16_TO_STREAM(pp, handle);
+ uint8_t command[HCI_SYNA_ACL_PRIORITY_PARAM_SIZE];
+ uint8_t* pp = command;
+ UINT16_TO_STREAM(pp, p_lcb->Handle());
UINT8_TO_STREAM(pp, vs_param);
BTM_VendorSpecificCommand(HCI_SYNA_SET_ACL_PRIORITY,
@@ -2335,7 +2350,7 @@
break;
case LMP_COMPID_SYNAPTICS:
- l2cu_set_acl_priority_syna(p_lcb->Handle(), priority);
+ l2cu_set_acl_priority_latency_syna(p_lcb, priority);
break;
default:
@@ -2380,6 +2395,32 @@
/*******************************************************************************
*
+ * Function l2cu_set_acl_latency_syna
+ *
+ * Description Sends a VSC to set the ACL latency on Synatics chip.
+ *
+ * Returns void
+ *
+ ******************************************************************************/
+
+static void l2cu_set_acl_latency_syna(tL2C_LCB* p_lcb, tL2CAP_LATENCY latency) {
+ LOG_INFO("Set ACL latency: %s",
+ latency == L2CAP_LATENCY_LOW ? "Low Latancy" : "Normal Latency");
+
+ uint8_t command[HCI_SYNA_ACL_PRIORITY_PARAM_SIZE];
+ uint8_t* pp = command;
+ uint8_t vs_param = latency == L2CAP_LATENCY_LOW
+ ? HCI_SYNA_ACL_HIGH_PRIORITY_LOW_LATENCY
+ : HCI_SYNA_ACL_HIGH_PRIORITY;
+ UINT16_TO_STREAM(pp, p_lcb->Handle());
+ UINT8_TO_STREAM(pp, vs_param);
+
+ BTM_VendorSpecificCommand(HCI_SYNA_SET_ACL_PRIORITY,
+ HCI_SYNA_ACL_PRIORITY_PARAM_SIZE, command, NULL);
+}
+
+/*******************************************************************************
+ *
* Function l2cu_set_acl_latency
*
* Description Sets the transmission latency for a channel.
@@ -2406,6 +2447,10 @@
l2cu_set_acl_latency_brcm(p_lcb, latency);
break;
+ case LMP_COMPID_SYNAPTICS:
+ l2cu_set_acl_latency_syna(p_lcb, latency);
+ break;
+
default:
/* Not supported/required for other vendors */
break;