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

Commit 21cfc8bc authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Use VSC to set the link priority for Synaptics BT chip.

Bug: 237505469
Test: Start A2DP streaming
Ignore-AOSP-First: Change specific to the tablet project
Change-Id: I02f97b8352ac716c76e78e2e4e9e6b58ff58c113
parent 30049002
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -897,6 +897,15 @@ typedef struct {
// TODO(zachoverflow): remove this once broadcom specific hacks are removed
#define LMP_COMPID_BROADCOM 15

// TODO: Remove this once Synaptics specific code is removed
#define LMP_COMPID_SYNAPTICS 0x0A76

/* 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_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)

/*
 * Define packet size
*/
+68 −21
Original line number Diff line number Diff line
@@ -2212,6 +2212,58 @@ bool l2cu_lcb_disconnecting(void) {
  return status;
}

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

static void l2cu_set_acl_priority_brcm(uint16_t handle,
                                       tL2CAP_PRIORITY priority) {
  uint8_t* pp;
  uint8_t command[HCI_BRCM_ACL_PRIORITY_PARAM_SIZE];
  uint8_t vs_param;

  pp = command;
  vs_param = (priority == L2CAP_PRIORITY_HIGH) ? HCI_BRCM_ACL_PRIORITY_HIGH
                                               : HCI_BRCM_ACL_PRIORITY_LOW;
  UINT16_TO_STREAM(pp, handle);
  UINT8_TO_STREAM(pp, vs_param);

  BTM_VendorSpecificCommand(HCI_BRCM_SET_ACL_PRIORITY,
                            HCI_BRCM_ACL_PRIORITY_PARAM_SIZE, command, NULL);
}

/*******************************************************************************
 *
 * Function         l2cu_set_acl_priority_syna
 *
 * Description      Sends a VSC to set the ACL priority 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];
  uint8_t vs_param;

  pp = command;
  vs_param = (priority == L2CAP_PRIORITY_HIGH) ? HCI_SYNA_ACL_PRIORITY_HIGH
                                               : HCI_SYNA_ACL_PRIORITY_LOW;
  UINT16_TO_STREAM(pp, 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_priority
@@ -2227,9 +2279,6 @@ bool l2cu_lcb_disconnecting(void) {
bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
                           bool reset_after_rs) {
  tL2C_LCB* p_lcb;
  uint8_t* pp;
  uint8_t command[HCI_BRCM_ACL_PRIORITY_PARAM_SIZE];
  uint8_t vs_param;

  APPL_TRACE_EVENT("SET ACL PRIORITY %d", priority);

@@ -2240,24 +2289,22 @@ bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
    return (false);
  }

  if (controller_get_interface()->get_bt_version()->manufacturer ==
      LMP_COMPID_BROADCOM) {
    /* Called from above L2CAP through API; send VSC if changed */
  /* Link priority is set if:
   * 1. Change in priority requested from above L2CAP through API, Or
   * 2. High priority requested because of central/peripheral role switch */
  if ((!reset_after_rs && (priority != p_lcb->acl_priority)) ||
        /* Called because of a central/peripheral role switch; if high resend
           VSC */
      (reset_after_rs && p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)) {
      pp = command;

      vs_param = (priority == L2CAP_PRIORITY_HIGH) ? HCI_BRCM_ACL_PRIORITY_HIGH
                                                   : HCI_BRCM_ACL_PRIORITY_LOW;

      UINT16_TO_STREAM(pp, p_lcb->Handle());
      UINT8_TO_STREAM(pp, vs_param);

      BTM_VendorSpecificCommand(HCI_BRCM_SET_ACL_PRIORITY,
                                HCI_BRCM_ACL_PRIORITY_PARAM_SIZE, command,
                                NULL);
    /* Use vendor specific commands to set the link priority */
    switch (controller_get_interface()->get_bt_version()->manufacturer) {
      case LMP_COMPID_BROADCOM:
        l2cu_set_acl_priority_brcm(p_lcb->Handle(), priority);
        break;
      case LMP_COMPID_SYNAPTICS:
        l2cu_set_acl_priority_syna(p_lcb->Handle(), priority);
        break;
      default:
        /* Not supported/required for other vendors */
        break;
    }
  }