Skip to content

Commit

Permalink
Bluetooth: Controller: Fix ISO Data timestamp when FT > 1
Browse files Browse the repository at this point in the history
Fix ISO data timestamp to reflect the SDU reference point
and not the ISO event anchor point when PDUs received after
retransmissions.

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
  • Loading branch information
cvinayak committed Jun 29, 2023
1 parent 363066c commit ae8e71b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions subsys/bluetooth/controller/ll_sw/lll_conn_iso.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ struct lll_conn_iso_group {
uint8_t role:1; /* 0: CENTRAL, 1: PERIPHERAL*/
uint8_t paused:1; /* 1: CIG is paused */

/* ISO interval to calculate timestamp under FT > 1 */
uint32_t iso_interval_us;

/* Accumulates LLL prepare callback latencies */
uint16_t latency_prepare;
uint16_t latency_event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ static void isr_rx(void *param)
(cis_lll->rx.bn_curr <= cis_lll->rx.bn) &&
(pdu_rx->sn == cis_lll->nesn) &&
ull_iso_pdu_rx_alloc_peek(2U)) {
struct lll_conn_iso_group *cig_lll;
struct node_rx_iso_meta *iso_meta;

cis_lll->nesn++;
Expand Down Expand Up @@ -771,6 +772,10 @@ static void isr_rx(void *param)
iso_meta->timestamp =
HAL_TICKER_TICKS_TO_US(radio_tmr_start_get()) +
radio_tmr_ready_restore();
cig_lll = ull_conn_iso_lll_group_get_by_stream(cis_lll);
iso_meta->timestamp -= (cis_lll->event_count -
(cis_lll->rx.payload_count / cis_lll->rx.bn)) *
cig_lll->iso_interval_us;
iso_meta->timestamp %=
HAL_TICKER_TICKS_TO_US(BIT(HAL_TICKER_CNTR_MSBIT + 1U));
iso_meta->status = 0U;
Expand Down Expand Up @@ -828,8 +833,8 @@ static void isr_rx(void *param)

isr_rx_next_subevent:
if (cie || (se_curr == cis_lll->nse)) {
struct lll_conn_iso_stream *old_cis_lll;
struct lll_conn_iso_stream *next_cis_lll;
struct lll_conn_iso_stream *old_cis_lll;
struct lll_conn_iso_group *cig_lll;
struct lll_conn *next_conn_lll;
uint8_t phy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ static void isr_rx(void *param)
(cis_lll->rx.bn_curr <= cis_lll->rx.bn) &&
(pdu_rx->sn == cis_lll->nesn) &&
ull_iso_pdu_rx_alloc_peek(2U)) {
struct lll_conn_iso_group *cig_lll;
struct node_rx_iso_meta *iso_meta;

cis_lll->nesn++;
Expand Down Expand Up @@ -588,6 +589,10 @@ static void isr_rx(void *param)
HAL_TICKER_TICKS_TO_US(radio_tmr_start_get()) +
radio_tmr_aa_restore() -
addr_us_get(cis_lll->rx.phy);
cig_lll = ull_conn_iso_lll_group_get_by_stream(cis_lll);
iso_meta->timestamp -= (cis_lll->event_count -
(cis_lll->rx.payload_count / cis_lll->rx.bn)) *
cig_lll->iso_interval_us;
iso_meta->timestamp %=
HAL_TICKER_TICKS_TO_US(BIT(HAL_TICKER_CNTR_MSBIT + 1U));
iso_meta->status = 0U;
Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/controller/ll_sw/ull_central_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ uint8_t ll_cig_parameters_commit(uint8_t cig_id, uint16_t *handles)
}

iso_interval_us = cig->iso_interval * ISO_INT_UNIT_US;
cig->lll.iso_interval_us = iso_interval_us;

lll_hdr_init(&cig->lll, cig);
max_se_length = 0U;
Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ uint8_t ull_peripheral_iso_acquire(struct ll_conn *acl,

cig->iso_interval = sys_le16_to_cpu(req->iso_interval);
iso_interval_us = cig->iso_interval * CONN_INT_UNIT_US;
cig->lll.iso_interval_us = iso_interval_us;

cig->cig_id = req->cig_id;
cig->lll.handle = LLL_HANDLE_INVALID;
Expand Down

0 comments on commit ae8e71b

Please sign in to comment.