avdtp: Fix connecting using streaming mode with signalling channel
Luiz Augusto von Dentz
maintainerRFC 1/2 avdtp: Fix connecting using streaming mode with signalling channel
From: Luiz Augusto von Dentz <[email protected]>
Signalling channel shall only use Basic or ERTM modes.
--- profiles/audio/avdtp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
profiles/audio/avdtp.c +16 -10
@@ -2429,20 +2429,13 @@ uint16_t avdtp_get_version(struct avdtp *session)return session->version; } -static GIOChannel *l2cap_connect (struct avdtp *session) +static GIOChannel *l2cap_connect (struct avdtp *session,BtIOMode mode) {GError *err =NULL ;GIOChannel *io;const bdaddr_t *src; -BtIOMode mode; - src =btd_adapter_get_address (device_get_adapter (session->device)); -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; -if (session->phy) io = bt_io_connect(avdtp_connect_cb, session, NULL, &err,
@@ -2610,7 +2603,14 @@ static int send_req(struct avdtp *session, gboolean priority,int err, timeout;if (session->state ==AVDTP_SESSION_STATE_DISCONNECTED ) { - session->io =l2cap_connect (session); +BtIOMode mode; + +if (btd_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_ERTM ; + + session->io =l2cap_connect (session, mode);if (!session->io) {/* Report disconnection anyways, as the other layers * are using this state for cleanup.
@@ -2807,8 +2807,14 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre struct seid_rej *resp, int size) {struct avdtp_local_sep *sep = stream->lsep; +BtIOMode mode; + +if (btd_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; - stream->io =l2cap_connect (session); + stream->io =l2cap_connect (session, mode);if (!stream->io) {avdtp_sep_set_state (session, sep,AVDTP_STATE_IDLE );return FALSE;
Signature · 1 line
2.26.2
Luiz Augusto von Dentz
maintainerRFC 2/2 main.conf: Add option to configure AVDP session/stream channel modes
From: Luiz Augusto von Dentz <[email protected]>
This adds a new group AVDTP where platform can confure the prefered modes L2CAP channel for both session (signalling) and stream (transport). For better backward compatibility the default modes of boths
--- profiles/audio/a2dp.c | 5 +---- profiles/audio/avdtp.c | 14 ++----------- src/btd.h | 7 +++++++ src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/main.conf | 13 ++++++++++++ 5 files changed, 68 insertions(+), 16 deletions(-)
profiles/audio/a2dp.c +1 -4
@@ -2324,10 +2324,7 @@ static bool a2dp_server_listen(struct a2dp_server *server)if (server->io)return true; -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; + mode = btd_opts.avdtp.session_mode; server->io = bt_io_listen(NULL, confirm_cb, server, NULL, &err, BT_IO_OPT_SOURCE_BDADDR,
profiles/audio/avdtp.c +2 -12
@@ -2603,12 +2603,7 @@ static int send_req(struct avdtp *session, gboolean priority,int err, timeout;if (session->state ==AVDTP_SESSION_STATE_DISCONNECTED ) { -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_ERTM ; +BtIOMode mode = btd_opts.avdtp.session_mode; session->io =l2cap_connect (session, mode);if (!session->io) {
@@ -2807,12 +2802,7 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre struct seid_rej *resp, int size) {struct avdtp_local_sep *sep = stream->lsep; -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; +BtIOMode mode = btd_opts.avdtp.stream_mode; stream->io =l2cap_connect (session, mode);if (!stream->io) {
src/btd.h +7 -0
@@ -84,6 +84,11 @@ struct btd_defaults {struct btd_le_defaults le; }; +struct btd_avdtp_opts { +uint8_t session_mode; +uint8_t stream_mode; +}; +struct btd_opts {char *name;uint32_t class;
@@ -112,6 +117,8 @@ struct btd_opts {uint8_t gatt_channels;enum mps_mode_t mps; +struct btd_avdtp_opts avdtp; +uint8_t key_size;enum jw_repairing_t jw_repairing;
src/main.c +45 -0
75 lines not on this page · raw message
src/main.conf +13 -0
@@ -200,6 +200,19 @@ # Default to 3 #Channels = 3 +[AVDTP] +# AVDTP L2CAP Signalling Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# ertm: Use L2CAP Enhanced Retransmission Mode +#SessionMode = basic + +# AVDTP L2CAP Transport Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# streaming: Use L2CAP Streaming Mode +#StreamMode = basic + [Policy] # # The ReconnectUUIDs defines the set of remote services that should try
Signature · 1 line
2.26.2
Re: [RFC BlueZ 2/2] main.conf: Add option to configure AVDP session/stream channel modes
Quoted 7 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds a new group AVDTP where platform can confure the prefered modes L2CAP channel for both session (signalling) and stream (transport). For better backward compatibility the default modes of boths
Quoted 192 lines
--- profiles/audio/a2dp.c | 5 +---- profiles/audio/avdtp.c | 14 ++----------- src/btd.h | 7 +++++++ src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/main.conf | 13 ++++++++++++ 5 files changed, 68 insertions(+), 16 deletions(-)profiles/audio/a2dp.c +1
-4@@ -2324,10 +2324,7 @@ static bool a2dp_server_listen(struct a2dp_server *server)if (server->io)return true; -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; + mode = btd_opts.avdtp.session_mode; server->io = bt_io_listen(NULL, confirm_cb, server, NULL, &err, BT_IO_OPT_SOURCE_BDADDR,profiles/audio/avdtp.c +2
-12@@ -2603,12 +2603,7 @@ static int send_req(struct avdtp *session, gboolean priority,int err, timeout;if (session->state ==AVDTP_SESSION_STATE_DISCONNECTED ) { -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_ERTM ; +BtIOMode mode = btd_opts.avdtp.session_mode; session->io =l2cap_connect (session, mode);if (!session->io) {@@ -2807,12 +2802,7 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre struct seid_rej *resp, int size) {struct avdtp_local_sep *sep = stream->lsep; -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; +BtIOMode mode = btd_opts.avdtp.stream_mode; stream->io =l2cap_connect (session, mode);if (!stream->io) {src/btd.h +7
-0@@ -84,6 +84,11 @@ struct btd_defaults {struct btd_le_defaults le; }; +struct btd_avdtp_opts { +uint8_t session_mode; +uint8_t stream_mode; +}; +struct btd_opts {char *name;uint32_t class;@@ -112,6 +117,8 @@ struct btd_opts {uint8_t gatt_channels;enum mps_mode_t mps; +struct btd_avdtp_opts avdtp; +uint8_t key_size;enum jw_repairing_t jw_repairing;src/main.c +45
-0@@ -34,6 +34,7 @@#include "lib/sdp.h" #include "gdbus/gdbus.h" +#include "btio/btio.h" #include "log.h" #include "backtrace.h" @@ -137,6 +138,12 @@ static const char *gatt_options[] = {NULL }; +static const char *avdtp_options[] = { +"SessionMode" , +"StreamMode" , +NULL +}; + static const struct group_table { const char *name; const char **options;@@ -146,6 +153,7 @@ static const struct group_table { { "LE", le_options }, { "Policy", policy_options }, { "GATT", gatt_options }, + { "AVDTP", avdtp_options }, { } };@@ -744,6 +752,40 @@ static void parse_config(GKeyFile *config) btd_opts.gatt_channels = val; } + str =g_key_file_get_string (config,"AVDTP" ,"SessionMode" , &err); +if (err) { +DBG ("%s" , err->message); +g_clear_error (&err); + }else { +DBG ("SessionMode=%s" , str); + +if (!strcmp (str,"basic" )) + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; +else if (!strcmp (str,"ertm" )) + btd_opts.avdtp.session_mode =BT_IO_MODE_ERTM ; +else { +DBG ("Invalid mode option: %s" , str); + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; + } + } + + val =g_key_file_get_integer (config,"AVDTP" ,"StreamMode" , &err); +if (err) { +DBG ("%s" , err->message); +g_clear_error (&err); + }else { +DBG ("StreamMode=%s" , str); + +if (!strcmp (str,"basic" )) + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; +else if (!strcmp (str,"streaming" )) + btd_opts.avdtp.stream_mode =BT_IO_MODE_STREAMING ; +else { +DBG ("Invalid mode option: %s" , str); + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; + } + } +parse_br_config (config);parse_le_config (config); }@@ -780,6 +822,9 @@ static void init_defaults(void) btd_opts.gatt_cache =BT_GATT_CACHE_ALWAYS ; btd_opts.gatt_mtu =BT_ATT_MAX_LE_MTU ; btd_opts.gatt_channels =3 ; + + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; } static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,src/main.conf +13
-1@@ -200,6 +200,19 @@ # Default to 3 #Channels = 3 +[AVDTP] +# AVDTP L2CAP Signalling Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# ertm: Use L2CAP Enhanced Retransmission Mode +#SessionMode = basic + +# AVDTP L2CAP Transport Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# streaming: Use L2CAP Streaming Mode +#StreamMode = basic + [Policy] # # The ReconnectUUIDs defines the set of remote services that should try --2.26.2
Luiz Augusto von Dentz
maintainerRe: [RFC BlueZ 2/2] main.conf: Add option to configure AVDP session/stream channel modes
Hi Alain,
Quoted 198 lines · Alain Michaud
Quoted 7 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds a new group AVDTP where platform can confure the prefered modes L2CAP channel for both session (signalling) and stream (transport). For better backward compatibility the default modes of boths
Reviewed-by Alain Michaud <[email protected]>Tested-by Alain Michaud <[email protected]>Quoted 184 lines
--- profiles/audio/a2dp.c | 5 +---- profiles/audio/avdtp.c | 14 ++----------- src/btd.h | 7 +++++++ src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/main.conf | 13 ++++++++++++ 5 files changed, 68 insertions(+), 16 deletions(-)profiles/audio/a2dp.c +1
-4@@ -2324,10 +2324,7 @@ static bool a2dp_server_listen(struct a2dp_server *server)if (server->io)return true; -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; + mode = btd_opts.avdtp.session_mode; server->io = bt_io_listen(NULL, confirm_cb, server, NULL, &err, BT_IO_OPT_SOURCE_BDADDR,profiles/audio/avdtp.c +2
-12@@ -2603,12 +2603,7 @@ static int send_req(struct avdtp *session, gboolean priority,int err, timeout;if (session->state ==AVDTP_SESSION_STATE_DISCONNECTED ) { -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_ERTM ; +BtIOMode mode = btd_opts.avdtp.session_mode; session->io =l2cap_connect (session, mode);if (!session->io) {@@ -2807,12 +2802,7 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre struct seid_rej *resp, int size) {struct avdtp_local_sep *sep = stream->lsep; -BtIOMode mode; - -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; +BtIOMode mode = btd_opts.avdtp.stream_mode; stream->io =l2cap_connect (session, mode);if (!stream->io) {src/btd.h +7
-0@@ -84,6 +84,11 @@ struct btd_defaults {struct btd_le_defaults le; }; +struct btd_avdtp_opts { +uint8_t session_mode; +uint8_t stream_mode; +}; +struct btd_opts {char *name;uint32_t class;@@ -112,6 +117,8 @@ struct btd_opts {uint8_t gatt_channels;enum mps_mode_t mps; +struct btd_avdtp_opts avdtp; +uint8_t key_size;enum jw_repairing_t jw_repairing;src/main.c +45
-0@@ -34,6 +34,7 @@#include "lib/sdp.h" #include "gdbus/gdbus.h" +#include "btio/btio.h" #include "log.h" #include "backtrace.h" @@ -137,6 +138,12 @@ static const char *gatt_options[] = {NULL }; +static const char *avdtp_options[] = { +"SessionMode" , +"StreamMode" , +NULL +}; + static const struct group_table { const char *name; const char **options;@@ -146,6 +153,7 @@ static const struct group_table { { "LE", le_options }, { "Policy", policy_options }, { "GATT", gatt_options }, + { "AVDTP", avdtp_options }, { } };@@ -744,6 +752,40 @@ static void parse_config(GKeyFile *config) btd_opts.gatt_channels = val; } + str =g_key_file_get_string (config,"AVDTP" ,"SessionMode" , &err); +if (err) { +DBG ("%s" , err->message); +g_clear_error (&err); + }else { +DBG ("SessionMode=%s" , str); + +if (!strcmp (str,"basic" )) + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; +else if (!strcmp (str,"ertm" )) + btd_opts.avdtp.session_mode =BT_IO_MODE_ERTM ; +else { +DBG ("Invalid mode option: %s" , str); + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; + } + } + + val =g_key_file_get_integer (config,"AVDTP" ,"StreamMode" , &err); +if (err) { +DBG ("%s" , err->message); +g_clear_error (&err); + }else { +DBG ("StreamMode=%s" , str); + +if (!strcmp (str,"basic" )) + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; +else if (!strcmp (str,"streaming" )) + btd_opts.avdtp.stream_mode =BT_IO_MODE_STREAMING ; +else { +DBG ("Invalid mode option: %s" , str); + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; + } + } +parse_br_config (config);parse_le_config (config); }@@ -780,6 +822,9 @@ static void init_defaults(void) btd_opts.gatt_cache =BT_GATT_CACHE_ALWAYS ; btd_opts.gatt_mtu =BT_ATT_MAX_LE_MTU ; btd_opts.gatt_channels =3 ; + + btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; + btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; } static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,src/main.conf +11
-0@@ -200,6 +200,19 @@ # Default to 3 #Channels = 3 +[AVDTP] +# AVDTP L2CAP Signalling Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# ertm: Use L2CAP Enhanced Retransmission Mode +#SessionMode = basic + +# AVDTP L2CAP Transport Channel Mode. +# Possible values: +# basic: Use L2CAP Basic Mode +# streaming: Use L2CAP Streaming Mode
Quoted 8 lines
Quoted 8 lines
src/main.conf +2
-1+#StreamMode = basic + [Policy] # # The ReconnectUUIDs defines the set of remote services that should try --2.26.2
Pushed.
Signature · 1 line
Luiz Augusto von Dentz
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=385541
---Test result---
##############################
Test: CheckPatch - FAIL
Output:
main.conf: Add option to configure AVDP session/stream channel modes WARNING:TYPO_SPELLING: 'prefered' may be misspelled - perhaps 'preferred'? #7:
This adds a new group AVDTP where platform can confure the prefered
WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #101: FILE: src/main.c:141:
+static const char *avdtp_options[] = {
- total: 0 errors, 2 warnings, 150 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
"[PATCH] main.conf: Add option to configure AVDP session/stream" has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: CheckGitLint - PASS
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
Quoted 4 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Signalling channel shall only use Basic or ERTM modes.
Quoted 65 lines
--- profiles/audio/avdtp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)profiles/audio/avdtp.c +16
-11@@ -2429,20 +2429,13 @@ uint16_t avdtp_get_version(struct avdtp *session)return session->version; } -static GIOChannel *l2cap_connect (struct avdtp *session) +static GIOChannel *l2cap_connect (struct avdtp *session,BtIOMode mode) {GError *err =NULL ;GIOChannel *io;const bdaddr_t *src; -BtIOMode mode; - src =btd_adapter_get_address (device_get_adapter (session->device)); -if (btd_opts.mps ==MPS_OFF ) - mode =BT_IO_MODE_BASIC ; -else - mode =BT_IO_MODE_STREAMING ; -if (session->phy) io = bt_io_connect(avdtp_connect_cb, session, NULL, &err,@@ -2610,7 +2603,14 @@ static int send_req(struct avdtp *session, gboolean priority,int err, timeout;if (session->state ==AVDTP_SESSION_STATE_DISCONNECTED ) { - session->io =l2cap_connect (session); +BtIOMode mode; + +if (btd_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_ERTM ; + + session->io =l2cap_connect (session, mode);if (!session->io) {/* Report disconnection anyways, as the other layers * are using this state for cleanup. @@ -2807,8 +2807,14 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre struct seid_rej *resp, int size) {struct avdtp_local_sep *sep = stream->lsep; +BtIOMode mode; + +if (btd_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; - stream->io =l2cap_connect (session); + stream->io =l2cap_connect (session, mode);if (!stream->io) {avdtp_sep_set_state (session, sep,AVDTP_STATE_IDLE );return FALSE; --2.26.2