bluez5: add faststream quirks

For some devices FastStream causes problems. Add quirk for disabling it.
This commit is contained in:
Pauli Virtanen 2021-09-29 18:31:45 +03:00
parent 84bc0490a5
commit c620121529
5 changed files with 27 additions and 5 deletions

View file

@ -13,6 +13,7 @@
# hw-volume AVRCP and HSP/HFP hardware volume support
# hw-volume-mic Functional HSP/HFP microphone volume support
# sbc-xq "nonstandard" SBC codec setting with better sound quality
# faststream FastStream codec support
#
# Features are disabled with the key "no-features" whose value is an
# array of strings in the match rule.
@ -31,6 +32,7 @@ bluez5.features.device = [
{ name = "AXLOIE Goin", no-features = [ msbc-alt1, msbc-alt1-rtl ] },
{ name = "BAA 100", no-features = [ hw-volume ] }, # Buxton BAA 100, doesn't remember volume, #pipewire-1449
{ name = "D50s", address = "~^00:13:ef:", no-features = [ hw-volume ] }, # volume has no effect, #pipewire-1562
{ name = "FiiO BTR3", address = "~^40:ed:98:", no-features = [ faststream ] }, # #pipewire-1658
{ name = "JBL Endurance RUN BT", no-features = [ msbc-alt1, msbc-alt1-rtl, sbc-xq ] },
{ name = "JBL LIVE650BTNC" },
{ name = "Motorola DC800", no-features = [ sbc-xq ] }, # #pipewire-1590

View file

@ -1409,6 +1409,12 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc
{
struct spa_bt_monitor *monitor = device->monitor;
struct spa_bt_remote_endpoint *ep;
const struct { enum spa_bluetooth_audio_codec codec; uint32_t mask; } quirks[] = {
{ SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ, SPA_BT_FEATURE_SBC_XQ },
{ SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM, SPA_BT_FEATURE_FASTSTREAM },
{ SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM_DUPLEX, SPA_BT_FEATURE_FASTSTREAM },
};
size_t i;
if (!is_a2dp_codec_enabled(device->monitor, codec))
return false;
@ -1418,11 +1424,17 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc
return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"));
}
if (codec->id == SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ) {
uint32_t bt_features = (uint32_t)-1;
if (monitor->quirks)
spa_bt_quirks_get_features(monitor->quirks, device->adapter, device, &bt_features);
if (!(bt_features & SPA_BT_FEATURE_SBC_XQ))
/* Check codec quirks */
for (i = 0; i < SPA_N_ELEMENTS(quirks); ++i) {
uint32_t bt_features;
if (codec->id != quirks[i].codec)
continue;
if (monitor->quirks == NULL)
break;
if (spa_bt_quirks_get_features(monitor->quirks, device->adapter, device, &bt_features) < 0)
break;
if (!(bt_features & quirks[i].mask))
return false;
}

View file

@ -678,6 +678,7 @@ enum spa_bt_feature {
SPA_BT_FEATURE_HW_VOLUME = (1 << 3),
SPA_BT_FEATURE_HW_VOLUME_MIC = (1 << 4),
SPA_BT_FEATURE_SBC_XQ = (1 << 5),
SPA_BT_FEATURE_FASTSTREAM = (1 << 6),
};
struct spa_bt_quirks;

View file

@ -69,6 +69,7 @@ struct spa_bt_quirks {
int force_msbc;
int force_hw_volume;
int force_sbc_xq;
int force_faststream;
char *device_rules;
char *adapter_rules;
@ -84,6 +85,7 @@ static enum spa_bt_feature parse_feature(const char *str)
{ "hw-volume", SPA_BT_FEATURE_HW_VOLUME },
{ "hw-volume-mic", SPA_BT_FEATURE_HW_VOLUME_MIC },
{ "sbc-xq", SPA_BT_FEATURE_SBC_XQ },
{ "faststream", SPA_BT_FEATURE_FASTSTREAM },
};
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(feature_keys); ++i) {
@ -248,6 +250,7 @@ struct spa_bt_quirks *spa_bt_quirks_create(const struct spa_dict *info, struct s
this->force_sbc_xq = parse_force_flag(info, "bluez5.enable-sbc-xq");
this->force_msbc = parse_force_flag(info, "bluez5.enable-msbc");
this->force_hw_volume = parse_force_flag(info, "bluez5.enable-hw-volume");
this->force_faststream = parse_force_flag(info, "bluez5.enable-faststream");
if ((str = spa_dict_lookup(info, "bluez5.hardware-database")) != NULL) {
spa_log_debug(this->log, "loading session manager provided data");
@ -389,5 +392,8 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
if (this->force_sbc_xq != -1)
SPA_FLAG_UPDATE(*features, SPA_BT_FEATURE_SBC_XQ, this->force_sbc_xq);
if (this->force_faststream != -1)
SPA_FLAG_UPDATE(*features, SPA_BT_FEATURE_FASTSTREAM, this->force_faststream);
return 0;
}

View file

@ -12,6 +12,7 @@ properties = {
#bluez5.enable-sbc-xq = true
#bluez5.enable-msbc = true
#bluez5.enable-hw-volume = true
#bluez5.enable-faststream = true
# See bluez-hardware.conf for the hardware database.