Commit fec9eb17 authored by Igor Kovalenko's avatar Igor Kovalenko
Browse files

bluetooth: disable HSP HS profile by default

A few headsets have issues if HFP HF profile connection is attempted before
HSP HS profile connection is closed. Looks like this could happen because
bluez bluetoothd alows to make simultaneous HSP HS and HFP HF peer connections.

One of affected headsets is WH-1000XM2

Until we find out how to prevent simultaneous HSP HS and HFP HF connections,
when native backend has HFP HF profile enabled (this is the default) do disable
HSP HS completely unless user explicitly request it via discovery modarg.

Do this by adding module-bluetooth-discover arg enable_native_hsp_hs,
default to inverse of enable_native_hfp_hf.

Part-of: <!538>
parent e3fa9375
......@@ -44,6 +44,7 @@ struct pa_bluetooth_backend {
pa_dbus_connection *connection;
pa_bluetooth_discovery *discovery;
bool enable_shared_profiles;
bool enable_hsp_hs;
bool enable_hfp_hf;
PA_LLIST_HEAD(pa_dbus_pending, pending);
......@@ -1069,8 +1070,13 @@ pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_d
backend->discovery = y;
backend->enable_shared_profiles = enable_shared_profiles;
backend->enable_hfp_hf = pa_bluetooth_discovery_get_enable_native_hfp_hf(y);
backend->enable_hsp_hs = pa_bluetooth_discovery_get_enable_native_hsp_hs(y);
profile_init(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
if (!backend->enable_hsp_hs && !backend->enable_hfp_hf)
pa_log_warn("Both HSP HS and HFP HF bluetooth profiles disabled in native backend. Native backend will not register for headset connections.");
if (backend->enable_hsp_hs)
profile_init(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
if (backend->enable_shared_profiles)
native_backend_apply_profile_registration_change(backend, true);
......@@ -1086,7 +1092,8 @@ void pa_bluetooth_native_backend_free(pa_bluetooth_backend *backend) {
if (backend->enable_shared_profiles)
native_backend_apply_profile_registration_change(backend, false);
profile_done(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
if (backend->enable_hsp_hs)
profile_done(backend, PA_BLUETOOTH_PROFILE_HSP_HS);
pa_dbus_connection_unref(backend->connection);
......
......@@ -117,6 +117,7 @@ struct pa_bluetooth_discovery {
int headset_backend;
pa_bluetooth_backend *ofono_backend, *native_backend;
PA_LLIST_HEAD(pa_dbus_pending, pending);
bool enable_native_hsp_hs;
bool enable_native_hfp_hf;
bool enable_msbc;
};
......@@ -808,6 +809,14 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_disc
return NULL;
}
bool pa_bluetooth_discovery_get_enable_native_hsp_hs(pa_bluetooth_discovery *y)
{
pa_assert(y);
pa_assert(PA_REFCNT_VALUE(y) > 0);
return y->enable_native_hsp_hs;
}
bool pa_bluetooth_discovery_get_enable_native_hfp_hf(pa_bluetooth_discovery *y)
{
pa_assert(y);
......@@ -2277,7 +2286,7 @@ static void object_manager_done(pa_bluetooth_discovery *y) {
A2DP_OBJECT_MANAGER_PATH);
}
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backend, bool enable_native_hfp_hf, bool enable_msbc) {
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backend, bool enable_native_hsp_hs, bool enable_native_hfp_hf, bool enable_msbc) {
pa_bluetooth_discovery *y;
DBusError err;
DBusConnection *conn;
......@@ -2290,6 +2299,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backe
PA_REFCNT_INIT(y);
y->core = c;
y->headset_backend = headset_backend;
y->enable_native_hsp_hs = enable_native_hsp_hs;
y->enable_native_hfp_hf = enable_native_hfp_hf;
y->enable_msbc = enable_msbc;
y->adapters = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
......
......@@ -209,10 +209,11 @@ static inline bool pa_bluetooth_uuid_is_hsp_hs(const char *uuid) {
#define HEADSET_BACKEND_NATIVE 1
#define HEADSET_BACKEND_AUTO 2
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend, bool default_profile_hfp, bool enable_msbc);
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend, bool enable_native_hsp_hs, bool enable_native_hfp_hf, bool enable_msbc);
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running);
bool pa_bluetooth_discovery_get_enable_native_hsp_hs(pa_bluetooth_discovery *y);
bool pa_bluetooth_discovery_get_enable_native_hfp_hf(pa_bluetooth_discovery *y);
bool pa_bluetooth_discovery_get_enable_msbc(pa_bluetooth_discovery *y);
#endif
......@@ -39,6 +39,7 @@ PA_MODULE_USAGE(
"autodetect_mtu=<boolean>"
"enable_msbc=<boolean, enable mSBC support in native and oFono backends, default is true>"
"output_rate_refresh_interval_ms=<interval between attempts to improve output rate in milliseconds>"
"enable_native_hsp_hs=<boolean, enable HSP support in native backend>"
"enable_native_hfp_hf=<boolean, enable HFP support in native backend>"
);
......@@ -47,6 +48,7 @@ static const char* const valid_modargs[] = {
"autodetect_mtu",
"enable_msbc",
"output_rate_refresh_interval_ms",
"enable_native_hsp_hs",
"enable_native_hfp_hf",
NULL
};
......@@ -115,7 +117,8 @@ int pa__init(pa_module *m) {
bool autodetect_mtu;
bool enable_msbc;
uint32_t output_rate_refresh_interval_ms;
bool enable_native_hfp_hf = true;
bool enable_native_hsp_hs;
bool enable_native_hfp_hf;
pa_assert(m);
......@@ -147,10 +150,16 @@ int pa__init(pa_module *m) {
if (pa_modargs_get_value_boolean(ma, "enable_msbc", &enable_msbc) < 0) {
pa_log("Invalid boolean value for enable_msbc parameter");
}
enable_native_hfp_hf = true;
if (pa_modargs_get_value_boolean(ma, "enable_native_hfp_hf", &enable_native_hfp_hf) < 0) {
pa_log("enable_native_hfp_hf must be true or false");
goto fail;
}
enable_native_hsp_hs = !enable_native_hfp_hf;
if (pa_modargs_get_value_boolean(ma, "enable_native_hsp_hs", &enable_native_hsp_hs) < 0) {
pa_log("enable_native_hsp_hs must be true or false");
goto fail;
}
output_rate_refresh_interval_ms = DEFAULT_OUTPUT_RATE_REFRESH_INTERVAL_MS;
if (pa_modargs_get_value_u32(ma, "output_rate_refresh_interval_ms", &output_rate_refresh_interval_ms) < 0) {
......@@ -165,7 +174,7 @@ int pa__init(pa_module *m) {
u->output_rate_refresh_interval_ms = output_rate_refresh_interval_ms;
u->loaded_device_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (!(u->discovery = pa_bluetooth_discovery_get(u->core, headset_backend, enable_native_hfp_hf, enable_msbc)))
if (!(u->discovery = pa_bluetooth_discovery_get(u->core, headset_backend, enable_native_hsp_hs, enable_native_hfp_hf, enable_msbc)))
goto fail;
u->device_connection_changed_slot =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment