summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@web.de>2008-11-28 19:24:13 +0100
committerDanny Kukawka <danny.kukawka@web.de>2008-11-28 19:24:13 +0100
commiteef409dfc82433edb32c73ce352671ab7fb1f79d (patch)
tree80fa4deb4618dcf1c2ba5ae2f461098614acac09
parentae21157ff150db8bc87fc5fead10b5925812131c (diff)
add the leds linux kernel subsystem to HAL
Added the leds linux kernel subsystem to HAL. These are the current properties of led devices: - leds.device_name (string, mandatory) - leds.function (string, mandatory) - leds.colour
-rw-r--r--doc/spec/hal-spec-properties.xml48
-rw-r--r--hald/linux/device.c74
2 files changed, 122 insertions, 0 deletions
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 2b40f627..d6136bd7 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2012,6 +2012,54 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</informaltable>
</sect2>
+ <sect2 id="device-properties-leds">
+ <title>
+ leds namespace
+ </title>
+ <para>
+ Device objects with <literal>info.subsystem</literal> set to <literal>leds
+ </literal> are LED (light-emitting diode) devices.
+ </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>leds.device_name</literal> (string)
+ </entry>
+ <entry>example: iwl-phy0, tpacpi</entry>
+ <entry>Yes</entry>
+ <entry>The name of the related led device</entry>
+ </row>
+ <row>
+ <entry>
+ <literal>leds.colour</literal> (string)
+ </entry>
+ <entry>example: green, orange</entry>
+ <entry>No</entry>
+ <entry>The colour of the LED</entry>
+ </row>
+ <row>
+ <entry>
+ <literal>leds.function</literal> (string)
+ </entry>
+ <entry>example: radio, power, standby, batt</entry>
+ <entry>Yes</entry>
+ <entry>The function of the LED.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
<sect2 id="device-properties-modemif">
<title>
modem namespace
diff --git a/hald/linux/device.c b/hald/linux/device.c
index d16ac3ac..9c9fce3a 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1259,6 +1259,72 @@ iucv_compute_udi (HalDevice *d)
return TRUE;
}
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
+leds_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+ HalDevice *d;
+ const gchar *dev_name;
+ gchar **attributes;
+
+ d = hal_device_new ();
+
+ if (parent_dev != NULL)
+ hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+ else
+ hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+
+ hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+ hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+ hal_device_property_set_string (d, "info.category", "leds");
+ hal_device_add_capability (d, "leds");
+
+ dev_name = hal_util_get_last_element (sysfs_path);
+ if (dev_name) {
+ attributes = g_strsplit_set (dev_name, ":", 0);
+
+ if (attributes != NULL) {
+ if (attributes[0] != NULL && attributes[0][0] != '\0')
+ hal_device_property_set_string (d, "leds.device_name", attributes[0]);
+ if (attributes[1] != NULL && attributes[1][0] != '\0')
+ hal_device_property_set_string (d, "leds.colour", attributes[1]);
+ if (attributes[2] != NULL && attributes[2][0] != '\0')
+ hal_device_property_set_string (d, "leds.function", attributes[2]);
+ }
+ g_strfreev (attributes);
+ }
+
+ return d;
+}
+
+static gboolean
+leds_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+ const char *name;
+ const char *colour;
+ const char *function;
+
+ name = hal_device_property_get_string (d, "leds.device_name");
+ colour = hal_device_property_get_string (d, "leds.colour");
+ function = hal_device_property_get_string (d, "leds.function");
+
+ if (name && function && colour) {
+ hald_compute_udi (udi, sizeof (udi), "/org/freedesktop/Hal/devices/leds_%s_%s_%s", name, function, colour);
+ } else if (name && function) {
+ hald_compute_udi (udi, sizeof (udi), "/org/freedesktop/Hal/devices/leds_%s_%s", name, function);
+ } else if (name) {
+ hald_compute_udi (udi, sizeof (udi), "/org/freedesktop/Hal/devices/leds_%s", name);
+ } else {
+ hald_compute_udi (udi, sizeof (udi), "/org/freedesktop/Hal/devices/leds_unknown");
+ }
+
+ hal_device_set_udi (d, udi);
+ return TRUE;
+}
+
/*--------------------------------------------------------------------------------------------------------------*/
@@ -4238,6 +4304,13 @@ static DevHandler dev_handler_iucv = {
.remove = dev_remove
};
+static DevHandler dev_handler_leds = {
+ .subsystem = "leds",
+ .add = leds_add,
+ .compute_udi = leds_compute_udi,
+ .remove = dev_remove
+};
+
static DevHandler dev_handler_memstick = {
.subsystem = "memstick",
.add = memstick_add,
@@ -4526,6 +4599,7 @@ static DevHandler *dev_handlers[] = {
&dev_handler_ieee1394,
&dev_handler_input,
&dev_handler_iucv,
+ &dev_handler_leds,
&dev_handler_mmc,
&dev_handler_memstick,
&dev_handler_memstick_host,