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

Commit 99193f3f authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Move SCO functions out of ACL" into main

parents 220708d9 ec9e324b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@
#include "stack/btm/btm_int_types.h"
#include "stack/btm/btm_sco.h"
#include "stack/btm/btm_sco_hfp_hal.h"
#include "stack/include/acl_api.h"
#include "stack/include/btm_api.h"
#include "stack/include/main_thread.h"
#include "types/raw_address.h"
@@ -575,7 +574,7 @@ void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
    if (p_scb->sco_idx < BTM_MAX_SCO_LINKS)
      p_sco = &btm_cb.sco_cb.sco_db[p_scb->sco_idx];
    if (p_sco && (p_sco->esco.data.link_type == BTM_LINK_TYPE_SCO ||
                  !sco_peer_supports_esco_ev3(p_sco->esco.data.bd_addr))) {
                  !btm_peer_supports_esco_ev3(p_sco->esco.data.bd_addr))) {
      params = esco_parameters_for_codec(SCO_CODEC_CVSD_D1, offload);
    }

+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
#include "stack/btm/btm_int_types.h"
#include "test/mock/mock_device_esco_parameters.h"

bool sco_peer_supports_esco_ev3(const RawAddress& remote_bda) { return true; }
bool btm_peer_supports_esco_ev3(const RawAddress& remote_bda) { return true; }
tBTM_CB btm_cb;
LeAudioClient* LeAudioClient::Get() { return nullptr; }
namespace hfp_hal_interface {
+0 −33
Original line number Diff line number Diff line
@@ -2346,39 +2346,6 @@ const RawAddress acl_address_from_handle(uint16_t handle) {
  return p_acl->remote_addr;
}

bool sco_peer_supports_esco_2m_phy(const RawAddress& remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_EDR_ESCO_2MPS_SUPPORTED(features);
}

bool sco_peer_supports_esco_3m_phy(const RawAddress& remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_EDR_ESCO_3MPS_SUPPORTED(features);
}

bool sco_peer_supports_esco_ev3(const RawAddress& remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_ESCO_EV3_SUPPORTED(features);
}

bool acl_is_switch_role_idle(const RawAddress& bd_addr,
                             tBT_TRANSPORT transport) {
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bd_addr, transport);
+36 −3
Original line number Diff line number Diff line
@@ -504,17 +504,17 @@ static tBTM_STATUS btm_send_connect_request(uint16_t acl_handle,
    /* UPF25:  Only SCO was brought up in this case */
    const RawAddress bd_addr = acl_address_from_handle(acl_handle);
    if (bd_addr != RawAddress::kEmpty) {
      if (!sco_peer_supports_esco_2m_phy(bd_addr)) {
      if (!btm_peer_supports_esco_2m_phy(bd_addr)) {
        LOG_VERBOSE("BTM Remote does not support 2-EDR eSCO");
        temp_packet_types |=
            (ESCO_PKT_TYPES_MASK_NO_2_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5);
      }
      if (!sco_peer_supports_esco_3m_phy(bd_addr)) {
      if (!btm_peer_supports_esco_3m_phy(bd_addr)) {
        LOG_VERBOSE("BTM Remote does not support 3-EDR eSCO");
        temp_packet_types |=
            (ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV5);
      }
      if (!sco_peer_supports_esco_ev3(bd_addr)) {
      if (!btm_peer_supports_esco_ev3(bd_addr)) {
        LOG_VERBOSE("BTM Remote does not support EV3 eSCO");
        // If EV3 is not supported, EV4 and EV% are not supported, either.
        temp_packet_types &= ~BTM_ESCO_LINK_ONLY_MASK;
@@ -1749,3 +1749,36 @@ tBTM_SCO_DEBUG_DUMP BTM_GetScoDebugDump() {
  data->status_in_binary = pkt_status->data_to_binary_string();
  return debug_dump;
}

bool btm_peer_supports_esco_2m_phy(RawAddress remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_EDR_ESCO_2MPS_SUPPORTED(features);
}

bool btm_peer_supports_esco_3m_phy(RawAddress remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_EDR_ESCO_3MPS_SUPPORTED(features);
}

bool btm_peer_supports_esco_ev3(RawAddress remote_bda) {
  uint8_t* features = BTM_ReadRemoteFeatures(remote_bda);
  if (features == nullptr) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_ESCO_EV3_SUPPORTED(features);
}
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include "btm_sco_hfp_hal.h"
#include "device/include/esco_parameters.h"
#include "raw_address.h"
#include "stack/btm/sco_pkt_status.h"
#include "stack/include/btm_api_types.h"

@@ -306,3 +307,7 @@ void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle);

/* Send a SCO packet */
void btm_send_sco_packet(std::vector<uint8_t> data);

bool btm_peer_supports_esco_2m_phy(RawAddress remote_bda);
bool btm_peer_supports_esco_3m_phy(RawAddress remote_bda);
bool btm_peer_supports_esco_ev3(RawAddress remote_bda);
Loading