summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-06-08 17:18:24 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-06-08 17:18:24 +0000
commitf4eb9e2dea643f41e261bb9e2bff33fc03bd9ecc (patch)
tree73cd9edc1e8de2f069ef5ee908030ef6ce6beaf8 /hcid
parent03b145d3945ccce2855d7a09944c81c9badf798a (diff)
Add first attempt for driver probing
Diffstat (limited to 'hcid')
-rw-r--r--hcid/device.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/hcid/device.c b/hcid/device.c
index 65ed8ab4..fee2a4e8 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -119,6 +119,8 @@ static struct hci_dev devices[MAX_DEVICES];
#define ASSERT_DEV_ID { if (dev_id >= MAX_DEVICES) return -ERANGE; }
+static GSList *drivers = NULL;
+
static uint16_t uuid_list[] = {
PUBLIC_BROWSE_GROUP,
GENERIC_AUDIO_SVCLASS_ID,
@@ -1102,6 +1104,37 @@ gint device_address_cmp(struct device *device, const gchar *address)
return strcasecmp(device->address, address);
}
+static void probe_matching_drivers(struct device *device)
+{
+ GSList *drv_list;
+ const char **drv_uuid;
+ struct btd_device_driver *driver;
+ int err;
+
+ debug("Probe drivers for %s", device->path);
+
+ for (drv_list = drivers; drv_list; drv_list = drv_list->next) {
+ driver = (struct btd_device_driver *) drv_list->data;
+ gboolean do_probe = FALSE;
+
+ for (drv_uuid = driver->uuids; *drv_uuid; drv_uuid++) {
+ GSList *match = g_slist_find_custom(device->uuids,
+ *drv_uuid, (GCompareFunc) strcasecmp);
+ if (match) {
+ do_probe = TRUE;
+ break;
+ }
+ }
+
+ if (do_probe == TRUE) {
+ err = driver->probe(device->path);
+ if (err < 0)
+ error("probe failed for driver %s",
+ driver->name);
+ }
+ }
+}
+
static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
{
sdp_list_t *seq, *next, *svcclass;
@@ -1165,7 +1198,7 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
/* Public browsing was succesful */
if (!req->search_uuid && recs)
- goto proceed;
+ goto probe;
if (uuid_list[++req->search_uuid]) {
sdp_uuid16_create(&uuid, uuid_list[req->search_uuid]);
@@ -1173,6 +1206,9 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
return;
}
+probe:
+ probe_matching_drivers(device);
+
proceed:
g_dbus_emit_signal(req->conn, dbus_message_get_path(req->msg),
ADAPTER_INTERFACE, "DeviceCreated",
@@ -1217,8 +1253,6 @@ int device_browse(struct device *device, DBusConnection *conn,
return bt_search_service(&src, &dst, &uuid, browse_cb, req, NULL);
}
-static GSList *drivers = NULL;
-
int btd_register_device_driver(struct btd_device_driver *driver)
{
const char **uuid;