Commit e6a7a46b authored by Pauli Virtanen's avatar Pauli Virtanen Committed by Luiz Augusto von Dentz

Bluetooth: ISO: Fix CIG auto-allocation to select configurable CIG

Make CIG auto-allocation to select the first CIG_ID that is still
configurable. Also use correct CIG_ID range (see Core v5.3 Vol 4 Part E
Sec 7.8.97 p.2553).

Previously, it would always select CIG_ID 0 regardless of anything,
because cis_list with data.cis == 0xff (BT_ISO_QOS_CIS_UNSET) would not
count any CIS. Since we are not adding CIS here, use find_cis instead.

Fixes: 26afbd82 ("Bluetooth: Add initial implementation of CIS connections")
Signed-off-by: default avatarPauli Virtanen <pav@iki.fi>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 31c5f916
...@@ -1769,24 +1769,23 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos) ...@@ -1769,24 +1769,23 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
/* Allocate a CIG if not set */ /* Allocate first still reconfigurable CIG if not set */
if (qos->ucast.cig == BT_ISO_QOS_CIG_UNSET) { if (qos->ucast.cig == BT_ISO_QOS_CIG_UNSET) {
for (data.cig = 0x00; data.cig < 0xff; data.cig++) { for (data.cig = 0x00; data.cig < 0xf0; data.cig++) {
data.count = 0; data.count = 0;
data.cis = 0xff;
hci_conn_hash_list_state(hdev, cis_list, ISO_LINK, hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
BT_BOUND, &data); BT_CONNECT, &data);
if (data.count) if (data.count)
continue; continue;
hci_conn_hash_list_state(hdev, cis_list, ISO_LINK, hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
BT_CONNECTED, &data); BT_CONNECTED, &data);
if (!data.count) if (!data.count)
break; break;
} }
if (data.cig == 0xff) if (data.cig == 0xf0)
return false; return false;
/* Update CIG */ /* Update CIG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment