hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Sun Apr 22 19:27:19 PDT 2007


 doc/spec/hal-spec-properties.xml |  106 +++++++++++++++++++++++++++++++++++++++
 hald/linux/coldplug.c            |   35 ++++++++++++
 hald/linux/device.c              |   67 ++++++++++++++++++++----
 3 files changed, 195 insertions(+), 13 deletions(-)

New commits:
diff-tree f849652ff11b22b8685c9bd4728e8eb2299a4c96 (from 78f05b63f792b2130f0ac20bbea02b8754bf406d)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Apr 22 22:27:18 2007 -0400

    document Bluetooth ACL / SCO, fixup UDI generation and make coldplug work
    
    Looks like coldplugging in broken in interesting ways. I had to add
    the hack for coldplug.c to get things rolling - need to talk to Kay
    about that....

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 481665a..3917360 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2568,6 +2568,112 @@ org.freedesktop.Hal.Device.Volume.method
         </tgroup>
       </informaltable>
     </sect2>
+
+    <sect2 id="device-properties-bluetooth_hci">
+      <title>bluetooth_hci namespace</title>
+      <para>
+	Device objects representing a Bluetooth Host Controller Interface.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>bluetooth_hci.address</literal> (uint64)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>Address of the host controller interface.</entry>
+            </row>
+            <row>
+              <entry><literal>bluetooth_hci.originating_device</literal> (string)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>The UDI of the physical device (e.g. an USB interface) that provides the HCI hardware.</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2 id="device-properties-bluetooth_acl">
+      <title>bluetooth_acl namespace</title>
+      <para>
+	Device objects representing Asynchronous Connection-oriented Links.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>bluetooth_acl.address</literal> (uint64)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>Address of the device at the other end of the connection.</entry>
+            </row>
+            <row>
+              <entry><literal>bluetooth_acl.originating_device</literal> (string)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>The UDI of the Bluetooth HCI (of
+              capability <literal>bluetooth_hci</literal>) that the
+              connection is made through.
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2 id="device-properties-bluetooth_sco">
+      <title>bluetooth_sco namespace</title>
+      <para>
+	Device objects representing Synchronous Connection-Oriented links.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>bluetooth_sco.address</literal> (uint64)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>Address of the device at the other end of the connection.</entry>
+            </row>
+            <row>
+              <entry><literal>bluetooth_sco.originating_device</literal> (string)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>The UDI of the Bluetooth HCI (of
+              capability <literal>bluetooth_hci</literal>) that the
+              connection is made through.
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
+
   </sect1>
 
   <sect1 id="properties-functional">
diff --git a/hald/linux/coldplug.c b/hald/linux/coldplug.c
index fd81e6a..d5771b6 100644
--- a/hald/linux/coldplug.c
+++ b/hald/linux/coldplug.c
@@ -333,6 +333,36 @@ error:
 	return -1;
 }
 
+static void
+scan_single_bus (const char *bus_name)
+{
+        char dirname[HAL_PATH_MAX];
+        DIR *dir2;
+        struct dirent *dent2;
+        
+        g_strlcpy(dirname, get_hal_sysfs_path (), sizeof(dirname));
+        g_strlcat(dirname, "/bus/", sizeof(dirname));
+        g_strlcat(dirname, bus_name, sizeof(dirname));
+        g_strlcat(dirname, "/devices", sizeof(dirname));
+        
+        /* look for devices */
+        dir2 = opendir(dirname);
+        if (dir2 != NULL) {
+                for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+                        char dirname2[HAL_PATH_MAX];
+                        
+                        if (dent2->d_name[0] == '.')
+                                continue;
+                        
+                        g_strlcpy(dirname2, dirname, sizeof(dirname2));
+                        g_strlcat(dirname2, "/", sizeof(dirname2));
+                        g_strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+                        device_list_insert(dirname2, bus_name, HOTPLUG_EVENT_SYSFS_DEVICE);
+                }
+                closedir(dir2);
+        }
+}
+
 static void scan_subsystem(const char *subsys)
 {
 	char base[HAL_PATH_MAX];
@@ -500,9 +530,9 @@ static int _device_order (const void *d1
 	const struct sysfs_device *dev2 = d2;
 
 	/* device mapper needs to be the last events, to have the other block devs already around */
-	if (strstr(dev2->path, "/" DMPREFIX))
+	if (strstr (dev2->path, "/" DMPREFIX))
 		return -1;
-	if (strstr(dev1->path, "/" DMPREFIX))
+	if (strstr (dev1->path, "/" DMPREFIX))
 		return 1;
 
 	return strcmp(dev1->path, dev2->path);
@@ -532,6 +562,7 @@ coldplug_synthesize_events (void)
 		queue_events ();
 
 		scan_class ();
+                scan_single_bus ("bluetooth");
 		device_list = g_slist_sort (device_list, _device_order);
 		queue_events ();
 
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 3fc1a5d..e5c78ff 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -355,6 +355,9 @@ bluetooth_add (const gchar *sysfs_path, 
 {
 	HalDevice *d;
 	const char *type_entry;
+	const char *addr_entry;
+        unsigned int a5, a4, a3, a2, a1, a0;
+        dbus_uint64_t address;
 
 	d = NULL;
 
@@ -362,20 +365,39 @@ bluetooth_add (const gchar *sysfs_path, 
 		goto out;
 	}
 
+	addr_entry = hal_util_get_string_from_file (sysfs_path, "address");
+        if (addr_entry == NULL)
+                goto out;
+
+        if (sscanf (addr_entry, "%x:%x:%x:%x:%x:%x", &a5, &a4, &a3, &a2, &a1, &a0) != 6) {
+                goto out;
+        }
+        address = ((dbus_uint64_t)a5<<40) |
+                ((dbus_uint64_t)a4<<32) | 
+                ((dbus_uint64_t)a3<<24) | 
+                ((dbus_uint64_t)a2<<16) | 
+                ((dbus_uint64_t)a1<< 8) | 
+                ((dbus_uint64_t)a0<< 0);
+
+	type_entry = hal_util_get_string_from_file (sysfs_path, "type");
+        if (type_entry == NULL)
+                goto out;
+
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
 	hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
 
-	type_entry = hal_util_get_string_from_file (sysfs_path, "type");
-
-	if (type_entry && strcmp (type_entry, "ACL") == 0) {
+	if (strcmp (type_entry, "ACL") == 0) {
 		hal_device_property_set_string (d, "info.category", "bluetooth_acl");
 		hal_device_add_capability (d, "bluetooth_acl");
+                hal_device_property_set_uint64 (d, "bluetooth_acl.address", address);
 		hal_device_property_set_string (d, "info.product", "Bluetooth Asynchronous Connection-oriented Link");
 		hal_device_property_set_string (d, "bluetooth_acl.originating_device", hal_device_get_udi (parent_dev));
-	} else if (type_entry && strcmp (type_entry, "SCO") == 0) {
+
+	} else if (strcmp (type_entry, "SCO") == 0) {
 		hal_device_property_set_string (d, "info.category", "bluetooth_sco");
 		hal_device_add_capability (d, "bluetooth_sco");
+                hal_device_property_set_uint64 (d, "bluetooth_sco.address", address);
 		hal_device_property_set_string (d, "info.product", "Bluetooth Synchronous Connection-oriented Link");
 		hal_device_property_set_string (d, "bluetooth_sco.originating_device", hal_device_get_udi (parent_dev));
 	} else {
@@ -383,7 +405,7 @@ bluetooth_add (const gchar *sysfs_path, 
 		hal_device_add_capability (d, "bluetooth_hci");
 		hal_device_property_set_string (d, "info.product", "Bluetooth Host Controller Interface");
 		hal_device_property_set_string (d, "bluetooth_hci.originating_device", hal_device_get_udi (parent_dev));
-		hal_device_property_set_string (d, "bluetooth_hci.physical_device", hal_device_get_udi (parent_dev));
+                hal_device_property_set_uint64 (d, "bluetooth_hci.address", address);
 	}
 
 out:
@@ -397,16 +419,17 @@ bluetooth_compute_udi (HalDevice *d)
 
 	if (hal_device_has_capability (d, "bluetooth_acl")) {
 		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
-			      "%s_bluetooth_acl",
-			      hal_device_property_get_string (d, "info.parent"));
+                                      "/org/freedesktop/Hal/devices/bluetooth_acl_%0llx",
+                                      hal_device_property_get_uint64 (d, "bluetooth_acl.address"));
 	} else if (hal_device_has_capability (d, "bluetooth_sco")) {
 		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
-			      "%s_bluetooth_sco",
-			      hal_device_property_get_string (d, "info.parent"));
+                                      "/org/freedesktop/Hal/devices/bluetooth_acl_%0llx",
+                                      hal_device_property_get_uint64 (d, "bluetooth_acl.address"));
 	} else {
 		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
-			      "%s_bluetooth_hci",
-			      hal_device_property_get_string (d, "info.parent"));
+                                      "%s_bluetooth_hci_%0llx",
+                                      hal_device_property_get_string (d, "info.parent"),
+                                      hal_device_property_get_uint64 (d, "bluetooth_hci.address"));
 	}
 	hal_device_set_udi (d, udi);
 	hal_device_property_set_string (d, "info.udi", udi);
