[PATCH BlueZ 1/2] btdev: Fix CIS Established Event parameters

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

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

ISO Interval and Transport Latency were inverted.
---
 emulator/btdev.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index d5450190c38e..637f0bb98057 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5940,8 +5940,14 @@ static int cmd_create_cis(struct btdev *dev, const void *data, uint8_t len)
 	return 0;
 }
 
-static uint32_t le_cis_transport_latecy(uint8_t ft, uint8_t iso_interval,
-						uint8_t sdu_interval[3])
+static uint8_t le_cis_interval(uint8_t sdu_interval[3])
+{
+	/* ISO Interval (slots of 1.25 ms) = SDU_Interval (us) */
+	return get_le24(sdu_interval) / 1250;
+}
+
+static uint32_t le_cis_latecy(uint8_t ft, uint8_t iso_interval,
+					uint8_t sdu_interval[3])
 {
 	uint32_t latency;
 	uint32_t interval = get_le24(sdu_interval);
@@ -5949,7 +5955,7 @@ static uint32_t le_cis_transport_latecy(uint8_t ft, uint8_t iso_interval,
 	/* Transport_Latency = FT × ISO_Interval - SDU_Interval */
 	latency = ft * (iso_interval * 1250) - interval;
 
-	return latency <= interval ? latency : interval;
+	return latency >= interval ? latency : interval;
 }
 
 static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
@@ -5983,7 +5989,7 @@ static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
 		evt.p_ft = 0x02;
 		evt.c_mtu = le_cig->cis[cis_idx].c_sdu;
 		evt.p_mtu = le_cig->cis[cis_idx].p_sdu;
-		evt.interval = (le_cig->params.c_latency + 0.625) / 1.25;
+		evt.interval = le_cis_interval(le_cig->params.c_interval);
 
 		/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part G
 		 * page 3050:
@@ -5993,9 +5999,9 @@ static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
 		 * Transport_Latency_P_To_C = CIG_Sync_Delay + FT_P_To_C ×
 		 * ISO_Interval - SDU_Interval_P_To_C
 		 */
-		put_le24(le_cis_transport_latecy(evt.c_ft, evt.interval,
+		put_le24(le_cis_latecy(evt.c_ft, evt.interval,
 				le_cig->params.c_interval), evt.c_latency);
-		put_le24(le_cis_transport_latecy(evt.p_ft, evt.interval,
+		put_le24(le_cis_latecy(evt.p_ft, evt.interval,
 				le_cig->params.p_interval), evt.p_latency);
 	}
 
-- 
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