Index: hald/linux2/acpi.c =================================================================== RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v retrieving revision 1.47 diff -u -p -u -p -r1.47 acpi.c --- hald/linux2/acpi.c 18 Feb 2006 23:11:23 -0000 1.47 +++ hald/linux2/acpi.c 26 Apr 2006 20:23:28 -0000 @@ -48,6 +48,7 @@ enum { ACPI_TYPE_PANASONIC_DISPLAY, ACPI_TYPE_SONY_DISPLAY, ACPI_TYPE_OMNIBOOK_DISPLAY, + ACPI_TYPE_SONYPI_DISPLAY, ACPI_TYPE_BUTTON }; @@ -698,6 +699,10 @@ laptop_panel_refresh (HalDevice *d, ACPI 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"; @@ -851,6 +856,44 @@ acpi_synthesize_display (char *vendor, c 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")); + + /* 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. * @@ -913,8 +956,10 @@ acpi_synthesize_hotplug_events (void) 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, @@ -1037,6 +1082,14 @@ static ACPIDevHandler acpidev_handler_la .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, @@ -1065,6 +1118,7 @@ static ACPIDevHandler *acpi_handlers[] = &acpidev_handler_laptop_panel_asus, &acpidev_handler_laptop_panel_sony, &acpidev_handler_laptop_panel_omnibook, + &acpidev_handler_laptop_panel_sonypi, NULL }; Index: tools/hal-system-lcd-get-brightness =================================================================== RCS file: /cvs/hal/hal/tools/hal-system-lcd-get-brightness,v retrieving revision 1.7 diff -u -p -u -p -r1.7 hal-system-lcd-get-brightness --- tools/hal-system-lcd-get-brightness 18 Feb 2006 23:11:23 -0000 1.7 +++ tools/hal-system-lcd-get-brightness 26 Apr 2006 20:23:28 -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/sbin/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 Index: tools/hal-system-lcd-set-brightness =================================================================== RCS file: /cvs/hal/hal/tools/hal-system-lcd-set-brightness,v retrieving revision 1.7 diff -u -p -u -p -r1.7 hal-system-lcd-set-brightness --- tools/hal-system-lcd-set-brightness 18 Feb 2006 23:11:23 -0000 1.7 +++ tools/hal-system-lcd-set-brightness 26 Apr 2006 20:23:28 -0000 @@ -27,15 +27,16 @@ 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 # Check for values outside range -if [ ${value} -lt 0 ] || [ ${value} -gt $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS ]; then +if [ ${value} -lt 0 ] || [ ${value} -ge $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS ]; then echo "org.freedesktop.Hal.Device.LaptopPanel.Invalid" >&2 echo "Brightness has to be between 0 and $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS!" >&2 exit 1 @@ -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/sbin/spicctrl -b ${value} else echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2 echo "No ACPI method found" >&2