Package: hal
Version: 0.5.7-2
Severity: wishlist
Tags: patch

spicctrl is the tool to use /dev/sonypi to get informations and set some
values on the controller in Sony Vaio laptops (and probably desktops as
well). It is useful to set the LCD panel brightness without needing the
recent sony-acpi patch, which don't work on all Vaio models, anyway.

Therefore, it'd be useful if hal would implement abstraction for using
this tool.

Attached here is a patch stolen from
https://bugs.freedesktop.org/show_bug.cgi?id=6729 and adapted so that it
applies flawlessly on 0.5.7.

Please apply this patch, it's useful to Vaio users.

Note the original patch fixes another issue about the maximum value
accepted by the script. I didn't include this one.

Cheers

Mike

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-686
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)

Versions of packages hal depends on:
ii  adduser                       3.87       Add and remove users and groups
ii  dbus                          0.62-3     simple interprocess messaging syst
ii  libc6                         2.3.6-15   GNU C Library: Shared libraries
ii  libdbus-1-2                   0.62-3     simple interprocess messaging syst
ii  libdbus-glib-1-2              0.62-3     simple interprocess messaging syst
ii  libexpat1                     1.95.8-3.2 XML parsing C library - runtime li
ii  libglib2.0-0                  2.10.3-1   The GLib library of C routines
ii  libhal1                       0.5.7-2.1  Hardware Abstraction Layer - share
ii  libusb-0.1-4                  2:0.1.12-2 userspace USB programming library
ii  lsb-base                      3.1-10     Linux Standard Base 3.1 init scrip
ii  pciutils                      1:2.2.1-2  Linux PCI Utilities
ii  udev                          0.093-1    /dev/ and hotplug management daemo
ii  usbutils                      0.72-4     USB console utilities

hal recommends no packages.

-- no debconf information
--- hal-0.5.7/hald/linux2/acpi.c	26 Apr 2006 21:51:20 -0000
+++ hal-0.5.7/hald/linux2/acpi.c	27 Apr 2006 21:25:53 -0000
@@ -48,6 +48,7 @@
 	ACPI_TYPE_PANASONIC_DISPLAY,
 	ACPI_TYPE_SONY_DISPLAY,
 	ACPI_TYPE_OMNIBOOK_DISPLAY,
+	ACPI_TYPE_SONYPI_DISPLAY,
 	ACPI_TYPE_BUTTON
 };
 
@@ -766,6 +767,10 @@
 		type = "omnibook";
 		desc = "Omnibook LCD Panel";
 		br_levels = 8;
+	} else if (acpi_type == ACPI_TYPE_SONYPI_DISPLAY) {
+		type = "sonypi";
+		desc = "Sony LCD Panel";
+		br_levels = 256;
 	} else {
 		type = "unknown";
 		desc = "Unknown LCD Panel";
@@ -919,6 +924,49 @@
 		acpi_synthesize_item (path, method);
 }
 
+static int sonypi_irq_list[] = { 11, 10, 9, 6, 5 };
+
+/** Synthesizes a sonypi object.
+ */
+static void
+acpi_synthesize_sonypi_display (void)
+{
+	HotplugEvent *hotplug_event;
+	gboolean found = FALSE;
+	guint i;
+	gchar *path;
+
+	HAL_INFO (("Processing sonypi display"));
+
+        /* Check that we don't support brightness change through ACPI,
+	 * for type3 VAIOs */
+	if (g_file_test ("/proc/acpi/sony/brightness", G_FILE_TEST_EXISTS))
+		return;
+
+	/* Find the sonypi device, this doesn't work
+	 * if the sonypi device doesn't have an IRQ, sorry */
+	for (i = 0; i < G_N_ELEMENTS (sonypi_irq_list); i++) {
+		path =  g_strdup_printf ("/proc/irq/%d/sonypi", sonypi_irq_list[i]);
+		if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
+			found = TRUE;
+			break;
+		}
+		g_free (path);
+	}
+
+	if (!found)
+		return;
+
+	hotplug_event = g_new0 (HotplugEvent, 1);
+	hotplug_event->action = HOTPLUG_ACTION_ADD;
+	hotplug_event->type = HOTPLUG_EVENT_ACPI;
+	g_strlcpy (hotplug_event->acpi.acpi_path, path, sizeof (hotplug_event->acpi.acpi_path));
+	hotplug_event->acpi.acpi_type = ACPI_TYPE_SONYPI_DISPLAY;
+	hotplug_event_enqueue (hotplug_event);
+
+	g_free (path);
+}
+
 /** Scan the data structures exported by the kernel and add hotplug
  *  events for adding ACPI objects.
  *
@@ -981,8 +1029,10 @@
 	acpi_synthesize_display ("acpi/pcc", "brightness", ACPI_TYPE_PANASONIC_DISPLAY);
 	acpi_synthesize_display ("acpi/ibm", "brightness", ACPI_TYPE_IBM_DISPLAY);
 	acpi_synthesize_display ("acpi/sony", "brightness", ACPI_TYPE_SONY_DISPLAY);
-	/* onmibook does not live under acpi GNOME#331458 */
+	/* omnibook does not live under acpi GNOME#331458 */
 	acpi_synthesize_display ("omnibook", "lcd", ACPI_TYPE_OMNIBOOK_DISPLAY);