diff-tree 78f05b63f792b2130f0ac20bbea02b8754bf406d (from 9e37dd339cba8e16587fa666c58906bf3bc1ef35)
Author: Luiz Augusto von Dentz <luiz.dentz at gmail.com>
Date:   Sun Apr 22 21:20:26 2007 -0400

    properly recognize Bluetooth SCO and ACL devices
    
    This fixes fd.o #10631.
    
    http://bugs.freedesktop.org/show_bug.cgi?id=10631

diff --git a/hald/linux/device.c b/hald/linux/device.c
index da1785a..3fc1a5d 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -354,6 +354,7 @@ bluetooth_add (const gchar *sysfs_path, 
 	       const gchar *parent_path)
 {
 	HalDevice *d;
+	const char *type_entry;
 
 	d = NULL;
 
@@ -365,14 +366,25 @@ bluetooth_add (const gchar *sysfs_path, 
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
 	hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
 
-	hal_device_property_set_string (d, "info.category", "bluetooth_hci");
-	hal_device_add_capability (d, "bluetooth_hci");
+	type_entry = hal_util_get_string_from_file (sysfs_path, "type");
 
-	hal_device_property_set_string (d, "bluetooth_hci.originating_device", hal_device_get_udi (parent_dev));
-	hal_device_property_set_string (d, "bluetooth_hci.physical_device", hal_device_get_udi (parent_dev));
-	hal_util_set_string_from_file (d, "bluetooth_hci.interface_name", sysfs_path, "name");
-
-	hal_device_property_set_string (d, "info.product", "Bluetooth Host Controller Interface");
+	if (type_entry && strcmp (type_entry, "ACL") == 0) {
+		hal_device_property_set_string (d, "info.category", "bluetooth_acl");
+		hal_device_add_capability (d, "bluetooth_acl");
+		hal_device_property_set_string (d, "info.product", "Bluetooth Asynchronous Connection-oriented Link");
+		hal_device_property_set_string (d, "bluetooth_acl.originating_device", hal_device_get_udi (parent_dev));
+	} else if (type_entry && strcmp (type_entry, "SCO") == 0) {
+		hal_device_property_set_string (d, "info.category", "bluetooth_sco");
+		hal_device_add_capability (d, "bluetooth_sco");
+		hal_device_property_set_string (d, "info.product", "Bluetooth Synchronous Connection-oriented Link");
+		hal_device_property_set_string (d, "bluetooth_sco.originating_device", hal_device_get_udi (parent_dev));
+	} else {
+		hal_device_property_set_string (d, "info.category", "bluetooth_hci");
+		hal_device_add_capability (d, "bluetooth_hci");
+		hal_device_property_set_string (d, "info.product", "Bluetooth Host Controller Interface");
+		hal_device_property_set_string (d, "bluetooth_hci.originating_device", hal_device_get_udi (parent_dev));
+		hal_device_property_set_string (d, "bluetooth_hci.physical_device", hal_device_get_udi (parent_dev));
+	}
 
 out:
 	return d;
@@ -383,9 +395,19 @@ bluetooth_compute_udi (HalDevice *d)
 {
 	gchar udi[256];
 
-	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+	if (hal_device_has_capability (d, "bluetooth_acl")) {
+		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "%s_bluetooth_acl",
+			      hal_device_property_get_string (d, "info.parent"));
+	} else if (hal_device_has_capability (d, "bluetooth_sco")) {
+		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "%s_bluetooth_sco",
+			      hal_device_property_get_string (d, "info.parent"));
+	} else {
+		hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
 			      "%s_bluetooth_hci",
 			      hal_device_property_get_string (d, "info.parent"));
+	}
 	hal_device_set_udi (d, udi);
 	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;


More information about the hal-commit mailing list