sco: SCO socket option for voice_setting
Subsystems (2)
v11 cover sco: SCO socket option for voice_setting
Hi,
v11 uses bool instead of int in hci_setup_sync
v10 include contribution from Johan, he reworks fallback handling and fixes Marcel remarks from v9.
error 0x0d handling moved into a separate patch
v9 is mostly cosmetics. Introduces LMP_TRANSPARENT bit in patch 8/8.
v8 declares BT_VOICE_CVSD_16BIT
Merge T*, S* and D* patches in one
The last patch returns -ECONNABORTED when trying to setup a transparent data connection if eSCO is not supported.
v7 changes defaults to BT_VOICE_CVSD
Remove mask parameter to sco_conn_defer_accept, it was always 0 check the bits for air codec instead of use constants.
Add S3, S2, S1, D1, D0 settings.
The controller default is now only used to initialize the controller or fill in the missing information in case of using the old Add_SCO command
v6 fixes style issues
v5 changes interface to SOL_BLUETOOTH, BT_VOICE.
Rework fallback mechanism.
This is the patch version 4 of the socket option for enabling transparent SCO. As requested by Marcel, this is now a 16-bit voice_setting. 0x0000 is the value corresponding to current behavior.0x0003 is the value to use for enabling transparent data.
It is easy to allow all possible values from Bluetooth core spec, but I guess results can be unexpected...
Should we filter allowed values in setsockopt ?
Let me know what you think.
Regards,
Fred
Frédéric Dalleau (10):
Bluetooth: Use hci_connect_sco directly
Bluetooth: Remove unused mask parameter in sco_conn_defer_accept
Bluetooth: Add Bluetooth socket voice option
Bluetooth: Add constants for SCO airmode
Bluetooth: Use voice setting in deferred SCO connection request
Bluetooth: Parameters for outgoing SCO connections
Bluetooth: Add constants and macro declaration for transparent data
Bluetooth: Prevent transparent SCO on older devices
Bluetooth: Handle specific error for SCO connection fallback
Bluetooth: Add SCO connection fallback
include/net/bluetooth/bluetooth.h | 8 ++++ include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 10 ++++- include/net/bluetooth/sco.h | 1 + net/bluetooth/hci_conn.c | 62 +++++++++++++++++++++++------ net/bluetooth/hci_event.c | 7 ++-- net/bluetooth/sco.c | 77 ++++++++++++++++++++++++++++++------- 7 files changed, 137 insertions(+), 29 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v11 1/10 Bluetooth: Use hci_connect_sco directly
hci_connect is a super function for connecting hci protocols. But the voice_setting parameter (introduced in subsequent patches) is only needed by SCO and security requirements are not needed for SCO channels. Thus, it makes sense to have a separate function for SCO.
--- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_conn.c | 8 ++------ net/bluetooth/sco.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -584,6 +584,8 @@ struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle);struct hci_conn *hci_connect (struct hci_dev *hdev,int type,bdaddr_t *dst,__u8 dst_type,__u8 sec_level,__u8 auth_type); +struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type, +bdaddr_t *dst);int hci_conn_check_link_mode (struct hci_conn *conn);int hci_conn_check_secure (struct hci_conn *conn,__u8 sec_level);int hci_conn_security (struct hci_conn *conn,__u8 sec_level,__u8 auth_type);
net/bluetooth/hci_conn.c +2 -6
@@ -560,13 +560,12 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,return acl; } -static struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type, -bdaddr_t *dst,u8 sec_level,u8 auth_type) +struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type,bdaddr_t *dst) {struct hci_conn *acl;struct hci_conn *sco; - acl =hci_connect_acl (hdev, dst, sec_level, auth_type); + acl =hci_connect_acl (hdev, dst,BT_SECURITY_LOW ,HCI_AT_NO_BONDING );if (IS_ERR (acl))return acl;
@@ -612,9 +611,6 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,return hci_connect_le (hdev, dst, dst_type, sec_level, auth_type);case ACL_LINK :return hci_connect_acl (hdev, dst, sec_level, auth_type); -case SCO_LINK : -case ESCO_LINK : -return hci_connect_sco (hdev, type, dst, sec_level, auth_type); }return ERR_PTR (-EINVAL );
net/bluetooth/sco.c +1 -2
@@ -176,8 +176,7 @@ static int sco_connect(struct sock *sk)else type =SCO_LINK ; - hcon =hci_connect (hdev, type, dst,BDADDR_BREDR ,BT_SECURITY_LOW , -HCI_AT_NO_BONDING ); + hcon =hci_connect_sco (hdev, type, dst);if (IS_ERR (hcon)) { err =PTR_ERR (hcon); goto done;
Signature · 1 line
1.7.9.5
PATCH v11 2/10 Bluetooth: Remove unused mask parameter in sco_conn_defer_accept
In reply to Frédéric DalleauQuoted 1 line
From Bluetooth Core v4.0 specification, 7.1.8 Accept Connection Request
Command "When accepting synchronous connection request, the Role parameter is not used and will be ignored by the BR/EDR Controller."
--- net/bluetooth/sco.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
net/bluetooth/sco.c +3 -7
@@ -651,7 +651,7 @@ static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,return err; } -static void sco_conn_defer_accept (struct hci_conn *conn,int mask) +static void sco_conn_defer_accept (struct hci_conn *conn) {struct hci_dev *hdev = conn->hdev;
@@ -663,11 +663,7 @@ static void sco_conn_defer_accept(struct hci_conn *conn, int mask)struct hci_cp_accept_conn_req cp;bacpy (&cp.bdaddr, &conn->dst); - -if (lmp_rswitch_capable (hdev) && (mask &HCI_LM_MASTER )) - cp.role =0x00 ;/* Become master */ -else - cp.role =0x01 ;/* Remain slave */ + cp.role =0x00 ;/* Ignored */ hci_send_cmd (hdev,HCI_OP_ACCEPT_CONN_REQ ,sizeof (cp), &cp); }else {
@@ -697,7 +693,7 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,if (sk->sk_state ==BT_CONNECT2 &&test_bit (BT_SK_DEFER_SETUP , &bt_sk (sk)->flags)) { -sco_conn_defer_accept (pi->conn->hcon,0 ); +sco_conn_defer_accept (pi->conn->hcon); sk->sk_state =BT_CONFIG ; msg->msg_namelen =0 ;
Signature · 1 line
1.7.9.5
PATCH v11 3/10 Bluetooth: Add Bluetooth socket voice option
In reply to Frédéric DalleauThis patch extends the current Bluetooth socket options with BT_VOICE. This is intended to choose voice data type at runtime. It only applies to SCO sockets. Incoming connections shall be setup during deferred setup. Outgoing connections shall be setup before connect(). The desired setting is stored in the SCO socket info. This patch declares needed members, modifies getsockopt() and setsockopt().
--- include/net/bluetooth/bluetooth.h | 8 ++++++++ include/net/bluetooth/sco.h | 1 + net/bluetooth/sco.c | 40 ++++++++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-)
include/net/bluetooth/bluetooth.h +8 -0
@@ -107,6 +107,14 @@ struct bt_power {*/ #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 +#define BT_VOICE 11 +struct bt_voice { +__u16 setting; +}; + +#define BT_VOICE_TRANSPARENT 0x0003 +#define BT_VOICE_CVSD_16BIT 0x0060 + __printf(1, 2)int bt_info (const char *fmt, ...);__printf (1 ,2 )
include/net/bluetooth/sco.h +1 -0
@@ -73,6 +73,7 @@ struct sco_conn {struct sco_pinfo {struct bt_sock bt;__u32 flags; +__u16 setting;struct sco_conn *conn; };
net/bluetooth/sco.c +39 -1
@@ -416,6 +416,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro sk->sk_protocol = proto; sk->sk_state =BT_OPEN ; +sco_pi (sk)->setting =BT_VOICE_CVSD_16BIT ; +setup_timer (&sk->sk_timer, sco_sock_timeout, (unsigned long )sk);bt_sock_link (&sco_sk_list, sk);
@@ -709,7 +711,8 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,static int sco_sock_setsockopt (struct socket *sock,int level,int optname,char __user *optval,unsigned int optlen) {struct sock *sk = sock->sk; -int err =0 ; +int len, err =0 ; +struct bt_voice voice;u32 opt;BT_DBG ("sk %p" , sk);
@@ -735,6 +738,31 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, charclear_bit (BT_SK_DEFER_SETUP , &bt_sk (sk)->flags);break ; +case BT_VOICE : +if (sk->sk_state !=BT_OPEN && sk->sk_state !=BT_BOUND && + sk->sk_state !=BT_CONNECT2 ) { + err = -EINVAL ; +break ; + } + + voice.setting =sco_pi (sk)->setting; + + len = min_t(unsigned int, sizeof(voice), optlen); +if (copy_from_user ((char *) &voice, optval, len)) { + err = -EFAULT ; +break ; + } + +/* Explicitly check for these values */ +if (voice.setting !=BT_VOICE_TRANSPARENT && + voice.setting !=BT_VOICE_CVSD_16BIT ) { + err = -EINVAL ; +break ; + } + +sco_pi (sk)->setting = voice.setting; +break ; +default : err = -ENOPROTOOPT ;break ;
@@ -804,6 +832,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char {struct sock *sk = sock->sk;int len, err =0 ; +struct bt_voice voice;BT_DBG ("sk %p" , sk);
@@ -829,6 +858,15 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, charbreak ; +case BT_VOICE : + voice.setting =sco_pi (sk)->setting; + + len = min_t(unsigned int, len, sizeof(voice)); +if (copy_to_user (optval, (char *)&voice, len)) + err = -EFAULT ; + +break ; +default : err = -ENOPROTOOPT ;break ;
Signature · 1 line
1.7.9.5
PATCH v11 4/10 Bluetooth: Add constants for SCO airmode
In reply to Frédéric DalleauThis patch defines constants for SCO airmode from SCO voice setting. It refers to Bluetooth Core V4.0 specification, Part E, Chap 6.12 which describe SCO voice setting format.
--- include/net/bluetooth/hci_core.h | 4 ++++ 1 file changed, 4 insertions(+)
include/net/bluetooth/hci_core.h +4 -0
@@ -1215,4 +1215,8 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],u8 bdaddr_to_le (u8 bdaddr_type); +#define SCO_AIRMODE_MASK 0x0003 +#define SCO_AIRMODE_CVSD 0x0000 +#define SCO_AIRMODE_TRANSP 0x0003 +#endif /* __HCI_CORE_H */
Signature · 1 line
1.7.9.5
PATCH v11 5/10 Bluetooth: Use voice setting in deferred SCO connection request
In reply to Frédéric DalleauWhen an incoming eSCO connection is requested, check the selected voice setting and reply appropriately. Voice setting should have been negotiated previously. For example, in case of HFP, the codec is negotiated using AT commands on the RFCOMM channel. This patch only changes replies for socket with deferred setup enabled.
--- net/bluetooth/sco.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
net/bluetooth/sco.c +17 -5
@@ -653,7 +653,7 @@ static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,return err; } -static void sco_conn_defer_accept (struct hci_conn *conn) +static void sco_conn_defer_accept (struct hci_conn *conn,u16 setting) {struct hci_dev *hdev = conn->hdev;
@@ -676,9 +676,21 @@ static void sco_conn_defer_accept(struct hci_conn *conn) cp.tx_bandwidth =__constant_cpu_to_le32 (0x00001f40 ); cp.rx_bandwidth =__constant_cpu_to_le32 (0x00001f40 ); - cp.max_latency =__constant_cpu_to_le16 (0xffff ); - cp.content_format =cpu_to_le16 (hdev->voice_setting); - cp.retrans_effort =0xff ; + cp.content_format =cpu_to_le16 (setting); + +switch (setting &SCO_AIRMODE_MASK ) { +case SCO_AIRMODE_TRANSP : +if (conn->pkt_type &ESCO_2EV3 ) + cp.max_latency =__constant_cpu_to_le16 (0x0008 ); +else + cp.max_latency =__constant_cpu_to_le16 (0x000D ); + cp.retrans_effort =0x02 ; +break ; +case SCO_AIRMODE_CVSD : + cp.max_latency =__constant_cpu_to_le16 (0xffff ); + cp.retrans_effort =0xff ; +break ; + }hci_send_cmd (hdev,HCI_OP_ACCEPT_SYNC_CONN_REQ ,sizeof (cp), &cp);
@@ -695,7 +707,7 @@ static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,if (sk->sk_state ==BT_CONNECT2 &&test_bit (BT_SK_DEFER_SETUP , &bt_sk (sk)->flags)) { -sco_conn_defer_accept (pi->conn->hcon); +sco_conn_defer_accept (pi->conn->hcon, pi->setting); sk->sk_state =BT_CONFIG ; msg->msg_namelen =0 ;
Signature · 1 line
1.7.9.5
PATCH v11 6/10 Bluetooth: Parameters for outgoing SCO connections
In reply to Frédéric DalleauIn order to establish a transparent SCO connection, the correct settings must be specified in the Setup Synchronous Connection request. For that, a setting field is added to ACL connection data to set up the desired parameters. The patch also removes usage of hdev->voice_setting in CVSD connection and makes use of T2 parameters for transparent data.
--- include/net/bluetooth/hci_core.h | 5 +++-- net/bluetooth/hci_conn.c | 24 +++++++++++++++++++----- net/bluetooth/sco.c | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-)
include/net/bluetooth/hci_core.h +3 -2
@@ -320,6 +320,7 @@ struct hci_conn {__u32 passkey_notify;__u8 passkey_entered;__u16 disc_timeout; +__u16 setting;unsigned long flags;__u8 remote_cap;
@@ -584,8 +585,8 @@ struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle);struct hci_conn *hci_connect (struct hci_dev *hdev,int type,bdaddr_t *dst,__u8 dst_type,__u8 sec_level,__u8 auth_type); -struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type, -bdaddr_t *dst); +struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type,bdaddr_t *dst, +__u16 setting);int hci_conn_check_link_mode (struct hci_conn *conn);int hci_conn_check_secure (struct hci_conn *conn,__u8 sec_level);int hci_conn_security (struct hci_conn *conn,__u8 sec_level,__u8 auth_type);
net/bluetooth/hci_conn.c +19 -5
@@ -185,13 +185,24 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle) conn->attempt++; cp.handle =cpu_to_le16 (handle); - cp.pkt_type =cpu_to_le16 (conn->pkt_type); cp.tx_bandwidth =__constant_cpu_to_le32 (0x00001f40 ); cp.rx_bandwidth =__constant_cpu_to_le32 (0x00001f40 ); - cp.max_latency =__constant_cpu_to_le16 (0xffff ); - cp.voice_setting =cpu_to_le16 (hdev->voice_setting); - cp.retrans_effort =0xff ; + cp.voice_setting =cpu_to_le16 (conn->setting); + +switch (conn->setting &SCO_AIRMODE_MASK ) { +case SCO_AIRMODE_TRANSP : + cp.pkt_type =__constant_cpu_to_le16 (EDR_ESCO_MASK & + ~ESCO_2EV3 ); + cp.max_latency =__constant_cpu_to_le16 (0x000d ); + cp.retrans_effort =0x02 ; +break ; +case SCO_AIRMODE_CVSD : + cp.pkt_type =cpu_to_le16 (conn->pkt_type); + cp.max_latency =__constant_cpu_to_le16 (0xffff ); + cp.retrans_effort =0xff ; +break ; + }hci_send_cmd (hdev,HCI_OP_SETUP_SYNC_CONN ,sizeof (cp), &cp); }
@@ -560,7 +571,8 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,return acl; } -struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type,bdaddr_t *dst) +struct hci_conn *hci_connect_sco (struct hci_dev *hdev,int type,bdaddr_t *dst, +__u16 setting) {struct hci_conn *acl;struct hci_conn *sco;
@@ -583,6 +595,8 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst)hci_conn_hold (sco); + sco->setting = setting; +if (acl->state ==BT_CONNECTED && (sco->state ==BT_OPEN || sco->state ==BT_CLOSED )) {set_bit (HCI_CONN_POWER_SAVE , &acl->flags);
net/bluetooth/sco.c +1 -1
@@ -176,7 +176,7 @@ static int sco_connect(struct sock *sk)else type =SCO_LINK ; - hcon =hci_connect_sco (hdev, type, dst); + hcon =hci_connect_sco (hdev, type, dst,sco_pi (sk)->setting);if (IS_ERR (hcon)) { err =PTR_ERR (hcon); goto done;
Signature · 1 line
1.7.9.5
PATCH v11 7/10 Bluetooth: Add constants and macro declaration for transparent data
In reply to Frédéric DalleauThis patch defines constants and macro for transparent data LMP features. It refers to Bluetooth Core V4.0 specification, Part C, Chap 3.3 which defines LMP feature mask.
--- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 + 2 files changed, 2 insertions(+)
include/net/bluetooth/hci.h +1 -0
@@ -238,6 +238,7 @@ enum {#define LMP_CVSD 0x01#define LMP_PSCHEME 0x02#define LMP_PCONTROL 0x04 +#define LMP_TRANSPARENT 0x08#define LMP_RSSI_INQ 0x40#define LMP_ESCO 0x80
include/net/bluetooth/hci_core.h +1 -0
@@ -800,6 +800,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);#define lmp_lsto_capable (dev) ((dev)->features[0][7] & LMP_LSTO)#define lmp_inq_tx_pwr_capable (dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR)#define lmp_ext_feat_capable (dev) ((dev)->features[0][7] & LMP_EXTFEATURES) +#define lmp_transp_capable (dev) ((dev)->features[0][2] & LMP_TRANSPARENT)/* ----- Extended LMP capabilities ----- */ #define lmp_host_ssp_capable (dev) ((dev)->features[1][0] & LMP_HOST_SSP)
Signature · 1 line
1.7.9.5
PATCH v11 8/10 Bluetooth: Prevent transparent SCO on older devices
In reply to Frédéric DalleauOlder Bluetooth devices may not support Setup Synchronous Connection or SCO transparent data. This is indicated by the corresponding LMP feature bits. It is not possible to know if the adapter support these features before setting BT_VOICE option since the socket is not bound to an adapter. An adapter can also be added after the socket is created. The socket can be bound to an address before adapter is plugged in.
Thus, on a such adapters, if user request BT_VOICE_TRANSPARENT, outgoing connections fail on connect() and returns -EOPNOTSUPP. Incoming connections do not fail. However, they should only be allowed depending on what was specified in Write_Voice_Settings command.
EOPNOTSUPP is choosen because connect() system call is failing after selecting route but before any connection attempt.
--- net/bluetooth/sco.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/sco.c +6 -0
@@ -176,6 +176,12 @@ static int sco_connect(struct sock *sk)else type =SCO_LINK ; +if (sco_pi (sk)->setting ==BT_VOICE_TRANSPARENT && + (!lmp_transp_capable (hdev) || !lmp_esco_capable (hdev))) { + err = -EOPNOTSUPP ; + goto done; + } + hcon =hci_connect_sco (hdev, type, dst,sco_pi (sk)->setting);if (IS_ERR (hcon)) { err =PTR_ERR (hcon);
Signature · 1 line
1.7.9.5
PATCH v11 9/10 Bluetooth: Handle specific error for SCO connection fallback
In reply to Frédéric DalleauSynchronous Connection Complete event can return error "Connection Rejected due to Limited resources (0x10)".
Handling this error is required for SCO connection fallback. This error happens when the server tried to accept the connection but failed to negotiate settings.
This error code has been verified experimentally by sending a T2 request to a T1 only SCO listener.
Client dump follows :
< HCI Command (0x01|0x0028) plen 17 [hci0] 3.696064
Handle: 12
Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 13
Setting: 0x0003
Retransmission effort: Optimize for link quality (0x02)
Packet type: 0x0380Quoted 1 line
HCI Event (
0x0f) plen 4 [hci0] 3.697034
Setup Synchronous Connection (0x01|0x0028) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event (
0x2c) plen 17 [hci0] 3.736059
Status: Connection Rejected due to Limited Resources (0x0d)
Handle: 0
Address: xx:xx:xx:xx:xx:AB (OUI 70-F3-95)
Link type: eSCO (0x02)
Transmission interval: 0x0c
Retransmission window: 0x06
RX packet length: 60
TX packet length: 60
Air mode: Transparent (0x03)Server dump follows :
Quoted 1 line
HCI Event (
0x04) plen 10 [hci0] 4.741513
Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
Class: 0x620100
Major class: Computer (desktop, notebook, PDA, organizers) Minor class: Uncategorized, code for device not assigned Networking (LAN, Ad hoc)
Audio (Speaker, Microphone, Headset)
Telephony (Cordless telephony, Modem, Headset)
Link type: eSCO (0x02)
< HCI Command (0x01|0x0029) plen 21 [hci0] 4.743269
Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 13
Setting: 0x0003
Retransmission effort: Optimize for link quality (0x02)
Packet type: 0x03c1Quoted 1 line
HCI Event (
0x0f) plen 4 [hci0] 4.745517
Accept Synchronous Connection (0x01|0x0029) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event (
0x2c) plen 17 [hci0] 4.749508
Status: Connection Rejected due to Limited Resources (0x0d)
Handle: 0
Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
Link type: eSCO (0x02)
Transmission interval: 0x0c
Retransmission window: 0x06
RX packet length: 60
TX packet length: 60
Air mode: Transparent (0x03)--- net/bluetooth/hci_event.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/hci_event.c +1 -0
@@ -2904,6 +2904,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,hci_conn_add_sysfs (conn);break ; +case 0x0d :/* Connection Rejected due to Limited Resources */ case 0x11 :/* Unsupported Feature or Parameter Value */ case 0x1c :/* SCO interval rejected */ case 0x1a :/* Unsupported Remote Feature */
Signature · 1 line
1.7.9.5
PATCH v11 10/10 Bluetooth: Add SCO connection fallback
In reply to Frédéric DalleauWhen initiating a transparent eSCO connection, make use of T2 settings at first try. T2 is the recommended settings from HFP 1.6 WideBand Speech. Upon connection failure, try T1 settings.
When CVSD is requested and eSCO is supported, try to establish eSCO connection using S3 settings. If it fails, fallback in sequence to S2, S1, D1, D0 settings.
To know which setting should be used, conn->attempt is used. It indicates the currently ongoing SCO connection attempt and can be used as the index for the fallback settings table.
These setting and the fallback order are described in Bluetooth HFP 1.6 specification p. 101.
--- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_conn.c | 44 +++++++++++++++++++++++++++++++------- net/bluetooth/hci_event.c | 6 +++--- 3 files changed, 40 insertions(+), 12 deletions(-)
include/net/bluetooth/hci_core.h +1 -1
@@ -570,7 +570,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, }void hci_disconnect (struct hci_conn *conn,__u8 reason); -void hci_setup_sync (struct hci_conn *conn,__u16 handle); +bool hci_setup_sync (struct hci_conn *conn,__u16 handle);void hci_sco_setup (struct hci_conn *conn,__u8 status);struct hci_conn *hci_conn_add (struct hci_dev *hdev,int type,bdaddr_t *dst);
net/bluetooth/hci_conn.c +36 -8
71 lines not on this page · raw message
net/bluetooth/hci_event.c +3 -3
@@ -2909,11 +2909,11 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,case 0x1c :/* SCO interval rejected */ case 0x1a :/* Unsupported Remote Feature */ case 0x1f :/* Unspecified error */ -if (conn->out && conn->attempt <2 ) { +if (conn->out) { conn->pkt_type = (hdev->esco_type &SCO_ESCO_MASK ) | (hdev->esco_type &EDR_ESCO_MASK ); -hci_setup_sync (conn, conn->link->handle); - goto unlock; +if (hci_setup_sync (conn, conn->link->handle)) + goto unlock; }/* fall through */
Signature · 1 line
1.7.9.5
Re: [PATCH v11 10/10] Bluetooth: Add SCO connection fallback
Hi Frédéric,
2013-08-19 Frédéric Dalleau <[email protected]>:
Quoted 15 lines
When initiating a transparent eSCO connection, make use of T2 settings at first try. T2 is the recommended settings from HFP 1.6 WideBand Speech. Upon connection failure, try T1 settings.
When CVSD is requested and eSCO is supported, try to establish eSCO connection using S3 settings. If it fails, fallback in sequence to S2, S1, D1, D0 settings.
To know which setting should be used,
conn->attemptis used. It indicates the currently ongoing SCO connection attempt and can be used as the index for the fallback settings table.These setting and the fallback order are described in Bluetooth HFP 1.6 specification p. 101.
Quoted 7 lines
Signed-off-by Frédéric Dalleau <[email protected]>Signed-off-by Johan Hedberg <[email protected]>--- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_conn.c | 44 +++++++++++++++++++++++++++++++------- net/bluetooth/hci_event.c | 6 +++--- 3 files changed, 40 insertions(+), 12 deletions(-)
All 10 patches have been applied to bluetooth-next. Thanks.
Gustavo