diff mbox series

[3/3] Bluetooth: btrtl: Enable WBS for the specific Realtek devices

Message ID 20210415035559.25743-5-aaron.ma@canonical.com
State New
Headers show
Series add realtek 8852 bluetooth support | expand

Commit Message

Aaron Ma April 15, 2021, 3:55 a.m. UTC
From: Max Chou <max.chou@realtek.com>

BugLink: https://bugs.launchpad.net/bugs/1924207

By this change, it will enable WBS supported on the specific Realtek BT
devices, such as RTL8822C and RTL8852A.
In the future, it's able to maintain what the Realtek devices support WBS
here.

Tested-by: Hilda Wu <hildawu@realtek.com>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Max Chou <max.chou@realtek.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 9ab9235fe5cf7f8823c5c5c90f56d18ec59350b4)
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
---
 drivers/bluetooth/btrtl.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

Comments

Stefan Bader April 23, 2021, 9:32 a.m. UTC | #1
On 15.04.21 05:55, Aaron Ma wrote:
> From: Max Chou <max.chou@realtek.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1924207
> 
> By this change, it will enable WBS supported on the specific Realtek BT
> devices, such as RTL8822C and RTL8852A.
> In the future, it's able to maintain what the Realtek devices support WBS
> here.
> 
> Tested-by: Hilda Wu <hildawu@realtek.com>
> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> Signed-off-by: Max Chou <max.chou@realtek.com>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> (cherry picked from commit 9ab9235fe5cf7f8823c5c5c90f56d18ec59350b4)
> Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
> ---

Applied to hirsute(context adjusted),groovy:linux/master-next. This patch needed 
some context adjusted in the first hunk to apply to hirsute. Thanks.

-Stefan

>   drivers/bluetooth/btrtl.c | 26 +++++++++++++++++++++++---
>   1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index 29200c9bd0e2..523f42e1710a 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -37,6 +37,19 @@
>   	.lmp_subver = (lmps), \
>   	.hci_rev = (hcir)
>   
> +enum btrtl_chip_id {
> +	CHIP_ID_8723A,
> +	CHIP_ID_8723B,
> +	CHIP_ID_8821A,
> +	CHIP_ID_8761A,
> +	CHIP_ID_8822B = 8,
> +	CHIP_ID_8723D,
> +	CHIP_ID_8821C,
> +	CHIP_ID_8822C = 13,
> +	CHIP_ID_8761B,
> +	CHIP_ID_8852A = 18,
> +};
> +
>   struct id_table {
>   	__u16 match_flags;
>   	__u16 lmp_subver;
> @@ -57,6 +70,7 @@ struct btrtl_device_info {
>   	u8 *cfg_data;
>   	int cfg_len;
>   	bool drop_fw;
> +	int project_id;
>   };
>   
>   static const struct id_table ic_id_table[] = {
> @@ -338,8 +352,10 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
>   
>   	/* Find project_id in table */
>   	for (i = 0; i < ARRAY_SIZE(project_id_to_lmp_subver); i++) {
> -		if (project_id == project_id_to_lmp_subver[i].id)
> +		if (project_id == project_id_to_lmp_subver[i].id) {
> +			btrtl_dev->project_id = project_id;
>   			break;
> +		}
>   	}
>   
>   	if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
> @@ -748,12 +764,16 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
>   	/* Enable central-peripheral role (able to create new connections with
>   	 * an existing connection in slave role).
>   	 */
> -	switch (btrtl_dev->ic_info->lmp_subver) {
> -	case RTL_ROM_LMP_8822B:
> +	/* Enable WBS supported for the specific Realtek devices. */
> +	switch (btrtl_dev->project_id) {
> +	case CHIP_ID_8822C:
> +	case CHIP_ID_8852A:
>   		set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
> +		set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
>   		break;
>   	default:
>   		rtl_dev_dbg(hdev, "Central-peripheral role not enabled.");
> +		rtl_dev_dbg(hdev, "WBS supported not enabled.");
>   		break;
>   	}
>   
>
diff mbox series

Patch

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 29200c9bd0e2..523f42e1710a 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -37,6 +37,19 @@ 
 	.lmp_subver = (lmps), \
 	.hci_rev = (hcir)
 
+enum btrtl_chip_id {
+	CHIP_ID_8723A,
+	CHIP_ID_8723B,
+	CHIP_ID_8821A,
+	CHIP_ID_8761A,
+	CHIP_ID_8822B = 8,
+	CHIP_ID_8723D,
+	CHIP_ID_8821C,
+	CHIP_ID_8822C = 13,
+	CHIP_ID_8761B,
+	CHIP_ID_8852A = 18,
+};
+
 struct id_table {
 	__u16 match_flags;
 	__u16 lmp_subver;
@@ -57,6 +70,7 @@  struct btrtl_device_info {
 	u8 *cfg_data;
 	int cfg_len;
 	bool drop_fw;
+	int project_id;
 };
 
 static const struct id_table ic_id_table[] = {
@@ -338,8 +352,10 @@  static int rtlbt_parse_firmware(struct hci_dev *hdev,
 
 	/* Find project_id in table */
 	for (i = 0; i < ARRAY_SIZE(project_id_to_lmp_subver); i++) {
-		if (project_id == project_id_to_lmp_subver[i].id)
+		if (project_id == project_id_to_lmp_subver[i].id) {
+			btrtl_dev->project_id = project_id;
 			break;
+		}
 	}
 
 	if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
@@ -748,12 +764,16 @@  int btrtl_setup_realtek(struct hci_dev *hdev)
 	/* Enable central-peripheral role (able to create new connections with
 	 * an existing connection in slave role).
 	 */
-	switch (btrtl_dev->ic_info->lmp_subver) {
-	case RTL_ROM_LMP_8822B:
+	/* Enable WBS supported for the specific Realtek devices. */
+	switch (btrtl_dev->project_id) {
+	case CHIP_ID_8822C:
+	case CHIP_ID_8852A:
 		set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
+		set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
 		break;
 	default:
 		rtl_dev_dbg(hdev, "Central-peripheral role not enabled.");
+		rtl_dev_dbg(hdev, "WBS supported not enabled.");
 		break;
 	}