mirror of git://git.sysmocom.de/ofono
hfp_ag_bluez5: Add initial handsfree audio driver
This commit is contained in:
parent
88601c4733
commit
989f9b26e2
|
@ -49,11 +49,47 @@
|
||||||
#define HFP_AG_EXT_PROFILE_PATH "/bluetooth/profile/hfp_ag"
|
#define HFP_AG_EXT_PROFILE_PATH "/bluetooth/profile/hfp_ag"
|
||||||
#define BT_ADDR_SIZE 18
|
#define BT_ADDR_SIZE 18
|
||||||
|
|
||||||
|
#define HFP_AG_DRIVER "hfp-ag-driver"
|
||||||
|
|
||||||
static guint modemwatch_id;
|
static guint modemwatch_id;
|
||||||
static GList *modems;
|
static GList *modems;
|
||||||
static GHashTable *sim_hash = NULL;
|
static GHashTable *sim_hash = NULL;
|
||||||
static GHashTable *connection_hash;
|
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)
|
static void connection_destroy(gpointer data)
|
||||||
{
|
{
|
||||||
int fd = GPOINTER_TO_INT(data);
|
int fd = GPOINTER_TO_INT(data);
|
||||||
|
@ -104,12 +140,15 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||||
goto invalid;
|
goto invalid;
|
||||||
|
|
||||||
dbus_message_iter_get_basic(&entry, &fd);
|
dbus_message_iter_get_basic(&entry, &fd);
|
||||||
dbus_message_iter_next(&entry);
|
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto invalid;
|
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 */
|
/* Pick the first voicecall capable modem */
|
||||||
if (modems == NULL) {
|
if (modems == NULL) {
|
||||||
|
@ -167,7 +206,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||||
|
|
||||||
card = ofono_handsfree_card_create(0,
|
card = ofono_handsfree_card_create(0,
|
||||||
OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
|
OFONO_HANDSFREE_CARD_TYPE_GATEWAY,
|
||||||
NULL, NULL);
|
HFP_AG_DRIVER, em);
|
||||||
|
|
||||||
ofono_handsfree_card_set_local(card, local);
|
ofono_handsfree_card_set_local(card, local);
|
||||||
ofono_handsfree_card_set_remote(card, remote);
|
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)
|
static int hfp_ag_init(void)
|
||||||
{
|
{
|
||||||
DBusConnection *conn = ofono_dbus_get_connection();
|
DBusConnection *conn = ofono_dbus_get_connection();
|
||||||
|
int err;
|
||||||
|
|
||||||
if (DBUS_TYPE_UNIX_FD < 0)
|
if (DBUS_TYPE_UNIX_FD < 0)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
@ -383,6 +423,13 @@ static int hfp_ag_init(void)
|
||||||
return -EIO;
|
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);
|
sim_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||||
|
|
||||||
modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
|
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,
|
g_dbus_unregister_interface(conn, HFP_AG_EXT_PROFILE_PATH,
|
||||||
BLUEZ_PROFILE_INTERFACE);
|
BLUEZ_PROFILE_INTERFACE);
|
||||||
|
|
||||||
|
ofono_handsfree_card_driver_unregister(&hfp_ag_driver);
|
||||||
|
|
||||||
g_hash_table_destroy(connection_hash);
|
g_hash_table_destroy(connection_hash);
|
||||||
|
|
||||||
g_list_free(modems);
|
g_list_free(modems);
|
||||||
|
|
Loading…
Reference in New Issue