0d56c74f9878c3df9c8194f1af837bd6f3e6fd59
[librecmc/librecmc.git] /
1 From 5cb03751455c299b1bf10cb48631bf359cfb11b5 Mon Sep 17 00:00:00 2001
2 From: "mark-yw.chen" <mark-yw.chen@mediatek.com>
3 Date: Wed, 1 Sep 2021 11:32:25 +0800
4 Subject: [PATCH 1/5] Bluetooth: btusb: Support public address configuration
5  for MediaTek Chip.
6
7 The MediaTek chip support vendor specific HCI command(0xfc1a) to
8 change the public address. Add hdev->set_bdaddr handler for MediaTek
9 Chip. After doing a power cycle or MediaTek Bluetooth reset, BD_ADDR
10 will bring back the original one.
11
12 Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
13 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 ---
15  drivers/bluetooth/btusb.c | 18 ++++++++++++++++++
16  1 file changed, 18 insertions(+)
17
18 --- a/drivers/bluetooth/btusb.c
19 +++ b/drivers/bluetooth/btusb.c
20 @@ -2287,6 +2287,23 @@ struct btmtk_section_map {
21         };
22  } __packed;
23  
24 +static int btusb_set_bdaddr_mtk(struct hci_dev *hdev, const bdaddr_t *bdaddr)
25 +{
26 +       struct sk_buff *skb;
27 +       long ret;
28 +
29 +       skb = __hci_cmd_sync(hdev, 0xfc1a, sizeof(bdaddr), bdaddr, HCI_INIT_TIMEOUT);
30 +       if (IS_ERR(skb)) {
31 +               ret = PTR_ERR(skb);
32 +               bt_dev_err(hdev, "changing Mediatek device address failed (%ld)",
33 +                          ret);
34 +               return ret;
35 +       }
36 +       kfree_skb(skb);
37 +
38 +       return 0;
39 +}
40 +
41  static void btusb_mtk_wmt_recv(struct urb *urb)
42  {
43         struct hci_dev *hdev = urb->context;
44 @@ -3940,6 +3957,7 @@ static int btusb_probe(struct usb_interf
45                 hdev->shutdown = btusb_mtk_shutdown;
46                 hdev->manufacturer = 70;
47                 hdev->cmd_timeout = btusb_mtk_cmd_timeout;
48 +               hdev->set_bdaddr = btusb_set_bdaddr_mtk;
49                 set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
50                 data->recv_acl = btusb_recv_acl_mtk;
51         }