hal: Branch 'origin' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Mon Dec 4 10:43:18 PST 2006


 hald/linux/acpi.c                               |    4 ++
 hald/linux/device.c                             |   47 ++++++++++++++++++++++++
 tools/hal-system-lcd-get-brightness             |    2 -
 tools/hal-system-lcd-set-brightness             |    2 -
 tools/linux/hal-system-lcd-get-brightness-linux |    6 +++
 tools/linux/hal-system-lcd-set-brightness-linux |    6 +++
 6 files changed, 65 insertions(+), 2 deletions(-)

New commits:
diff-tree 8fb1128494b678a51ae683e2c4fbd34d12a81082 (from parents)
Merge: e92bb4cb40219ed615f80e6dd88c25e7e7dea4bb e3996a7b5fa880657458494ef4a4f99ed6d4fe5e
Author: Holger Macht <holger at homac.de>
Date:   Mon Dec 4 10:58:51 2006 +0100

    Merge branch 'master' of git+ssh://homac@git.freedesktop.org/git/hal

diff-tree e92bb4cb40219ed615f80e6dd88c25e7e7dea4bb (from 26771543399755085d885234c68ff4f9888015ab)
Author: Holger Macht <holger at homac.de>
Date:   Mon Dec 4 10:58:08 2006 +0100

    add /sys/class/backlight/* interface support
    
    If available, a device /org/freedesktop/Hal/devices/computer_backlight
    is created. The change adds a class device and adjusts the scripts for
    the methods GetBrightness and SetBrightness on the interface
    org.freedesktop.Hal.Device.LaptopPanel. As soon as all kernel drivers are
    all converted to the new interface, we can drop the vendor specific code in
    acpi.c. In case a driver supports both, the old /proc interface and the
    new /sysfs one, the code in acpi.c immediately returns so that the /sysfs
    interface is preferred.

diff --git a/hald/linux/acpi.c b/hald/linux/acpi.c
index 2c59fbf..50a1e13 100644
--- a/hald/linux/acpi.c
+++ b/hald/linux/acpi.c
@@ -743,6 +743,10 @@ laptop_panel_refresh (HalDevice *d, ACPI
 	char *type = NULL;
 	char *desc = NULL;
 	int br_levels = -1;
+	
+	if ((hal_device_store_find (hald_get_gdl (),
+				    "/org/freedesktop/Hal/devices/computer_backlight")) != NULL)
+		return FALSE;
 
 	path = hal_device_property_get_string (d, "linux.acpi_path");
 	if (path == NULL)
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 1fbb682..ea36af7 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2299,6 +2299,44 @@ iucv_compute_udi (HalDevice *d)
 
 }
 
+static HalDevice *
+backlight_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *physdev,
+	       const gchar *sysfs_path_in_devices)
+{
+	HalDevice *d;
+	int max_brightness;
+
+	d = NULL;
+	d = hal_device_new ();
+	hal_device_add_capability (d, "laptop_panel");
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+	
+	hal_device_property_set_string (d, "info.category", "laptop_panel");
+	
+	hal_util_get_int_from_file (sysfs_path, "max_brightness", &max_brightness, 10);
+	hal_device_property_set_int (d, "laptop_panel.num_levels", max_brightness + 1);
+	return d;
+}
+
+static gboolean
+backlight_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);
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "%s_backlight",
+			      hal_device_property_get_string (d, "info.parent"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+}
+
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
@@ -2609,6 +2647,14 @@ static DevHandler dev_handler_iucv = {
 	.remove      = dev_remove
 };
 
+static DevHandler dev_handler_backlight =
+{
+       .subsystem    = "backlight",
+       .add          = backlight_add,
+       .compute_udi  = backlight_compute_udi,
+       .remove       = dev_remove
+};
+
 /* SCSI debug, to test thousends of fake devices */
 static DevHandler dev_handler_pseudo = {
 	.subsystem   = "pseudo",
@@ -2649,6 +2695,7 @@ static DevHandler *dev_handlers[] = {
 	&dev_handler_tape,
 	&dev_handler_tape390,
 	&dev_handler_mmc_host,
+	&dev_handler_backlight,
 	NULL
 };
 
diff --git a/tools/hal-system-lcd-get-brightness b/tools/hal-system-lcd-get-brightness
index bf8fcfc..e647095 100755
--- a/tools/hal-system-lcd-get-brightness
+++ b/tools/hal-system-lcd-get-brightness
@@ -8,7 +8,7 @@
 # (at your option) any later version.
 
 # Check for environment variables
-if [ -z "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" ]; then
+if [ -z "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" -a -z "$HAL_PROP_LINUX_SYSFS_PATH" ]; then
         echo "org.freedesktop.Hal.Device.UnknownError" >&2
 	echo "Missing or empty environment variable(s)." >&2
 	echo "This script should be started by hald." >&2
diff --git a/tools/hal-system-lcd-set-brightness b/tools/hal-system-lcd-set-brightness
index a677412..f288f99 100755
--- a/tools/hal-system-lcd-set-brightness
+++ b/tools/hal-system-lcd-set-brightness
@@ -8,7 +8,7 @@
 # (at your option) any later version.
 
 # Check for environment variables
-if [ -z "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" ] || 
+if [ -z "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" -a -z "$HAL_PROP_LINUX_SYSFS_PATH" ] || 
    [ -z "$HAL_PROP_LAPTOP_PANEL_NUM_LEVELS" ] ; then
         echo "org.freedesktop.Hal.Device.UnknownError" >&2
         echo "Missing or empty environment variable(s)." >&2
diff --git a/tools/linux/hal-system-lcd-get-brightness-linux b/tools/linux/hal-system-lcd-get-brightness-linux
index 3ff9284..477a22d 100755
--- a/tools/linux/hal-system-lcd-get-brightness-linux
+++ b/tools/linux/hal-system-lcd-get-brightness-linux
@@ -7,6 +7,12 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 
+# we have /sys/class/backlight
+if [ -r "$HAL_PROP_LINUX_SYSFS_PATH/actual_brightness" ]; then
+	value="`cat $HAL_PROP_LINUX_SYSFS_PATH/actual_brightness`"
+	exit ${value}
+fi
+
 if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
 	value="`hal-system-power-pmu getlcd`"
 	if [ $? -ne 0 ]; then
diff --git a/tools/linux/hal-system-lcd-set-brightness-linux b/tools/linux/hal-system-lcd-set-brightness-linux
index f73e680..38e5730 100755
--- a/tools/linux/hal-system-lcd-set-brightness-linux
+++ b/tools/linux/hal-system-lcd-set-brightness-linux
@@ -7,6 +7,12 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 
+# we have /sys/class/backlight
+if [ -w "$HAL_PROP_LINUX_SYSFS_PATH/brightness" ]; then
+	echo "$value" > $HAL_PROP_LINUX_SYSFS_PATH/brightness
+	exit 0
+fi
+
 if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
 	hal-system-power-pmu setlcd $value
 	if [ $? -ne 0 ]; then


More information about the hal-commit mailing list