aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/fujitsu-laptop.c114
1 files changed, 21 insertions, 93 deletions
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c
index 9c407ab9ba2b..65dc41540c62 100644
--- a/drivers/misc/fujitsu-laptop.c
+++ b/drivers/misc/fujitsu-laptop.c
@@ -155,7 +155,6 @@ struct fujitsu_t {
155 155
156static struct fujitsu_t *fujitsu; 156static struct fujitsu_t *fujitsu;
157static int use_alt_lcd_levels = -1; 157static int use_alt_lcd_levels = -1;
158static int disable_brightness_keys = -1;
159static int disable_brightness_adjust = -1; 158static int disable_brightness_adjust = -1;
160 159
161/* Device used to access other hotkeys on the laptop */ 160/* Device used to access other hotkeys on the laptop */
@@ -413,36 +412,11 @@ static int get_max_brightness(void)
413 return fujitsu->max_brightness; 412 return fujitsu->max_brightness;
414} 413}
415 414
416static int get_lcd_level_alt(void)
417{
418 unsigned long long state = 0;
419 acpi_status status = AE_OK;
420
421 vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLS\n");
422
423 status =
424 acpi_evaluate_integer(fujitsu->acpi_handle, "GBLS", NULL, &state);
425 if (status < 0)
426 return status;
427
428 fujitsu->brightness_level = state & 0x0fffffff;
429
430 if (state & 0x80000000)
431 fujitsu->brightness_changed = 1;
432 else
433 fujitsu->brightness_changed = 0;
434
435 return fujitsu->brightness_level;
436}
437
438/* Backlight device stuff */ 415/* Backlight device stuff */
439 416
440static int bl_get_brightness(struct backlight_device *b) 417static int bl_get_brightness(struct backlight_device *b)
441{ 418{
442 if (use_alt_lcd_levels) 419 return get_lcd_level();
443 return get_lcd_level_alt();
444 else
445 return get_lcd_level();
446} 420}
447 421
448static int bl_update_status(struct backlight_device *b) 422static int bl_update_status(struct backlight_device *b)
@@ -509,10 +483,7 @@ static ssize_t show_lcd_level(struct device *dev,
509 483
510 int ret; 484 int ret;
511 485
512 if (use_alt_lcd_levels) 486 ret = get_lcd_level();
513 ret = get_lcd_level_alt();
514 else
515 ret = get_lcd_level();
516 if (ret < 0) 487 if (ret < 0)
517 return ret; 488 return ret;
518 489
@@ -537,10 +508,7 @@ static ssize_t store_lcd_level(struct device *dev,
537 if (ret < 0) 508 if (ret < 0)
538 return ret; 509 return ret;
539 510
540 if (use_alt_lcd_levels) 511 ret = get_lcd_level();
541 ret = get_lcd_level_alt();
542 else
543 ret = get_lcd_level();
544 if (ret < 0) 512 if (ret < 0)
545 return ret; 513 return ret;
546 514
@@ -622,24 +590,16 @@ static struct platform_driver fujitsupf_driver = {
622static void dmi_check_cb_common(const struct dmi_system_id *id) 590static void dmi_check_cb_common(const struct dmi_system_id *id)
623{ 591{
624 acpi_handle handle; 592 acpi_handle handle;
625 int have_blnf;
626 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n", 593 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
627 id->ident); 594 id->ident);
628 have_blnf = ACPI_SUCCESS
629 (acpi_get_handle(NULL, "\\_SB.PCI0.GFX0.LCD.BLNF", &handle));
630 if (use_alt_lcd_levels == -1) { 595 if (use_alt_lcd_levels == -1) {
631 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detecting usealt\n"); 596 if (ACPI_SUCCESS(acpi_get_handle(NULL,
632 use_alt_lcd_levels = 1; 597 "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
633 } 598 use_alt_lcd_levels = 1;
634 if (disable_brightness_keys == -1) { 599 else
635 vdbg_printk(FUJLAPTOP_DBG_TRACE, 600 use_alt_lcd_levels = 0;
636 "auto-detecting disable_keys\n"); 601 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
637 disable_brightness_keys = have_blnf ? 1 : 0; 602 "%i\n", use_alt_lcd_levels);
638 }
639 if (disable_brightness_adjust == -1) {
640 vdbg_printk(FUJLAPTOP_DBG_TRACE,
641 "auto-detecting disable_adjust\n");
642 disable_brightness_adjust = have_blnf ? 0 : 1;
643 } 603 }
644} 604}
645 605
@@ -768,19 +728,14 @@ static int acpi_fujitsu_add(struct acpi_device *device)
768 728
769 /* do config (detect defaults) */ 729 /* do config (detect defaults) */
770 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; 730 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
771 disable_brightness_keys = disable_brightness_keys == 1 ? 1 : 0;
772 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; 731 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
773 vdbg_printk(FUJLAPTOP_DBG_INFO, 732 vdbg_printk(FUJLAPTOP_DBG_INFO,
774 "config: [alt interface: %d], [key disable: %d], [adjust disable: %d]\n", 733 "config: [alt interface: %d], [adjust disable: %d]\n",
775 use_alt_lcd_levels, disable_brightness_keys, 734 use_alt_lcd_levels, disable_brightness_adjust);
776 disable_brightness_adjust);
777 735
778 if (get_max_brightness() <= 0) 736 if (get_max_brightness() <= 0)
779 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; 737 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
780 if (use_alt_lcd_levels) 738 get_lcd_level();
781 get_lcd_level_alt();
782 else
783 get_lcd_level();
784 739
785 return result; 740 return result;
786 741
@@ -831,43 +786,23 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
831 case ACPI_FUJITSU_NOTIFY_CODE1: 786 case ACPI_FUJITSU_NOTIFY_CODE1:
832 keycode = 0; 787 keycode = 0;
833 oldb = fujitsu->brightness_level; 788 oldb = fujitsu->brightness_level;
834 get_lcd_level(); /* the alt version always yields changed */ 789 get_lcd_level();
835 newb = fujitsu->brightness_level; 790 newb = fujitsu->brightness_level;
836 791
837 vdbg_printk(FUJLAPTOP_DBG_TRACE, 792 vdbg_printk(FUJLAPTOP_DBG_TRACE,
838 "brightness button event [%i -> %i (%i)]\n", 793 "brightness button event [%i -> %i (%i)]\n",
839 oldb, newb, fujitsu->brightness_changed); 794 oldb, newb, fujitsu->brightness_changed);
840 795
841 if (oldb == newb && fujitsu->brightness_changed) { 796 if (oldb < newb) {
842 keycode = 0;
843 if (disable_brightness_keys != 1) {
844 if (oldb == 0) {
845 acpi_bus_generate_proc_event
846 (fujitsu->dev,
847 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS,
848 0);
849 keycode = KEY_BRIGHTNESSDOWN;
850 } else if (oldb ==
851 (fujitsu->max_brightness) - 1) {
852 acpi_bus_generate_proc_event
853 (fujitsu->dev,
854 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS,
855 0);
856 keycode = KEY_BRIGHTNESSUP;
857 }
858 }
859 } else if (oldb < newb) {
860 if (disable_brightness_adjust != 1) { 797 if (disable_brightness_adjust != 1) {
861 if (use_alt_lcd_levels) 798 if (use_alt_lcd_levels)
862 set_lcd_level_alt(newb); 799 set_lcd_level_alt(newb);
863 else 800 else
864 set_lcd_level(newb); 801 set_lcd_level(newb);
865 } 802 }
866 if (disable_brightness_keys != 1) { 803 acpi_bus_generate_proc_event(fujitsu->dev,
867 acpi_bus_generate_proc_event(fujitsu->dev, 804 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
868 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0); 805 keycode = KEY_BRIGHTNESSUP;
869 keycode = KEY_BRIGHTNESSUP;
870 }
871 } else if (oldb > newb) { 806 } else if (oldb > newb) {
872 if (disable_brightness_adjust != 1) { 807 if (disable_brightness_adjust != 1) {
873 if (use_alt_lcd_levels) 808 if (use_alt_lcd_levels)
@@ -875,13 +810,9 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
875 else 810 else
876 set_lcd_level(newb); 811 set_lcd_level(newb);
877 } 812 }
878 if (disable_brightness_keys != 1) { 813 acpi_bus_generate_proc_event(fujitsu->dev,
879 acpi_bus_generate_proc_event(fujitsu->dev, 814 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
880 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0); 815 keycode = KEY_BRIGHTNESSDOWN;
881 keycode = KEY_BRIGHTNESSDOWN;
882 }
883 } else {
884 keycode = KEY_UNKNOWN;
885 } 816 }
886 break; 817 break;
887 default: 818 default:
@@ -1336,9 +1267,6 @@ module_exit(fujitsu_cleanup);
1336module_param(use_alt_lcd_levels, uint, 0644); 1267module_param(use_alt_lcd_levels, uint, 0644);
1337MODULE_PARM_DESC(use_alt_lcd_levels, 1268MODULE_PARM_DESC(use_alt_lcd_levels,
1338 "Use alternative interface for lcd_levels (needed for Lifebook s6410)."); 1269 "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
1339module_param(disable_brightness_keys, uint, 0644);
1340MODULE_PARM_DESC(disable_brightness_keys,
1341 "Disable brightness keys (eg. if they are already handled by the generic ACPI_VIDEO device).");
1342module_param(disable_brightness_adjust, uint, 0644); 1270module_param(disable_brightness_adjust, uint, 0644);
1343MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); 1271MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
1344#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG 1272#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG