Skip to content

Commit

Permalink
Fix VTS loopback issue in bt hal and Add BT HFP support for TyP2
Browse files Browse the repository at this point in the history
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 <gowtham.anandha.babu@intel.com>
  • Loading branch information
AmanBh0709 authored and sysopenci committed Oct 11, 2024
1 parent c7fec22 commit b97c809
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions bluetooth/bluetooth_hci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -53,6 +55,26 @@ class BluetoothDeathRecipient : public hidl_death_recipient {
BluetoothHci::BluetoothHci()
: death_recipient_(new BluetoothDeathRecipient(this)) {}

void sendNOCPHciEvent(const hidl_vec<uint8_t>& packet,
const ::android::sp<IBluetoothHciCallbacks>& cb) {
//send NOCP for every ACL packet received on loopback mode
if (packet.size() > 2) {
hidl_vec<uint8_t> 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<void> BluetoothHci::initialize(
const ::android::sp<IBluetoothHciCallbacks>& cb) {
ALOGI("BluetoothHci::initialize()");
Expand All @@ -64,6 +86,8 @@ Return<void> 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(
Expand All @@ -80,6 +104,8 @@ Return<void> BluetoothHci::initialize(
},
[cb](const hidl_vec<uint8_t>& packet) {
auto hidl_status = cb->aclDataReceived(packet);
if (isLocalLoopbackActive)
sendNOCPHciEvent(packet, cb);
if (!hidl_status.isOk()) {
ALOGE("VendorInterface -> Unable to call aclDataReceived()");
}
Expand Down Expand Up @@ -110,11 +136,26 @@ Return<void> BluetoothHci::initialize(
Return<void> BluetoothHci::close() {
ALOGI("BluetoothHci::close()");
unlink_cb_(death_recipient_);
isLocalLoopbackActive = false;
VendorInterface::Shutdown();
return Void();
}

void checkLocalLoopbackCmd(const hidl_vec<uint8_t>& 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<void> BluetoothHci::sendHciCommand(const hidl_vec<uint8_t>& command) {
checkLocalLoopbackCmd(command);
sendDataToController(HCI_DATA_TYPE_COMMAND, command);
return Void();
}
Expand Down
4 changes: 3 additions & 1 deletion bluetooth/h4_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b97c809

Please sign in to comment.