* [PATCH 0/3] sony-laptop fixes for 2.6.39
@ 2011-04-05 14:38 Mattia Dongili
2011-04-05 14:38 ` [PATCH 1/3] sony-laptop: keyboard backlight fixes Mattia Dongili
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mattia Dongili @ 2011-04-05 14:38 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86
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
--
Mattia
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] sony-laptop: keyboard backlight fixes
2011-04-05 14:38 [PATCH 0/3] sony-laptop fixes for 2.6.39 Mattia Dongili
@ 2011-04-05 14:38 ` Mattia Dongili
2011-04-05 14:38 ` [PATCH 2/3] sony-laptop: only show the handles sysfs file in debug mode Mattia Dongili
2011-04-05 14:38 ` [PATCH 3/3] sony-laptop: report failures on setting LCD brightness Mattia Dongili
2 siblings, 0 replies; 4+ messages in thread
From: Mattia Dongili @ 2011-04-05 14:38 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Marco Chiappero, Mattia Dongili
From: Marco Chiappero <marco@absence.it>
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.
[malattia@linux.it: patch taken from a largely modified sony-laptop.c,
ported and slightly modified to use defines already available.]
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index e642f5f..77646fc 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -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 0xE00
struct 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;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] sony-laptop: only show the handles sysfs file in debug mode
2011-04-05 14:38 [PATCH 0/3] sony-laptop fixes for 2.6.39 Mattia Dongili
2011-04-05 14:38 ` [PATCH 1/3] sony-laptop: keyboard backlight fixes Mattia Dongili
@ 2011-04-05 14:38 ` Mattia Dongili
2011-04-05 14:38 ` [PATCH 3/3] sony-laptop: report failures on setting LCD brightness Mattia Dongili
2 siblings, 0 replies; 4+ messages in thread
From: Mattia Dongili @ 2011-04-05 14:38 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
It makes no sense to expose this type of information to userspace unless
the driver was explicitly loaded with the debug option.
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 77646fc..c8d755a 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -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;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] sony-laptop: report failures on setting LCD brightness
2011-04-05 14:38 [PATCH 0/3] sony-laptop fixes for 2.6.39 Mattia Dongili
2011-04-05 14:38 ` [PATCH 1/3] sony-laptop: keyboard backlight fixes Mattia Dongili
2011-04-05 14:38 ` [PATCH 2/3] sony-laptop: only show the handles sysfs file in debug mode Mattia Dongili
@ 2011-04-05 14:38 ` Mattia Dongili
2 siblings, 0 replies; 4+ messages in thread
From: Mattia Dongili @ 2011-04-05 14:38 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
Check if we were successful in setting the requested brightness and
report failure in that case.
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index c8d755a..2fe7ddd 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -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 = {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-05 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-05 14:38 [PATCH 0/3] sony-laptop fixes for 2.6.39 Mattia Dongili
2011-04-05 14:38 ` [PATCH 1/3] sony-laptop: keyboard backlight fixes Mattia Dongili
2011-04-05 14:38 ` [PATCH 2/3] sony-laptop: only show the handles sysfs file in debug mode Mattia Dongili
2011-04-05 14:38 ` [PATCH 3/3] sony-laptop: report failures on setting LCD brightness Mattia Dongili
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.