Message ID | 20210908165017.v1.1.I17f57656757b83a1c0fb4b78525d8aca581725db@changeid (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v1,1/3] Bluetooth: btandroid: Support Android Bluetooth Quality Report | expand |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=543659 ---Test result--- Test Summary: CheckPatch FAIL 1.09 seconds GitLint FAIL 0.39 seconds BuildKernel PASS 711.40 seconds TestRunner: Setup PASS 463.39 seconds TestRunner: l2cap-tester PASS 3.46 seconds TestRunner: bnep-tester PASS 2.24 seconds TestRunner: mgmt-tester FAIL 35.94 seconds TestRunner: rfcomm-tester PASS 2.55 seconds TestRunner: sco-tester PASS 2.46 seconds TestRunner: smp-tester PASS 2.55 seconds TestRunner: userchan-tester PASS 2.27 seconds Details ############################## Test: CheckPatch - FAIL - 1.09 seconds Run checkpatch.pl script with rule in .checkpatch.conf Bluetooth: btandroid: Support Android Bluetooth Quality Report WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #28: new file mode 100644 total: 0 errors, 1 warnings, 123 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. "[PATCH] Bluetooth: btandroid: Support Android Bluetooth Quality" has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. ############################## Test: GitLint - FAIL - 0.39 seconds Run gitlint with rule in .gitlint CHROMIUM: drivers: bluetooth: set up Qualcomm WCN399x for Android BQR commands 1: T1 Title exceeds max length (78>72): "CHROMIUM: drivers: bluetooth: set up Qualcomm WCN399x for Android BQR commands" CHROMIUM: drivers: bluetooth: set up Realtek 8822CE for Android BQR commands 1: T1 Title exceeds max length (76>72): "CHROMIUM: drivers: bluetooth: set up Realtek 8822CE for Android BQR commands" ############################## Test: BuildKernel - PASS - 711.40 seconds Build Kernel with minimal configuration supports Bluetooth ############################## Test: TestRunner: Setup - PASS - 463.39 seconds Setup environment for running Test Runner ############################## Test: TestRunner: l2cap-tester - PASS - 3.46 seconds Run test-runner with l2cap-tester Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0 ############################## Test: TestRunner: bnep-tester - PASS - 2.24 seconds Run test-runner with bnep-tester Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0 ############################## Test: TestRunner: mgmt-tester - FAIL - 35.94 seconds Run test-runner with mgmt-tester Total: 452, Passed: 451 (99.8%), Failed: 1, Not Run: 0 Failed Test Cases Read Exp Feature - Success Failed 0.028 seconds ############################## Test: TestRunner: rfcomm-tester - PASS - 2.55 seconds Run test-runner with rfcomm-tester Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0 ############################## Test: TestRunner: sco-tester - PASS - 2.46 seconds Run test-runner with sco-tester Total: 11, Passed: 11 (100.0%), Failed: 0, Not Run: 0 ############################## Test: TestRunner: smp-tester - PASS - 2.55 seconds Run test-runner with smp-tester Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0 ############################## Test: TestRunner: userchan-tester - PASS - 2.27 seconds Run test-runner with userchan-tester Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0 --- Regards, Linux Bluetooth
Hi Joseph, > Add the btandroid.c file to support Android BQR commands. > > This module may be referenced by btusb, btrtl, and hci_qca when a > Bluetooth controller supports the Android Bluetooth Quality Report. > > Reviewed-by: Miao-chen Chou <mcchou@chromium.org> > Signed-off-by: Joseph Hwang <josephsih@chromium.org> > --- > > drivers/bluetooth/Makefile | 1 + > drivers/bluetooth/btandroid.c | 106 ++++++++++++++++++++++++++++++++++ > drivers/bluetooth/btandroid.h | 10 ++++ > 3 files changed, 117 insertions(+) > create mode 100644 drivers/bluetooth/btandroid.c > create mode 100644 drivers/bluetooth/btandroid.h so please lets not do this. Nothing AOSP specific belongs into drivers/bluetooth/. Doing this multitudes of dependencies for the drivers will cause long term so much pain and complexity that it is not worth it. If more than one manufacturer supports it, it has earned the right to be in net/bluetooth/ as a pseudo standard. Like with the MSFT extensions, I expect this to be in net/bluetooth/aosp.c and enabled based on hci_set_aosp_capable() being set by a driver or not. And I choose “aosp” for prefix on purpose and not “android”. Regards Marcel
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile index 16286ea2655d..4d5d010bb947 100644 --- a/drivers/bluetooth/Makefile +++ b/drivers/bluetooth/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_BT_HCIBT3C) += bt3c_cs.o obj-$(CONFIG_BT_HCIBLUECARD) += bluecard_cs.o obj-$(CONFIG_BT_HCIBTUSB) += btusb.o +obj-$(CONFIG_BT_HCIBTUSB) += btandroid.o obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o obj-$(CONFIG_BT_INTEL) += btintel.o diff --git a/drivers/bluetooth/btandroid.c b/drivers/bluetooth/btandroid.c new file mode 100644 index 000000000000..fffacc8d67cc --- /dev/null +++ b/drivers/bluetooth/btandroid.c @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Support for Android Bluetooth Quality Report (BQR) specifications + * https://source.android.com/devices/bluetooth/hci_requirements + * + * Copyright (C) 2021 Google Corporation + */ + +#include <linux/module.h> + +#include <net/bluetooth/bluetooth.h> +#include <net/bluetooth/hci.h> + +#include "btandroid.h" + +#define VERSION "0.1" + +/* + * Reference for the command op codes and parameters below: + * https://source.android.com/devices/bluetooth/hci_requirements#bluetooth-quality-report-command + */ +#define BQR_COMMAND_OCF 0x015e +#define BQR_OPCODE hci_opcode_pack(0x3f, BQR_COMMAND_OCF) + +/* report action */ +#define REPORT_ACTION_ADD 0x00 +#define REPORT_ACTION_DELETE 0x01 +#define REPORT_ACTION_CLEAR 0x02 + +/* BQR event masks */ +#define QUALITY_MONITORING (1 << 0) +#define APPRAOCHING_LSTO (1 << 1) +#define A2DP_AUDIO_CHOPPY (1 << 2) +#define SCO_VOICE_CHOPPY (1 << 3) + +#define DEFAULT_BQR_EVENT_MASK (QUALITY_MONITORING | APPRAOCHING_LSTO | \ + A2DP_AUDIO_CHOPPY | SCO_VOICE_CHOPPY) + +/* + * Reporting at seconds so as not to stress the controller too much. + * Range: 0 ~ 65535 ms + */ +#define DEFALUT_REPORT_INTERVAL_MS 5000 + +struct android_bqr_cp { + __u8 report_action; + __u32 event_mask; + __u16 min_report_interval; +} __packed; + +static int enable_quality_report(struct hci_dev *hdev) +{ + struct sk_buff *skb; + struct android_bqr_cp cp; + + cp.report_action = REPORT_ACTION_ADD; + cp.event_mask = DEFAULT_BQR_EVENT_MASK; + cp.min_report_interval = DEFALUT_REPORT_INTERVAL_MS; + + skb = __hci_cmd_sync(hdev, BQR_OPCODE, sizeof(cp), &cp, + HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Enabling Android BQR failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + kfree_skb(skb); + return 0; +} + +static int disable_quality_report(struct hci_dev *hdev) +{ + struct sk_buff *skb; + struct android_bqr_cp cp = { 0 }; + + cp.report_action = REPORT_ACTION_CLEAR; + + skb = __hci_cmd_sync(hdev, BQR_OPCODE, sizeof(cp), &cp, + HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Disabling Android BQR failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + kfree_skb(skb); + return 0; +} + +int btandroid_set_quality_report(struct hci_dev *hdev, bool enable) +{ + bt_dev_info(hdev, "quality report enable %d", enable); + + /* Enable or disable the quality report feature. */ + if (enable) + return enable_quality_report(hdev); + else + return disable_quality_report(hdev); +} +EXPORT_SYMBOL_GPL(btandroid_set_quality_report); + +MODULE_AUTHOR("Google"); +MODULE_DESCRIPTION("Support for Android Bluetooth Specification " VERSION); +MODULE_VERSION(VERSION); +MODULE_LICENSE("GPL"); diff --git a/drivers/bluetooth/btandroid.h b/drivers/bluetooth/btandroid.h new file mode 100644 index 000000000000..6abc9e8e0838 --- /dev/null +++ b/drivers/bluetooth/btandroid.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Bluetooth support for Android specifications + * + * Copyright (C) 2021 Google Corporation + */ + +#include <net/bluetooth/hci_core.h> + +int btandroid_set_quality_report(struct hci_dev *hdev, bool enable);