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

Commit 74e42acc authored by Myles Watson's avatar Myles Watson
Browse files

Use GD Controller for ACL sizes

Bug: 321273521
Test: mma -j32
Flag: EXEMPT, no logical change
Change-Id: I9c54d9eaf59ff750dba9c8f89eac6d6a315e1d46
parent 2b41e879
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -37,14 +37,12 @@ typedef struct controller_t {
  const uint8_t* (*get_ble_supported_states)(void);

  // Get the cached acl data sizes for the controller.
  uint16_t (*get_acl_data_size_classic)(void);
  uint16_t (*get_acl_data_size_ble)(void);
  uint16_t (*get_iso_data_size)(void);

  // Get the cached acl packet sizes for the controller.
  // This is a convenience function for the respective
  // acl data size + size of the acl header.
  uint16_t (*get_acl_packet_size_classic)(void);
  uint16_t (*get_acl_packet_size_ble)(void);
  uint16_t (*get_iso_packet_size)(void);

+0 −8
Original line number Diff line number Diff line
@@ -117,18 +117,12 @@ static const uint8_t* get_ble_supported_states(void) {
#define FORWARD_GETTER(type, legacy, gd) \
  static type legacy(void) { return gd; }

FORWARD_GETTER(uint16_t, get_acl_buffer_length,
               GetController()->GetAclPacketLength())
FORWARD_GETTER(uint16_t, get_le_buffer_length,
               GetController()->GetLeBufferSize().le_data_packet_length_)
FORWARD_GETTER(
    uint16_t, get_iso_buffer_length,
    GetController()->GetControllerIsoBufferSize().le_data_packet_length_)

static uint16_t get_acl_packet_size_classic(void) {
  return get_acl_buffer_length() + kHciDataPreambleSize;
}

static uint16_t get_acl_packet_size_ble(void) {
  return get_le_buffer_length() + kHciDataPreambleSize;
}
@@ -238,11 +232,9 @@ static const controller_t interface = {

    .get_ble_supported_states = get_ble_supported_states,

    .get_acl_data_size_classic = get_acl_buffer_length,
    .get_acl_data_size_ble = get_le_buffer_length,
    .get_iso_data_size = get_iso_buffer_length,

    .get_acl_packet_size_classic = get_acl_packet_size_classic,
    .get_acl_packet_size_ble = get_acl_packet_size_ble,
    .get_iso_packet_size = get_iso_packet_size,

+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ void BTM_reset_complete() {

  btm_pm_reset();

  l2c_link_init(controller->get_acl_buffer_count_classic());
  l2c_link_init(bluetooth::shim::GetController()->GetNumAclPacketBuffers());

  // setup the random number generator
  std::srand(std::time(nullptr));
+1 −1
Original line number Diff line number Diff line
@@ -117,11 +117,11 @@ class FakeBtStack {
    GetInterfaceToProfiles()->profileSpecific_HACK->GetHearingAidDeviceCount =
        []() { return 1; };

    test::mock::device_controller::acl_data_size_classic = 512;
    test::mock::device_controller::acl_data_size_ble = 512;
    test::mock::device_controller::iso_data_size = 512;
    test::mock::device_controller::ble_suggested_default_data_length = 512;
    ON_CALL(controller_, SupportsBle).WillByDefault(Return(true));
    ON_CALL(controller_, GetAclPacketLength).WillByDefault(Return(512));
    bluetooth::hci::testing::mock_controller_ = &controller_;
  }

+5 −3
Original line number Diff line number Diff line
@@ -970,10 +970,12 @@ void l2cu_send_peer_echo_rsp(tL2C_LCB* p_lcb, uint8_t signal_id,
  } else
    p_lcb->cur_echo_id = signal_id;

  constexpr int kHciDataPreambleSize = 4;
  uint16_t acl_data_size =
      controller_get_interface()->get_acl_data_size_classic();
      bluetooth::shim::GetController()->GetAclPacketLength();
  uint16_t acl_packet_size =
      controller_get_interface()->get_acl_packet_size_classic();
      bluetooth::shim::GetController()->GetAclPacketLength() +
      kHciDataPreambleSize;
  /* Don't return data if it does not fit in ACL and L2CAP MTU */
  maxlen = (L2CAP_CMD_BUF_SIZE > acl_packet_size)
               ? acl_data_size
@@ -3482,7 +3484,7 @@ void l2cu_set_acl_hci_header(BT_HDR* p_buf, tL2C_CCB* p_ccb) {
    }

    uint16_t acl_data_size =
        controller_get_interface()->get_acl_data_size_classic();
        bluetooth::shim::GetController()->GetAclPacketLength();
    /* The HCI transport will segment the buffers. */
    if (p_buf->len > acl_data_size) {
      UINT16_TO_STREAM(p, acl_data_size);
Loading