hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Sat Mar 24 15:37:00 PDT 2007
doc/spec/hal-spec-properties.xml | 17 +++++++++++++++++
hald/freebsd/hf-usb.c | 25 +++++++++++++++++++++++++
hald/linux/device.c | 2 ++
3 files changed, 44 insertions(+)
New commits:
diff-tree 8e00f386dd4af855116cb1082c0ae6fd8db7ce5e (from a087639568372d531d6214f9ddfe6cdab36d1f28)
Author: Alex Kanavin <ak at sensi.org>
Date: Sat Mar 24 18:37:01 2007 -0400
provide textual interface description for USB devices
Many USB devices provide textual descriptions for their interfaces and
configurations. Currently HAL ignores them. For example, I have a Nokia 6680
phone which has two OBEX interfaces that provide different services, but the
only way to tell that is to read interface descriptions:
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 4
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 2 Communications
bInterfaceSubClass 11 OBEX
bInterfaceProtocol 0
iInterface 5 SYNCML-SYNC
CDC Header:
bcdCDC 1.10
CDC OBEX:
bcdVersion 1.00
CDC Union:
bMasterInterface 4
bSlaveInterface 5
....
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 6
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 2 Communications
bInterfaceSubClass 11 OBEX
bInterfaceProtocol 0
iInterface 6 PC Suite Services
CDC Header:
bcdCDC 1.10
CDC OBEX:
bcdVersion 1.00
CDC Union:
bMasterInterface 6
bSlaveInterface 7
From reading the source code, it seems like an easy to fix thing to me. At least
on Linux these descriptions are available as 'interface' and 'configuration'
files in sysfs directories for the USB interfaces and devices respectively. The
specification should be corrected also of course. If you want, I can write the
patch.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index e7f4ae5..e454143 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -508,6 +508,15 @@
</row>
<row>
<entry>
+ <literal>usb_device.configuration</literal> (int)
+ </entry>
+ <entry>example: Bulk transfer configuration</entry>
+ <entry>No</entry>
+ <entry>Human-readable description of the current configuration the USB device is in
+ </entry>
+ </row>
+ <row>
+ <entry>
<literal>usb_device.num_configurations</literal> (int)
</entry>
<entry>example: 1</entry>
@@ -750,6 +759,14 @@
</row>
<row>
<entry>
+ <literal>usb.interface.description</literal> (int)
+ </entry>
+ <entry>example: SyncML interface</entry>
+ <entry>No</entry>
+ <entry>Human-readable description for the interface provided by the device</entry>
+ </row>
+ <row>
+ <entry>
<literal>usb.interface.number</literal> (int)
</entry>
<entry>example: 1</entry>
diff --git a/hald/freebsd/hf-usb.c b/hald/freebsd/hf-usb.c
index 7a30a61..f7b2bf0 100644
--- a/hald/freebsd/hf-usb.c
+++ b/hald/freebsd/hf-usb.c
@@ -371,6 +371,18 @@ hf_usb_device_new (HalDevice *parent,
{
can_wake_up = (config_desc.bmAttributes & UC_REMOTE_WAKEUP) != 0;
num_interfaces = config_desc.bNumInterface;
+
+ if (config_desc->iConfiguration != 0)
+ {
+ char *configuration;
+
+ configuration = hf_usb_get_string_descriptor(controller->fd, di->udi_addr, config_desc->iConfiguration, NULL);
+ if (configuration)
+ {
+ hal_device_property_set_string(device, "usb_device.configuration", configuration);
+ g_free(configuration);
+ }
+ }
}
hal_device_property_set_bool(device, "usb_device.can_wake_up", can_wake_up);
@@ -435,6 +447,19 @@ hf_usb_interface_device_new (HalDevice *
hal_device_property_set_int(device, "usb.interface.protocol", desc->bInterfaceProtocol);
hal_device_property_set_int(device, "usb.interface.number", desc->bInterfaceNumber);
+ if (desc->iInterface != 0)
+ {
+ char *interface;
+
+ interface = hf_usb_get_string_descriptor(controller->fd, di->udi_addr, desc->iInterface, NULL);
+ if (interface)
+ {
+ hal_device_property_set_string(device, "usb.interface.description", interface);
+ g_free(interface);
+ }
+ }
+
+
hf_usb_device_compute_udi(device);
return device;
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 3936229..fe05fe9 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1494,6 +1494,7 @@ usb_add (const gchar *sysfs_path, const
hal_device_property_set_string (d, "usb_device.linux.sysfs_path", sysfs_path);
+ hal_util_set_string_from_file(d, "usb_device.configuration", sysfs_path, "configuration");
hal_util_set_int_from_file (d, "usb_device.configuration_value", sysfs_path, "bConfigurationValue", 10);
hal_util_set_int_from_file (d, "usb_device.num_configurations", sysfs_path, "bNumConfigurations", 10);
hal_util_set_int_from_file (d, "usb_device.num_interfaces", sysfs_path, "bNumInterfaces", 10);
@@ -1589,6 +1590,7 @@ usb_add (const gchar *sysfs_path, const
hal_util_set_int_from_file (d, "usb.interface.class", sysfs_path, "bInterfaceClass", 16);
hal_util_set_int_from_file (d, "usb.interface.subclass", sysfs_path, "bInterfaceSubClass", 16);
hal_util_set_int_from_file (d, "usb.interface.protocol", sysfs_path, "bInterfaceProtocol", 16);
+ hal_util_set_string_from_file(d, "usb.interface.description", sysfs_path, "interface");
usbif_set_name (d,
hal_device_property_get_int (d, "usb.interface.class"),
More information about the hal-commit
mailing list