Skip to content

Commit 3bf09c6

Browse files
fdanis-ossgregkh
authored andcommitted
Bluetooth: SCO: Add support for 16 bits transparent voice setting
[ Upstream commit 29a6514 ] The voice setting is used by sco_connect() or sco_conn_defer_accept() after being set by sco_sock_setsockopt(). The PCM part of the voice setting is used for offload mode through PCM chipset port. This commits add support for mSBC 16 bits offloading, i.e. audio data not transported over HCI. The BCM4349B1 supports 16 bits transparent data on its I2S port. If BT_VOICE_TRANSPARENT is used when accepting a SCO connection, this gives only garbage audio while using BT_VOICE_TRANSPARENT_16BIT gives correct audio. This has been tested with connection to iPhone 14 and Samsung S24. Fixes: ad10b1a ("Bluetooth: Add Bluetooth socket voice option") Signed-off-by: Frédéric Danis <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 263b390 commit 3bf09c6

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct bt_voice {
123123

124124
#define BT_VOICE_TRANSPARENT 0x0003
125125
#define BT_VOICE_CVSD_16BIT 0x0060
126+
#define BT_VOICE_TRANSPARENT_16BIT 0x0063
126127

127128
#define BT_SNDMTU 12
128129
#define BT_RCVMTU 13

net/bluetooth/sco.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,13 @@ static int sco_connect(struct sock *sk)
267267
else
268268
type = SCO_LINK;
269269

270-
if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
271-
(!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
272-
err = -EOPNOTSUPP;
273-
goto unlock;
270+
switch (sco_pi(sk)->setting & SCO_AIRMODE_MASK) {
271+
case SCO_AIRMODE_TRANSP:
272+
if (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)) {
273+
err = -EOPNOTSUPP;
274+
goto unlock;
275+
}
276+
break;
274277
}
275278

276279
hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
@@ -876,23 +879,21 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
876879
if (err)
877880
break;
878881

879-
/* Explicitly check for these values */
880-
if (voice.setting != BT_VOICE_TRANSPARENT &&
881-
voice.setting != BT_VOICE_CVSD_16BIT) {
882-
err = -EINVAL;
883-
break;
884-
}
885-
886882
sco_pi(sk)->setting = voice.setting;
887883
hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src,
888884
BDADDR_BREDR);
889885
if (!hdev) {
890886
err = -EBADFD;
891887
break;
892888
}
893-
if (enhanced_sync_conn_capable(hdev) &&
894-
voice.setting == BT_VOICE_TRANSPARENT)
895-
sco_pi(sk)->codec.id = BT_CODEC_TRANSPARENT;
889+
890+
switch (sco_pi(sk)->setting & SCO_AIRMODE_MASK) {
891+
case SCO_AIRMODE_TRANSP:
892+
if (enhanced_sync_conn_capable(hdev))
893+
sco_pi(sk)->codec.id = BT_CODEC_TRANSPARENT;
894+
break;
895+
}
896+
896897
hci_dev_put(hdev);
897898
break;
898899

0 commit comments

Comments
 (0)