diff mbox series

[v1] Bluetooth: btintel: Send new command for PPAG

Message ID 20230810105502.27012-1-lokendra.singh@intel.com
State New
Headers show
Series [v1] Bluetooth: btintel: Send new command for PPAG | expand

Commit Message

Singh, Lokendra Aug. 10, 2023, 10:55 a.m. UTC
From: Seema Sreemantha <seema.sreemantha@intel.com>

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
> HCI Event: Command Complete (0x0e) plen 4
      Intel PPAG Enable (0x3f|0x020b) ncmd 1
        Status: Success (0x00)

Signed-off-by: Seema Sreemantha <seema.sreemantha@intel.com>
Signed-off-by: Lokendra Singh <lokendra.singh@intel.com>
---
 drivers/bluetooth/btintel.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

Comments

kernel test robot Aug. 10, 2023, 3:08 p.m. UTC | #1
Hi Lokendra,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on bluetooth/master linus/master v6.5-rc5 next-20230809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lokendra-Singh/Bluetooth-btintel-Send-new-command-for-PPAG/20230810-185334
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20230810105502.27012-1-lokendra.singh%40intel.com
patch subject: [PATCH v1] Bluetooth: btintel: Send new command for PPAG
config: x86_64-randconfig-x011-20230810 (https://download.01.org/0day-ci/archive/20230810/202308102242.EKYkZi8t-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230810/202308102242.EKYkZi8t-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308102242.EKYkZi8t-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/bluetooth/btintel.c: In function 'btintel_set_ppag':
   drivers/bluetooth/btintel.c:2404:36: error: storage size of 'ppag_cmd' isn't known
    2404 |         struct hci_ppag_enable_cmd ppag_cmd;
         |                                    ^~~~~~~~
>> drivers/bluetooth/btintel.c:2404:36: warning: unused variable 'ppag_cmd' [-Wunused-variable]


vim +/ppag_cmd +2404 drivers/bluetooth/btintel.c

  2399	
  2400	static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver)
  2401	{
  2402		struct btintel_ppag ppag;
  2403		struct sk_buff *skb;
> 2404		struct hci_ppag_enable_cmd ppag_cmd;
  2405		acpi_handle handle;
  2406	
  2407		/* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */
  2408		switch (ver->cnvr_top & 0xFFF) {
  2409		case 0x504:     /* Hrp2 */
  2410		case 0x202:     /* Jfp2 */
  2411		case 0x201:     /* Jfp1 */
  2412			bt_dev_warn(hdev, "PPAG not supported for Intel CNVr (0x%3x)",
  2413				    ver->cnvr_top & 0xFFF);
  2414			return;
  2415		}
  2416	
  2417		handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
  2418		if (!handle) {
  2419			bt_dev_info(hdev, "No support for BT device in ACPI firmware");
  2420			return;
  2421		}
  2422	
  2423		memset(&ppag, 0, sizeof(ppag));
  2424	
  2425		ppag.hdev = hdev;
  2426		ppag.status = AE_NOT_FOUND;
  2427		acpi_walk_namespace(ACPI_TYPE_PACKAGE, handle, 1, NULL,
  2428				    btintel_ppag_callback, &ppag, NULL);
  2429	
  2430		if (ACPI_FAILURE(ppag.status)) {
  2431			if (ppag.status == AE_NOT_FOUND) {
  2432				bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found");
  2433				return;
  2434			}
  2435			return;
  2436		}
  2437	
  2438		if (ppag.domain != 0x12) {
  2439			bt_dev_warn(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");
  2440			return;
  2441		}
  2442	
  2443		/* PPAG mode
  2444		 * BIT 0 : 0 Disabled in EU
  2445		 *         1 Enabled in EU
  2446		 * BIT 1 : 0 Disabled in China
  2447		 *         1 Enabled in China
  2448		 */
  2449		if((ppag.mode & 0x01) != BIT(0) && (ppag.mode & 0x02) != BIT(1)) {
  2450			bt_dev_warn(hdev, "PPAG-BT: EU, China mode are disabled in CB/BIOS");
  2451			return;
  2452		}
  2453	
  2454		/* HCI_Intel_PpagEnable_CMD - opcode: 0xFE0B
  2455		 * ppag_enable_flags - ppag mode
  2456		 */
  2457		ppag_cmd.ppag_enable_flags = ppag.mode;
  2458	
  2459		skb = __hci_cmd_sync(hdev, 0xfe0b, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
  2460		if (IS_ERR(skb)) {
  2461			bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
  2462			return;
  2463		}
  2464		bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
  2465		kfree_skb(skb);
  2466	}
  2467
diff mbox series

Patch

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 633e8d9bf58f..71964c99f5f3 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -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);
 }