Commit graph

1094 commits

Author SHA1 Message Date
Sanchayan Maity
74fe7728d2 bluez5: media-sink: Set up node group for ASHA
ASHA devices with the same HiSyncId should use the same
node group/driver.
2025-05-05 07:43:34 +00:00
Sanchayan Maity
8120493edb bluez5-dbus: Track ASHA HiSyncId & Side information in transport
ASHA devices with the same HiSyncId are a pair and this
will be used later on to set them up together with a
combine sink like device set for BAP. Side information
is required for channel information when setting up the
combine sink.
2025-05-05 07:43:34 +00:00
Frédéric Danis
612cbf5176 bluez5: hfp-hf: Fix HFP HF states
hfp_hf_slc1 is not used so remove it, and rename hfp_hf_slc2 to
hfp_hf_clcc to be consistent with other states.
2025-05-05 07:41:06 +00:00
Frédéric Danis
533c67710e bluez5: backend-native: Fix rfcomm_send_volume_cmd()
This function always returns true. Change to not returning anything.
2025-05-05 07:41:06 +00:00
George Kiagiadakis
8e62b08e58 bluez5: hfp-hf: don't change hf_state after sending AT+BCS
The +BCS event may interrupt any of the initialization commands after
SLC is established and by changing the state here we may lose track
of the initialization sequence.

There is no reason to have the hfp_hf_bcs state anyway. If the
initialization sequence is over, we can remain in the hfp_hf_vgm state.
2025-05-05 07:41:06 +00:00
George Kiagiadakis
92643f77f9 bluez5: backend-native: fix sco HUP|ERR debug message
Print the error in td->err (the SO_ERROR) or else let the user know
this is a regular hangup. The previous printout was always reporting
EAGAIN (remainder in errno from the event loop code, I suppose)
as an error, without any real data.
2025-05-02 16:12:23 +03:00
Pauli Virtanen
46c4261998 bluez5: fix cmsg align in spa_bt_recmsg & smaller buffer 2025-04-21 14:46:58 +03:00
Pauli Virtanen
0d61cc1b1d bluez5: use kernel-provided RX timestamps
Use kernel-provided packet reception timestamps to get less jitter in
packet timings. Mostly matters for ISO/SCO which have regular schedule.

A2DP (L2CAP) doesn't currently do RX timestamps in kernel, but we can as
well use the same mechanism for it.
2025-04-21 10:22:50 +00:00
Pauli Virtanen
081116906d bluez5: bap: allow configuring server locations/context
Add configuration options for the BAP/PACS sink and source endpoint
location (= channel positions) and context settings.

Although BlueZ associates these with individual endpoints, in the PACS
spec they are actually device-global, so configure directly in monitor
settings.
2025-04-20 20:34:35 +03:00
Vinit Mehta
3140ede326 bluez5: Fix return status for parse_qos_settings 2025-04-14 07:26:28 +00:00
Pauli Virtanen
e9dae61cca bluez5: simplify BAP settings parsing and use device settings for them
Parse BAP settings in a single place, and simplify QoS customization a
bit.

Ensure the selected preset gets selected.

For all the BAP codec settings, use device settings instead of global
monitor ones.
2025-04-14 07:26:28 +00:00
Vinit Mehta
55372a41b1 bluez5: Add support to select BAP QoS config
The current BAP QoS configuration allows to register a sampling
frequency based on the configuration done using wireplumber configuration.
However, for a scenario were the user need to use a specific SDU framelength
it cannot be done as the select_bap_qos function selects the QOS based on
priority and hence it will use the best possible config rather than the user
configured.

This PR adds option to select the QoS set based on user configured value. If
the remote device doesn't have the user configured capabilities it will always
use the best priority config.

Further, this change also allows the user to set RTN, Latency, Delay QoS config
for certain use case to have controller use optimum bandwidth usage.

Below are the example configuration on setting LC3 capabilities in config file:

bluez5.bap.set_name = "48_2_1"
bluez5.bap.rtn = 5
bluez5.bap.latency = 20
bluez5.bap.delay = 40000
bluez5.framing = false
2025-04-14 07:26:28 +00:00
Vinit Mehta
6dfb164cab bluez5: Add support to configure & select BAP QoS config
The current BAP unicast QoS configuration allows to register a sampling
frequency based on the configuration done using wireplumber configuration.
However, for a scenario were the user need to use a specific SDU framelength
it cannot be done as the select_bap_qos function selects the QoS based on
priority and hence it will use the best possible config rather than the user
configured.

This PR adds option to select the QoS set based on user configured value. If
the remote device doesn't have the user configured capabilities it will always
use the best priority config.

Further, this change also allows the user to set RTN, Latency, Delay QoS config
for certain use case to have controller use optimum bandwidth usage.

Below is the example for the options that can be configured & selected
in config file:

bluez5.bap.set_name = "48_2_1"
bluez5.bap.rtn = 5
bluez5.bap.latency = 20
bluez5.bap.delay = 40000
bluez5.framing = false
2025-04-14 07:26:28 +00:00
Pauli Virtanen
4c51e6518b bluez5: ldac decoding support
Add support for LDAC decoding, if libldac decoder is available.
2025-04-10 13:22:57 +00:00
Pauli Virtanen
bbe1587f71 bluez5: fix volume ids
Node ids don't map directly to volume ids. Fix the indexing.
2025-04-09 07:50:30 +00:00
Wim Taymans
722776cf65 Remove some hardcoded channel number values
Mostly related to the number of channels.
2025-04-04 15:46:03 +02:00
Frédéric Danis
1af1fc846c bluez5: backend-native: Add volume support to HFP HF
The volume synchronization could be done even if there's no audio link
and so no transport opened.

This patch allows to send the Speaker (AT+VGS) and Microphone (AT+VGM)
commands at the end of the SLC. And to exchange volume updates using the
telephony DBus interface, even without a transport.
2025-03-12 11:01:50 +01:00
Frédéric Danis
0e92ab9307 bluez5: backend-native: Fix 3way active call hangup
HFP/HF/TWC/BV-03-C test, which setup an active and a held calls,
expects to receive AT+CHLD=1 (release and swap calls) instead of
AT+CHUP on active call hang up request.

As this changes the active call to disconnected and held call to
being active, the call states should be managed in hfp_hf_hangup
instead of waiting for +CIEV (callheld=0) event which will drop
the previously held call before AT+CLCC reply can inform this call
is now active.
2025-03-07 08:31:24 +00:00
Frédéric Danis
90b95ae065 bluez5: backend-native: Fix incoming call crash
HFP/HF/TWC/BV-01-C test creates an incoming call as soon as the SLC is
completed, i.e. a +CIEV: <callsetup>,1 event just after AT+CHLD=? reply
has been received. This try to parse the rfcomm->telephony_ag->call_list
which has not yet been created.

This commit move the telephony_ag creation to the SLC completed event.
2025-03-07 08:31:24 +00:00
Frédéric Danis
be1fc5f3a6 bluez5: backend-native: Fix ECNR support in HFP HF SDP record
Sending AT+ECNR is supported by the native backend
2025-03-07 08:31:24 +00:00
George Kiagiadakis
491fb26f18 bluez5: backend-native: fix parsing +CLCC response with optional number
The format is: <idx>,<dir>,<status>,<mode>,<mpty>[,<number>,<type>]
so the response can be considered parsed when mpty is read.
2025-03-04 08:29:30 +00:00
Pauli Virtanen
8cd8138cc8 bluez5: specify node.latency at node rate
Avoid some potential rounding-down-to-power-of-2 by specifying the
wanted latency at the samplerate of the stream. Also looks nicer in
pw-top.
2025-02-17 19:42:56 +02:00
Pauli Virtanen
75243b7b02 bluez5: set node.rate for output streams
As AG, set node.rate for output streams that originate from remote
source, so that graph switches rate as needed.  This follows what
pipewire-pulse etc. do.

The patch is by Wim.
2025-02-14 19:59:50 +02:00
Sanchayan Maity
dbed1bdf3d bluez5: asha-codec-g722: Drop the dependency on FFmpeg
We use the G722 encoder from Android itself and drop
the dependency on FFmpeg/libav.
2025-02-13 19:55:18 +05:30
George Kiagiadakis
48fb960274 bluez5: backend-native: fix erroneous goto
In this error condition, execution is supposed to return immediately
because rfcomm is no longer valid. However, the code was incorrectly
changed to jump to the done label, which would try to use rfcomm
again to process pending commands.
2025-02-07 13:14:59 +02:00
Frédéric Danis
62645214a7 bluez5: telephony: Postpone AT commands if one is already in progress
To be sure that the AG reply correspond to the command sent, this
postpone the new command if previous reply (OK, ERROR or +CME) has
not yet been received.
The postponed command is sent on reception of the reply.
2025-02-06 17:25:17 +01:00
Frédéric Danis
fc45aba032 bluez5: telephony: Add configuration to disable NR/EC
This allows to disable the Noise Reduction and Echo Cancellation
on the Audio Gateway.
2025-02-06 17:25:12 +01:00
Frédéric Danis
b7c00e2f24 bluez5: telephony: Add CMEE support 2025-02-06 17:24:42 +01:00
Wim Taymans
4d502cb470 bluez: org.freedesktop.PipeWire -> org.pipewire
We have our own domain name.
2025-02-05 10:18:17 +01:00
George Kiagiadakis
b8e202f02e bluez5: telephony: add call transfer with user interaction capability
This allows implementing UI mechanisms to transfer the audio of a call
to the HF (pipewire) only when the user explicitly asks/allows it.

