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

Commit 9a4a6ecc authored by Tom Huang's avatar Tom Huang Committed by Automerger Merge Worker
Browse files

Merge "Support setting BT controller Low Latency mode" am: f52ca077

parents 17009306 f52ca077
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -914,8 +914,9 @@ typedef struct {

/* 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)

/*
+56 −11
Original line number Diff line number Diff line
@@ -2274,24 +2274,39 @@ static void l2cu_set_acl_priority_latency_brcm(tL2C_LCB* p_lcb,

/*******************************************************************************
 *
 * 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,
static void l2cu_set_acl_priority_latency_syna(tL2C_LCB* p_lcb,
                                               tL2CAP_PRIORITY priority) {
  uint8_t* pp;
  uint8_t command[HCI_SYNA_ACL_PRIORITY_PARAM_SIZE];
  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 @@ bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
        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:
@@ -2378,6 +2393,32 @@ static void l2cu_set_acl_latency_brcm(tL2C_LCB* p_lcb, tL2CAP_LATENCY latency) {
                            HCI_BRCM_ACL_PRIORITY_PARAM_SIZE, command, NULL);
}

/*******************************************************************************
 *
 * 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
@@ -2406,6 +2447,10 @@ bool l2cu_set_acl_latency(const RawAddress& bd_addr, tL2CAP_LATENCY latency) {
        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;