hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Thu Dec 6 00:59:11 PST 2007


 doc/spec/hal-spec-properties.xml |   33 ++++++++++++++++++++
 hald/linux/device.c              |   64 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)

New commits:
commit 322fd1e68a68c5de975e43672e14916f895ba87c
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Dec 6 09:59:01 2007 +0100

    linux: add drm subsystem
    
    Add the drm (Direct Rendering Manager devices) subsystem to HAL. This
    should allow to get the device file of the dri devices, which allows to set
    ACL permissions via HAL on them.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 4234e8d..75cad45 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2747,6 +2747,39 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
       </informaltable>
     </sect2>
 
+    <sect2 id="device-properties-drm">
+      <title>drm namespace</title>
+      <para>
+	The <literal>drm</literal> namespace is present for Direct Rendering Manager device objects.
+	They represent a Direct Rendering 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>drm.dri_library</literal> (string)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>Name of the dri (Direct Rendering Interface) library (e.g. i915).</entry>
+            </row>
+            <row>
+              <entry><literal>drm.version</literal> (string)</entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>The drm version (of the kernel module/diver).</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
   </sect1>
 
   <sect1 id="properties-functional">
diff --git a/hald/linux/device.c b/hald/linux/device.c
index c346bd5..7e6e83a 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3302,6 +3302,61 @@ power_supply_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+drm_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+	HalDevice *d = NULL;
+
+	d = hal_device_new ();
+
+	hal_device_add_capability (d, "drm");
+
+	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");
+	}
+
+	hal_device_property_set_string (d, "info.product", "Direct Rendering Manager Device");
+	hal_device_property_set_string (d, "info.category", "drm");
+	hal_device_property_set_string (d, "linux.device_file", device_file);
+	hal_device_property_set_string (d, "linux.subsystem", "drm");
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path); /* not sure if this is needed/set */
+	hal_util_set_string_from_file (d, "drm.dri_library", sysfs_path, "dri_library_name");
+	hal_util_set_string_from_file (d, "drm.version", sysfs_path, "../version");
+	
+	return d;
+}
+
+static gboolean
+drm_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+	const char *dir;
+	const char *name;
+
+	dir = hal_device_property_get_string (d, "linux.sysfs_path");
+
+	name = hal_util_get_last_element(dir);
+
+	/* generate e.g.: /org/freedesktop/Hal/devices/pci_8086_2a02_drm_i915_card0 */
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "%s_drm_%s_%s",
+			      hal_device_property_get_string (d, "info.parent"),
+			      hal_device_property_get_string (d, "drm.dri_library"),
+			      name);
+
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 pseudo_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
@@ -3638,6 +3693,14 @@ static DevHandler dev_handler_power_supply =
        .remove       = dev_remove
 };
 
+static DevHandler dev_handler_drm =
+{
+       .subsystem    = "drm",
+       .add          = drm_add,
+       .compute_udi  = drm_compute_udi,
+       .remove       = dev_remove
+};
+
 /* SCSI debug, to test thousends of fake devices */
 static DevHandler dev_handler_pseudo = {
 	.subsystem   = "pseudo",
@@ -3681,6 +3744,7 @@ static DevHandler *dev_handlers[] = {
 	&dev_handler_backlight,
 	&dev_handler_firewire,
 	&dev_handler_power_supply,
+	&dev_handler_drm,
 	NULL
 };
 


More information about the hal-commit mailing list