Skip to content

Commit aa2e5ff

Browse files
fdanis-ossSasha Levin
authored and
Sasha Levin
committed
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 <frederic.danis@collabora.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9f85191 commit aa2e5ff

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

include/net/bluetooth/bluetooth.h

+1
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

+15-14
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,
@@ -877,23 +880,21 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
877880
if (err)
878881
break;
879882

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

0 commit comments

Comments
 (0)