Commit | Line | Data |
---|---|---|
903e4541 AE |
1 | /* |
2 | Copyright (c) 2011,2012 Intel Corp. | |
3 | ||
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License version 2 and | |
6 | only version 2 as published by the Free Software Foundation. | |
7 | ||
8 | This program is distributed in the hope that it will be useful, | |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | GNU General Public License for more details. | |
12 | */ | |
13 | ||
14 | #include <net/bluetooth/bluetooth.h> | |
15 | #include <net/bluetooth/hci.h> | |
16 | #include <net/bluetooth/hci_core.h> | |
17 | #include <net/bluetooth/a2mp.h> | |
18 | #include <net/bluetooth/amp.h> | |
19 | ||
3161ae1c AE |
20 | /* Physical Link interface */ |
21 | static u8 __next_handle(struct amp_mgr *mgr) | |
22 | { | |
23 | if (++mgr->handle == 0) | |
24 | mgr->handle = 1; | |
25 | ||
26 | return mgr->handle; | |
27 | } | |
28 | ||
29 | struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | |
30 | u8 remote_id) | |
31 | { | |
32 | bdaddr_t *dst = mgr->l2cap_conn->dst; | |
33 | struct hci_conn *hcon; | |
34 | ||
35 | hcon = hci_conn_add(hdev, AMP_LINK, dst); | |
36 | if (!hcon) | |
37 | return NULL; | |
38 | ||
39 | hcon->state = BT_CONNECT; | |
40 | hcon->out = true; | |
41 | hcon->attempt++; | |
42 | hcon->handle = __next_handle(mgr); | |
43 | hcon->remote_id = remote_id; | |
44 | hcon->amp_mgr = mgr; | |
45 | ||
46 | return hcon; | |
47 | } | |
48 | ||
903e4541 AE |
49 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle) |
50 | { | |
51 | struct hci_cp_read_local_amp_assoc cp; | |
52 | struct amp_assoc *loc_assoc = &hdev->loc_assoc; | |
53 | ||
54 | BT_DBG("%s handle %d", hdev->name, phy_handle); | |
55 | ||
56 | cp.phy_handle = phy_handle; | |
57 | cp.max_len = cpu_to_le16(hdev->amp_assoc_size); | |
58 | cp.len_so_far = cpu_to_le16(loc_assoc->offset); | |
59 | ||
60 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); | |
61 | } | |
62 | ||
63 | void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr) | |
64 | { | |
65 | struct hci_cp_read_local_amp_assoc cp; | |
66 | ||
67 | memset(&hdev->loc_assoc, 0, sizeof(struct amp_assoc)); | |
68 | memset(&cp, 0, sizeof(cp)); | |
69 | ||
70 | cp.max_len = cpu_to_le16(hdev->amp_assoc_size); | |
71 | ||
72 | mgr->state = READ_LOC_AMP_ASSOC; | |
73 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); | |
74 | } |