linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities
@ 2021-10-21 15:04 Joseph Hwang
  2021-10-21 15:04 ` [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report Joseph Hwang
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Joseph Hwang @ 2021-10-21 15:04 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	David S. Miller, Jakub Kicinski, Johan Hedberg, linux-kernel,
	netdev

This patch adds the struct of reading AOSP vendor capabilities.
New capabilities are added incrementally. Note that the
version_supported octets will be used to determine whether a
capability has been defined for the version.

Signed-off-by: Joseph Hwang <josephsih@chromium.org>

---

Changes in v6:
- Add historical versions of struct aosp_rp_le_get_vendor_capabilities.
- Perform the basic check about the struct length.
- Through the version, bluetooth_quality_report_support can be checked.

Changes in v5:
- This is a new patch.
- Add struct aosp_rp_le_get_vendor_capabilities so that next patch
  can determine whether a particular capability is supported or not.

 include/net/bluetooth/hci_core.h |   1 +
 net/bluetooth/aosp.c             | 116 ++++++++++++++++++++++++++++++-
 2 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index dd8840e70e25..32b3774227f2 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -603,6 +603,7 @@ struct hci_dev {
 
 #if IS_ENABLED(CONFIG_BT_AOSPEXT)
 	bool			aosp_capable;
+	bool			aosp_quality_report;
 #endif
 
 	int (*open)(struct hci_dev *hdev);
diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
index a1b7762335a5..64684b2bf79b 100644
--- a/net/bluetooth/aosp.c
+++ b/net/bluetooth/aosp.c
@@ -8,9 +8,53 @@
 
 #include "aosp.h"
 
+/* Command complete parameters of LE_Get_Vendor_Capabilities_Command
+ * The parameters grow over time. The first version that declares the
+ * version_supported field is v0.95. Refer to
+ * https://cs.android.com/android/platform/superproject/+/master:system/
+ *         bt/gd/hci/controller.cc;l=452?q=le_get_vendor_capabilities_handler
+ */
+
+/* the base capabilities struct with the version_supported field */
+struct aosp_rp_le_get_vendor_capa_v95 {
+	__u8	status;
+	__u8	max_advt_instances;
+	__u8	offloaded_resolution_of_private_address;
+	__u16	total_scan_results_storage;
+	__u8	max_irk_list_sz;
+	__u8	filtering_support;
+	__u8	max_filter;
+	__u8	activity_energy_info_support;
+	__u16	version_supported;
+	__u16	total_num_of_advt_tracked;
+	__u8	extended_scan_support;
+	__u8	debug_logging_supported;
+} __packed;
+
+struct aosp_rp_le_get_vendor_capa_v96 {
+	struct aosp_rp_le_get_vendor_capa_v95 v95;
+	/* v96 */
+	__u8	le_address_generation_offloading_support;
+} __packed;
+
+struct aosp_rp_le_get_vendor_capa_v98 {
+	struct aosp_rp_le_get_vendor_capa_v96 v96;
+	/* v98 */
+	__u32	a2dp_source_offload_capability_mask;
+	__u8	bluetooth_quality_report_support;
+} __packed;
+
+struct aosp_rp_le_get_vendor_capa_v100 {
+	struct aosp_rp_le_get_vendor_capa_v98 v98;
+	/* v100 */
+	__u32	dynamic_audio_buffer_support;
+} __packed;
+
 void aosp_do_open(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	struct aosp_rp_le_get_vendor_capa_v95 *base_rp;
+	u16 version_supported;
 
 	if (!hdev->aosp_capable)
 		return;
@@ -20,9 +64,79 @@ void aosp_do_open(struct hci_dev *hdev)
 	/* LE Get Vendor Capabilities Command */
 	skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL,
 			     HCI_CMD_TIMEOUT);
-	if (IS_ERR(skb))
+	if (IS_ERR(skb)) {
+		bt_dev_warn(hdev, "AOSP get vendor capabilities (%ld)",
+			    PTR_ERR(skb));
 		return;
+	}
+
+	bt_dev_dbg(hdev, "aosp le vendor capabilities length %d", skb->len);
+
+	base_rp = (struct aosp_rp_le_get_vendor_capa_v95 *)skb->data;
+
+	if (base_rp->status) {
+		bt_dev_err(hdev, "AOSP LE Get Vendor Capabilities status %d",
+			   base_rp->status);
+		goto done;
+	}
+
+	version_supported = le16_to_cpu(base_rp->version_supported);
+	bt_dev_info(hdev, "AOSP version %u", version_supported);
+
+	/* Do not support very old versions. */
+	if (version_supported < 95) {
+		bt_dev_err(hdev, "capabilities version %u too old",
+			   version_supported);
+		goto done;
+	}
+
+	if (version_supported >= 95) {
+		struct aosp_rp_le_get_vendor_capa_v95 *rp;
+
+		rp = (struct aosp_rp_le_get_vendor_capa_v95 *)skb->data;
+		if (skb->len < sizeof(*rp))
+			goto length_error;
+	}
+
+	if (version_supported >= 96) {
+		struct aosp_rp_le_get_vendor_capa_v96 *rp;
+
+		rp = (struct aosp_rp_le_get_vendor_capa_v96 *)skb->data;
+		if (skb->len < sizeof(*rp))
+			goto length_error;
+	}
+
+	if (version_supported >= 98) {
+		struct aosp_rp_le_get_vendor_capa_v98 *rp;
+
+		rp = (struct aosp_rp_le_get_vendor_capa_v98 *)skb->data;
+		if (skb->len < sizeof(*rp))
+			goto length_error;
+
+		/* The bluetooth_quality_report_support is defined at version v0.98.
+		 * Refer to https://cs.android.com/android/platform/superproject/+/
+		 *                  master:system/bt/gd/hci/controller.cc;l=477
+		 */
+		if (rp->bluetooth_quality_report_support) {
+			hdev->aosp_quality_report = true;
+			bt_dev_info(hdev, "bluetooth quality report is supported");
+		}
+	}
+
+	if (version_supported >= 100) {
+		struct aosp_rp_le_get_vendor_capa_v100 *rp;
+
+		rp = (struct aosp_rp_le_get_vendor_capa_v100 *)skb->data;
+		if (skb->len < sizeof(*rp))
+			goto length_error;
+	}
+
+	goto done;
+
+length_error:
+	bt_dev_err(hdev, "AOSP capabilities length %d too short", skb->len);
 
+done:
 	kfree_skb(skb);
 }
 
-- 
2.33.0.1079.g6e70778dc9-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report
  2021-10-21 15:04 [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities Joseph Hwang
@ 2021-10-21 15:04 ` Joseph Hwang
  2021-10-25 13:24   ` Marcel Holtmann
  2021-10-21 15:04 ` [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension Joseph Hwang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Joseph Hwang @ 2021-10-21 15:04 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	Miao-chen Chou, David S. Miller, Jakub Kicinski, Johan Hedberg,
	linux-kernel, netdev

This patch adds the support of the AOSP Bluetooth Quality Report
(BQR) events.

Multiple vendors have supported the AOSP Bluetooth Quality Report.
When a Bluetooth controller supports the capability, it can enable
the aosp capability through hci_set_aosp_capable. Then hci_core will
set up the hdev->aosp_set_quality_report callback through aosp_do_open
if the controller responds to support the quality report capability.

Note that Intel also supports a distinct telemetry quality report
specification. Intel sets up the hdev->set_quality_report callback
in the btusb driver module.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>

---

Changes in v6:
- Use the decimal version instead of hexadecimal version to be
  consistent with the AOSP specification.
- Move the code of checking the bluetooth_quality_report_support field
  to the previous patch.

Changes in v5:
- Fix the patch per
  [RFC PATCH] Bluetooth: Add framework for AOSP quality report setting
- Declare aosp_set_quality_report.
- Use aosp_do_open() to set hdev->aosp_set_quality_report.
- Add aosp_has_quality_report().
- In mgmt, use hdev->aosp_set_quality_report and
  hdev->set_quality_report separately.

Changes in v4:
- Move the AOSP BQR support from the driver level to net/bluetooth/aosp.
- Fix the drivers to use hci_set_aosp_capable to enable aosp.
- Add Mediatek to support the capability too.

Changes in v3:
- Fix the auto build test ERROR
  "undefined symbol: btandroid_set_quality_report" that occurred
  with some kernel configs.
- Note that the mgmt-tester "Read Exp Feature - Success" failed.
  But on my test device, the same test passed. Please kindly let me
  know what may be going wrong. These patches do not actually
  modify read/set experimental features.
- As to CheckPatch failed. No need to modify the MAINTAINERS file.
  Thanks.

Changes in v2:
- Fix the titles of patches 2/3 and 3/3 and reduce their lengths.

 net/bluetooth/aosp.c | 87 ++++++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/aosp.h | 13 +++++++
 net/bluetooth/mgmt.c | 18 ++++++---
 3 files changed, 113 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
index 64684b2bf79b..582c380a29fa 100644
--- a/net/bluetooth/aosp.c
+++ b/net/bluetooth/aosp.c
@@ -147,3 +147,90 @@ void aosp_do_close(struct hci_dev *hdev)
 
 	bt_dev_dbg(hdev, "Cleanup of AOSP extension");
 }
