From b97c809bf80c1c109b7d45c75ed6018db1e43d41 Mon Sep 17 00:00:00 2001 From: "Bhadouria, Aman" Date: Wed, 9 Oct 2024 05:01:25 +0000 Subject: [PATCH] Fix VTS loopback issue in bt hal and Add BT HFP support for TyP2 Cumilative commit for two Bsp Diffs: 1. Fix VTS loopback issue in bt hal: Send this NOCP HCI event from BT HAL to for ACL transcations during local loopback mode to pass VTS test cases. 2. Add BT HFP support for TyP2: Send sco handle during BT HFP sco call for Intel Bluetooth AX210 bt card (TyphoonPeak - Typ2) Tracked-On: OAM-126286 Signed-off-by: Gowtham Anandha Babu --- bluetooth/bluetooth_hci.cc | 41 ++++++++++++++++++++++++++++++++++++++ bluetooth/h4_protocol.cc | 4 +++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/bluetooth/bluetooth_hci.cc b/bluetooth/bluetooth_hci.cc index cc1abad..040e8a0 100644 --- a/bluetooth/bluetooth_hci.cc +++ b/bluetooth/bluetooth_hci.cc @@ -30,6 +30,8 @@ namespace implementation { static const uint8_t HCI_DATA_TYPE_COMMAND = 1; static const uint8_t HCI_DATA_TYPE_ACL = 2; static const uint8_t HCI_DATA_TYPE_SCO = 3; +static const uint16_t HCI_WRITE_LOCAL_LOOPBACK_OPCODE = 0x1802; +static bool isLocalLoopbackActive; class BluetoothDeathRecipient : public hidl_death_recipient { public: @@ -53,6 +55,26 @@ class BluetoothDeathRecipient : public hidl_death_recipient { BluetoothHci::BluetoothHci() : death_recipient_(new BluetoothDeathRecipient(this)) {} +void sendNOCPHciEvent(const hidl_vec& packet, + const ::android::sp& cb) { + //send NOCP for every ACL packet received on loopback mode + if (packet.size() > 2) { + hidl_vec nocp_packet (7); + nocp_packet[0] = 0x13; //HCI NOCP opcode + nocp_packet[1] = 0x05; //Length + nocp_packet[2] = 0x01; //No of handles + nocp_packet[3] = packet[0]; //acl handle (2b) + nocp_packet[4] = packet[1] & 0x0F; + nocp_packet[5] = 0x01; //No of cmpl pkts (2b) + nocp_packet[6] = 0x00; + + auto hidl_status = cb->hciEventReceived(nocp_packet); + if (!hidl_status.isOk()) { + ALOGE("VendorInterface -> Unable to call hciEventReceived()"); + } + } +} + Return BluetoothHci::initialize( const ::android::sp& cb) { ALOGI("BluetoothHci::initialize()"); @@ -64,6 +86,8 @@ Return BluetoothHci::initialize( death_recipient_->setHasDied(false); cb->linkToDeath(death_recipient_, 0); + isLocalLoopbackActive = false; + bool rc = VendorInterface::Initialize( [cb](bool status) { auto hidl_status = cb->initializationComplete( @@ -80,6 +104,8 @@ Return BluetoothHci::initialize( }, [cb](const hidl_vec& packet) { auto hidl_status = cb->aclDataReceived(packet); + if (isLocalLoopbackActive) + sendNOCPHciEvent(packet, cb); if (!hidl_status.isOk()) { ALOGE("VendorInterface -> Unable to call aclDataReceived()"); } @@ -110,11 +136,26 @@ Return BluetoothHci::initialize( Return BluetoothHci::close() { ALOGI("BluetoothHci::close()"); unlink_cb_(death_recipient_); + isLocalLoopbackActive = false; VendorInterface::Shutdown(); return Void(); } +void checkLocalLoopbackCmd(const hidl_vec& command) { + if (command.size() > 3 && + (((uint16_t)command[1] << 8) | command[0]) + == HCI_WRITE_LOCAL_LOOPBACK_OPCODE) { + ALOGI("LocalLoopbackCmd"); + if (command[3] == 0x01) { + isLocalLoopbackActive = true; + } else { + isLocalLoopbackActive = false; + } + } +} + Return BluetoothHci::sendHciCommand(const hidl_vec& command) { + checkLocalLoopbackCmd(command); sendDataToController(HCI_DATA_TYPE_COMMAND, command); return Void(); } diff --git a/bluetooth/h4_protocol.cc b/bluetooth/h4_protocol.cc index 1b29117..4463518 100644 --- a/bluetooth/h4_protocol.cc +++ b/bluetooth/h4_protocol.cc @@ -40,6 +40,7 @@ #define INTEL_PID_9560 0x0aaa // 9460/9560 also know as Jefferson Peak (JfP) #define INTEL_PID_AX201 0x0026 // AX201 also know as Harrison Peak (HrP) #define INTEL_PID_AX211 0x0033 // AX211 also know as GarfieldPeak (Gfp) +#define INTEL_PID_AX210 0x0032 // AX210 also know as TyphoonPeak (TyP2) #include #include @@ -88,7 +89,8 @@ bool H4Protocol::IsIntelController(uint16_t vid, uint16_t pid) { (pid == INTEL_PID_9260)|| (pid == INTEL_PID_9560)|| (pid == INTEL_PID_AX201)|| - (pid == INTEL_PID_AX211))) + (pid == INTEL_PID_AX211)|| + (pid == INTEL_PID_AX210))) return true; else return false;