mbox series

[BlueZ,v2,00/16] Add Scan Delegator support for Add Source op

Message ID 20240829124918.84809-1-iulia.tanasescu@nxp.com (mailing list archive)
Headers show
Series Add Scan Delegator support for Add Source op | expand

Message

Iulia Tanasescu Aug. 29, 2024, 12:49 p.m. UTC
This adds support for the BAP Scan Delegator role to handle the
Add Source command received from a Broadcast Assistant.

The Broadcast Assistant informs a Scan Delegator about a Broadcaster
by sending a GATT write command for the BASS Broadcast Audio Scan
Control Point characteristic with the "Add Source" opcode. Using
the parameters received through GATT, the Scan Delegator creates
a device for the Broadcaster and probes it with BAP. The BAP plugin
will then perform long-lived PA sync and it will create streams
for each BIS required by the Assistant. The transports can then be
acquired/released, and the Assistant will be notified about each
change in the state of the streams.

The bluetoothctl and btmon logs below show an example of this scenario:

client/bluetoothctl
[bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 1
[/local/endpoint/ep0] Supported Context (value): 1
[bluetooth]# Endpoint /local/endpoint/ep0 registered
[bluetooth]# advertise on
[bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F
[00-60-37-31-7E-3F]# [NEW] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA
[00-60-37-31-7E-3F]# [NEW] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Endpoint: SetConfiguration
[00-60-37-31-7E-3F]# Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Properties.Device:
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA
[00-60-37-31-7E-3F]# Auto Accepting...
[00-60-37-31-7E-3F]# transport.select
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: broadcasting
[00-60-37-31-7E-3F]# transport.acquire
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
auto acquiring...
Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring
[00-60-37-31-7E-3F]# Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring complete
[00-60-37-31-7E-3F]# Acquire successful: fd 8 MTU 40:0
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: active
[00-60-37-31-7E-3F]# transport.release
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Transport fd disconnected
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: idle
[00-60-37-31-7E-3F]# Release successful

> ACL Data RX: Handle 0 flags 0x01 dlen 1
      ATT: Write Command (0x52) len 23
        Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7)
          Data[21]: 0201da5711c0e203001a2d5602ffff010100000000
            Opcode: Add Source (0x02)
            Source_Address_Type: 1
            Source_Address: 03:E2:C0:11:57:DA
            Source_Adv_SID: 0
            Broadcast_ID: 0x562d1a
            PA_Sync_State: Synchronize to PA - PAST not available
            PA_Interval: 0xffff
            Num_Subgroups: 1
            Subgroup #0:
              BIS_Sync State: 0x00000001
< HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044)
        Options: 0x0000
        Use advertising SID, Advertiser Address Type and address
        Reporting initially enabled
        SID: 0x00
        Adv address type: Random (0x01)
        Adv address: 03:E2:C0:11:57:DA (Non-Resolvable)
        Skip: 0x0000
        Sync timeout: 20000 msec (0x07d0)
        Sync CTE type: 0x0000
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 16
      LE Periodic Advertising Sync Established (0x0e)
        Status: Success (0x00)
        Sync handle: 0
        Advertising SID: 0x00
        Advertiser address type: Random (0x01)
        Advertiser address: 03:E2:C0:11:57:DA (Non-Resolvable)
        Advertiser PHY: LE 2M (0x02)
        Periodic advertising interval: 10.00 msec (0x0008)
        Advertiser clock accuracy: 0x07
> HCI Event: LE Meta Event (0x3e) plen 42
      LE Periodic Advertising Report (0x0f)
        Sync handle: 0
        TX power: 127 dbm (0x7f)
        RSSI: -64 dBm (0xc0)
        CTE Type: No Constant Tone Extension (0xff)
        Data status: Complete
        Data length: 0x22
        Service Data: Basic Audio Announcement (0x1851)
          Presetation Delay: 40000
          Number of Subgroups: 1
            Subgroup #0:
            Number of BIS(s): 1
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
            Codec Specific Configuration: Sampling Frequency: 16 Khz
            Codec Specific Configuration: #1: len 0x02 type 0x02
            Codec Specific Configuration: Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
            Codec Specific Configuration: Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
            Codec Specific Configuration: Location: 0x00000001
            Codec Specific Configuration: Location: Front Left
              BIS #0:
              Index: 1
> HCI Event: LE Meta Event (0x3e) plen 20
      LE Broadcast Isochronous Group Info Advertising Report (0x22)
        Sync Handle: 0x0000
        Number BIS: 1
        NSE: 3
        ISO Interval: 10.00 msec (0x0008)
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        SDU Interval: 10000 us (0x002710)
        Maximum SDU: 40
        PHY: LE 2M (0x02)
        Framing: Unframed (0x00)
        Encryption: 0x00
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010000000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000000
< HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b)
        BIG Handle: 0x00
        BIG Sync Handle: 0x0000
        Encryption: Unencrypted (0x00)
        Broadcast Code[16]: 00000000000000000000000000000000
        Maximum Number Subevents: 0x00
        Timeout: 20000 ms (0x07d0)
        Number of BIS: 1
        BIS ID: 0x01
> HCI Event: Command Status (0x0f) plen 4
      LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1
        Status: Success (0x00
> HCI Event: LE Meta Event (0x3e) plen 17
      LE Broadcast Isochronous Group Sync Estabilished (0x1d)
        Status: Success (0x00)
        BIG Handle: 0x00
        Transport Latency: 912 us (0x000390)
        NSE: 3
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 10
< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 10
        Data Path Direction: Output (Controller to Host) (0x01)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration[0]:
> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 10
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010100000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000001
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010000000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000000
< HCI Command: LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c)
        BIG Handle: 0x00
> HCI Event: Command Complete (0x0e) plen 5
      LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c) ncmd 1
        Status: Success (0x00)

Iulia Tanasescu (16):
  shared/bass: Register ATT disconnect cb
  shared/bass: Make bt_bcast_src private
  shared/bass: Remove io handling
  shared/bass: Add support to register cp handlers
  shared/bass: Call cp handler for the Add Source cmd
  bap: Add support for long-lived PA sync
  bap: Add API for Scan Delegator probe
  bass: Register cp handler for Add Source cmd
  shared/bass: Add API to set PA sync state
  bass: Add APIs to probe/remove Broadcasters
  bap: Probe Broadcasters with BASS
  shared/bass: Add APIs to set/clear BIS sync bits
  bass: Register BAP state changed cb
  shared/bass: Add API to check BIS required for sync
  bass: Add API to check BIS required for sync
  bap: Create streams for required BISes

 profiles/audio/bap.c  | 124 +++++++--
 profiles/audio/bap.h  |   1 +
 profiles/audio/bass.c | 202 +++++++++++++++
 profiles/audio/bass.h |   5 +
 src/shared/bass.c     | 587 +++++++++++++++++++-----------------------
 src/shared/bass.h     |  43 +---
 6 files changed, 590 insertions(+), 372 deletions(-)


base-commit: 32a0811685c5dd290f1152bef2dfbde3b2848446

Comments

patchwork-bot+bluetooth@kernel.org Sept. 9, 2024, 4:50 p.m. UTC | #1
Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 29 Aug 2024 15:49:02 +0300 you wrote:
> This adds support for the BAP Scan Delegator role to handle the
> Add Source command received from a Broadcast Assistant.
> 
> The Broadcast Assistant informs a Scan Delegator about a Broadcaster
> by sending a GATT write command for the BASS Broadcast Audio Scan
> Control Point characteristic with the "Add Source" opcode. Using
> the parameters received through GATT, the Scan Delegator creates
> a device for the Broadcaster and probes it with BAP. The BAP plugin
> will then perform long-lived PA sync and it will create streams
> for each BIS required by the Assistant. The transports can then be
> acquired/released, and the Assistant will be notified about each
> change in the state of the streams.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2,01/16] shared/bass: Register ATT disconnect cb
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=38b7dc7d17b4
  - [BlueZ,v2,02/16] shared/bass: Make bt_bcast_src private
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=25119b6a72aa
  - [BlueZ,v2,03/16] shared/bass: Remove io handling
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8abcfd7028e8
  - [BlueZ,v2,04/16] shared/bass: Add support to register cp handlers
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=30c190089ffe
  - [BlueZ,v2,05/16] shared/bass: Call cp handler for the Add Source cmd
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0446d1eef9ef
  - [BlueZ,v2,06/16] bap: Add support for long-lived PA sync
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b65767c5dab5
  - [BlueZ,v2,07/16] bap: Add API for Scan Delegator probe
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b8530f0d2672
  - [BlueZ,v2,08/16] bass: Register cp handler for Add Source cmd
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4191ff1c4045
  - [BlueZ,v2,09/16] shared/bass: Add API to set PA sync state
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=06d20a80249b
  - [BlueZ,v2,10/16] bass: Add APIs to probe/remove Broadcasters
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f3a43bd0e4af
  - [BlueZ,v2,11/16] bap: Probe Broadcasters with BASS
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ea7b69102434
  - [BlueZ,v2,12/16] shared/bass: Add APIs to set/clear BIS sync bits
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c6278d24d9d2
  - [BlueZ,v2,13/16] bass: Register BAP state changed cb
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a032a570489b
  - [BlueZ,v2,14/16] shared/bass: Add API to check BIS required for sync
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7c3821f822f8
  - [BlueZ,v2,15/16] bass: Add API to check BIS required for sync
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=df4e11fab68b
  - [BlueZ,v2,16/16] bap: Create streams for required BISes
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=dfcbc2d3c011

You are awesome, thank you!