aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus-laptop.c
diff options
context:
space:
mode:
authorCorentin Chary <corentin.chary@gmail.com>2011-02-06 07:27:31 -0500
committerMatthew Garrett <mjg@redhat.com>2011-03-28 06:05:20 -0400
commit3b81cf9d558c57406b4ed9b0d2639113d1d428b6 (patch)
tree53fa3cfe6ca2b65c1042aa42fc39b55efc5ba9d9 /drivers/platform/x86/asus-laptop.c
parentaf96f87703f33a4dba4b51c7b3f0d6f874aa4853 (diff)
asus-laptop: remove deprecated interfaces (lcd_switch and display_get)
I should have done that one year ago, so it's more than time to do it. These two features use non-standard interfaces. There are the only features that really need multiple path to guess what's the right method name on a specific laptop. Removing them allow to remove a lot of code an significantly clean the driver. This will affect the backlight code which won't be able to know if the backlight is on or off. The platform display file will also be write only (like the one in eeepc-laptop). Signed-off-by: Corentin Chary <corentin.chary@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86/asus-laptop.c')
-rw-r--r--drivers/platform/x86/asus-laptop.c163
1 files changed, 3 insertions, 160 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 2b9d7b8636e3..62ef43ef06d2 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -158,46 +158,9 @@ MODULE_PARM_DESC(wwan_status, "Set the wireless status on boot "
158#define METHOD_BRIGHTNESS_SET "SPLV" 158#define METHOD_BRIGHTNESS_SET "SPLV"
159#define METHOD_BRIGHTNESS_GET "GPLV" 159#define METHOD_BRIGHTNESS_GET "GPLV"
160 160
161/* Backlight */
162static acpi_handle lcd_switch_handle;
163static char *lcd_switch_paths[] = {
164 "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */
165 "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */
166 "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */
167 "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */
168 "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */
169 "\\_SB.PCI0.LPCB.EC0._Q0E", /* P30/P35 */
170 "\\_SB.PCI0.PX40.Q10", /* S1x */
171 "\\Q10"}; /* A2x, L2D, L3D, M2E */
172
173/* Display */ 161/* Display */
174#define METHOD_SWITCH_DISPLAY "SDSP" 162#define METHOD_SWITCH_DISPLAY "SDSP"
175 163
176static acpi_handle display_get_handle;
177static char *display_get_paths[] = {
178 /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */
179 "\\_SB.PCI0.P0P1.VGA.GETD",
180 /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */
181 "\\_SB.PCI0.P0P2.VGA.GETD",
182 /* A6V A6Q */
183 "\\_SB.PCI0.P0P3.VGA.GETD",
184 /* A6T, A6M */
185 "\\_SB.PCI0.P0PA.VGA.GETD",
186 /* L3C */
187 "\\_SB.PCI0.PCI1.VGAC.NMAP",
188 /* Z96F */
189 "\\_SB.PCI0.VGA.GETD",
190 /* A2D */
191 "\\ACTD",
192 /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */
193 "\\ADVG",
194 /* P30 */
195 "\\DNXT",
196 /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */
197 "\\INFB",
198 /* A3F A6F A3N A3L M6N W3N W6A */
199 "\\SSTE"};
200
201#define METHOD_ALS_CONTROL "ALSC" /* Z71A Z71V */ 164#define METHOD_ALS_CONTROL "ALSC" /* Z71A Z71V */
202#define METHOD_ALS_LEVEL "ALSL" /* Z71A Z71V */ 165#define METHOD_ALS_LEVEL "ALSL" /* Z71A Z71V */
203 166
@@ -247,7 +210,6 @@ struct asus_laptop {
247 210
248 int wireless_status; 211 int wireless_status;
249 bool have_rsts; 212 bool have_rsts;
250 int lcd_state;
251 213
252 struct rfkill *gps_rfkill; 214 struct rfkill *gps_rfkill;
253 215
@@ -560,48 +522,6 @@ error:
560/* 522/*
561 * Backlight device 523 * Backlight device
562 */ 524 */
563static int asus_lcd_status(struct asus_laptop *asus)
564{
565 return asus->lcd_state;
566}
567
568static int asus_lcd_set(struct asus_laptop *asus, int value)
569{
570 int lcd = 0;
571 acpi_status status = 0;
572
573 lcd = !!value;
574
575 if (lcd == asus_lcd_status(asus))
576 return 0;
577
578 if (!lcd_switch_handle)
579 return -ENODEV;
580
581 status = acpi_evaluate_object(lcd_switch_handle,
582 NULL, NULL, NULL);
583
584 if (ACPI_FAILURE(status)) {
585 pr_warning("Error switching LCD\n");
586 return -ENODEV;
587 }
588
589 asus->lcd_state = lcd;
590 return 0;
591}
592
593static void lcd_blank(struct asus_laptop *asus, int blank)
594{
595 struct backlight_device *bd = asus->backlight_device;
596
597 asus->lcd_state = (blank == FB_BLANK_UNBLANK);
598
599 if (bd) {
600 bd->props.power = blank;
601 backlight_update_status(bd);
602 }
603}
604
605static int asus_read_brightness(struct backlight_device *bd) 525static int asus_read_brightness(struct backlight_device *bd)
606{ 526{
607 struct asus_laptop *asus = bl_get_data(bd); 527 struct asus_laptop *asus = bl_get_data(bd);
@@ -629,16 +549,9 @@ static int asus_set_brightness(struct backlight_device *bd, int value)
629 549
630static int update_bl_status(struct backlight_device *bd) 550static int update_bl_status(struct backlight_device *bd)
631{ 551{
632 struct asus_laptop *asus = bl_get_data(bd);
633 int rv;
634 int value = bd->props.brightness; 552 int value = bd->props.brightness;
635 553
636 rv = asus_set_brightness(bd, value); 554 return asus_set_brightness(bd, value);
637 if (rv)
638 return rv;
639
640 value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0;
641 return asus_lcd_set(asus, value);
642} 555}
643 556
644static const struct backlight_ops asusbl_ops = { 557static const struct backlight_ops asusbl_ops = {
@@ -662,8 +575,7 @@ static int asus_backlight_init(struct asus_laptop *asus)
662 struct backlight_properties props; 575 struct backlight_properties props;
663 576
664 if (acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) || 577 if (acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) ||
665 acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) || 578 acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL))
666 !lcd_switch_handle)
667 return 0; 579 return 0;
668 580
669 memset(&props, 0, sizeof(struct backlight_properties)); 581 memset(&props, 0, sizeof(struct backlight_properties));
@@ -972,41 +884,6 @@ static void asus_set_display(struct asus_laptop *asus, int value)
972 return; 884 return;
973} 885}
974 886
975static int read_display(struct asus_laptop *asus)
976{
977 unsigned long long value = 0;
978 acpi_status rv = AE_OK;
979
980 /*
981 * In most of the case, we know how to set the display, but sometime
982 * we can't read it
983 */
984 if (display_get_handle) {
985 rv = acpi_evaluate_integer(display_get_handle, NULL,
986 NULL, &value);
987 if (ACPI_FAILURE(rv))
988 pr_warning("Error reading display status\n");
989 }
990
991 value &= 0x0F; /* needed for some models, shouldn't hurt others */
992
993 return value;
994}
995
996/*
997 * Now, *this* one could be more user-friendly, but so far, no-one has
998 * complained. The significance of bits is the same as in store_disp()
999 */
1000static ssize_t show_disp(struct device *dev,
1001 struct device_attribute *attr, char *buf)
1002{
1003 struct asus_laptop *asus = dev_get_drvdata(dev);
1004
1005 if (!display_get_handle)
1006 return -ENODEV;
1007 return sprintf(buf, "%d\n", read_display(asus));
1008}
1009
1010/* 887/*
1011 * Experimental support for display switching. As of now: 1 should activate 888 * Experimental support for display switching. As of now: 1 should activate
1012 * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI. 889 * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI.
@@ -1248,15 +1125,6 @@ static void asus_acpi_notify(struct acpi_device *device, u32 event)
1248 struct asus_laptop *asus = acpi_driver_data(device); 1125 struct asus_laptop *asus = acpi_driver_data(device);
1249 u16 count; 1126 u16 count;
1250 1127
1251 /*
1252 * We need to tell the backlight device when the backlight power is
1253 * switched
1254 */
1255 if (event == ATKD_LCD_ON)
1256 lcd_blank(asus, FB_BLANK_UNBLANK);
1257 else if (event == ATKD_LCD_OFF)
1258 lcd_blank(asus, FB_BLANK_POWERDOWN);
1259
1260 /* TODO Find a better way to handle events count. */ 1128 /* TODO Find a better way to handle events count. */
1261 count = asus->event_count[event % 128]++; 1129 count = asus->event_count[event % 128]++;
1262 acpi_bus_generate_proc_event(asus->device, event, count); 1130 acpi_bus_generate_proc_event(asus->device, event, count);
@@ -1283,7 +1151,7 @@ static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR,
1283 show_bluetooth, store_bluetooth); 1151 show_bluetooth, store_bluetooth);
1284static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax); 1152static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax);
1285static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan); 1153static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan);
1286static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp); 1154static DEVICE_ATTR(display, S_IWUSR, NULL, store_disp);
1287static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); 1155static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd);
1288static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); 1156static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl);
1289static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw); 1157static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw);
@@ -1394,26 +1262,6 @@ static struct platform_driver platform_driver = {
1394 } 1262 }
1395}; 1263};
1396 1264
1397static int asus_handle_init(char *name, acpi_handle * handle,
1398 char **paths, int num_paths)
1399{
1400 int i;
1401 acpi_status status;
1402
1403 for (i = 0; i < num_paths; i++) {
1404 status = acpi_get_handle(NULL, paths[i], handle);
1405 if (ACPI_SUCCESS(status))
1406 return 0;
1407 }
1408
1409 *handle = NULL;
1410 return -ENODEV;
1411}
1412
1413#define ASUS_HANDLE_INIT(object) \
1414 asus_handle_init(#object, &object##_handle, object##_paths, \
1415 ARRAY_SIZE(object##_paths))
1416
1417/* 1265/*
1418 * This function is used to initialize the context with right values. In this 1266 * This function is used to initialize the context with right values. In this
1419 * method, we can make all the detection we want, and modify the asus_laptop 1267 * method, we can make all the detection we want, and modify the asus_laptop
@@ -1499,10 +1347,6 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
1499 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL)) 1347 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL))
1500 asus->have_rsts = true; 1348 asus->have_rsts = true;
1501 1349
1502 /* Scheduled for removal */
1503 ASUS_HANDLE_INIT(lcd_switch);
1504 ASUS_HANDLE_INIT(display_get);
1505
1506 kfree(model); 1350 kfree(model);
1507 1351
1508 return AE_OK; 1352 return AE_OK;
@@ -1554,7 +1398,6 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
1554 asus_als_level(asus, asus->light_level); 1398 asus_als_level(asus, asus->light_level);
1555 } 1399 }
1556 1400
1557 asus->lcd_state = 1; /* LCD should be on when the module load */
1558 return result; 1401 return result;
1559} 1402}
1560 1403