Bluetooth: btusb: Add support to read Intel debug feature
authorChethan T N <chethan.tumkur.narayan@intel.com>
Mon, 8 Jun 2020 12:27:46 +0000 (17:57 +0530)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 10 Jun 2020 04:51:49 +0000 (06:51 +0200)
The command shall read the Intel controller supported
debug feature. Based on the supported features additional debug
configuration shall be enabled.

Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Ps AyappadasX <AyappadasX.Ps@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btintel.c
drivers/bluetooth/btintel.h
drivers/bluetooth/btusb.c

index 6a0e2c5..105ab28 100644 (file)
@@ -754,6 +754,38 @@ void btintel_reset_to_bootloader(struct hci_dev *hdev)
 }
 EXPORT_SYMBOL_GPL(btintel_reset_to_bootloader);
 
+int btintel_read_debug_features(struct hci_dev *hdev,
+                               struct intel_debug_features *features)
+{
+       struct sk_buff *skb;
+       u8 page_no = 1;
+
+       /* Intel controller supports two pages, each page is of 128-bit
+        * feature bit mask. And each bit defines specific feature support
+        */
+       skb = __hci_cmd_sync(hdev, 0xfca6, sizeof(page_no), &page_no,
+                            HCI_INIT_TIMEOUT);
+       if (IS_ERR(skb)) {
+               bt_dev_err(hdev, "Reading supported features failed (%ld)",
+                          PTR_ERR(skb));
+               return PTR_ERR(skb);
+       }
+
+       if (skb->len != (sizeof(features->page1) + 3)) {
+               bt_dev_err(hdev, "Supported features event size mismatch");
+               kfree_skb(skb);
+               return -EILSEQ;
+       }
+
+       memcpy(features->page1, skb->data + 3, sizeof(features->page1));
+
+       /* Read the supported features page2 if required in future.
+        */
+       kfree_skb(skb);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(btintel_read_debug_features);
+
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
 MODULE_VERSION(VERSION);
index a69ea8a..7cd813f 100644 (file)
@@ -62,6 +62,10 @@ struct intel_reset {
        __le32   boot_param;
 } __packed;
 
+struct intel_debug_features {
+       __u8    page1[16];
+} __packed;
+
 #if IS_ENABLED(CONFIG_BT_INTEL)
 
 int btintel_check_bdaddr(struct hci_dev *hdev);
@@ -88,6 +92,10 @@ int btintel_read_boot_params(struct hci_dev *hdev,
 int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
                              u32 *boot_param);
 void btintel_reset_to_bootloader(struct hci_dev *hdev);
+
+int btintel_read_debug_features(struct hci_dev *hdev,
+                               struct intel_debug_features *features);
+
 #else
 
 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
@@ -186,4 +194,11 @@ static inline int btintel_download_firmware(struct hci_dev *dev,
 static inline void btintel_reset_to_bootloader(struct hci_dev *hdev)
 {
 }
+
+static inline int btintel_read_debug_features(struct hci_dev *hdev,
+                                             struct intel_debug_features *features)
+{
+       return -EOPNOTSUPP;
+}
+
 #endif
index 5f022e9..e12d88e 100644 (file)
@@ -2267,6 +2267,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
        struct btusb_data *data = hci_get_drvdata(hdev);
        struct intel_version ver;
        struct intel_boot_params params;
+       struct intel_debug_features features;
        const struct firmware *fw;
        u32 boot_param;
        char fwname[64];
@@ -2542,6 +2543,11 @@ done:
         */
        btintel_load_ddc_config(hdev, fwname);
 
+       /* Read the Intel supported features and if new exception formats
+        * supported, need to load the additional DDC config to enable.
+        */
+       btintel_read_debug_features(hdev, &features);
+
        /* Read the Intel version information after loading the FW  */
        err = btintel_read_version(hdev, &ver);
        if (err)