[PATCH v2 1/1] Bluetooth: hci_event: Fix setting of broadcast qos interval and latency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The latency parameter of the broadcast qos is calculated wrongly.
In fact, no calculation should be made. For broadcast sink the
latency should be taken directly from the BIG Sync Established
event and for the source it should be taken from the Create BIG
Complete event.

The interval parameter of the broadcast qos reffers to the SDU
Interval and shouldn't be set based on the latency. The Host will
read this value from the BASE.

Signed-off-by: Vlad Pruteanu <vlad.pruteanu@xxxxxxx>
---
 net/bluetooth/hci_event.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 868ffccff773..f34775059c17 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -6983,6 +6983,11 @@ static void hci_le_create_big_complete_evt(struct hci_dev *hdev, void *data,
 
 		if (!ev->status) {
 			conn->state = BT_CONNECTED;
+			/* The transport_delay field of this event contains the transport latency
+			 * expressed in us, convert it to ms for consistency.
+			 */
+			conn->iso_qos.bcast.out.latency =
+				DIV_ROUND_CLOSEST(get_unaligned_le24(ev->transport_delay), 1000);
 			set_bit(HCI_CONN_BIG_CREATED, &conn->flags);
 			rcu_read_unlock();
 			hci_debugfs_create_conn(conn);
@@ -7029,7 +7034,6 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
 
 	for (i = 0; i < ev->num_bis; i++) {
 		u16 handle = le16_to_cpu(ev->bis[i]);
-		__le32 interval;
 
 		bis = hci_conn_hash_lookup_handle(hdev, handle);
 		if (!bis) {
@@ -7044,11 +7048,12 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
 			set_bit(HCI_CONN_PA_SYNC, &bis->flags);
 
 		bis->iso_qos.bcast.big = ev->handle;
-		memset(&interval, 0, sizeof(interval));
-		memcpy(&interval, ev->latency, sizeof(ev->latency));
-		bis->iso_qos.bcast.in.interval = le32_to_cpu(interval);
-		/* Convert ISO Interval (1.25 ms slots) to latency (ms) */
-		bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100;
+		/* The latency field of this event contains the transport latency
+		 * expressed in us, convert it to ms for consistency.
+		 */
+		bis->iso_qos.bcast.in.latency =
+			DIV_ROUND_CLOSEST(get_unaligned_le24(ev->latency),
+					  1000);
 		bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu);
 
 		if (!ev->status) {
-- 
2.40.1





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux