Skip to contentSkip to conversation

Bluetooth: SCO: Add support for 16 bits transparent voice setting

PATCH In review Frédéric Danis 3 participants 3 messages Dec 5, 2024 – Dec 6, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Bluetooth: SCO: Add support for 16 bits transparent voice setting

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.

---
v1 -> v2: Enhance commit message
v2 -> v3: Enhance commit message

 include/net/bluetooth/bluetooth.h | 1 +
 net/bluetooth/sco.c               | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
include/net/bluetooth/bluetooth.h +1 -0
index e6760c11f007..435250c72d56 100644
@@ -123,6 +123,7 @@ struct bt_voice {
 
 #define BT_VOICE_TRANSPARENT			0x0003
 #define BT_VOICE_CVSD_16BIT			0x0060
+#define BT_VOICE_TRANSPARENT_16BIT		0x0063
 
 #define BT_SNDMTU		12
 #define BT_RCVMTU		13
net/bluetooth/sco.c +5 -2
index 7eb8d3e04ec4..7b54d8826bcc 100644
@@ -319,7 +319,8 @@ static int sco_connect(struct sock *sk)
 	else
 		type = SCO_LINK;
 
-	if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
+	if ((sco_pi(sk)->setting == BT_VOICE_TRANSPARENT ||
+	     sco_pi(sk)->setting == BT_VOICE_TRANSPARENT_16BIT) &&
 	    (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
 		err = -EOPNOTSUPP;
 		goto unlock;
@@ -922,6 +923,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 
 		/* Explicitly check for these values */
 		if (voice.setting != BT_VOICE_TRANSPARENT &&
+		    voice.setting != BT_VOICE_TRANSPARENT_16BIT &&
 		    voice.setting != BT_VOICE_CVSD_16BIT) {
 			err = -EINVAL;
 			break;
@@ -935,7 +937,8 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 			break;
 		}
 		if (enhanced_sync_conn_capable(hdev) &&
-		    voice.setting == BT_VOICE_TRANSPARENT)
+		    (voice.setting == BT_VOICE_TRANSPARENT ||
+		     voice.setting == BT_VOICE_TRANSPARENT_16BIT))
 			sco_pi(sk)->codec.id = BT_CODEC_TRANSPARENT;
 		hci_dev_put(hdev);
 		break;
Signature · 1 line
2.34.1
#1 lore raw

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=915024

---Test result---

Test Summary:

CheckPatch                    PENDING   0.25 seconds
GitLint                       PENDING   0.25 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      25.68 seconds
CheckAllWarning               PASS      27.47 seconds
CheckSparse                   WARNING   30.97 seconds
BuildKernel32                 PASS      24.80 seconds
TestRunnerSetup               PASS      438.49 seconds
TestRunner_l2cap-tester       PASS      20.50 seconds
TestRunner_iso-tester         FAIL      29.48 seconds
TestRunner_bnep-tester        PASS      4.89 seconds
TestRunner_mgmt-tester        PASS      117.29 seconds
TestRunner_rfcomm-tester      PASS      7.70 seconds
TestRunner_sco-tester         PASS      9.46 seconds
TestRunner_ioctl-tester       PASS      8.05 seconds
TestRunner_mesh-tester        PASS      6.06 seconds
TestRunner_smp-tester         PASS      7.03 seconds
TestRunner_userchan-tester    PASS      5.04 seconds
IncrementalBuild              PENDING   0.84 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/sco.c: note: in included file:./include/net/bluetooth/hci_core.h:147:35: warning: array of flexible structures
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
Total: 125, Passed: 121 (96.8%), Failed: 0, Not Run: 4
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Frédéric Danis

Hi Frederic,

Quoted 51 lines · Frédéric Danis

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.

---
v1 -> v2: Enhance commit message
v2 -> v3: Enhance commit message

 include/net/bluetooth/bluetooth.h | 1 +
 net/bluetooth/sco.c               | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
include/net/bluetooth/bluetooth.h +1 -0
index e6760c11f007..435250c72d56 100644
@@ -123,6 +123,7 @@ struct bt_voice {
 
 #define BT_VOICE_TRANSPARENT                   0x0003
 #define BT_VOICE_CVSD_16BIT                    0x0060
+#define BT_VOICE_TRANSPARENT_16BIT             0x0063
 
 #define BT_SNDMTU              12
 #define BT_RCVMTU              13
net/bluetooth/sco.c +2 -1
index 7eb8d3e04ec4..7b54d8826bcc 100644
@@ -319,7 +319,8 @@ static int sco_connect(struct sock *sk)
        else
                type = SCO_LINK;
 
-       if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
+       if ((sco_pi(sk)->setting == BT_VOICE_TRANSPARENT ||
+            sco_pi(sk)->setting == BT_VOICE_TRANSPARENT_16BIT) &&
            (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
                err = -EOPNOTSUPP;
                goto unlock;

net/bluetooth/sco.c static int sco_sock_setsockopt(struct socket *sock, int level, int optname, · line 927

Quoted 5 lines
net/bluetooth/sco.c +1 -0
@@ -922,6 +923,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
 
                /* Explicitly check for these values */
                if (voice.setting != BT_VOICE_TRANSPARENT &&
+                   voice.setting != BT_VOICE_TRANSPARENT_16BIT &&
                    voice.setting != BT_VOICE_CVSD_16BIT) {

We might need to allow all valid settings here, since there can be different PCM settings other than just these which is probably why the HCI field is a bitmask, so I suggest we do something like this:

https://gist.github.com/Vudentz/ae1502e6e402ae95aca330bae6096941

Quoted 16 lines
net/bluetooth/sco.c +2 -2
                        err = -EINVAL;
                        break;
@@ -935,7 +937,8 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname,
                        break;
                }
                if (enhanced_sync_conn_capable(hdev) &&
-                   voice.setting == BT_VOICE_TRANSPARENT)
+                   (voice.setting == BT_VOICE_TRANSPARENT ||
+                    voice.setting == BT_VOICE_TRANSPARENT_16BIT))
                        sco_pi(sk)->codec.id = BT_CODEC_TRANSPARENT;
                hci_dev_put(hdev);
                break;
--

2.34.1

Signature · 1 line
Luiz Augusto von Dentz