Skip to contentSkip to conversation

android: Add "eSCO transparent data is mSBC" mode

PATCH In review Szymon Janc 2 participants 3 messages Mar 13, 2014 – Mar 14, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 android: Add "eSCO transparent data is mSBC" mode

This is usefull for platforms that assume transparent eSCO data is mSBC e.g. Nexus 4.

---
 android/hal-ipc-api.txt | 1 +
 android/hal-msg.h       | 1 +
 2 files changed, 2 insertions(+)
android/hal-ipc-api.txt +1 -0
index e4a4e9c..acfb8a0 100644
@@ -757,6 +757,7 @@ Bluetooth Handsfree HAL (ID 5)
 Android HAL name: "handsfree" (BT_PROFILE_HANDSFREE_ID)
 
 	Service modes:               0x01 = Headset Profile only mode
+	                             0x02 = eSCO transparent data is mSBC mode
 
 Commands and responses:
 
android/hal-msg.h +1 -0
index 0abbbe6..c3a96d5 100644
@@ -386,6 +386,7 @@ struct hal_cmd_pan_disconnect {
 /* Handsfree HAL API */
 
 #define HAL_MODE_HANDSFREE_HSP_ONLY		0x01
+#define HAL_MODE_HANDSFREE_ESCO_MSBC		0x02
 
 #define HAL_OP_HANDSFREE_CONNECT		0x01
 struct hal_cmd_handsfree_connect {
Signature · 1 line
1.9.0
#1 lore raw

PATCH 2/2 android/handsfree: Add support for enabling mSBC codec

---
 android/hal-handsfree.c |  4 ++++
 android/handsfree.c     | 18 +++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)
android/hal-handsfree.c +4 -0
index 31793b0..1cdb447 100644
@@ -214,6 +214,10 @@ static uint8_t get_mode(void)
 					(!strcasecmp(value, "hsp_only")))
 		return HAL_MODE_HANDSFREE_HSP_ONLY;
 
+	if (property_get("bluetooth.handsfree_mode", value, "") > 0 &&
+					(!strcasecmp(value, "esco_msbc")))
+		return HAL_MODE_HANDSFREE_ESCO_MSBC;
+
 	return HAL_MODE_DEFAULT;
 }
 
android/handsfree.c +15 -3
index e488859..319bf91 100644
@@ -150,6 +150,8 @@ static struct {
 	guint sco_watch;
 } device;
 
+static uint8_t hal_mode = HAL_MODE_DEFAULT;
+
 static bdaddr_t adapter_addr;
 static struct ipc *hal_ipc = NULL;
 
@@ -181,6 +183,14 @@ static void device_set_state(uint8_t state)
 				HAL_EV_HANDSFREE_CONN_STATE, sizeof(ev), &ev);
 }
 
+static void init_codecs(void)
+{
+	memcpy(device.codecs, codecs_defaults, sizeof(device.codecs));
+
+	if (hal_mode == HAL_MODE_HANDSFREE_ESCO_MSBC)
+		device.codecs[MSBC_OFFSET].local_supported = true;
+}
+
 static void device_set_audio_state(uint8_t state)
 {
 	struct hal_ev_handsfree_audio_state ev;
@@ -207,7 +217,7 @@ static void device_init(const bdaddr_t *bdaddr)
 
 	memcpy(device.inds, inds_defaults, sizeof(device.inds));
 
-	memcpy(device.codecs, codecs_defaults, sizeof(device.codecs));
+	init_codecs();
 
 	device_set_state(HAL_EV_HANDSFREE_CONN_STATE_CONNECTING);
 }
@@ -1252,8 +1262,8 @@ static void at_cmd_bac(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
 		if (!(device.features & HFP_HF_FEAT_CODEC))
 			goto failed;
 
-		/* Clear list of codecs */
-		memcpy(device.codecs, codecs_defaults, sizeof(device.codecs));
+		/* set codecs to defaults */
+		init_codecs();
 		device.negotiated_codec = 0;
 
 		/* At least CVSD mandatory codec must exist
@@ -2487,6 +2497,8 @@ bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
 	ipc_register(hal_ipc, HAL_SERVICE_ID_HANDSFREE, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
+	hal_mode = mode;
+
 	return true;
 }
 
Signature · 1 line
1.9.0
maintainer
#2 lore raw
In reply to Szymon Janc

Hi Szymon,

Quoted 12 lines

This is usefull for platforms that assume transparent eSCO data is mSBC e.g. Nexus 4.
---
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +

2 files changed, 2 insertions(+)
android/hal-ipc-api.txt +0 -0
index e4a4e9c..acfb8a0 100644

android/hal-ipc-api.txt Bluetooth Handsfree HAL (ID 5) · line 760

Quoted 4 lines
android/hal-ipc-api.txt +1 -0
@@ -757,6 +757,7 @@ Bluetooth Handsfree HAL (ID 5)
 Android HAL name: "handsfree" (BT_PROFILE_HANDSFREE_ID)
 
 	Service modes:               0x01 = Headset Profile only mode
+	                             0x02 = eSCO transparent data is mSBC mode

actually lets do them a little bit different here:

		0x00 = Headset Profile only mode
		0x01 = Handsfree Profile (narrowband speech)
		0x02 = Handsfree Profile (narrowband and wideband speech)

We should default to HSP only since that is the only safe default we can have here. The existence of a cellular modem is not always given.

Which means on a device like the Nexus 7 or any other WiFi only tablet, the defaults will work just fine.

Regards

Marcel