+	/* sonypi doesn't have an acpi object fd.o#6729 */
+	acpi_synthesize_sonypi_display ();
 
 	/* setup timer for things that we need to poll */
 	g_timeout_add (ACPI_POLL_INTERVAL,
@@ -1105,6 +1155,14 @@
 	.remove      = acpi_generic_remove
 };
 
+static ACPIDevHandler acpidev_handler_laptop_panel_sonypi = {
+	.acpi_type   = ACPI_TYPE_SONYPI_DISPLAY,
+	.add         = acpi_generic_add,
+	.compute_udi = acpi_generic_compute_udi,
+	.refresh     = laptop_panel_refresh,
+	.remove      = acpi_generic_remove
+};
+
 static ACPIDevHandler acpidev_handler_button = {
 	.acpi_type   = ACPI_TYPE_BUTTON,
 	.add         = acpi_generic_add,
@@ -1133,6 +1191,7 @@
 	&acpidev_handler_laptop_panel_asus,
 	&acpidev_handler_laptop_panel_sony,
 	&acpidev_handler_laptop_panel_omnibook,
+	&acpidev_handler_laptop_panel_sonypi,
 	NULL
 };
 
--- hal-0.5.7/tools/hal-system-lcd-get-brightness	18 Feb 2006 23:11:23 -0000	1.7
+++ hal-0.5.7/tools/hal-system-lcd-get-brightness	26 Apr 2006 21:51:20 -0000
@@ -58,6 +58,17 @@ elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_ME
 	# cat /proc/omnibook/lcd
 	#  LCD brightness:  7
 	value="`cat $HAL_PROP_LINUX_ACPI_PATH | awk '{print $3;}'`"
+elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" == "sonypi" ]; then
+		# spicctrl -B
+		# 70
+		# 0..255
+		value="`/usr/bin/spicctrl -B`"
+		RETVAL=$?
+		if [ $RETVAL != 0 ]; then
+			echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
+			exit 1;
+		fi
+		exit ${value}
 else
 	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
 	echo "No ACPI method found" >&2
--- hal-0.5.7/tools/hal-system-lcd-set-brightness	10 Mar 2006 19:45:27 -0000	1.8
+++ hal-0.5.7/tools/hal-system-lcd-set-brightness	26 Apr 2006 21:51:20 -0000
@@ -27,9 +27,10 @@ if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METH
 	exit 0
 fi
 
-# Check for file existance and that it's writable
-if [ ! -w "$HAL_PROP_LINUX_ACPI_PATH" ]; then
+# Check for file existance and that it's writable and that we don't have a sonypi
+# access method
+if [ ! -w "$HAL_PROP_LINUX_ACPI_PATH" -a "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" != "sonypi" ]; then
 	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
 	echo "$1 not writable!" >&2
 	exit 1
 fi
@@ -64,6 +65,9 @@ elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_ME
 	# echo "{0..7}" > /proc/omnibook/lcd
 	# http://bugzilla.gnome.org/show_bug.cgi?id=331458
 	echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
+elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" == "sonypi" ]; then
+	# spicctrl -b "{0..255}"
+	/usr/bin/spicctrl -b ${value}
 else
 	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
 	echo "No ACPI method found" >&2

Reply via email to