+
+/* BQR command */
+#define BQR_OPCODE			hci_opcode_pack(0x3f, 0x015e)
+
+/* BQR report action */
+#define REPORT_ACTION_ADD		0x00
+#define REPORT_ACTION_DELETE		0x01
+#define REPORT_ACTION_CLEAR		0x02
+
+/* BQR event masks */
+#define QUALITY_MONITORING		BIT(0)
+#define APPRAOCHING_LSTO		BIT(1)
+#define A2DP_AUDIO_CHOPPY		BIT(2)
+#define SCO_VOICE_CHOPPY		BIT(3)
+
+#define DEFAULT_BQR_EVENT_MASK	(QUALITY_MONITORING | APPRAOCHING_LSTO | \
+				 A2DP_AUDIO_CHOPPY | SCO_VOICE_CHOPPY)
+
+/* Reporting at milliseconds so as not to stress the controller too much.
+ * Range: 0 ~ 65535 ms
+ */
+#define DEFALUT_REPORT_INTERVAL_MS	5000
+
+struct aosp_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 aosp_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 aosp_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;
+}
+
+bool aosp_has_quality_report(struct hci_dev *hdev)
+{
+	return hdev->aosp_quality_report;
+}
+
+int aosp_set_quality_report(struct hci_dev *hdev, bool enable)
+{
+	if (!aosp_has_quality_report(hdev))
+		return -EOPNOTSUPP;
+
+	bt_dev_dbg(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);
+}
diff --git a/net/bluetooth/aosp.h b/net/bluetooth/aosp.h
index 328fc6d39f70..2fd8886d51b2 100644
--- a/net/bluetooth/aosp.h
+++ b/net/bluetooth/aosp.h
@@ -8,9 +8,22 @@
 void aosp_do_open(struct hci_dev *hdev);
 void aosp_do_close(struct hci_dev *hdev);
 
+bool aosp_has_quality_report(struct hci_dev *hdev);
+int aosp_set_quality_report(struct hci_dev *hdev, bool enable);
+
 #else
 
 static inline void aosp_do_open(struct hci_dev *hdev) {}
 static inline void aosp_do_close(struct hci_dev *hdev) {}
 
+static inline bool aosp_has_quality_report(struct hci_dev *hdev)
+{
+	return false;
+}
+
+static inline int aosp_set_quality_report(struct hci_dev *hdev, bool enable)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 44683443300c..d6c322763567 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -39,6 +39,7 @@
 #include "mgmt_config.h"
 #include "msft.h"
 #include "eir.h"
+#include "aosp.h"
 
 #define MGMT_VERSION	1
 #define MGMT_REVISION	21
@@ -3863,7 +3864,8 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 		idx++;
 	}
 
-	if (hdev && hdev->set_quality_report) {
+	if (hdev && (aosp_has_quality_report(hdev) ||
+		     hdev->set_quality_report)) {
 		if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT))
 			flags = BIT(0);
 		else
@@ -4127,7 +4129,8 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
 	val = !!cp->param[0];
 	changed = (val != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT));
 
-	if (!hdev->set_quality_report) {
+	if (!aosp_has_quality_report(hdev) && !hdev->set_quality_report) {
+		BT_INFO("quality report not supported");
 		err = mgmt_cmd_status(sk, hdev->id,
 				      MGMT_OP_SET_EXP_FEATURE,
 				      MGMT_STATUS_NOT_SUPPORTED);
@@ -4135,13 +4138,18 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
 	}
 
 	if (changed) {
-		err = hdev->set_quality_report(hdev, val);
+		if (hdev->set_quality_report)
+			err = hdev->set_quality_report(hdev, val);
+		else
+			err = aosp_set_quality_report(hdev, val);
+
 		if (err) {
 			err = mgmt_cmd_status(sk, hdev->id,
 					      MGMT_OP_SET_EXP_FEATURE,
 					      MGMT_STATUS_FAILED);
 			goto unlock_quality_report;
 		}
+
 		if (val)
 			hci_dev_set_flag(hdev, HCI_QUALITY_REPORT);
 		else
@@ -4153,8 +4161,8 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
 	memcpy(rp.uuid, quality_report_uuid, 16);
 	rp.flags = cpu_to_le32(val ? BIT(0) : 0);
 	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
-	err = mgmt_cmd_complete(sk, hdev->id,
-				MGMT_OP_SET_EXP_FEATURE, 0,
+
+	err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_EXP_FEATURE, 0,
 				&rp, sizeof(rp));
 
 	if (changed)
-- 
2.33.0.1079.g6e70778dc9-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension
  2021-10-21 15:04 [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities Joseph Hwang
  2021-10-21 15:04 ` [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report Joseph Hwang
@ 2021-10-21 15:04 ` Joseph Hwang
  2021-10-25 13:26   ` Marcel Holtmann
  2021-10-21 16:43 ` [v6,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities bluez.test.bot
  2021-10-25 13:18 ` [PATCH v6 1/3] " Marcel Holtmann
  3 siblings, 1 reply; 10+ messages in thread
From: Joseph Hwang @ 2021-10-21 15:04 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	Miao-chen Chou, Johan Hedberg, linux-kernel

This patch enables Mediatek to support the AOSP extension.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>

---

(no changes since v5)

Changes in v5:
- Let the vendor command in aosp_do_open() to determine what
  capabilities are supported.

Changes in v4:
- Call hci_set_aosp_capable in the driver.
- This patch is added in this Series-changes 4.

 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 87b71740fad8..00311ebd7823 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3876,6 +3876,8 @@ static int btusb_probe(struct usb_interface *intf,
 		hdev->set_bdaddr = btusb_set_bdaddr_mtk;
 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
 		data->recv_acl = btusb_recv_acl_mtk;
+
+		hci_set_aosp_capable(hdev);
 	}
 
 	if (id->driver_info & BTUSB_SWAVE) {
-- 
2.33.0.1079.g6e70778dc9-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* RE: [v6,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities
  2021-10-21 15:04 [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities Joseph Hwang
  2021-10-21 15:04 ` [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report Joseph Hwang
  2021-10-21 15:04 ` [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension Joseph Hwang
@ 2021-10-21 16:43 ` bluez.test.bot
  2021-10-25 13:18 ` [PATCH v6 1/3] " Marcel Holtmann
  3 siblings, 0 replies; 10+ messages in thread
From: bluez.test.bot @ 2021-10-21 16:43 UTC (permalink / raw)
  To: linux-bluetooth, josephsih

[-- Attachment #1: Type: text/plain, Size: 937 bytes --]

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=567909

---Test result---

Test Summary:
CheckPatch                    PASS      3.34 seconds
GitLint                       PASS      1.03 seconds
BuildKernel                   PASS      803.16 seconds
TestRunner: Setup             PASS      575.90 seconds
TestRunner: l2cap-tester      PASS      12.11 seconds
TestRunner: bnep-tester       PASS      6.37 seconds
TestRunner: mgmt-tester       PASS      113.68 seconds
TestRunner: rfcomm-tester     PASS      8.11 seconds
TestRunner: sco-tester        PASS      8.48 seconds
TestRunner: smp-tester        PASS      8.25 seconds
TestRunner: userchan-tester   PASS      6.83 seconds



---
Regards,
Linux Bluetooth


[-- Attachment #2: l2cap-tester.log --]
[-- Type: application/octet-stream, Size: 44357 bytes --]

[-- Attachment #3: bnep-tester.log --]
[-- Type: application/octet-stream, Size: 3564 bytes --]

[-- Attachment #4: mgmt-tester.log --]
[-- Type: application/octet-stream, Size: 646010 bytes --]

[-- Attachment #5: rfcomm-tester.log --]
[-- Type: application/octet-stream, Size: 11684 bytes --]

[-- Attachment #6: sco-tester.log --]
[-- Type: application/octet-stream, Size: 13924 bytes --]

[-- Attachment #7: smp-tester.log --]
[-- Type: application/octet-stream, Size: 11830 bytes --]

[-- Attachment #8: userchan-tester.log --]
[-- Type: application/octet-stream, Size: 6372 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities
  2021-10-21 15:04 [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities Joseph Hwang
                   ` (2 preceding siblings ...)
  2021-10-21 16:43 ` [v6,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities bluez.test.bot
@ 2021-10-25 13:18 ` Marcel Holtmann
  3 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2021-10-25 13:18 UTC (permalink / raw)
  To: Joseph Hwang
  Cc: linux-bluetooth, Luiz Augusto von Dentz, pali,
	chromeos-bluetooth-upstreaming, josephsih, David S. Miller,
	Jakub Kicinski, Johan Hedberg, linux-kernel, netdev

Hi Jospeh,

> This patch adds the struct of reading AOSP vendor capabilities.
> New capabilities are added incrementally. Note that the
> version_supported octets will be used to determine whether a
> capability has been defined for the version.
> 
> Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> 
> ---
> 
> Changes in v6:
> - Add historical versions of struct aosp_rp_le_get_vendor_capabilities.
> - Perform the basic check about the struct length.
> - Through the version, bluetooth_quality_report_support can be checked.
> 
> Changes in v5:
> - This is a new patch.
> - Add struct aosp_rp_le_get_vendor_capabilities so that next patch
>  can determine whether a particular capability is supported or not.
> 
> include/net/bluetooth/hci_core.h |   1 +
> net/bluetooth/aosp.c             | 116 ++++++++++++++++++++++++++++++-
> 2 files changed, 116 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index dd8840e70e25..32b3774227f2 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -603,6 +603,7 @@ struct hci_dev {
> 
> #if IS_ENABLED(CONFIG_BT_AOSPEXT)
> 	bool			aosp_capable;
> +	bool			aosp_quality_report;
> #endif
> 
> 	int (*open)(struct hci_dev *hdev);
> diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
> index a1b7762335a5..64684b2bf79b 100644
> --- a/net/bluetooth/aosp.c
> +++ b/net/bluetooth/aosp.c
> @@ -8,9 +8,53 @@
> 
> #include "aosp.h"
> 
> +/* Command complete parameters of LE_Get_Vendor_Capabilities_Command
> + * The parameters grow over time. The first version that declares the
> + * version_supported field is v0.95. Refer to
> + * https://cs.android.com/android/platform/superproject/+/master:system/
> + *         bt/gd/hci/controller.cc;l=452?q=le_get_vendor_capabilities_handler
> + */
> +
> +/* the base capabilities struct with the version_supported field */
> +struct aosp_rp_le_get_vendor_capa_v95 {
> +	__u8	status;
> +	__u8	max_advt_instances;
> +	__u8	offloaded_resolution_of_private_address;
> +	__u16	total_scan_results_storage;
> +	__u8	max_irk_list_sz;
> +	__u8	filtering_support;
> +	__u8	max_filter;
> +	__u8	activity_energy_info_support;
> +	__u16	version_supported;
> +	__u16	total_num_of_advt_tracked;
> +	__u8	extended_scan_support;
> +	__u8	debug_logging_supported;
> +} __packed;
> +
> +struct aosp_rp_le_get_vendor_capa_v96 {
> +	struct aosp_rp_le_get_vendor_capa_v95 v95;
> +	/* v96 */
> +	__u8	le_address_generation_offloading_support;
> +} __packed;
> +
> +struct aosp_rp_le_get_vendor_capa_v98 {
> +	struct aosp_rp_le_get_vendor_capa_v96 v96;
> +	/* v98 */
> +	__u32	a2dp_source_offload_capability_mask;
> +	__u8	bluetooth_quality_report_support;
> +} __packed;
> +
> +struct aosp_rp_le_get_vendor_capa_v100 {
> +	struct aosp_rp_le_get_vendor_capa_v98 v98;
> +	/* v100 */
> +	__u32	dynamic_audio_buffer_support;
> +} __packed;
> +

while this is an interesting idea to document the different versions, I don’t thing you need to overboard like this. Just use the full struct and make sure you check the version_supported to ensure you are not reading beyond the bounds of your result.

Meaning you can have a struct pointer point to smaller memory, just make sure you never access it if it is not there. So I would just add defines for the different versions and their length of the struct.

Oh, I might have forgotten that, you need to use __le16 and __le32 to indicate the endianness of the data on the wire.

> void aosp_do_open(struct hci_dev *hdev)
> {
> 	struct sk_buff *skb;
> +	struct aosp_rp_le_get_vendor_capa_v95 *base_rp;
> +	u16 version_supported;
> 
> 	if (!hdev->aosp_capable)
> 		return;
> @@ -20,9 +64,79 @@ void aosp_do_open(struct hci_dev *hdev)
> 	/* LE Get Vendor Capabilities Command */
> 	skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL,
> 			     HCI_CMD_TIMEOUT);
> -	if (IS_ERR(skb))
> +	if (IS_ERR(skb)) {
> +		bt_dev_warn(hdev, "AOSP get vendor capabilities (%ld)",
> +			    PTR_ERR(skb));

This is actually an error. If the driver indicates support for it, this better succeed. If not complain loudly.

> 		return;
> +	}
> +
> +	bt_dev_dbg(hdev, "aosp le vendor capabilities length %d", skb->len);

Skip this one.

Add a basic length check that you know you can get to rp->version_supported field.

> +
> +	base_rp = (struct aosp_rp_le_get_vendor_capa_v95 *)skb->data;
> +
> +	if (base_rp->status) {
> +		bt_dev_err(hdev, "AOSP LE Get Vendor Capabilities status %d",
> +			   base_rp->status);
> +		goto done;
> +	}

Actually the status is already evaluated via the __hci_cmd_sync command. No need to repeat it here.

> +
> +	version_supported = le16_to_cpu(base_rp->version_supported);
> +	bt_dev_info(hdev, "AOSP version %u", version_supported);
> +
> +	/* Do not support very old versions. */
> +	if (version_supported < 95) {
> +		bt_dev_err(hdev, "capabilities version %u too old",
> +			   version_supported);
> +		goto done;
> +	}

This is not an error. Just print a warning here. And “AOSP capabilities ..” please.

> +
> +	if (version_supported >= 95) {
> +		struct aosp_rp_le_get_vendor_capa_v95 *rp;
> +
> +		rp = (struct aosp_rp_le_get_vendor_capa_v95 *)skb->data;
> +		if (skb->len < sizeof(*rp))
> +			goto length_error;
> +	}
> +
> +	if (version_supported >= 96) {
> +		struct aosp_rp_le_get_vendor_capa_v96 *rp;
> +
> +		rp = (struct aosp_rp_le_get_vendor_capa_v96 *)skb->data;
> +		if (skb->len < sizeof(*rp))
> +			goto length_error;
> +	}

Since we don’t use any data out of these two above, skip it. If the version is less than < 0.98 we are just ignoring it. You can print a warning that "AOSP quality report is not supported”.


> +
> +	if (version_supported >= 98) {
> +		struct aosp_rp_le_get_vendor_capa_v98 *rp;
> +
> +		rp = (struct aosp_rp_le_get_vendor_capa_v98 *)skb->data;
> +		if (skb->len < sizeof(*rp))
> +			goto length_error;
> +
> +		/* The bluetooth_quality_report_support is defined at version v0.98.
> +		 * Refer to https://cs.android.com/android/platform/superproject/+/
> +		 *                  master:system/bt/gd/hci/controller.cc;l=477
> +		 */
> +		if (rp->bluetooth_quality_report_support) {
> +			hdev->aosp_quality_report = true;
> +			bt_dev_info(hdev, "bluetooth quality report is supported");
> +		}
> +	}
> +
> +	if (version_supported >= 100) {
> +		struct aosp_rp_le_get_vendor_capa_v100 *rp;
> +
> +		rp = (struct aosp_rp_le_get_vendor_capa_v100 *)skb->data;
> +		if (skb->len < sizeof(*rp))
> +			goto length_error;
> +	}

Skip that one as well. We only care about quality report support.

> +
> +	goto done;
> +
> +length_error:
> +	bt_dev_err(hdev, "AOSP capabilities length %d too short", skb->len);
> 
> +done:
> 	kfree_skb(skb);
> }

Regards

Marcel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report
  2021-10-21 15:04 ` [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report Joseph Hwang
@ 2021-10-25 13:24   ` Marcel Holtmann
  0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2021-10-25 13:24 UTC (permalink / raw)
  To: Joseph Hwang
  Cc: linux-bluetooth, Luiz Augusto von Dentz, Pali Rohár,
	CrosBT Upstreaming, Joseph Hwang, Miao-chen Chou,
	David S. Miller, Jakub Kicinski, Johan Hedberg,
	Linux Kernel Mailing List, netdev

Hi Joseph,

> This patch adds the support of the AOSP Bluetooth Quality Report
> (BQR) events.
> 
> Multiple vendors have supported the AOSP Bluetooth Quality Report.
> When a Bluetooth controller supports the capability, it can enable
> the aosp capability through hci_set_aosp_capable. Then hci_core will
> set up the hdev->aosp_set_quality_report callback through aosp_do_open
> if the controller responds to support the quality report capability.
> 
> Note that Intel also supports a distinct telemetry quality report
> specification. Intel sets up the hdev->set_quality_report callback
> in the btusb driver module.
> 
> Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
> Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> 
> ---
> 
> Changes in v6:
> - Use the decimal version instead of hexadecimal version to be
>  consistent with the AOSP specification.
> - Move the code of checking the bluetooth_quality_report_support field
>  to the previous patch.
> 
> Changes in v5:
> - Fix the patch per
>  [RFC PATCH] Bluetooth: Add framework for AOSP quality report setting
> - Declare aosp_set_quality_report.
> - Use aosp_do_open() to set hdev->aosp_set_quality_report.
> - Add aosp_has_quality_report().
> - In mgmt, use hdev->aosp_set_quality_report and
>  hdev->set_quality_report separately.
> 
> Changes in v4:
> - Move the AOSP BQR support from the driver level to net/bluetooth/aosp.
> - Fix the drivers to use hci_set_aosp_capable to enable aosp.
> - Add Mediatek to support the capability too.
> 
> Changes in v3:
> - Fix the auto build test ERROR
>  "undefined symbol: btandroid_set_quality_report" that occurred
>  with some kernel configs.
> - Note that the mgmt-tester "Read Exp Feature - Success" failed.
>  But on my test device, the same test passed. Please kindly let me
>  know what may be going wrong. These patches do not actually
>  modify read/set experimental features.
> - As to CheckPatch failed. No need to modify the MAINTAINERS file.
>  Thanks.
> 
> Changes in v2:
> - Fix the titles of patches 2/3 and 3/3 and reduce their lengths.
> 
> net/bluetooth/aosp.c | 87 ++++++++++++++++++++++++++++++++++++++++++++
> net/bluetooth/aosp.h | 13 +++++++
> net/bluetooth/mgmt.c | 18 ++++++---
> 3 files changed, 113 insertions(+), 5 deletions(-)
> 
> diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c
> index 64684b2bf79b..582c380a29fa 100644
> --- a/net/bluetooth/aosp.c
> +++ b/net/bluetooth/aosp.c
> @@ -147,3 +147,90 @@ void aosp_do_close(struct hci_dev *hdev)
> 
> 	bt_dev_dbg(hdev, "Cleanup of AOSP extension");
> }
> +
> +/* BQR command */
> +#define BQR_OPCODE			hci_opcode_pack(0x3f, 0x015e)
> +
> +/* BQR report action */
> +#define REPORT_ACTION_ADD		0x00
> +#define REPORT_ACTION_DELETE		0x01
> +#define REPORT_ACTION_CLEAR		0x02
> +
> +/* BQR event masks */
> +#define QUALITY_MONITORING		BIT(0)
> +#define APPRAOCHING_LSTO		BIT(1)
> +#define A2DP_AUDIO_CHOPPY		BIT(2)
> +#define SCO_VOICE_CHOPPY		BIT(3)
> +
> +#define DEFAULT_BQR_EVENT_MASK	(QUALITY_MONITORING | APPRAOCHING_LSTO | \
> +				 A2DP_AUDIO_CHOPPY | SCO_VOICE_CHOPPY)
> +
> +/* Reporting at milliseconds so as not to stress the controller too much.
> + * Range: 0 ~ 65535 ms
> + */
> +#define DEFALUT_REPORT_INTERVAL_MS	5000
> +
> +struct aosp_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 aosp_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 aosp_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;
> +}
> +
> +bool aosp_has_quality_report(struct hci_dev *hdev)
> +{
> +	return hdev->aosp_quality_report;
> +}
> +
> +int aosp_set_quality_report(struct hci_dev *hdev, bool enable)
> +{
> +	if (!aosp_has_quality_report(hdev))
> +		return -EOPNOTSUPP;
> +
> +	bt_dev_dbg(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);
> +}
> diff --git a/net/bluetooth/aosp.h b/net/bluetooth/aosp.h
> index 328fc6d39f70..2fd8886d51b2 100644
> --- a/net/bluetooth/aosp.h
> +++ b/net/bluetooth/aosp.h
> @@ -8,9 +8,22 @@
> void aosp_do_open(struct hci_dev *hdev);
> void aosp_do_close(struct hci_dev *hdev);
> 
> +bool aosp_has_quality_report(struct hci_dev *hdev);
> +int aosp_set_quality_report(struct hci_dev *hdev, bool enable);
> +
> #else
> 
> static inline void aosp_do_open(struct hci_dev *hdev) {}
> static inline void aosp_do_close(struct hci_dev *hdev) {}
> 
> +static inline bool aosp_has_quality_report(struct hci_dev *hdev)
> +{
> +	return false;
> +}
> +
> +static inline int aosp_set_quality_report(struct hci_dev *hdev, bool enable)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> #endif
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 44683443300c..d6c322763567 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -39,6 +39,7 @@
> #include "mgmt_config.h"
> #include "msft.h"
> #include "eir.h"
> +#include "aosp.h"
> 
> #define MGMT_VERSION	1
> #define MGMT_REVISION	21
> @@ -3863,7 +3864,8 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
> 		idx++;
> 	}
> 
> -	if (hdev && hdev->set_quality_report) {
> +	if (hdev && (aosp_has_quality_report(hdev) ||
> +		     hdev->set_quality_report)) {
> 		if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT))
> 			flags = BIT(0);
> 		else
> @@ -4127,7 +4129,8 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
> 	val = !!cp->param[0];
> 	changed = (val != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT));
> 
> -	if (!hdev->set_quality_report) {
> +	if (!aosp_has_quality_report(hdev) && !hdev->set_quality_report) {
> +		BT_INFO("quality report not supported");

this is a debug print. It does not belong here. Just remove it. You can use btmgmt to check the status if quality report is supported or not.

> 		err = mgmt_cmd_status(sk, hdev->id,
> 				      MGMT_OP_SET_EXP_FEATURE,
> 				      MGMT_STATUS_NOT_SUPPORTED);
> @@ -4135,13 +4138,18 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
> 	}
> 
> 	if (changed) {
> -		err = hdev->set_quality_report(hdev, val);
> +		if (hdev->set_quality_report)
> +			err = hdev->set_quality_report(hdev, val);
> +		else
> +			err = aosp_set_quality_report(hdev, val);
> +
> 		if (err) {
> 			err = mgmt_cmd_status(sk, hdev->id,
> 					      MGMT_OP_SET_EXP_FEATURE,
> 					      MGMT_STATUS_FAILED);
> 			goto unlock_quality_report;
> 		}
> +
> 		if (val)
> 			hci_dev_set_flag(hdev, HCI_QUALITY_REPORT);
> 		else
> @@ -4153,8 +4161,8 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
> 	memcpy(rp.uuid, quality_report_uuid, 16);
> 	rp.flags = cpu_to_le32(val ? BIT(0) : 0);
> 	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
> -	err = mgmt_cmd_complete(sk, hdev->id,
> -				MGMT_OP_SET_EXP_FEATURE, 0,
> +
> +	err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_EXP_FEATURE, 0,
> 				&rp, sizeof(rp));
> 

Regards

Marcel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension
  2021-10-21 15:04 ` [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension Joseph Hwang
@ 2021-10-25 13:26   ` Marcel Holtmann
  2021-10-29  8:08     ` Joseph Hwang
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2021-10-25 13:26 UTC (permalink / raw)
  To: Joseph Hwang
  Cc: linux-bluetooth, Luiz Augusto von Dentz, pali,
	chromeos-bluetooth-upstreaming, josephsih, Miao-chen Chou,
	Johan Hedberg, linux-kernel

Hi Joseph,

> This patch enables Mediatek to support the AOSP extension.
> 
> Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
> Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> 
> ---
> 
> (no changes since v5)
> 
> Changes in v5:
> - Let the vendor command in aosp_do_open() to determine what
>  capabilities are supported.
> 
> Changes in v4:
> - Call hci_set_aosp_capable in the driver.
> - This patch is added in this Series-changes 4.
> 
> drivers/bluetooth/btusb.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 87b71740fad8..00311ebd7823 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -3876,6 +3876,8 @@ static int btusb_probe(struct usb_interface *intf,
> 		hdev->set_bdaddr = btusb_set_bdaddr_mtk;
> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> 		data->recv_acl = btusb_recv_acl_mtk;
> +
> +		hci_set_aosp_capable(hdev);

can we get an ACK from Mediatek people that all their firmwares support the AOSP extensions.

Regards

Marcel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension
  2021-10-25 13:26   ` Marcel Holtmann
@ 2021-10-29  8:08     ` Joseph Hwang
  2021-10-29  8:21       ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Hwang @ 2021-10-29  8:08 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-bluetooth, Luiz Augusto von Dentz, pali,
	chromeos-bluetooth-upstreaming, Miao-chen Chou, Johan Hedberg,
	linux-kernel, Mark-YW Chen (陳揚文)

+Mark-YW.Chen@mediatek.com

Some of Mediatek's controllers/firmwares do NOT support AOSP extensions.

Please refer to this Gerrit patch review link for chrome os
(https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3054233/8/drivers/bluetooth/btusb.c)
which was reviewed by Mark-YW Chen, Mediatek's engineer.

As an example, MediaTek MT7615E does not support the AOSP extensions.

That was why I used a new BTUSB_QUALITY_REPORT flag in the changes v4
and earlier ones.

Please let me know how you would like to proceed with this patch.

Thanks!
Joseph


On Mon, Oct 25, 2021 at 9:26 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Joseph,
>
> > This patch enables Mediatek to support the AOSP extension.
> >
> > Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
> > Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> >
> > ---
> >
> > (no changes since v5)
> >
> > Changes in v5:
> > - Let the vendor command in aosp_do_open() to determine what
> >  capabilities are supported.
> >
> > Changes in v4:
> > - Call hci_set_aosp_capable in the driver.
> > - This patch is added in this Series-changes 4.
> >
> > drivers/bluetooth/btusb.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> > index 87b71740fad8..00311ebd7823 100644
> > --- a/drivers/bluetooth/btusb.c
> > +++ b/drivers/bluetooth/btusb.c
> > @@ -3876,6 +3876,8 @@ static int btusb_probe(struct usb_interface *intf,
> >               hdev->set_bdaddr = btusb_set_bdaddr_mtk;
> >               set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> >               data->recv_acl = btusb_recv_acl_mtk;
> > +
> > +             hci_set_aosp_capable(hdev);
>
> can we get an ACK from Mediatek people that all their firmwares support the AOSP extensions.
>
> Regards
>
> Marcel
>


-- 

Joseph Shyh-In Hwang
Email: josephsih@google.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension
  2021-10-29  8:08     ` Joseph Hwang
@ 2021-10-29  8:21       ` Marcel Holtmann
  2021-10-29 14:12         ` Joseph Hwang
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2021-10-29  8:21 UTC (permalink / raw)
  To: Joseph Hwang
  Cc: linux-bluetooth, Luiz Augusto von Dentz, pali,
	chromeos-bluetooth-upstreaming, Miao-chen Chou, Johan Hedberg,
	linux-kernel, "Mark-YW Chen (陳揚文)"

Hi Joseph,

> Some of Mediatek's controllers/firmwares do NOT support AOSP extensions.
> 
> Please refer to this Gerrit patch review link for chrome os
> (https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3054233/8/drivers/bluetooth/btusb.c)
> which was reviewed by Mark-YW Chen, Mediatek's engineer.
> 
> As an example, MediaTek MT7615E does not support the AOSP extensions.
> 
> That was why I used a new BTUSB_QUALITY_REPORT flag in the changes v4
> and earlier ones.
> 
> Please let me know how you would like to proceed with this patch.

I want that inside the Mediatek specific hdev->setup() procedure, they decide if AOSP extensions are supported or not. The BTUSB flag business is getting out of hand. I really don’t want that in btusb.c anymore. I moved Intel over to do that in btintel.c and also Realtek is doing it in btrtl.c for their hardware with the MSFT extensions.

We are not doing try-and-error of HCI commands. Just keep that in mind since I said that multiple times now.

Regards

Marcel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension
  2021-10-29  8:21       ` Marcel Holtmann
@ 2021-10-29 14:12         ` Joseph Hwang
  0 siblings, 0 replies; 10+ messages in thread
From: Joseph Hwang @ 2021-10-29 14:12 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-bluetooth, Luiz Augusto von Dentz, pali,
	chromeos-bluetooth-upstreaming, Miao-chen Chou, Johan Hedberg,
	linux-kernel, Mark-YW Chen (陳揚文)

Hi Marcel:

  I see your point. Thank you for letting us know the right way to go.
I will discuss with Mediatek and request them to implement their
specific setup() for the purpose. And then they will submit a new
patch to enable AOSP extensions for their hardware.

Thanks and regards,
Joseph

On Fri, Oct 29, 2021 at 4:21 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Joseph,
>
> > Some of Mediatek's controllers/firmwares do NOT support AOSP extensions.
> >
> > Please refer to this Gerrit patch review link for chrome os
> > (https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3054233/8/drivers/bluetooth/btusb.c)
> > which was reviewed by Mark-YW Chen, Mediatek's engineer.
> >
> > As an example, MediaTek MT7615E does not support the AOSP extensions.
> >
> > That was why I used a new BTUSB_QUALITY_REPORT flag in the changes v4
> > and earlier ones.
> >
> > Please let me know how you would like to proceed with this patch.
>
> I want that inside the Mediatek specific hdev->setup() procedure, they decide if AOSP extensions are supported or not. The BTUSB flag business is getting out of hand. I really don’t want that in btusb.c anymore. I moved Intel over to do that in btintel.c and also Realtek is doing it in btrtl.c for their hardware with the MSFT extensions.
>
> We are not doing try-and-error of HCI commands. Just keep that in mind since I said that multiple times now.
>
> Regards
>
> Marcel
>


-- 

Joseph Shyh-In Hwang
Email: josephsih@google.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-29 14:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 15:04 [PATCH v6 1/3] Bluetooth: Add struct of reading AOSP vendor capabilities Joseph Hwang
2021-10-21 15:04 ` [PATCH v6 2/3] Bluetooth: aosp: Support AOSP Bluetooth Quality Report Joseph Hwang
2021-10-25 13:24   ` Marcel Holtmann
2021-10-21 15:04 ` [PATCH v6 3/3] Bluetooth: btusb: enable Mediatek to support AOSP extension Joseph Hwang
2021-10-25 13:26   ` Marcel Holtmann
2021-10-29  8:08     ` Joseph Hwang
2021-10-29  8:21       ` Marcel Holtmann
2021-10-29 14:12         ` Joseph Hwang
2021-10-21 16:43 ` [v6,1/3] Bluetooth: Add struct of reading AOSP vendor capabilities bluez.test.bot
2021-10-25 13:18 ` [PATCH v6 1/3] " Marcel Holtmann

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).