sony-laptop fixes for 2.6.39
Subsystems (2)
Mattia Dongili
maintainercover sony-laptop fixes for 2.6.39
Hi Matthew,
a few fixes for the code that was added in 2.6.39.
One note about the "largely modified sony-laptop.c" mentioned in [PATCH 1/3]:
the file is distributed via the author's website[1] and a Google Code project[2]. The file reports the same original license (GPLv2+) so I'm taking bits and pieces from there and integrating them for mainline.
[1]: http://www.absence.it/vaio-acpi/
[2]: http://code.google.com/p/vaio-f11-linux/
Thanks
Signature · 1 line
Mattia
Mattia Dongili
maintainerPATCH 1/3 sony-laptop: keyboard backlight fixes
From: Marco Chiappero <[email protected]>
Restore the original state on module removal, set the latest values on resume.
When setting the keyboard backlight mode try to turn on/off backlight immediately.
[[email protected]: patch taken from a largely modified sony-laptop.c, ported and slightly modified to use defines already available.]
--- drivers/platform/x86/sony-laptop.c | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/platform/x86/sony-laptop.c +34 -1
@@ -138,6 +138,8 @@ MODULE_PARM_DESC(kbd_backlight_timeout,"1 for 30 seconds, 2 for 60 seconds and 3 to disable timeout " "(default: 0)"); +static void sony_nc_kbd_backlight_resume (void ); +enum sony_nc_rfkill {SONY_WIFI ,SONY_BLUETOOTH ,
@@ -1168,6 +1170,9 @@ static int sony_nc_resume(struct acpi_device *device)/* re-read rfkill state */ sony_nc_rfkill_update (); +/* restore kbd backlight states */ +sony_nc_kbd_backlight_resume (); +return 0 ; }
@@ -1355,6 +1360,7 @@ out_no_enum:#define KBDBL_HANDLER 0x137#define KBDBL_PRESENT 0xB00#define SET_MODE 0xC00 +#define SET_STATE 0xD00#define SET_TIMEOUT 0xE00struct kbd_backlight {
@@ -1377,6 +1383,10 @@ static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value) (value << 0x10) | SET_MODE, &result))return -EIO ; +/* Try to turn the light on/off immediately */ +sony_call_snc_handle (KBDBL_HANDLER , (value <<0x10 ) |SET_STATE , + &result); + kbdbl_handle->mode = value;return 0 ;
@@ -1458,7 +1468,7 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd) {int result; -if (sony_call_snc_handle (0x137 ,KBDBL_PRESENT , &result)) +if (sony_call_snc_handle (KBDBL_HANDLER ,KBDBL_PRESENT , &result))return 0 ;if (!(result &0x02 ))return 0 ;
@@ -1501,13 +1511,36 @@ outkzalloc:static int sony_nc_kbd_backlight_cleanup (struct platform_device *pd) {if (kbdbl_handle) { +int result; +device_remove_file (&pd->dev, &kbdbl_handle->mode_attr);device_remove_file (&pd->dev, &kbdbl_handle->timeout_attr); + +/* restore the default hw behaviour */ +sony_call_snc_handle (KBDBL_HANDLER ,0x1000 |SET_MODE , &result); +sony_call_snc_handle (KBDBL_HANDLER ,SET_TIMEOUT , &result); +kfree (kbdbl_handle); }return 0 ; } +static void sony_nc_kbd_backlight_resume (void ) +{ +int ignore =0 ; + +if (!kbdbl_handle) +return ; + +if (kbdbl_handle->mode ==0 ) +sony_call_snc_handle (KBDBL_HANDLER ,SET_MODE , &ignore); + +if (kbdbl_handle->timeout !=0 ) +sony_call_snc_handle (KBDBL_HANDLER , + (kbdbl_handle->timeout <<0x10 ) |SET_TIMEOUT , + &ignore); +} +static void sony_nc_backlight_setup (void ) {acpi_handle unused;
Signature · 1 line
1.7.4.1
Mattia Dongili
maintainerPATCH 2/3 sony-laptop: only show the handles sysfs file in debug mode
In reply to Mattia DongiliIt makes no sense to expose this type of information to userspace unless the driver was explicitly loaded with the debug option.
--- drivers/platform/x86/sony-laptop.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-)
drivers/platform/x86/sony-laptop.c +14 -11
@@ -773,11 +773,6 @@ static int sony_nc_handles_setup(struct platform_device *pd)if (!handles)return -ENOMEM ; -sysfs_attr_init (&handles->devattr.attr); - handles->devattr.attr.name ="handles" ; - handles->devattr.attr.mode =S_IRUGO ; - handles->devattr.show = sony_nc_handles_show; -for (i =0 ; i <ARRAY_SIZE (handles->cap); i++) {if (!acpi_callsetfunc (sony_nc_acpi_handle,"SN00" , i +0x20 , &result)) {
@@ -787,11 +782,18 @@ static int sony_nc_handles_setup(struct platform_device *pd) } } -/* allow reading capabilities via sysfs */ -if (device_create_file (&pd->dev, &handles->devattr)) { -kfree (handles); - handles =NULL ; -return -1 ; +if (debug) { +sysfs_attr_init (&handles->devattr.attr); + handles->devattr.attr.name ="handles" ; + handles->devattr.attr.mode =S_IRUGO ; + handles->devattr.show = sony_nc_handles_show; + +/* allow reading capabilities via sysfs */ +if (device_create_file (&pd->dev, &handles->devattr)) { +kfree (handles); + handles =NULL ; +return -1 ; + } }return 0 ;
@@ -800,7 +802,8 @@ static int sony_nc_handles_setup(struct platform_device *pd)static int sony_nc_handles_cleanup (struct platform_device *pd) {if (handles) { -device_remove_file (&pd->dev, &handles->devattr); +if (debug) +device_remove_file (&pd->dev, &handles->devattr);kfree (handles); handles =NULL ; }
Signature · 1 line
1.7.4.1
Mattia Dongili
maintainerPATCH 3/3 sony-laptop: report failures on setting LCD brightness
In reply to Mattia DongiliCheck if we were successful in setting the requested brightness and report failure in that case.
--- drivers/platform/x86/sony-laptop.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/sony-laptop.c +3 -2
@@ -961,9 +961,10 @@ static int sony_nc_update_status_ng(struct backlight_device *bd)int *handle = (int *)bl_get_data (bd); value = bd->props.brightness; -sony_call_snc_handle (*handle,0x0100 | (value <<16 ), &result); +if (sony_call_snc_handle (*handle,0x0100 | (value <<16 ), &result)) +return -EIO ; -return sony_nc_get_brightness_ng (bd); +return value; }static const struct backlight_ops sony_backlight_ops = {
Signature · 1 line
1.7.4.1