From c7c30ac0f588629cc6ca4f437f01e4207c08befe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Sun, 13 Jan 2019 18:23:20 +0100 Subject: [PATCH] btmon: Fix parsing A2DP FastStream codec configuration This codec is bi-directional, therefore both sink and source directions may be present in configuration at same time. Some Creative headsets send more frequency bits in configuration and when both 41kHz and 48kHz are present then headset expects 48kHz. So adjust FastStream frequency table as find_value_bit() takes first matched bit. --- monitor/a2dp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monitor/a2dp.c b/monitor/a2dp.c index ffdcbb962..4a1d0e1c4 100644 --- a/monitor/a2dp.c +++ b/monitor/a2dp.c @@ -201,8 +201,11 @@ static const struct bit_desc faststream_direction_table[] = { }; static const struct bit_desc faststream_sink_frequency_table[] = { - { 1, "44100" }, + /* in config buffer, there may be more frequency bits + * and 48kHz takes precedence over 41kHz + */ { 0, "48000" }, + { 1, "44100" }, { } }; @@ -746,9 +749,9 @@ static bool codec_vendor_faststream_cfg(uint8_t losc, struct l2cap_frame *frame) l2cap_frame_get_u8(frame, &cap); - print_field("%*cDirection: %s (0x%02x)", BASE_INDENT + 2, ' ', - find_value_bit(cap, faststream_direction_table), - cap); + /* FastStream codec is bi-directional */ + print_field("%*cDirection: 0x%02x", BASE_INDENT + 2, ' ', cap); + print_value_bits(BASE_INDENT + 2, cap, faststream_direction_table); l2cap_frame_get_u8(frame, &cap); -- 2.47.3