Commit f87a1a5f authored by Tony Vroon's avatar Tony Vroon Committed by Len Brown

fujitsu-laptop: Simplify SBLL/SBL2 backlight handling

GBLS and GBLL only differ in the clearing of the GHKS flag, so there is no need
to have two backlight level readouts. Also, per Peter Gruber, the need for the
BLNF check has disappeared.
As a result, cleanups can be made in the code. This has been tested on the both
the S6410 and the S6420 platforms and causes no functionality regressions, on
the console without X or within X. One module parameter to disable the hotkeys
is dropped, as we only ever took one codepath anyway.
Signed-off-by: default avatarTony Vroon <tony@linx.net>
Tested-by: default avatarPeter Gruber <nokos@gmx.net>
Tested-By: default avatarStephen Gildea <stepheng+linux@gildea.com>
Acked-by: default avatarJonathan Woithe <jwoithe@physics.adelaide.edu.au>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 3a407086
...@@ -155,7 +155,6 @@ struct fujitsu_t { ...@@ -155,7 +155,6 @@ struct fujitsu_t {
static struct fujitsu_t *fujitsu; static struct fujitsu_t *fujitsu;
static int use_alt_lcd_levels = -1; static int use_alt_lcd_levels = -1;
static int disable_brightness_keys = -1;
static int disable_brightness_adjust = -1; static int disable_brightness_adjust = -1;
/* Device used to access other hotkeys on the laptop */ /* Device used to access other hotkeys on the laptop */
...@@ -413,36 +412,11 @@ static int get_max_brightness(void) ...@@ -413,36 +412,11 @@ static int get_max_brightness(void)
return fujitsu->max_brightness; return fujitsu->max_brightness;
} }
static int get_lcd_level_alt(void)
{
unsigned long long state = 0;
acpi_status status = AE_OK;
vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLS\n");
status =
acpi_evaluate_integer(fujitsu->acpi_handle, "GBLS", NULL, &state);
if (status < 0)
return status;
fujitsu->brightness_level = state & 0x0fffffff;
if (state & 0x80000000)
fujitsu->brightness_changed = 1;
else
fujitsu->brightness_changed = 0;
return fujitsu->brightness_level;
}
/* Backlight device stuff */ /* Backlight device stuff */
static int bl_get_brightness(struct backlight_device *b) static int bl_get_brightness(struct backlight_device *b)
{ {
if (use_alt_lcd_levels) return get_lcd_level();
return get_lcd_level_alt();
else
return get_lcd_level();
} }
static int bl_update_status(struct backlight_device *b) static int bl_update_status(struct backlight_device *b)
...@@ -509,10 +483,7 @@ static ssize_t show_lcd_level(struct device *dev, ...@@ -509,10 +483,7 @@ static ssize_t show_lcd_level(struct device *dev,
int ret; int ret;
if (use_alt_lcd_levels) ret = get_lcd_level();
ret = get_lcd_level_alt();
else
ret = get_lcd_level();
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -537,10 +508,7 @@ static ssize_t store_lcd_level(struct device *dev, ...@@ -537,10 +508,7 @@ static ssize_t store_lcd_level(struct device *dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
if (use_alt_lcd_levels) ret = get_lcd_level();
ret = get_lcd_level_alt();
else
ret = get_lcd_level();
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -622,24 +590,16 @@ static struct platform_driver fujitsupf_driver = { ...@@ -622,24 +590,16 @@ static struct platform_driver fujitsupf_driver = {
static void dmi_check_cb_common(const struct dmi_system_id *id) static void dmi_check_cb_common(const struct dmi_system_id *id)
{ {
acpi_handle handle; acpi_handle handle;
int have_blnf;
printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n", printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
id->ident); id->ident);
have_blnf = ACPI_SUCCESS
(acpi_get_handle(NULL, "\\_SB.PCI0.GFX0.LCD.BLNF", &handle));
if (use_alt_lcd_levels == -1) { if (use_alt_lcd_levels == -1) {
vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detecting usealt\n"); if (ACPI_SUCCESS(acpi_get_handle(NULL,
use_alt_lcd_levels = 1; "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
} use_alt_lcd_levels = 1;
if (disable_brightness_keys == -1) { else
vdbg_printk(FUJLAPTOP_DBG_TRACE, use_alt_lcd_levels = 0;
"auto-detecting disable_keys\n"); vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
disable_brightness_keys = have_blnf ? 1 : 0; "%i\n", use_alt_lcd_levels);
}
if (disable_brightness_adjust == -1) {
vdbg_printk(FUJLAPTOP_DBG_TRACE,
"auto-detecting disable_adjust\n");
disable_brightness_adjust = have_blnf ? 0 : 1;
} }
} }
...@@ -768,19 +728,14 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -768,19 +728,14 @@ static int acpi_fujitsu_add(struct acpi_device *device)
/* do config (detect defaults) */ /* do config (detect defaults) */
use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
disable_brightness_keys = disable_brightness_keys == 1 ? 1 : 0;
disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
vdbg_printk(FUJLAPTOP_DBG_INFO, vdbg_printk(FUJLAPTOP_DBG_INFO,
"config: [alt interface: %d], [key disable: %d], [adjust disable: %d]\n", "config: [alt interface: %d], [adjust disable: %d]\n",
use_alt_lcd_levels, disable_brightness_keys, use_alt_lcd_levels, disable_brightness_adjust);
disable_brightness_adjust);
if (get_max_brightness() <= 0) if (get_max_brightness() <= 0)
fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
if (use_alt_lcd_levels) get_lcd_level();
get_lcd_level_alt();
else
get_lcd_level();
return result; return result;
...@@ -831,43 +786,23 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data) ...@@ -831,43 +786,23 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
case ACPI_FUJITSU_NOTIFY_CODE1: case ACPI_FUJITSU_NOTIFY_CODE1:
keycode = 0; keycode = 0;
oldb = fujitsu->brightness_level; oldb = fujitsu->brightness_level;
get_lcd_level(); /* the alt version always yields changed */ get_lcd_level();
newb = fujitsu->brightness_level; newb = fujitsu->brightness_level;
vdbg_printk(FUJLAPTOP_DBG_TRACE, vdbg_printk(FUJLAPTOP_DBG_TRACE,
"brightness button event [%i -> %i (%i)]\n", "brightness button event [%i -> %i (%i)]\n",
oldb, newb, fujitsu->brightness_changed); oldb, newb, fujitsu->brightness_changed);
if (oldb == newb && fujitsu->brightness_changed) { if (oldb < newb) {
keycode = 0;
if (disable_brightness_keys != 1) {
if (oldb == 0) {
acpi_bus_generate_proc_event
(fujitsu->dev,
ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS,
0);
keycode = KEY_BRIGHTNESSDOWN;
} else if (oldb ==
(fujitsu->max_brightness) - 1) {
acpi_bus_generate_proc_event
(fujitsu->dev,
ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS,
0);
keycode = KEY_BRIGHTNESSUP;
}
}
} else if (oldb < newb) {
if (disable_brightness_adjust != 1) { if (disable_brightness_adjust != 1) {
if (use_alt_lcd_levels) if (use_alt_lcd_levels)
set_lcd_level_alt(newb); set_lcd_level_alt(newb);
else else
set_lcd_level(newb); set_lcd_level(newb);
} }
if (disable_brightness_keys != 1) { acpi_bus_generate_proc_event(fujitsu->dev,
acpi_bus_generate_proc_event(fujitsu->dev, ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0); keycode = KEY_BRIGHTNESSUP;
keycode = KEY_BRIGHTNESSUP;
}
} else if (oldb > newb) { } else if (oldb > newb) {
if (disable_brightness_adjust != 1) { if (disable_brightness_adjust != 1) {
if (use_alt_lcd_levels) if (use_alt_lcd_levels)
...@@ -875,13 +810,9 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data) ...@@ -875,13 +810,9 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
else else
set_lcd_level(newb); set_lcd_level(newb);
} }
if (disable_brightness_keys != 1) { acpi_bus_generate_proc_event(fujitsu->dev,
acpi_bus_generate_proc_event(fujitsu->dev, ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0); keycode = KEY_BRIGHTNESSDOWN;
keycode = KEY_BRIGHTNESSDOWN;
}
} else {
keycode = KEY_UNKNOWN;
} }
break; break;
default: default:
...@@ -1336,9 +1267,6 @@ module_exit(fujitsu_cleanup); ...@@ -1336,9 +1267,6 @@ module_exit(fujitsu_cleanup);
module_param(use_alt_lcd_levels, uint, 0644); module_param(use_alt_lcd_levels, uint, 0644);
MODULE_PARM_DESC(use_alt_lcd_levels, MODULE_PARM_DESC(use_alt_lcd_levels,
"Use alternative interface for lcd_levels (needed for Lifebook s6410)."); "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
module_param(disable_brightness_keys, uint, 0644);
MODULE_PARM_DESC(disable_brightness_keys,
"Disable brightness keys (eg. if they are already handled by the generic ACPI_VIDEO device).");
module_param(disable_brightness_adjust, uint, 0644); module_param(disable_brightness_adjust, uint, 0644);
MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment