Skip to contentSkip to conversation

Bluetooth: btintel: Send new command for PPAG

PATCH Superseded Lokendra Singh 3 participants 4 messages Aug 10, 2023 – Aug 17, 2023 Bluetooth drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Bluetooth: btintel: Send new command for PPAG

Added support for the new command opcode FE0B
(HCI Intel PPAG Enable).

btmon log:
< HCI Command: Intel PPAG Enable (0x3f|0x020b) plen 4

        Enable: 0x00000002
Quoted 1 line

HCI Event: Command Complete (0x0e) plen 4

      Intel PPAG Enable (0x3f|0x020b) ncmd 1
        Status: Success (0x00)
---
 drivers/bluetooth/btintel.c | 28 +++++++++++++++++++---------
 drivers/bluetooth/btintel.h |  8 +++-----
 2 files changed, 22 insertions(+), 14 deletions(-)
drivers/bluetooth/btintel.c +19 -9
index 633e8d9bf58f..d2c93b88c527 100644
@@ -2401,7 +2401,7 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
 {
 	struct btintel_ppag ppag;
 	struct sk_buff *skb;
-	struct btintel_loc_aware_reg ppag_cmd;
+	struct hci_ppag_enable_cmd ppag_cmd;
 	acpi_handle handle;
 
 	/* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */
@@ -2409,6 +2409,8 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
 	case 0x504:     /* Hrp2 */
 	case 0x202:     /* Jfp2 */
 	case 0x201:     /* Jfp1 */
+		bt_dev_warn(hdev, "PPAG not supported for Intel CNVr (0x%3x)",
+			    ver->cnvr_top & 0xFFF);
 		return;
 	}
 
@@ -2434,24 +2436,32 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
 	}
 
 	if (ppag.domain != 0x12) {
-		bt_dev_warn(hdev, "PPAG-BT: domain is not bluetooth");
+		bt_dev_warn(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");
 		return;
 	}
 
-	/* PPAG mode, BIT0 = 0 Disabled, BIT0 = 1 Enabled */
-	if (!(ppag.mode & BIT(0))) {
-		bt_dev_dbg(hdev, "PPAG-BT: disabled");
+	/* PPAG mode
+	 * BIT 0 : 0 Disabled in EU
+	 *         1 Enabled in EU
+	 * BIT 1 : 0 Disabled in China
+	 *         1 Enabled in China
+	 */
+	if ((ppag.mode & 0x01) != BIT(0) && (ppag.mode & 0x02) != BIT(1)) {
+		bt_dev_warn(hdev, "PPAG-BT: EU, China mode are disabled in CB/BIOS");
 		return;
 	}
 
-	ppag_cmd.mcc = cpu_to_le32(0);
-	ppag_cmd.sel = cpu_to_le32(0); /* 0 - Enable , 1 - Disable, 2 - Testing mode */
-	ppag_cmd.delta = cpu_to_le32(0);
-	skb = __hci_cmd_sync(hdev, 0xfe19, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
+	/* HCI_Intel_PpagEnable_CMD - opcode: 0xFE0B
+	 * ppag_enable_flags - ppag mode
+	 */
+	ppag_cmd.ppag_enable_flags = ppag.mode;
+
+	skb = __hci_cmd_sync(hdev, 0xfe0b, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
 	if (IS_ERR(skb)) {
 		bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
 		return;
 	}
+	bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
 	kfree_skb(skb);
 }
 
drivers/bluetooth/btintel.h +3 -5
index 2ed646609dee..01e87f68fab0 100644
@@ -137,11 +137,9 @@ struct intel_offload_use_cases {
 	__u8	preset[8];
 } __packed;
 
-struct btintel_loc_aware_reg {
-	__le32 mcc;
-	__le32 sel;
-	__le32 delta;
-} __packed;
+struct hci_ppag_enable_cmd {
+	u32 ppag_enable_flags;
+};
 
 #define INTEL_TLV_TYPE_ID		0x01
 
Signature · 1 line
2.25.1
#1 lore raw

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

---Test result---

Test Summary:

CheckPatch                    PASS      0.90 seconds
GitLint                       PASS      0.35 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      33.09 seconds
CheckAllWarning               PASS      35.67 seconds
CheckSparse                   PASS      41.00 seconds
CheckSmatch                   PASS      113.97 seconds
BuildKernel32                 PASS      31.62 seconds
TestRunnerSetup               PASS      477.82 seconds
TestRunner_l2cap-tester       PASS      22.40 seconds
TestRunner_iso-tester         PASS      44.84 seconds
TestRunner_bnep-tester        PASS      10.03 seconds
TestRunner_mgmt-tester        PASS      215.11 seconds
TestRunner_rfcomm-tester      PASS      15.19 seconds
TestRunner_sco-tester         PASS      18.28 seconds
TestRunner_ioctl-tester       PASS      17.03 seconds
TestRunner_mesh-tester        PASS      12.75 seconds
TestRunner_smp-tester         PASS      13.69 seconds
TestRunner_userchan-tester    PASS      10.55 seconds
IncrementalBuild              PASS      30.00 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Lokendra Singh

Hi Lokendra,

Quoted 32 lines · Lokendra Singh

Added support for the new command opcode FE0B
(HCI Intel PPAG Enable).

btmon log:
< HCI Command: Intel PPAG Enable (0x3f|0x020b) plen 4

        Enable: 0x00000002
Quoted 1 line

HCI Event: Command Complete (0x0e) plen 4

      Intel PPAG Enable (0x3f|0x020b) ncmd 1
        Status: Success (0x00)
---
 drivers/bluetooth/btintel.c | 28 +++++++++++++++++++---------
 drivers/bluetooth/btintel.h |  8 +++-----
 2 files changed, 22 insertions(+), 14 deletions(-)
drivers/bluetooth/btintel.c +1 -1
index 633e8d9bf58f..d2c93b88c527 100644
@@ -2401,7 +2401,7 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
 {
        struct btintel_ppag ppag;
        struct sk_buff *skb;
-       struct btintel_loc_aware_reg ppag_cmd;
+       struct hci_ppag_enable_cmd ppag_cmd;
        acpi_handle handle;
 
        /* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver · line 2413

Quoted 5 lines
drivers/bluetooth/btintel.c +2 -0
@@ -2409,6 +2409,8 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
        case 0x504:     /* Hrp2 */
        case 0x202:     /* Jfp2 */
        case 0x201:     /* Jfp1 */
+               bt_dev_warn(hdev, "PPAG not supported for Intel CNVr (0x%3x)",
+                           ver->cnvr_top & 0xFFF);

If this doesn't change the functionality I'd recommend using bt_dev_dbg so we don't warn users for no reason.

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver · line 2439

Quoted 9 lines
drivers/bluetooth/btintel.c +1 -1
                return;
        }
 
@@ -2434,24 +2436,32 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
        }
 
        if (ppag.domain != 0x12) {
-               bt_dev_warn(hdev, "PPAG-BT: domain is not bluetooth");
+               bt_dev_warn(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");

Ditto.

Quoted 4 lines
drivers/bluetooth/btintel.c +0 -1
                return;
        }
 
-       /* PPAG mode, BIT0 = 0 Disabled, BIT0 = 1 Enabled */

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver · line 2450

Quoted 10 lines
drivers/bluetooth/btintel.c +8 -2
-       if (!(ppag.mode & BIT(0))) {
-               bt_dev_dbg(hdev, "PPAG-BT: disabled");
+       /* PPAG mode
+        * BIT 0 : 0 Disabled in EU
+        *         1 Enabled in EU
+        * BIT 1 : 0 Disabled in China
+        *         1 Enabled in China
+        */
+       if ((ppag.mode & 0x01) != BIT(0) && (ppag.mode & 0x02) != BIT(1)) {
+               bt_dev_warn(hdev, "PPAG-BT: EU, China mode are disabled in CB/BIOS");

Ditto.

Quoted 27 lines
drivers/bluetooth/btintel.c +7 -4
                return;
        }
 
-       ppag_cmd.mcc = cpu_to_le32(0);
-       ppag_cmd.sel = cpu_to_le32(0); /* 0 - Enable , 1 - Disable, 2 - Testing mode */
-       ppag_cmd.delta = cpu_to_le32(0);
-       skb = __hci_cmd_sync(hdev, 0xfe19, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
+       /* HCI_Intel_PpagEnable_CMD - opcode: 0xFE0B
+        * ppag_enable_flags - ppag mode
+        */
+       ppag_cmd.ppag_enable_flags = ppag.mode;
+
+       skb = __hci_cmd_sync(hdev, 0xfe0b, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
        if (IS_ERR(skb)) {
                bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
                return;
        }
+       bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
        kfree_skb(skb);
 }
 
drivers/bluetooth/btintel.h +0 -0
index 2ed646609dee..01e87f68fab0 100644
@@ -137,11 +137,9 @@ struct intel_offload_use_cases {
        __u8    preset[8];

drivers/bluetooth/btintel.h struct intel_offload_use_cases { · line 142

Quoted 10 lines
drivers/bluetooth/btintel.h +3 -5
 } __packed;
 
-struct btintel_loc_aware_reg {
-       __le32 mcc;
-       __le32 sel;
-       __le32 delta;
-} __packed;
+struct hci_ppag_enable_cmd {
+       u32 ppag_enable_flags;
+};

Lets also add defines to command opcodes so we don't have to add comments on what the opcode means around the codebase.

Quoted 5 lines
drivers/bluetooth/btintel.h +0 -1
 #define INTEL_TLV_TYPE_ID              0x01
 
--

2.25.1

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

Hi Luiz,

Quoted 51 lines

-----Original Message-----
From: Luiz Augusto von Dentz <[email protected]>
Sent: Thursday, 10 August, 2023 11:20 PM
To: Singh, Lokendra <[email protected]>
Cc: [email protected]; Srivatsa, Ravishankar <[email protected]>; Tumkur Narayan, Chethan <[email protected]>; Von Dentz, Luiz <[email protected]>; An, Tedd <[email protected]>; K, Kiran <[email protected]>; Seema Sreemantha <[email protected]>
Subject: Re: [PATCH v2] Bluetooth: btintel: Send new command for PPAG

Hi Lokendra,

Quoted 22 lines · Lokendra Singh

Added support for the new command opcode FE0B (HCI Intel PPAG Enable).

btmon log:
< HCI Command: Intel PPAG Enable (0x3f|0x020b) plen 4

        Enable: 0x00000002
Quoted 1 line

HCI Event: Command Complete (0x0e) plen 4

      Intel PPAG Enable (0x3f|0x020b) ncmd 1
        Status: Success (0x00)
---
 drivers/bluetooth/btintel.c | 28 +++++++++++++++++++---------
drivers/bluetooth/btintel.h |  8 +++-----
 2 files changed, 22 insertions(+), 14 deletions(-)
drivers/bluetooth/btintel.c +0 -0
index 633e8d9bf58f..d2c93b88c527 100644

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev

Quoted 9 lines
drivers/bluetooth/btintel.c +1 -2
@@ -2401,7 +2401,7 @@ static void btintel_set_ppag(struct hci_dev
 *hdev, struct intel_version_tlv *ver  {
        struct btintel_ppag ppag;
        struct sk_buff *skb;
-       struct btintel_loc_aware_reg ppag_cmd;
+       struct hci_ppag_enable_cmd ppag_cmd;
        acpi_handle handle;
 
        /* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */ @@
-2409,6 +2409,8 @@ static void btintel_set_ppag(struct hci_dev *hdev,

struct intel_version_tlv *ver

Quoted 4 lines
        case 0x504:     /* Hrp2 */
        case 0x202:     /* Jfp2 */
        case 0x201:     /* Jfp1 */

+ bt_dev_warn(hdev, "PPAG not supported for Intel CNVr

Quoted 5 lines

(0x%3x)",

Quoted 1 line

+ ver->cnvr_top & 0xFFF);

If this doesn't change the functionality I'd recommend using bt_dev_dbg so we don't warn users for no reason.

Ack. I will update it in next patch.

Quoted 6 lines

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev

Quoted 5 lines
                return;
        }
drivers/bluetooth/btintel.c +0 -0
@@ -2434,24 +2436,32 @@ static void btintel_set_ppag(struct hci_dev

*hdev, struct intel_version_tlv *ver

Quoted 8 lines

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver

Quoted 6 lines
drivers/bluetooth/btintel.c +2 -1
        }
 
        if (ppag.domain != 0x12) {
-               bt_dev_warn(hdev, "PPAG-BT: domain is not bluetooth");
+               bt_dev_warn(hdev, "PPAG-BT: Bluetooth domain is
+ disabled in ACPI firmware");

Ditto.

Ack. I will update it in next patch.

Quoted 14 lines
Quoted 4 lines
drivers/bluetooth/btintel.c +0 -0
                return;
        }
 

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver

Quoted 10 lines
drivers/bluetooth/btintel.c +7 -3
-       /* PPAG mode, BIT0 = 0 Disabled, BIT0 = 1 Enabled */
-       if (!(ppag.mode & BIT(0))) {
-               bt_dev_dbg(hdev, "PPAG-BT: disabled");
+       /* PPAG mode
+        * BIT 0 : 0 Disabled in EU
+        *         1 Enabled in EU
+        * BIT 1 : 0 Disabled in China
+        *         1 Enabled in China
+        */
+       if ((ppag.mode & 0x01) != BIT(0) && (ppag.mode & 0x02) !=
Quoted 5 lines

BIT(1)) {

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev · line 2452

Quoted 2 lines
drivers/bluetooth/btintel.c +2 -0
+               bt_dev_warn(hdev, "PPAG-BT: EU, China mode are
+ disabled in CB/BIOS");

Ditto.

Ack. I will update it in next patch.

Quoted 34 lines

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver

Quoted 6 lines
drivers/bluetooth/btintel.c +0 -2
                return;
        }
 
-       ppag_cmd.mcc = cpu_to_le32(0);
-       ppag_cmd.sel = cpu_to_le32(0); /* 0 - Enable , 1 - Disable, 2

- Testing mode */

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev · line 2450

Quoted 2 lines
drivers/bluetooth/btintel.c +0 -2
-       ppag_cmd.delta = cpu_to_le32(0);
-       skb = __hci_cmd_sync(hdev, 0xfe19, sizeof(ppag_cmd),

&ppag_cmd, HCI_CMD_TIMEOUT);

drivers/bluetooth/btintel.c static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver

Quoted 9 lines
drivers/bluetooth/btintel.c +7 -0
+       /* HCI_Intel_PpagEnable_CMD - opcode: 0xFE0B
+        * ppag_enable_flags - ppag mode
+        */
+       ppag_cmd.ppag_enable_flags = ppag.mode;
+
+       skb = __hci_cmd_sync(hdev, 0xfe0b, sizeof(ppag_cmd),
+ &ppag_cmd, HCI_CMD_TIMEOUT);
        if (IS_ERR(skb)) {
                bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)",

PTR_ERR(skb));

Quoted 14 lines
drivers/bluetooth/btintel.c +1 -0
                return;
        }
+       bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
        kfree_skb(skb);
 }
drivers/bluetooth/btintel.h +0 -0
index 2ed646609dee..01e87f68fab0 100644
@@ -137,11 +137,9 @@ struct intel_offload_use_cases {
        __u8    preset[8];
 } __packed;
 
Quoted 11 lines

drivers/bluetooth/btintel.h struct intel_offload_use_cases { · line 142

Quoted 8 lines
drivers/bluetooth/btintel.h +3 -5
-struct btintel_loc_aware_reg {
-       __le32 mcc;
-       __le32 sel;
-       __le32 delta;
-} __packed;
+struct hci_ppag_enable_cmd {
+       u32 ppag_enable_flags;
+};

Lets also add defines to command opcodes so we don't have to add comments on what the opcode means around the codebase.

Ack. I will update it in next patch.

Quoted 10 lines
Quoted 6 lines
drivers/bluetooth/btintel.h +0 -1
 #define INTEL_TLV_TYPE_ID              0x01
 
--

2.25.1

--
Luiz Augusto von Dentz