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 <[email protected]>
---
v2: rename btintel_ddc_send into btintel_load_ddc_config
drivers/bluetooth/btintel.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
drivers/bluetooth/btintel.h | 7 +++++++
2 files changed, 53 insertions(+)
diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 048423f..9e18988 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 <[email protected]>");
MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
MODULE_VERSION(VERSION);
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index b278d14..39c67f3 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -78,6 +78,7 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code);
void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
const void *param);
+int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
#else
@@ -105,4 +106,10 @@ static inline int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type,
return -EOPNOTSUPP;
}
+static inline int btintel_load_ddc_config(struct hci_dev *hdev,
+ const char *ddc_name)
+{
+ return -EOPNOTSUPP
+}
+
#endif
--
1.9.1
Hi Loic,
> btintel_load_ddc_config is now part of btintel.
>
> Signed-off-by: Loic Poulain <[email protected]>
> ---
> v2: introduce this patch in the serie
>
> drivers/bluetooth/btusb.c | 31 +------------------------------
> 1 file changed, 1 insertion(+), 30 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Hi Loic,
> Apply DDC parameters once controller is in operational mode.
>
> Signed-off-by: Loic Poulain <[email protected]>
> ---
> v2: use fwname instead of additional dedicated buffer
>
> drivers/bluetooth/hci_intel.c | 7 +++++++
> 1 file changed, 7 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Hi Loic,
> 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 <[email protected]>
> ---
> v2: rename btintel_ddc_send into btintel_load_ddc_config
>
> drivers/bluetooth/btintel.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
> drivers/bluetooth/btintel.h | 7 +++++++
> 2 files changed, 53 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
btintel_load_ddc_config is now part of btintel.
Signed-off-by: Loic Poulain <[email protected]>
---
v2: introduce this patch in the serie
drivers/bluetooth/btusb.c | 31 +------------------------------
1 file changed, 1 insertion(+), 30 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index eeff7ca..9521b7b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2219,36 +2219,7 @@ done:
* The device can work without DDC parameters, so even if it fails
* to load the file, no need to fail the setup.
*/
- err = request_firmware_direct(&fw, fwname, &hdev->dev);
- if (err < 0)
- return 0;
-
- BT_INFO("%s: Found Intel DDC parameters: %s", hdev->name, fwname);
-
- 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_ERR("%s: Failed to send Intel_Write_DDC (%ld)",
- hdev->name, PTR_ERR(skb));
- release_firmware(fw);
- return PTR_ERR(skb);
- }
-
- fw_ptr += cmd_plen;
- kfree_skb(skb);
- }
-
- release_firmware(fw);
-
- BT_INFO("%s: Applying Intel DDC parameters completed", hdev->name);
+ btintel_load_ddc_config(hdev, fwname);
return 0;
}
--
1.9.1
Apply DDC parameters once controller is in operational mode.
Signed-off-by: Loic Poulain <[email protected]>
---
v2: use fwname instead of additional dedicated buffer
drivers/bluetooth/hci_intel.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
index b4dc3c5..556d2e6 100644
--- a/drivers/bluetooth/hci_intel.c
+++ b/drivers/bluetooth/hci_intel.c
@@ -735,6 +735,10 @@ static int intel_setup(struct hci_uart *hu)
bt_dev_info(hdev, "Found device firmware: %s", fwname);
+ /* Save the DDC file name for later */
+ snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.ddc",
+ le16_to_cpu(params->dev_revid));
+
kfree_skb(skb);
if (fw->size < 644) {
@@ -927,6 +931,9 @@ done:
set_bit(STATE_LPM_ENABLED, &intel->flags);
no_lpm:
+ /* Ignore ddc error, device can work without DDC parameters */
+ btintel_load_ddc_config(hdev, fwname);
+
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_CMD_TIMEOUT);
if (IS_ERR(skb))
return PTR_ERR(skb);
--
1.9.1