aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/asus_acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/asus_acpi.c')
-rw-r--r--drivers/acpi/asus_acpi.c70
1 files changed, 49 insertions, 21 deletions
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index c7ac9297a204..396140bbbe57 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -35,6 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/backlight.h>
38#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
39#include <acpi/acpi_bus.h> 40#include <acpi/acpi_bus.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
@@ -402,6 +403,8 @@ static struct model_data model_conf[END_MODEL] = {
402/* procdir we use */ 403/* procdir we use */
403static struct proc_dir_entry *asus_proc_dir; 404static struct proc_dir_entry *asus_proc_dir;
404 405
406static struct backlight_device *asus_backlight_device;
407
405/* 408/*
406 * This header is made available to allow proper configuration given model, 409 * This header is made available to allow proper configuration given model,
407 * revision number , ... this info cannot go in struct asus_hotk because it is 410 * revision number , ... this info cannot go in struct asus_hotk because it is
@@ -779,7 +782,7 @@ proc_write_lcd(struct file *file, const char __user * buffer,
779 return rv; 782 return rv;
780} 783}
781 784
782static int read_brightness(void) 785static int read_brightness(struct backlight_device *bd)
783{ 786{
784 int value; 787 int value;
785 788
@@ -801,9 +804,10 @@ static int read_brightness(void)
801/* 804/*
802 * Change the brightness level 805 * Change the brightness level
803 */ 806 */
804static void set_brightness(int value) 807static int set_brightness(int value)
805{ 808{
806 acpi_status status = 0; 809 acpi_status status = 0;
810 int ret = 0;
807 811
808 /* SPLV laptop */ 812 /* SPLV laptop */
809 if (hotk->methods->brightness_set) { 813 if (hotk->methods->brightness_set) {
@@ -811,11 +815,12 @@ static void set_brightness(int value)
811 value, NULL)) 815 value, NULL))
812 printk(KERN_WARNING 816 printk(KERN_WARNING
813 "Asus ACPI: Error changing brightness\n"); 817 "Asus ACPI: Error changing brightness\n");
814 return; 818 ret = -EIO;
819 goto out;
815 } 820 }
816 821
817 /* No SPLV method if we are here, act as appropriate */ 822 /* No SPLV method if we are here, act as appropriate */
818 value -= read_brightness(); 823 value -= read_brightness(NULL);
819 while (value != 0) { 824 while (value != 0) {
820 status = acpi_evaluate_object(NULL, (value > 0) ? 825 status = acpi_evaluate_object(NULL, (value > 0) ?
821 hotk->methods->brightness_up : 826 hotk->methods->brightness_up :
@@ -825,15 +830,22 @@ static void set_brightness(int value)
825 if (ACPI_FAILURE(status)) 830 if (ACPI_FAILURE(status))
826 printk(KERN_WARNING 831 printk(KERN_WARNING
827 "Asus ACPI: Error changing brightness\n"); 832 "Asus ACPI: Error changing brightness\n");
833 ret = -EIO;
828 } 834 }
829 return; 835out:
836 return ret;
837}
838
839static int set_brightness_status(struct backlight_device *bd)
840{
841 return set_brightness(bd->props->brightness);
830} 842}
831 843
832static int 844static int
833proc_read_brn(char *page, char **start, off_t off, int count, int *eof, 845proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
834 void *data) 846 void *data)
835{ 847{
836 return sprintf(page, "%d\n", read_brightness()); 848 return sprintf(page, "%d\n", read_brightness(NULL));
837} 849}
838 850
839static int 851static int
@@ -1134,7 +1146,7 @@ static int asus_hotk_get_info(void)
1134 if (ACPI_FAILURE(status)) 1146 if (ACPI_FAILURE(status))
1135 printk(KERN_WARNING " Couldn't get the DSDT table header\n"); 1147 printk(KERN_WARNING " Couldn't get the DSDT table header\n");
1136 else 1148 else
1137 asus_info = (struct acpi_table_header *)dsdt.pointer; 1149 asus_info = dsdt.pointer;
1138 1150
1139 /* We have to write 0 on init this far for all ASUS models */ 1151 /* We have to write 0 on init this far for all ASUS models */
1140 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { 1152 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
@@ -1156,7 +1168,7 @@ static int asus_hotk_get_info(void)
1156 * asus_model_match() and try something completely different. 1168 * asus_model_match() and try something completely different.
1157 */ 1169 */
1158 if (buffer.pointer) { 1170 if (buffer.pointer) {
1159 model = (union acpi_object *)buffer.pointer; 1171 model = buffer.pointer;
1160 switch (model->type) { 1172 switch (model->type) {
1161 case ACPI_TYPE_STRING: 1173 case ACPI_TYPE_STRING:
1162 string = model->string.pointer; 1174 string = model->string.pointer;
@@ -1252,11 +1264,9 @@ static int asus_hotk_add(struct acpi_device *device)
1252 printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n", 1264 printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
1253 ASUS_ACPI_VERSION); 1265 ASUS_ACPI_VERSION);
1254 1266
1255 hotk = 1267 hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
1256 (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
1257 if (!hotk) 1268 if (!hotk)
1258 return -ENOMEM; 1269 return -ENOMEM;
1259 memset(hotk, 0, sizeof(struct asus_hotk));
1260 1270
1261 hotk->handle = device->handle; 1271 hotk->handle = device->handle;
1262 strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); 1272 strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
@@ -1333,6 +1343,26 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
1333 return 0; 1343 return 0;
1334} 1344}
1335 1345
1346static struct backlight_properties asus_backlight_data = {
1347 .owner = THIS_MODULE,
1348 .get_brightness = read_brightness,
1349 .update_status = set_brightness_status,
1350 .max_brightness = 15,
1351};
1352
1353static void __exit asus_acpi_exit(void)
1354{
1355 if (asus_backlight_device)
1356 backlight_device_unregister(asus_backlight_device);
1357
1358 acpi_bus_unregister_driver(&asus_hotk_driver);
1359 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1360
1361 kfree(asus_info);
1362
1363 return;
1364}
1365
1336static int __init asus_acpi_init(void) 1366static int __init asus_acpi_init(void)
1337{ 1367{
1338 int result; 1368 int result;
@@ -1370,17 +1400,15 @@ static int __init asus_acpi_init(void)
1370 return result; 1400 return result;
1371 } 1401 }
1372 1402
1373 return 0; 1403 asus_backlight_device = backlight_device_register("asus",NULL,NULL,
1374} 1404 &asus_backlight_data);
1375 1405 if (IS_ERR(asus_backlight_device)) {
1376static void __exit asus_acpi_exit(void) 1406 printk(KERN_ERR "Could not register asus backlight device\n");
1377{ 1407 asus_backlight_device = NULL;
1378 acpi_bus_unregister_driver(&asus_hotk_driver); 1408 asus_acpi_exit();
1379 remove_proc_entry(PROC_ASUS, acpi_root_dir); 1409 }
1380
1381 kfree(asus_info);
1382 1410
1383 return; 1411 return 0;
1384} 1412}
1385 1413
1386module_init(asus_acpi_init); 1414module_init(asus_acpi_init);