From 131d4822b9fb081fb1b9768c00cefeef09fac032 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 6 Dec 2007 09:59:01 +0100 Subject: [PATCH] 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. --- doc/spec/hal-spec-properties.xml | 33 +++++++++++++++++++ hald/linux/device.c | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 0 deletions(-) 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'} + + drm namespace + + The drm namespace is present for Direct Rendering Manager device objects. + They represent a Direct Rendering Interface. + + + + + + Key (type) + Values + Mandatory + Description + + + + + drm.dri_library (string) + + Yes + Name of the dri (Direct Rendering Interface) library (e.g. i915). + + + drm.version (string) + + Yes + The drm version (of the kernel module/diver). + + + + + diff --git a/hald/linux/device.c b/hald/linux/device.c index 2e68378..a59107f 100644 --- a/hald/linux/device.c +++ b/hald/linux/device.c @@ -3301,6 +3301,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; @@ -3637,6 +3692,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", @@ -3680,6 +3743,7 @@ static DevHandler *dev_handlers[] = { &dev_handler_backlight, &dev_handler_firewire, &dev_handler_power_supply, + &dev_handler_drm, NULL }; -- 1.5.3.7