From 04ee8f63235ddf319d895064394caf6963f56289 Mon Sep 17 00:00:00 2001 From: "weifan.zhang" <weifan.zhang@mediatek.corp-partner.google.com> Date: Thu, 1 Feb 2024 13:44:37 +0800 Subject: [PATCH] [ALPS08619561] Add VSC Cmd for Mediatek chip [Description] Add VSC cmd for low latency mode CR-Id: ALPS08619561 Bug: 309700239 Test: m . Flag: EXEMPT VSC command Change-Id: I789b6bddfc6b5661430b399943d1288a7c52e988 --- system/stack/include/hcidefs.h | 2 +- system/stack/l2cap/l2c_utils.cc | 64 ++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/system/stack/include/hcidefs.h b/system/stack/include/hcidefs.h index a8ad4499bff..9cc8be39d5b 100644 --- a/system/stack/include/hcidefs.h +++ b/system/stack/include/hcidefs.h @@ -933,7 +933,7 @@ typedef struct { #define HCI_UNISOC_ACL_HIGH_PRIORITY 0xFF /* Parameter information for HCI_MTK_SET_ACL_PRIORITY */ -#define HCI_MTK_ACL_PRIORITY_PARAM_SIZE 1 +#define HCI_MTK_ACL_PRIORITY_PARAM_SIZE 4 #define HCI_MTK_SET_ACL_PRIORITY (0xFD95 | HCI_GRP_VENDOR_SPECIFIC) #define HCI_MTK_ACL_NORMAL_PRIORITY 0x00 #define HCI_MTK_ACL_HIGH_PRIORITY 0x01 diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc index 7b722f426a2..657b5b09975 100644 --- a/system/stack/l2cap/l2c_utils.cc +++ b/system/stack/l2cap/l2c_utils.cc @@ -2338,34 +2338,6 @@ static void l2cu_set_acl_priority_unisoc(tL2C_LCB* p_lcb, HCI_UNISOC_ACL_PRIORITY_PARAM_SIZE, command, NULL); } -/******************************************************************************* - * - * Function l2cu_set_acl_priority_latency_mtk - * - * Description Sends a VSC to set the ACL priority and recorded latency on - * Mediatek chip. - * - * Returns void - * - ******************************************************************************/ - -static void l2cu_set_acl_priority_latency_mtk(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 - LOG_INFO("Set ACL priority: High Priority Mode"); - vs_param = HCI_MTK_ACL_HIGH_PRIORITY; - } else { - // priority to normal - LOG_INFO("Set ACL priority: Normal Mode"); - vs_param = HCI_MTK_ACL_NORMAL_PRIORITY; - } - - BTM_VendorSpecificCommand(HCI_MTK_SET_ACL_PRIORITY, - HCI_MTK_ACL_PRIORITY_PARAM_SIZE, &vs_param, NULL); -} - /******************************************************************************* * * Function l2cu_set_acl_priority @@ -2410,10 +2382,6 @@ bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority, l2cu_set_acl_priority_unisoc(p_lcb, priority); break; - case LMP_COMPID_MEDIATEK: - l2cu_set_acl_priority_latency_mtk(p_lcb, priority); - break; - default: /* Not supported/required for other vendors */ break; @@ -2480,6 +2448,34 @@ static void l2cu_set_acl_latency_syna(tL2C_LCB* p_lcb, tL2CAP_LATENCY latency) { HCI_SYNA_ACL_PRIORITY_PARAM_SIZE, command, NULL); } +/******************************************************************************* + * + * Function l2cu_set_acl_latency_mtk + * + * Description Sends a VSC to set the ACL latency on Mediatek chip. + * + * Returns void + * + ******************************************************************************/ + +static void l2cu_set_acl_latency_mtk(tL2CAP_LATENCY latency) { + LOG_INFO("Set ACL latency: %s", + latency == L2CAP_LATENCY_LOW ? "Low Latancy" : "Normal Latency"); + + uint8_t command[HCI_MTK_ACL_PRIORITY_PARAM_SIZE]; + uint8_t* pp = command; + uint8_t vs_param = latency == L2CAP_LATENCY_LOW + ? HCI_MTK_ACL_HIGH_PRIORITY + : HCI_MTK_ACL_NORMAL_PRIORITY; + UINT8_TO_STREAM(pp, vs_param); + UINT8_TO_STREAM(pp, 0); + UINT16_TO_STREAM(pp, 0); //reserved bytes + + BTM_VendorSpecificCommand(HCI_MTK_SET_ACL_PRIORITY, + HCI_MTK_ACL_PRIORITY_PARAM_SIZE, command, NULL); +} + + /******************************************************************************* * * Function l2cu_set_acl_latency @@ -2512,6 +2508,10 @@ bool l2cu_set_acl_latency(const RawAddress& bd_addr, tL2CAP_LATENCY latency) { l2cu_set_acl_latency_syna(p_lcb, latency); break; + case LMP_COMPID_MEDIATEK: + l2cu_set_acl_latency_mtk(latency); + break; + default: /* Not supported/required for other vendors */ break; -- GitLab