Re: [PATCH] Add generic backlight support to toshiba_acpi driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 09, 2006 at 05:47:49PM +0100, Jan Engelhardt wrote:

> Note to self: Don't forget to change 2.6-sony-acpi?.diff from -mm to use 
> this /sys/class/backlight instead of /proc/acpi/sony/brightness when it's 
> ready.

Ah, you're maintaining that now. Here you go (Stelian took a look and 
seemed happy with it - the /sys/class/backlight stuff is in mainstream)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 7636bba..6505b24 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -27,6 +27,8 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
@@ -62,6 +64,8 @@ static struct acpi_driver sony_acpi_driv
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
+static struct backlight_device *sony_backlight_device;
+
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
 	struct proc_dir_entry 	*proc;	 /* /proc entry */
@@ -258,6 +262,31 @@ static acpi_status sony_walk_callback(ac
 	return AE_OK;
 }
 
+static int sony_brightness_get(struct backlight_device *bd) 
+{
+	int value;
+
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+
+	return value-1;
+}
+	
+
+static int sony_brightness_set(struct backlight_device *bd, int value) {
+	value &= 0x7;
+	value++;
+
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT", value, NULL);
+}
+
+static struct backlight_properties sonybl_data = {
+	.owner          = THIS_MODULE,
+	.get_brightness = sony_brightness_get,
+	.set_brightness = sony_brightness_set,
+	.max_brightness = 7,
+};
+
 static int __init sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
@@ -378,12 +407,24 @@ static int __init sony_acpi_init(void)
 		remove_proc_entry("sony", acpi_root_dir);
 		return -ENODEV;
 	}
+
+	sony_backlight_device = backlight_device_register ("sony_bl", NULL,
+							   &sonybl_data);
+
+	if (IS_ERR (sony_backlight_device)) {
+		printk("Unable to register backlight\n");
+		acpi_bus_unregister_driver(&sony_acpi_driver);
+		remove_proc_entry("sony", acpi_root_dir);
+		return -ENODEV;
+	}
+
 	return 0;
 }
 
 
 static void __exit sony_acpi_exit(void)
 {
+	backlight_device_unregister(sony_backlight_device);
 	acpi_bus_unregister_driver(&sony_acpi_driver);
 	remove_proc_entry("sony", acpi_root_dir);
 }

-- 
Matthew Garrett | [email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux