-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bluetooth: bap: Fix shift of BIS_Sync parameter of notification #64665
bluetooth: bap: Fix shift of BIS_Sync parameter of notification #64665
Conversation
bis_sync contains BIS index bitfield which is shifted by 1 bit relative to the BIS_Sync parameter of Broadcast Receive State notification. Signed-off-by: Magdalena Kasenberg <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate?
The BIS sync (and requested_bis_sync) are bitfields of BIS indexes and are stored in the same manner that should be sent over air, so it's unclear to me what the issue is what this is fixing
The received over the air in Add Source or Modify Source operation, where BIT(0) is allowed and represents BIS_index 1. But the zephyr//include/zephyr/bluetooth/audio/bap.h Lines 281 to 283 in 90fec53
is filled like this: zephyr/subsys/bluetooth/audio/bap_broadcast_sink.c Lines 107 to 123 in 90fec53
so it seems to be left-shifted by 1 bit relative to (void)net_buf_simple_add_le32(&read_buf, subgroup->bis_sync >> 1); |
I'm sorry, I'm still not following how the above does any shifting. The BIS index bitfields of the subgroups are populated as
and since Can you provide any logs to describe the issue? |
Yes, please have a look at logs from BASS/SR/CP/BV-07-C test case:
The PTS sent Modify Source operation with BIS_Sync bitfield set to 0x01. So because the
So since And that is why this log in IUT logs appears: |
I see. I think this part was missing for me:
So BIS_index 0x01 uses BIT(0). Which is both counterintuitive and conflicting with
As Or do you read it differently? That |
I would treat those x-es as a wildcard values. There are some examples in BAP_v1.0.1.pdf like this one from 'Figure 6.13: Broadcast Assistant initiates Add Source operation' which seem to confirm this usage. But I must say I would sleep better too if the range of allowed values for BIS Indexes started from 0 instead of 1. |
Thanks for that example - That seems to agree with PTS. I think it makes sense to keep the BAP API to be similar to the ISO API (i.e. BIT(1) means index 1), and then as you've suggested here, we will shift the values when sending/receiving over air.
In Zephyr, or in the spec? The BIS indexes range are defined by the core spec, and I think it won't be backwards compatible if modified to start from 0x00 instead of 0x01. We could also, since the bitfield for indexes are not defined by the core, modify Zephyr to use BIT(0) for Index 1, BIT(1) for Index 2, etc. so that the Zephyr API follows the ranges of BASS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, otherwise LGTM as an initial fix.
I've created #64838 to implement a more thorough solution.
@@ -1338,7 +1338,7 @@ int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_par | |||
/* Verify that the BIS sync values is acceptable for the receive state */ | |||
for (uint8_t i = 0U; i < state->num_subgroups; i++) { | |||
const uint32_t bis_sync = param->subgroups[i].bis_sync; | |||
const uint32_t bis_sync_requested = internal_state->requested_bis_sync[i]; | |||
const uint32_t bis_sync_requested = internal_state->requested_bis_sync[i] << 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if we shifted the requested_bis_sync
when storing it, so that the requested_bis_sync
and param->subgroups[i].bis_sync;
are stored the same way
That would also remove the need to shift in bt_bap_scan_delegator_set_bis_sync_state
28c9b6d
to
6081f45
Compare
6081f45
to
9fdd580
Compare
@@ -422,7 +422,7 @@ static void test_bass_mod_source(void) | |||
mod_src_param.pa_sync = true; | |||
mod_src_param.subgroups = &subgroup; | |||
mod_src_param.pa_interval = g_broadcaster_info.interval; | |||
subgroup.bis_sync = BIT(1) | BIT(2); /* Indexes 1 and 2 */ | |||
subgroup.bis_sync = BIT(0) | BIT(1); /* BIS Indexes 1 and 2 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API should still expect BIT(1) for BIS index 1, so if this is needed, then further fixes is required in the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so a shift of the bis_sync is needed inside of bt_bap_broadcast_assistant_add_src
and bt_bap_broadcast_assistant_mod_src
, so the BIS_Sync value sent over the air could contain BIT(0) for BIS index 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, at least until we do it for all functions as part of #64838
9fdd580
to
3da5451
Compare
The BIS_Sync bitfiled received over the air in Add Source and Modify Source operations uses BIT(0) for BIS Index 1. Shift it when storing it to match bis_sync bitfield where BIS Index 1 is at BIT(1). Signed-off-by: Magdalena Kasenberg <[email protected]>
3da5451
to
c668ced
Compare
The PTS BASS/SR/CP test cases fails because of wrong value of the BIS_Sync parameter of the Add Source and Modify Source operations and of notification of Broadcast Audio Scan Control Point.