All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3 v2] hfp_ag_bluez5: Add initial handsfree audio driver
@ 2015-10-16  5:59 Simon Fels
  2015-10-16  5:59 ` [PATCH 2/3 v2] emulator: add codec negotiation support Simon Fels
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Simon Fels @ 2015-10-16  5:59 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3173 bytes --]

---
 plugins/hfp_ag_bluez5.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)

diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index ef8a048..3aca792 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -49,11 +49,47 @@
 #define HFP_AG_EXT_PROFILE_PATH   "/bluetooth/profile/hfp_ag"
 #define BT_ADDR_SIZE 18
 
+#define HFP_AG_DRIVER		"hfp-ag-driver"
+
 static guint modemwatch_id;
 static GList *modems;
 static GHashTable *sim_hash = NULL;
 static GHashTable *connection_hash;
 
+static int hfp_card_probe(struct ofono_handsfree_card *card,
+					unsigned int vendor, void *data)
+{
+	DBG("");
+
+	return 0;
+}
+
+static void hfp_card_remove(struct ofono_handsfree_card *card)
+{
+	DBG("");
+}
+
+static void hfp_card_connect(struct ofono_handsfree_card *card,
+					ofono_handsfree_card_connect_cb_t cb,
+					void *data)
+{
+	DBG("");
+	ofono_handsfree_card_connect_sco(card);
+}
+
+static void hfp_sco_connected_hint(struct ofono_handsfree_card *card)
+{
+	DBG("");
+}
+
+static struct ofono_handsfree_card_driver hfp_ag_driver = {
+	.name			= HFP_AG_DRIVER,
+	.probe			= hfp_card_probe,
+	.remove			= hfp_card_remove,
+	.connect		= hfp_card_connect,
+	.sco_connected_hint	= hfp_sco_connected_hint,
+};
+
 static void connection_destroy(gpointer data)
 {
 	int fd = GPOINTER_TO_INT(data);
@@ -104,12 +140,15 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 		goto invalid;
 
 	dbus_message_iter_get_basic(&entry, &fd);
-	dbus_message_iter_next(&entry);
 
 	if (fd < 0)
 		goto invalid;
 
-	DBG("%s", device);
+	dbus_message_iter_next(&entry);
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_ARRAY) {
+		close(fd);
+		goto invalid;
+	}
 
 	/* Pick the first voicecall capable modem */
 	if (modems == NULL) {
@@ -167,7 +206,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 
 	card = ofono_handsfree_card_create(0,
 					OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
-					NULL, NULL);
+					HFP_AG_DRIVER, em);
 
 	ofono_handsfree_card_set_local(card, local);
 	ofono_handsfree_card_set_remote(card, remote);
@@ -369,6 +408,7 @@ static void call_modemwatch(struct ofono_modem *modem, void *user)
 static int hfp_ag_init(void)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
+	int err;
 
 	if (DBUS_TYPE_UNIX_FD < 0)
 		return -EBADF;
@@ -383,6 +423,13 @@ static int hfp_ag_init(void)
 		return -EIO;
 	}
 
+	err = ofono_handsfree_card_driver_register(&hfp_ag_driver);
+	if (err < 0) {
+		g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
+						BLUEZ_PROFILE_INTERFACE);
+		return err;
+	}
+
 	sim_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
 
 	modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
@@ -404,6 +451,8 @@ static void hfp_ag_exit(void)
 	g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
 						BLUEZ_PROFILE_INTERFACE);
 
+	ofono_handsfree_card_driver_unregister(&hfp_ag_driver);
+
 	g_hash_table_destroy(connection_hash);
 
 	g_list_free(modems);
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-19 14:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-16  5:59 [PATCH 1/3 v2] hfp_ag_bluez5: Add initial handsfree audio driver Simon Fels
2015-10-16  5:59 ` [PATCH 2/3 v2] emulator: add codec negotiation support Simon Fels
2015-10-19 14:20   ` Denis Kenzior
2015-10-16  6:00 ` [PATCH 3/3 v3] hfp_ag_bluez5: use codec negotiation Simon Fels
2015-10-19 14:21   ` Denis Kenzior
2015-10-19 14:22 ` [PATCH 1/3 v2] hfp_ag_bluez5: Add initial handsfree audio driver Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.