Commit graph

12 commits

Author SHA1 Message Date
Pauli Virtanen
e860f2bb4e bluez5: basic codec-switching framework 2021-02-02 09:56:29 +00:00
Pauli Virtanen
073217ae63 bluez5: remove mtu hardcoding
Hardcoding MTU is no longer necessary with the reworked SCO i/o, which
guesses suitable write sizes based on rx.
2021-01-04 19:19:16 +02:00
Pauli Virtanen
368182d963 bluez5: rework sco i/o + autodetect mtu
Move SCO polling to a single place, and abstract mtu handling.
Autodetect suitable tx packet size based on rx, instead of relying on
the kernel providing correct values.
2021-01-04 19:19:16 +02:00
Pauli Virtanen
036c10717d bluez5: refcount transport acquire and release, let it manage fd
Backends don't necessarily allow for opening the same device multiple
times, and it shouldn't be necessary.

Since source and sink are not necessarily both running at the same time,
refcount the transport acquire/release so that it knows to close the fd
only when no source/sink is running.

Let the transport manage the fd lifecycle, also closing it once it is
not needed.

Don't return the fd from acquire(), since each transport is associated
with a single socket fd.
2020-12-28 13:38:41 +01:00
Frédéric Danis
bd051e89a5 bluez5: improve debug 2020-12-25 14:57:30 +00:00
Pauli Virtanen
4144427655 ofono/hsphfpd: force write_mtu=24 for mSBC codec
Kernel should provide the correct mtu/packet size to use for SCO socket
I/O, but it does not currently appear to (as of linux 5.9), see
https://lore.kernel.org/linux-bluetooth/20201210003528.3pmaxvubiwegxmhl@pali/T/

When using mSBC, instead of using the (incorrect) kernel-provided value,
hardcode mtu to 24, corresponding to ALT1 mode.  BT-UART adapters should
not require specific mtu, and it appears most BT-USB adapters only
support ALT1, see
https://lore.kernel.org/linux-bluetooth/20201210012003.133000-1-tpiepho@gmail.com/

This code needs to be revised when the issue is sorted out on the kernel
side.

Add setting bluez5.msbc-force-mtu for easier debugging in special cases.

Leave read_mtu as the detected value --- it does not seem to affect
whether BT-USB can record, but Raspberry Pi BT-UART fails to record if a
different value is used.
2020-12-21 04:16:11 +02:00
Frédéric Danis
6308c5d806 bluez5: backend-hsphfpd: Add mSBC support
mSBC can be enabled by passing "bluez5.msbc-support=true" parameter to
pipewire-media-session.
mSBC is automatically selected if remote device supports it.
2020-11-16 18:15:39 +01:00
Frédéric Danis
48c64f9084 bluez5: backend-hsphfpd: Fix PCM agent name
The audio agent gets or provides data in the format requested between host
and chipset.
The HSP and HFP profile request PCM data to be sent to the chipset which
will encode/decode them in CVSD format.
This audio agent format may be re-used later for another air codec hw
encoded.
So, rename the audio agent to be more explicit.
2020-10-20 19:10:21 +00:00
Frédéric Danis
7c84b1251d bluez5: backend-hsphfpd: Fix transport release on disconnection
Release transport when endpoint connection property is updated to false.
This also checks if the transport is already created when receiving
endpoint properties update to prevent multiple transport creation.
2020-09-16 16:20:54 +00:00
Frédéric Danis
d607a461ce bluez5: backend-hsphfpd: Fix crash when switching profile to HFP 2020-08-25 16:43:03 +02:00
Frédéric Danis
7120bfe059 bluez5: backend-hsphfpd: Add spa_bt_transport support
The ConnectAudio method triggers Introspect and NewConnection calls from
hsphfpd to the backend, which will set the fd to use for the SCO data.
This imply to run the DBus loop while waiting for ConnectAudio reply to be
able to reply to those method calls.

MTU is hard-coded to 48. Using MTU from hsphfpd may prevent correct
sound operations.

Volume management is not yet implemented.
2020-08-19 17:49:36 +00:00
Frédéric Danis
7bad76737e bluez5: Create backend skeleton for HSP/HFP support using hsphfpd
As hsphfpd is a prototype and its API subject to change, this backend is
disable by default.

This skeleton connects to hsphfpd daemon and list the managed devices.
2020-08-19 17:49:36 +00:00