Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78b3684e authored by Weifan's avatar Weifan Committed by Edward Wang
Browse files

BT: Add Low latency flow for Mediatek BT Chip

Description:
Use VSC to set link priority for Mediatek chip

Bug: 309700239
Test: m .
Flag: EXEMPT VSC command

Change-Id: Iccbb40416f938cffd2fdffa6452f994cfb99507d
parent dcd1cd7e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -916,6 +916,9 @@ typedef struct {
// TODO Remove this once all UNISOC specific hacks are removed.
#define LMP_COMPID_UNISOC 0x073F

// TODO Remove this once all Mediatek specific hacks are removed.
#define LMP_COMPID_MEDIATEK 0x0046

/* Parameter information for HCI_SYNA_SET_ACL_PRIORITY */
#define HCI_SYNA_ACL_PRIORITY_PARAM_SIZE 3
#define HCI_SYNA_ACL_NORMAL_PRIORITY 0xF0
@@ -929,6 +932,12 @@ typedef struct {
#define HCI_UNISOC_ACL_NORMAL_PRIORITY 0x00
#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_SET_ACL_PRIORITY (0xFD95 | HCI_GRP_VENDOR_SPECIFIC)
#define HCI_MTK_ACL_NORMAL_PRIORITY 0x00
#define HCI_MTK_ACL_HIGH_PRIORITY 0x01

/*
 * Define packet size
*/
+32 −0
Original line number Diff line number Diff line
@@ -2335,6 +2335,34 @@ 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
@@ -2379,6 +2407,10 @@ 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;