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

Commit 92821b8c authored by inocen.liu's avatar inocen.liu
Browse files

Use VSC to set the link priority for Unisoc BT chip



Set ACL Priority via VSC for Unisoc BT chip

Change-Id: I1c8305324f143f033ef00cb9dc2990fb6bf5b326
Signed-off-by: default avatarinocen.liu <inocen.liu@unisoc.com>
parent 22ee677a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -912,6 +912,9 @@ typedef struct {
// TODO Remove this once all QTI specific hacks are removed.
#define LMP_COMPID_QTI 0x001D

// TODO Remove this once all UNISOC specific hacks are removed.
#define LMP_COMPID_UNISOC 0x073F

/* Parameter information for HCI_SYNA_SET_ACL_PRIORITY */
#define HCI_SYNA_ACL_PRIORITY_PARAM_SIZE 3
#define HCI_SYNA_ACL_NORMAL_PRIORITY 0xF0
@@ -919,6 +922,12 @@ typedef struct {
#define HCI_SYNA_ACL_HIGH_PRIORITY_LOW_LATENCY 0xF3
#define HCI_SYNA_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)

/* Parameter information for HCI_UNISOC_SET_ACL_PRIORITY */
#define HCI_UNISOC_ACL_PRIORITY_PARAM_SIZE 3
#define HCI_UNISOC_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)
#define HCI_UNISOC_ACL_NORMAL_PRIORITY 0x00
#define HCI_UNISOC_ACL_HIGH_PRIORITY 0xFF

/*
 * Define packet size
*/
+36 −0
Original line number Diff line number Diff line
@@ -2313,6 +2313,38 @@ static void l2cu_set_acl_priority_latency_syna(tL2C_LCB* p_lcb,
                            HCI_SYNA_ACL_PRIORITY_PARAM_SIZE, command, NULL);
}

/*******************************************************************************
 *
 * Function         l2cu_set_acl_priority_unisoc
 *
 * Description      Sends a VSC to set the ACL priority on Unisoc chip.
 *
 * Returns          void
 *
 ******************************************************************************/

static void l2cu_set_acl_priority_unisoc(tL2C_LCB* p_lcb,
                                               tL2CAP_PRIORITY priority) {
  uint8_t vs_param;
  if (priority == L2CAP_PRIORITY_HIGH) {
    // priority to high
    LOG_INFO("Set ACL priority: High Priority Mode");
    vs_param = HCI_UNISOC_ACL_HIGH_PRIORITY;
  } else {
    // priority to normal
    LOG_INFO("Set ACL priority: Normal Mode");
    vs_param = HCI_UNISOC_ACL_NORMAL_PRIORITY;
  }

  uint8_t command[HCI_UNISOC_ACL_PRIORITY_PARAM_SIZE];
  uint8_t* pp = command;
  UINT16_TO_STREAM(pp, p_lcb->Handle());
  UINT8_TO_STREAM(pp, vs_param);

  BTM_VendorSpecificCommand(HCI_UNISOC_SET_ACL_PRIORITY,
                            HCI_UNISOC_ACL_PRIORITY_PARAM_SIZE, command, NULL);
}

/*******************************************************************************
 *
 * Function         l2cu_set_acl_priority
@@ -2353,6 +2385,10 @@ bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
        l2cu_set_acl_priority_latency_syna(p_lcb, priority);
        break;

      case LMP_COMPID_UNISOC:
        l2cu_set_acl_priority_unisoc(p_lcb, priority);
        break;

      default:
        /* Not supported/required for other vendors */
        break;