Normally, when a call is connected, the phone initiates a SCO connection
and the HF accepts it, transfering audio automatically. In order to
allow for user interaction, this patch enables the UI to set the RejectSCO
property to 'true' in order to automatically reject the SCO connection.
Later on, at the UI's discression, the audio may be reconnected by calling
the Activate() method, which sends AT+BCC to re-initialize the SCO channel.

A configuration file option is also added to configure the default value
of the RejectSCO property. By setting this to 'true' in the config file,
it is possible to implement rejecting the audio of a call that is already
active at the time the Bluetooth connection to the phone initializes.
2025-02-05 08:50:24 +00:00
George Kiagiadakis
7de0419ca3 bluez5: telephony: add Address property on the AudioGateway interface
This allows associating the AG with a remote device on higher level
software.
2025-02-05 08:50:24 +00:00
Frédéric Danis
a0356cf4ae bluez5: backend-native: Fix parsing of +CLCC event for PTS
PTS 8.7.3 Build 6 send +CLCC events without space after '+CLCC:'
Found with PTS test HFP/HF/ICA/BV-04-C
2025-02-05 08:50:24 +00:00
Frédéric Danis
99fa7efc2c bluez5: backend-native: Add eSCO S4 feature.
eSCO S4 feature is mandatory since HFP 1.7.
Found with PTS test HFP/HF/SLC/BV-03-C.
2025-02-05 08:50:24 +00:00
George Kiagiadakis
abd96e592b bluez5: telephony: improve +CLCC parsing
Make sure we don't crash or do anything stupid if the incoming
command is malformed
2025-02-05 08:50:24 +00:00
George Kiagiadakis
9d1862a6f8 bluez5: telephony: use spa_callbacks instead of spa_hook_list 2025-02-05 08:50:24 +00:00
Frédéric Danis
627515f641 bluez5: backend-native: Check current calls on SLC completion
This allows to create the calls existing before the HFP connection.
2025-02-05 08:50:24 +00:00
George Kiagiadakis
63e1c48c8b bluez5: telephony: report transport codec & state on D-Bus
This is useful for implementations that do hardware offloading of the
SCO audio channel and need to communicate state information to the
hardware (at least).
2025-02-05 08:50:24 +00:00
George Kiagiadakis
dc5b85fe57 bluez5: backend-native: fallthrough to report volume instead of duplicating code 2025-02-05 08:50:24 +00:00
Frédéric Danis
bd5de6eb1c bluez5: backend-native: Manage 3way commands asynchronously
The call's states should not be updated on 3ways commands but wait for
CIEV or CLCC events.
This allows to manage user actions on the phone.
2025-02-05 08:50:24 +00:00
Frédéric Danis
8e7a1a5235 bluez5: telephony: Do not return call objects in CreateMultiparty
The call's state updates are asynchronous, and even if AT+CHLD=3
returns OK the network may not create the multiparty.
2025-02-05 08:50:24 +00:00
Frédéric Danis
9f37ab25f5 bluez5: backend-native: Destroy only active calls on +CIEV:(call,0) 2025-02-05 08:50:24 +00:00
Frédéric Danis
056c2dd535 bluez5: backend-native: Create call on +CLCC event if supported
Wait for +CLCC event to create the call so the remote phone number can
be set.
2025-02-05 08:50:24 +00:00
Frédéric Danis
f5e08677a2 bluez5: backend-native: add CLCC support
Start call id at 1 as for the index calls in HFP, and move this id
to spa_bt_telephony_[ag|call] so they can be used by CLCC to retrieve
the related call.

if enhanced call status is supported, send AT+CLCC on +CIEV events to
get the calls information.
2025-02-05 08:50:24 +00:00
Frédéric Danis
a8363ff92b bluez5: backend-native: Fix dialing call-setup management
The call should be created if it is started from the phone, i.e. if it
doesn't yet exist.
2025-02-05 08:50:24 +00:00
Frédéric Danis
ffb19547b0 bluez5: backend-native: Fix supported HF features
The HF should declare the features supported before trying to send
related AT commands.
It should only send AT+CHLD related commands if the remote AG supports
them.
2025-02-05 08:50:24 +00:00
George Kiagiadakis
37fb79b9b8 bluez5: backend-native: hangup held/active calls respectively only if they exist
On some phones (at least), sending AT+CHLD=0 while there is no held
call returns an error. Make sure we don't do this to avoid returning
an error on D-Bus when in fact hangup_all actually succeeds.
2025-02-05 08:50:24 +00:00
George Kiagiadakis
a2fc92ee69 bluez5: backend-native: allow hanging up DIALING/ALERTING calls 2025-02-05 08:50:24 +00:00
George Kiagiadakis
03ab9dd771 bluez5: telephony: implement error reporting from all methods 2025-02-05 08:50:24 +00:00
George Kiagiadakis
159846d226 bluez5: telephony: implement ofono compatibility 2025-02-05 08:50:24 +00:00
George Kiagiadakis
e02eedb5a7 bluez5: README-Telephony: document ofono service compatibility 2025-02-05 08:50:24 +00:00