hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Sep 23 10:11:36 PDT 2008


 doc/spec/hal-spec-properties.xml           |    8 +++
 fdi/policy/10osvendor/10-rfkill-switch.fdi |   23 +++++-----
 hald/linux/device.c                        |   62 +++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 11 deletions(-)

New commits:
commit 2d83a3c272c7ece4f3b6ffbc19d1754ab5c3b392
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Sep 23 19:08:01 2008 -0700

    added linux rfkill subsystem to HAL
    
    Added the (new) rfkill subsystem to HAL. Added new, not mandatory,
    property killswitch.name to the killswitch namespace.
    
    NOTE: There is currently no addon to get/set the state of the
          killswitch. Need to add a singleton addon to handle all
          killswitchs at once.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 4f03617..f5faa59 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7524,6 +7524,14 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
             </row>
             <row>
               <entry>
+                <literal>killswitch.name</literal> (string)
+              </entry>
+              <entry></entry>
+              <entry>No</entry>
+              <entry>Name of the kill switch (as reported by the kernel).</entry>
+            </row>
+            <row>
+              <entry>
                 <literal>killswitch.access_method</literal> (string)
               </entry>
               <entry></entry>
diff --git a/fdi/policy/10osvendor/10-rfkill-switch.fdi b/fdi/policy/10osvendor/10-rfkill-switch.fdi
index 7977dcc..b98fd54 100644
--- a/fdi/policy/10osvendor/10-rfkill-switch.fdi
+++ b/fdi/policy/10osvendor/10-rfkill-switch.fdi
@@ -10,18 +10,19 @@
       </match>
 
       <!-- For all other KillSwitch devices -->
-        <match key="killswitch.access_method" contains_not="ipw">
-        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.KillSwitch</append>
+      <match key="killswitch.access_method" contains_not="ipw">
+        <match key="info.subsystem" contains_not="rfkill">
+          <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.KillSwitch</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_names" type="strlist">SetPower</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_signatures" type="strlist">b</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_argnames" type="strlist">power</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_execpaths" type="strlist">hal-system-killswitch-set-power</append>
 
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_names" type="strlist">SetPower</append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_signatures" type="strlist">b</append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_argnames" type="strlist">power</append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_execpaths" type="strlist">hal-system-killswitch-set-power</append>
-
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_names" type="strlist">GetPower</append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_signatures" type="strlist"></append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_argnames" type="strlist"></append>
-        <append key="org.freedesktop.Hal.Device.KillSwitch.method_execpaths" type="strlist">hal-system-killswitch-get-power</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_names" type="strlist">GetPower</append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_signatures" type="strlist"></append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_argnames" type="strlist"></append>
+          <append key="org.freedesktop.Hal.Device.KillSwitch.method_execpaths" type="strlist">hal-system-killswitch-get-power</append>
+        </match>
       </match>
 
     </match>
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 036e6a8..b639f4c 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3502,6 +3502,58 @@ power_supply_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+rfkill_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+	HalDevice *d;
+        gchar buf[64];
+	const gchar *type;
+
+	d = hal_device_new ();
+	hal_device_add_capability (d, "killswitch");
+	hal_device_property_set_string (d, "info.category", "killswitch");
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	
+	if (parent_dev != NULL) {
+		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+		hal_device_copy_property( parent_dev, "info.vendor", d, "info.vendor");
+	} else {
+		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+	}
+
+	type = hal_util_get_string_from_file (sysfs_path, "type");
+
+	if (strcasecmp (type, "wimax") == 0) {
+		hal_device_property_set_string (d, "killswitch.type", "wwan");
+	} else { 
+		hal_device_property_set_string (d, "killswitch.type", type);
+	}
+
+	hal_util_set_string_from_file (d, "killswitch.name", sysfs_path, "name");
+
+        g_snprintf(buf, sizeof(buf), "%s %s Killswitch", hal_device_property_get_string (d, "killswitch.name"),
+							 hal_device_property_get_string (d, "killswitch.type"));
+        hal_device_property_set_string (d, "info.product", buf);
+
+	return d;
+}
+
+static gboolean
+rfkill_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hald_compute_udi (udi, sizeof (udi),
+			  "%s_rfkill_%s_%s",
+			  hal_device_property_get_string (d, "info.parent"),
+			  hal_device_property_get_string (d, "killswitch.name"),
+			  hal_device_property_get_string (d, "killswitch.type"));
+	hal_device_set_udi (d, udi);
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 drm_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d = NULL;
@@ -4154,6 +4206,15 @@ static DevHandler dev_handler_power_supply =
        .remove       = dev_remove
 };
 
+static DevHandler dev_handler_rfkill =
+{
+       .subsystem    = "rfkill",
+       .add          = rfkill_add,
+       .compute_udi  = rfkill_compute_udi,
+       .remove       = dev_remove
+};
+
+
 static DevHandler dev_handler_drm =
 {
        .subsystem    = "drm",
@@ -4247,6 +4308,7 @@ static DevHandler *dev_handlers[] = {
 	&dev_handler_backlight,
 	&dev_handler_firewire,
 	&dev_handler_power_supply,
+	&dev_handler_rfkill,
 	&dev_handler_drm,
 	&dev_handler_ps3_system_bus,
 	&dev_handler_virtio,


More information about the hal-commit mailing list