summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/btintel.c
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@intel.com>2015-09-04 17:54:34 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-09-17 13:20:05 +0200
commit145f2368c5fd7962e37315ccc092670743019d08 (patch)
tree8da5f5be3f49f6a2a68cebfb67df221c4b11f958 /drivers/bluetooth/btintel.c
parentBluetooth: hci_intel: Fix warnings due to unused lpm functions (diff)
downloadlinux-145f2368c5fd7962e37315ccc092670743019d08.tar.xz
linux-145f2368c5fd7962e37315ccc092670743019d08.zip
Bluetooth: btintel: Add Device Configuration support
btintel_load_ddc_config retrieves the ddc file and sends its content via DDC commands (opcode 0xfc8b). The ddc file should contain one or more DDC structures. A DDC structure is composed of the folowing fields: field: | DDC LEN | DDC ID | DDC VALUE | size: | 1 byte | 2 bytes | DDC LEN - 2 | Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth/btintel.c')
-rw-r--r--drivers/bluetooth/btintel.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 048423fd83bf..9e18988375eb 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -22,6 +22,7 @@
*/
#include <linux/module.h>
+#include <linux/firmware.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -169,6 +170,51 @@ int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
}
EXPORT_SYMBOL_GPL(btintel_secure_send);
+int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)
+{
+ const struct firmware *fw;
+ struct sk_buff *skb;
+ const u8 *fw_ptr;
+ int err;
+
+ err = request_firmware_direct(&fw, ddc_name, &hdev->dev);
+ if (err < 0) {
+ bt_dev_err(hdev, "Failed to load Intel DDC file %s (%d)",
+ ddc_name, err);
+ return err;
+ }
+
+ bt_dev_info(hdev, "Found Intel DDC parameters: %s", ddc_name);
+
+ fw_ptr = fw->data;
+
+ /* DDC file contains one or more DDC structure which has
+ * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2).
+ */
+ while (fw->size > fw_ptr - fw->data) {
+ u8 cmd_plen = fw_ptr[0] + sizeof(u8);
+
+ skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr,
+ HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ bt_dev_err(hdev, "Failed to send Intel_Write_DDC (%ld)",
+ PTR_ERR(skb));
+ release_firmware(fw);
+ return PTR_ERR(skb);
+ }
+
+ fw_ptr += cmd_plen;
+ kfree_skb(skb);
+ }
+
+ release_firmware(fw);
+
+ bt_dev_info(hdev, "Applying Intel DDC parameters completed");
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(btintel_load_ddc_config);
+
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
MODULE_VERSION(VERSION);