[PATCH 3/6] android/hal-handsfree: Add support for enable HFP command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 android/hal-handsfree.c | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 1b150c3..790d7a5 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -196,6 +196,25 @@ static const struct hal_ipc_handler ev_handlers[] = {
 	{handle_hsp_key_press, false, 0},
 };
 
+static void cleanup(void)
+{
+	struct hal_cmd_unregister_module cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return;
+
+	cbs = NULL;
+
+	cmd.service_id = HAL_SERVICE_ID_HANDSFREE;
+
+	hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+
+	hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE);
+}
+
 static bt_status_t init(bthf_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -219,8 +238,15 @@ static bt_status_t init(bthf_callbacks_t *callbacks)
 	if (ret != BT_STATUS_SUCCESS) {
 		cbs = NULL;
 		hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE);
+		return ret;
 	}
 
+	/* TODO should be based on some property value */
+	ret = hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE, HAL_OP_HANDSFREE_ENABLE_HFP,
+							0, NULL, 0, NULL, NULL);
+	if (ret != BT_STATUS_SUCCESS)
+		cleanup();
+
 	return ret;
 }
 
@@ -518,25 +544,6 @@ static bt_status_t phone_state_change(int num_active, int num_held,
 					len, cmd, 0, NULL, NULL);
 }
 
-static void cleanup(void)
-{
-	struct hal_cmd_unregister_module cmd;
-
-	DBG("");
-
-	if (!interface_ready())
-		return;
-
-	cbs = NULL;
-
-	cmd.service_id = HAL_SERVICE_ID_HANDSFREE;
-
-	hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
-					sizeof(cmd), &cmd, 0, NULL, NULL);
-
-	hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE);
-}
-
 static bthf_interface_t iface = {
 	.size = sizeof(iface),
 	.init = init,
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux