Skip to content

Commit

Permalink
Bluetooth: Add support for reading AOSP vendor capabilities
Browse files Browse the repository at this point in the history
When drivers indicate support for AOSP vendor extension, initialize them
and read its capabilities.

Signed-off-by: Marcel Holtmann <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
  • Loading branch information
holtmann authored and Vudentz committed Apr 6, 2021
1 parent 8ce85ad commit f67743f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ struct hci_dev {
void *msft_data;
#endif

#if IS_ENABLED(CONFIG_BT_AOSPEXT)
bool aosp_capable;
#endif

int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev);
Expand Down Expand Up @@ -1239,6 +1243,13 @@ static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
#endif
}

static inline void hci_set_aosp_capable(struct hci_dev *hdev)
{
#if IS_ENABLED(CONFIG_BT_AOSPEXT)
hdev->aosp_capable = true;
#endif
}

int hci_dev_open(__u16 dev);
int hci_dev_close(__u16 dev);
int hci_dev_do_close(struct hci_dev *hdev);
Expand Down
7 changes: 7 additions & 0 deletions net/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ config BT_MSFTEXT
This options enables support for the Microsoft defined HCI
vendor extensions.

config BT_AOSPEXT
bool "Enable Android Open Source Project extensions"
depends on BT
help
This options enables support for the Android Open Source
Project defined HCI vendor extensions.

config BT_DEBUGFS
bool "Export Bluetooth internals in debugfs"
depends on BT && DEBUG_FS
Expand Down
1 change: 1 addition & 0 deletions net/bluetooth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ bluetooth-$(CONFIG_BT_BREDR) += sco.o
bluetooth-$(CONFIG_BT_HS) += a2mp.o amp.o
bluetooth-$(CONFIG_BT_LEDS) += leds.o
bluetooth-$(CONFIG_BT_MSFTEXT) += msft.o
bluetooth-$(CONFIG_BT_AOSPEXT) += aosp.o
bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
35 changes: 35 additions & 0 deletions net/bluetooth/aosp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021 Intel Corporation
*/

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

#include "aosp.h"

void aosp_do_open(struct hci_dev *hdev)
{
struct sk_buff *skb;

if (!hdev->aosp_capable)
return;

bt_dev_dbg(hdev, "Initialize AOSP extension");

/* LE Get Vendor Capabilities Command */
skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL,
HCI_CMD_TIMEOUT);
if (IS_ERR(skb))
return;

kfree_skb(skb);
}

void aosp_do_close(struct hci_dev *hdev)
{
if (!hdev->aosp_capable)
return;

bt_dev_dbg(hdev, "Cleanup of AOSP extension");
}
16 changes: 16 additions & 0 deletions net/bluetooth/aosp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021 Intel Corporation
*/

#if IS_ENABLED(CONFIG_BT_AOSPEXT)

void aosp_do_open(struct hci_dev *hdev);
void aosp_do_close(struct hci_dev *hdev);

#else

static inline void aosp_do_open(struct hci_dev *hdev) {}
static inline void aosp_do_close(struct hci_dev *hdev) {}

#endif
3 changes: 3 additions & 0 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "smp.h"
#include "leds.h"
#include "msft.h"
#include "aosp.h"

static void hci_rx_work(struct work_struct *work);
static void hci_cmd_work(struct work_struct *work);
Expand Down Expand Up @@ -1586,6 +1587,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
ret = hdev->set_diag(hdev, true);

msft_do_open(hdev);
aosp_do_open(hdev);

clear_bit(HCI_INIT, &hdev->flags);

Expand Down Expand Up @@ -1782,6 +1784,7 @@ int hci_dev_do_close(struct hci_dev *hdev)

hci_sock_dev_event(hdev, HCI_DEV_DOWN);

aosp_do_close(hdev);
msft_do_close(hdev);

if (hdev->flush)
Expand Down

0 comments on commit f67743f

Please sign in to comment.