From: Miao-chen Chou <mcchou@chromium.org>
To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Alain Michaud <alainm@chromium.org>,
Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Miao-chen Chou <mcchou@chromium.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v5 1/3] Bluetooth: Add the framework of using Microsoft vendor extension
Date: Fri, 3 Apr 2020 20:31:16 -0700 [thread overview]
Message-ID: <20200403203058.v5.1.I04214d389ccfe933f1056a17c0e0ecdacb0395b5@changeid> (raw)
In-Reply-To: <20200404033118.22135-1-mcchou@chromium.org>
This adds the framework of using Microsoft vendor extension by
introducing a kernel config, BT_MSFTEXT, and a source file to facilitate
Microsoft vendor extension functions.
This was verified with Intel ThunderPeak BT controller
where msft_opcode is 0xFC1E. See https://docs.microsoft.com/en-us/windows-
hardware/drivers/bluetooth/microsoft-defined-bluetooth-hci-commands-and-
events for more information about the extension.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit dadae5cfbf84abb7b5465e82a7aae801a2a4f163)
Signed-off-by: Miao-chen Chou <mcchou@chromium.org>
---
Changes in v5:
- Extract the changes on btusb as a different commit.
Changes in v4:
- Introduce CONFIG_BT_MSFTEXT as a starting point of providing a
framework to use Microsoft extension
- Create include/net/bluetooth/msft.h and net/bluetooth/msft.c to
facilitate functions of Microsoft extension.
Changes in v3:
- Create net/bluetooth/msft.c with struct msft_vnd_ext defined internally
and change the hdev->msft_ext field to void*.
- Define and expose msft_vnd_ext_set_opcode() for btusb use.
- Init hdev->msft_ext in hci_alloc_dev() and deinit it in hci_free_dev().
Changes in v2:
- Define struct msft_vnd_ext and add a field of this type to struct
hci_dev to facilitate the support of Microsoft vendor extension.
include/net/bluetooth/hci_core.h | 4 ++++
include/net/bluetooth/msft.h | 19 +++++++++++++++++++
net/bluetooth/Kconfig | 7 +++++++
net/bluetooth/Makefile | 1 +
net/bluetooth/msft.c | 15 +++++++++++++++
5 files changed, 46 insertions(+)
create mode 100644 include/net/bluetooth/msft.h
create mode 100644 net/bluetooth/msft.c
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d4e28773d3781..239cae2d99986 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -484,6 +484,10 @@ struct hci_dev {
struct led_trigger *power_led;
#endif
+#if IS_ENABLED(CONFIG_BT_MSFTEXT)
+ __u16 msft_opcode;
+#endif
+
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev);
diff --git a/include/net/bluetooth/msft.h b/include/net/bluetooth/msft.h
new file mode 100644
index 0000000000000..7218ea759dde4
--- /dev/null
+++ b/include/net/bluetooth/msft.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (C) 2020 Google Corporation */
+
+#ifndef __MSFT_H
+#define __MSFT_H
+
+#include <net/bluetooth/hci_core.h>
+
+#if IS_ENABLED(CONFIG_BT_MSFTEXT)
+
+void msft_set_opcode(struct hci_dev *hdev, __u16 opcode);
+
+#else
+
+static inline void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) {}
+
+#endif
+
+#endif /* __MSFT_H*/
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index 165148c7c4ce5..d439be5c534e7 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -93,6 +93,13 @@ config BT_LEDS
This option selects a few LED triggers for different
Bluetooth events.
+config BT_MSFTEXT
+ bool "Enable Microsoft extensions"
+ depends on BT
+ help
+ This options enables support for the Microsoft defined HCI
+ vendor extensions.
+
config BT_SELFTEST
bool "Bluetooth self testing support"
depends on BT && DEBUG_KERNEL
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index fda41c0b47818..41dd541a44a52 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -19,5 +19,6 @@ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
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_DEBUGFS) += hci_debugfs.o
bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
new file mode 100644
index 0000000000000..04dad4ac7bf78
--- /dev/null
+++ b/net/bluetooth/msft.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (C) 2020 Google Corporation */
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+#include <net/bluetooth/msft.h>
+
+void msft_set_opcode(struct hci_dev *hdev, __u16 opcode)
+{
+ hdev->msft_opcode = opcode;
+
+ bt_dev_info(hdev, "Enabling MSFT extensions with opcode 0x%2.2x",
+ hdev->msft_opcode);
+}
+EXPORT_SYMBOL(msft_set_opcode);
--
2.24.1
next prev parent reply other threads:[~2020-04-04 3:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-04 3:31 [PATCH v5 0/3] btusb: Introduce the use of vendor extension(s) Miao-chen Chou
2020-04-04 3:31 ` Miao-chen Chou [this message]
2020-04-04 3:31 ` [PATCH v5 2/3] Bluetooth: Read the supported features of Microsoft vendor extension Miao-chen Chou
2020-04-04 3:31 ` [PATCH v5 3/3] Bluetooth: btusb: Indicate Microsoft vendor extension for Intel 9160/9260 Miao-chen Chou
2020-04-06 6:14 ` Marcel Holtmann
2020-04-06 21:55 ` Miao-chen Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200403203058.v5.1.I04214d389ccfe933f1056a17c0e0ecdacb0395b5@changeid \
--to=mcchou@chromium.org \
--cc=alainm@chromium.org \
--cc=davem@davemloft.net \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).