* [PATCH 1/7] ACPI: thinkpad-acpi: revert keymap changes
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 2/7] ACPI: thinkpad-acpi: support 16 levels of brightness (v3) Henrique de Moraes Holschuh
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown
Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh,
Jeremy Katz
Revert commit fba956c46a72f9e7503fd464ffee43c632307e31, "Map volume and
brightness events on thinkpads".
That commit made some modifications to the default keymaps that cause bad
behaviour on all IBM ThinkPads if HAL doesn't know to change them into
passive (on-screen-display only) events.
The proper solution for IBM ThinkPads is to use the _NOTIFY version of the
key codes for the IBM default map (which are not available in mainline
yet), and for the Lenovo keymap, it will take some studying of the various
DSDTs and testing to know the best path (which I will do shortly).
For more data, refer to:
http://thread.gmane.org/gmane.linux.kernel/591037/focus=591045
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Jeremy Katz <katzj@redhat.com>
---
drivers/misc/thinkpad_acpi.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e953276..63b1e26 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -964,15 +964,15 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */
KEY_UNKNOWN, /* 0x0D: FN+INSERT */
KEY_UNKNOWN, /* 0x0E: FN+DELETE */
- KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */
+ KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */
/* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
- KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */
+ KEY_RESERVED, /* 0x10: FN+END (brightness down) */
KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
- KEY_VOLUMEUP, /* 0x14: VOLUME UP */
- KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */
- KEY_MUTE, /* 0x16: MUTE */
+ KEY_RESERVED, /* 0x14: VOLUME UP */
+ KEY_RESERVED, /* 0x15: VOLUME DOWN */
+ KEY_RESERVED, /* 0x16: MUTE */
KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
/* (assignments unknown, please report if found) */
KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
@@ -993,9 +993,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
- KEY_VOLUMEUP, /* 0x14: VOLUME UP */
- KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */
- KEY_MUTE, /* 0x16: MUTE */
+ KEY_RESERVED, /* 0x14: VOLUME UP */
+ KEY_RESERVED, /* 0x15: VOLUME DOWN */
+ KEY_RESERVED, /* 0x16: MUTE */
KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
/* (assignments unknown, please report if found) */
KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/7] ACPI: thinkpad-acpi: support 16 levels of brightness (v3)
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 1/7] ACPI: thinkpad-acpi: revert keymap changes Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 3/7] ACPI: thinkpad-acpi: add brightness_force parameter Henrique de Moraes Holschuh
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown
Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh,
Thomas Renninger
Lenovo ThinkPads often have 16 brightness levels in EC, and not just eight
levels like older ThinkPads. They also have standard ACPI backlight
brightness control.
We detect the number of brightness levels by the presence of a BCLL package
with 16 entries. If BCLL is not there, we assume eight levels (Z6*). If
it is there, but it doesn't have 16 entries, we assume eight levels (T60).
Otherwise we assume sixteen levels (T61, X61, etc).
We don't use _BCL because it can have side-effects in thinkpads. Thanks to
Thomas Renninger <trenn@suse.de> for notifying me of this potential
problem.
Using the standard ACPI backlight brightness control *instead* of the
native thinkpad backlight control is a better idea, though. A different
patch will take care of this.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Thomas Renninger <trenn@suse.de>
---
Documentation/thinkpad-acpi.txt | 61 +++++++++++++++-----------
drivers/misc/thinkpad_acpi.c | 91 ++++++++++++++++++++++++++++++++++----
drivers/misc/thinkpad_acpi.h | 3 +-
3 files changed, 118 insertions(+), 37 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index ec49926..a743bfa 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -923,19 +923,26 @@ sysfs backlight device "thinkpad_screen"
This feature allows software control of the LCD brightness on ThinkPad
models which don't have a hardware brightness slider.
-It has some limitations: the LCD backlight cannot be actually turned on or off
-by this interface, and in many ThinkPad models, the "dim while on battery"
-functionality will be enabled by the BIOS when this interface is used, and
-cannot be controlled.
-
-The backlight control has eight levels, ranging from 0 to 7. Some of the
-levels may not be distinct.
-
-There are two interfaces to the firmware for brightness control, EC and CMOS.
-To select which one should be used, use the brightness_mode module parameter:
-brightness_mode=1 selects EC mode, brightness_mode=2 selects CMOS mode,
-brightness_mode=3 selects both EC and CMOS. The driver tries to autodetect
-which interface to use.
+It has some limitations: the LCD backlight cannot be actually turned on or
+off by this interface, and in many ThinkPad models, the "dim while on
+battery" functionality will be enabled by the BIOS when this interface is
+used, and cannot be controlled.
+
+On IBM (and some of the earlier Lenovo) ThinkPads, the backlight control
+has eight brightness levels, ranging from 0 to 7. Some of the levels
+may not be distinct. Later Lenovo models that implement the ACPI
+display backlight brightness control methods have 16 levels, ranging
+from 0 to 15.
+
+There are two interfaces to the firmware for direct brightness control,
+EC and CMOS. To select which one should be used, use the
+brightness_mode module parameter: brightness_mode=1 selects EC mode,
+brightness_mode=2 selects CMOS mode, brightness_mode=3 selects both EC
+and CMOS. The driver tries to autodetect which interface to use.
+
+When display backlight brightness controls are available through the
+standard ACPI interface, it is best to use it instead of this direct
+ThinkPad-specific interface.
Procfs notes:
@@ -947,11 +954,11 @@ Procfs notes:
Sysfs notes:
-The interface is implemented through the backlight sysfs class, which is poorly
-documented at this time.
+The interface is implemented through the backlight sysfs class, which is
+poorly documented at this time.
-Locate the thinkpad_screen device under /sys/class/backlight, and inside it
-there will be the following attributes:
+Locate the thinkpad_screen device under /sys/class/backlight, and inside
+it there will be the following attributes:
max_brightness:
Reads the maximum brightness the hardware can be set to.
@@ -961,17 +968,19 @@ there will be the following attributes:
Reads what brightness the screen is set to at this instant.
brightness:
- Writes request the driver to change brightness to the given
- value. Reads will tell you what brightness the driver is trying
- to set the display to when "power" is set to zero and the display
- has not been dimmed by a kernel power management event.
+ Writes request the driver to change brightness to the
+ given value. Reads will tell you what brightness the
+ driver is trying to set the display to when "power" is set
+ to zero and the display has not been dimmed by a kernel
+ power management event.
power:
- power management mode, where 0 is "display on", and 1 to 3 will
- dim the display backlight to brightness level 0 because
- thinkpad-acpi cannot really turn the backlight off. Kernel
- power management events can temporarily increase the current
- power management level, i.e. they can dim the display.
+ power management mode, where 0 is "display on", and 1 to 3
+ will dim the display backlight to brightness level 0
+ because thinkpad-acpi cannot really turn the backlight
+ off. Kernel power management events can temporarily
+ increase the current power management level, i.e. they can
+ dim the display.
Volume control -- /proc/acpi/ibm/volume
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 63b1e26..322ba25 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3114,6 +3114,66 @@ static struct backlight_ops ibm_backlight_data = {
static struct mutex brightness_mutex;
+static int __init tpacpi_query_bcll_levels(acpi_handle handle)
+{
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *obj;
+ int rc;
+
+ if (ACPI_SUCCESS(acpi_evaluate_object(handle, NULL, NULL, &buffer))) {
+ obj = (union acpi_object *)buffer.pointer;
+ if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
+ printk(IBM_ERR "Unknown BCLL data, "
+ "please report this to %s\n", IBM_MAIL);
+ rc = 0;
+ } else {
+ rc = obj->package.count;
+ }
+ } else {
+ return 0;
+ }
+
+ kfree(buffer.pointer);
+ return rc;
+}
+
+static acpi_status __init brightness_find_bcll(acpi_handle handle, u32 lvl,
+ void *context, void **rv)
+{
+ char name[ACPI_PATH_SEGMENT_LENGTH];
+ struct acpi_buffer buffer = { sizeof(name), &name };
+
+ if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
+ !strncmp("BCLL", name, sizeof(name) - 1)) {
+ if (tpacpi_query_bcll_levels(handle) == 16) {
+ *rv = handle;
+ return AE_CTRL_TERMINATE;
+ } else {
+ return AE_OK;
+ }
+ } else {
+ return AE_OK;
+ }
+}
+
+static int __init brightness_check_levels(void)
+{
+ int status;
+ void *found_node = NULL;
+
+ if (!vid_handle) {
+ IBM_ACPIHANDLE_INIT(vid);
+ }
+ if (!vid_handle)
+ return 0;
+
+ /* Search for a BCLL package with 16 levels */
+ status = acpi_walk_namespace(ACPI_TYPE_PACKAGE, vid_handle, 3,
+ brightness_find_bcll, NULL, &found_node);
+
+ return (ACPI_SUCCESS(status) && found_node != NULL);
+}
+
static int __init brightness_init(struct ibm_init_struct *iibm)
{
int b;
@@ -3135,10 +3195,17 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
if (brightness_mode > 3)
return -EINVAL;
+ tp_features.bright_16levels =
+ thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO &&
+ brightness_check_levels();
+
b = brightness_get(NULL);
if (b < 0)
return 1;
+ if (tp_features.bright_16levels)
+ printk(IBM_INFO "detected a 16-level brightness capable ThinkPad\n");
+
ibm_backlight_device = backlight_device_register(
TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
&ibm_backlight_data);
@@ -3148,7 +3215,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
}
vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n");
- ibm_backlight_device->props.max_brightness = 7;
+ ibm_backlight_device->props.max_brightness =
+ (tp_features.bright_16levels)? 15 : 7;
ibm_backlight_device->props.brightness = b;
backlight_update_status(ibm_backlight_device);
@@ -3184,13 +3252,14 @@ static int brightness_get(struct backlight_device *bd)
if (brightness_mode & 1) {
if (!acpi_ec_read(brightness_offset, &lec))
return -EIO;
- lec &= 7;
+ lec &= (tp_features.bright_16levels)? 0x0f : 0x07;
level = lec;
};
if (brightness_mode & 2) {
lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
& TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
>> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
+ lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07;
level = lcmos;
}
@@ -3211,7 +3280,7 @@ static int brightness_set(int value)
int cmos_cmd, inc, i, res;
int current_value;
- if (value > 7)
+ if (value > ((tp_features.bright_16levels)? 15 : 7))
return -EINVAL;
res = mutex_lock_interruptible(&brightness_mutex);
@@ -3227,7 +3296,7 @@ static int brightness_set(int value)
cmos_cmd = value > current_value ?
TP_CMOS_BRIGHTNESS_UP :
TP_CMOS_BRIGHTNESS_DOWN;
- inc = value > current_value ? 1 : -1;
+ inc = (value > current_value)? 1 : -1;
res = 0;
for (i = current_value; i != value; i += inc) {
@@ -3256,10 +3325,11 @@ static int brightness_read(char *p)
if ((level = brightness_get(NULL)) < 0) {
len += sprintf(p + len, "level:\t\tunreadable\n");
} else {
- len += sprintf(p + len, "level:\t\t%d\n", level & 0x7);
+ len += sprintf(p + len, "level:\t\t%d\n", level);
len += sprintf(p + len, "commands:\tup, down\n");
len += sprintf(p + len, "commands:\tlevel <level>"
- " (<level> is 0-7)\n");
+ " (<level> is 0-%d)\n",
+ (tp_features.bright_16levels) ? 15 : 7);
}
return len;
@@ -3270,18 +3340,19 @@ static int brightness_write(char *buf)
int level;
int new_level;
char *cmd;
+ int max_level = (tp_features.bright_16levels) ? 15 : 7;
while ((cmd = next_cmd(&buf))) {
if ((level = brightness_get(NULL)) < 0)
return level;
- level &= 7;
if (strlencmp(cmd, "up") == 0) {
- new_level = level == 7 ? 7 : level + 1;
+ new_level = level == (max_level)?
+ max_level : level + 1;
} else if (strlencmp(cmd, "down") == 0) {
- new_level = level == 0 ? 0 : level - 1;
+ new_level = level == 0? 0 : level - 1;
} else if (sscanf(cmd, "level %d", &new_level) == 1 &&
- new_level >= 0 && new_level <= 7) {
+ new_level >= 0 && new_level <= max_level) {
/* new_level set */
} else
return -EINVAL;
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 3abcc81..8ca19c3 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -84,7 +84,7 @@
/* ThinkPad CMOS NVRAM constants */
#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e
-#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07
+#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f
#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0
#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
@@ -246,6 +246,7 @@ static struct {
u32 hotkey_wlsw:1;
u32 light:1;
u32 light_status:1;
+ u32 bright_16levels:1;
u32 wan:1;
u32 fan_ctrl_status_undef:1;
u32 input_device_registered:1;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/7] ACPI: thinkpad-acpi: add brightness_force parameter
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 1/7] ACPI: thinkpad-acpi: revert keymap changes Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 2/7] ACPI: thinkpad-acpi: support 16 levels of brightness (v3) Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:55 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 4/7] ACPI: thinkpad-acpi: prefer standard ACPI backlight level control Henrique de Moraes Holschuh
` (4 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh
Add a "brightness_force" module parameter that allows the local admin to
force the backlight support to not be enabled.
It can also be used to force the backlight support to be enabled, but that
is currently a no-op as the backlight support is enabled by default when
available. This will be changed by a different patch.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/thinkpad-acpi.txt | 4 ++++
drivers/misc/thinkpad_acpi.c | 9 +++++++++
drivers/misc/thinkpad_acpi.h | 1 +
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index a743bfa..f877c13 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -944,6 +944,10 @@ When display backlight brightness controls are available through the
standard ACPI interface, it is best to use it instead of this direct
ThinkPad-specific interface.
+The brightness_enable module parameter can be used to control whether
+the LCD brightness control feature will be enabled when available.
+brightness_enable=0 forces it to be disabled.
+
Procfs notes:
The available commands are:
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 322ba25..56a21e6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3182,6 +3182,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
mutex_init(&brightness_mutex);
+ if (!brightness_enable) {
+ dbg_printk(TPACPI_DBG_INIT,
+ "brightness support disabled by module parameter\n");
+ return 1;
+ }
+
if (!brightness_mode) {
if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
brightness_mode = 2;
@@ -4803,6 +4809,9 @@ module_param_named(fan_control, fan_control_allowed, bool, 0);
static int brightness_mode;
module_param_named(brightness_mode, brightness_mode, int, 0);
+static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */
+module_param(brightness_enable, uint, 0);
+
static unsigned int hotkey_report_mode;
module_param(hotkey_report_mode, uint, 0);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 8ca19c3..8fba2bb 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -339,6 +339,7 @@ static int bluetooth_write(char *buf);
static struct backlight_device *ibm_backlight_device;
static int brightness_offset = 0x31;
static int brightness_mode;
+static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */
static int brightness_init(struct ibm_init_struct *iibm);
static void brightness_exit(void);
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 3/7] ACPI: thinkpad-acpi: add brightness_force parameter
2007-10-30 19:46 ` [PATCH 3/7] ACPI: thinkpad-acpi: add brightness_force parameter Henrique de Moraes Holschuh
@ 2007-10-30 19:55 ` Henrique de Moraes Holschuh
2007-10-30 20:02 ` [PATCH 3/7 v2] " Henrique de Moraes Holschuh
0 siblings, 1 reply; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:55 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi
On Tue, 30 Oct 2007, Henrique de Moraes Holschuh wrote:
> Add a "brightness_force" module parameter that allows the local admin to
> force the backlight support to not be enabled.
Err, brightness_enable. The patch is correct, though. I will send an
updated one which fixes the description, just in case.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/7 v2] ACPI: thinkpad-acpi: add brightness_force parameter
2007-10-30 19:55 ` Henrique de Moraes Holschuh
@ 2007-10-30 20:02 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 20:02 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi
Add a "brightness_enable" module parameter that allows the local admin to
force the backlight support to not be enabled.
It can also be used to force the backlight support to be enabled, but that
is currently a no-op as the backlight support is enabled by default when
available. This will be changed by a different patch.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/thinkpad-acpi.txt | 4 ++++
drivers/misc/thinkpad_acpi.c | 9 +++++++++
drivers/misc/thinkpad_acpi.h | 1 +
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index a743bfa..f877c13 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -944,6 +944,10 @@ When display backlight brightness controls are available through the
standard ACPI interface, it is best to use it instead of this direct
ThinkPad-specific interface.
+The brightness_enable module parameter can be used to control whether
+the LCD brightness control feature will be enabled when available.
+brightness_enable=0 forces it to be disabled.
+
Procfs notes:
The available commands are:
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 322ba25..56a21e6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3182,6 +3182,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
mutex_init(&brightness_mutex);
+ if (!brightness_enable) {
+ dbg_printk(TPACPI_DBG_INIT,
+ "brightness support disabled by module parameter\n");
+ return 1;
+ }
+
if (!brightness_mode) {
if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
brightness_mode = 2;
@@ -4803,6 +4809,9 @@ module_param_named(fan_control, fan_control_allowed, bool, 0);
static int brightness_mode;
module_param_named(brightness_mode, brightness_mode, int, 0);
+static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */
+module_param(brightness_enable, uint, 0);
+
static unsigned int hotkey_report_mode;
module_param(hotkey_report_mode, uint, 0);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 8ca19c3..8fba2bb 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -339,6 +339,7 @@ static int bluetooth_write(char *buf);
static struct backlight_device *ibm_backlight_device;
static int brightness_offset = 0x31;
static int brightness_mode;
+static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */
static int brightness_init(struct ibm_init_struct *iibm);
static void brightness_exit(void);
--
1.5.3.4
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] ACPI: thinkpad-acpi: prefer standard ACPI backlight level control
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
` (2 preceding siblings ...)
2007-10-30 19:46 ` [PATCH 3/7] ACPI: thinkpad-acpi: add brightness_force parameter Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 5/7] ACPI: thinkpad-acpi: bump up version to 0.17 Henrique de Moraes Holschuh
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh
Newer Lenovo BIOSes support the standard ACPI backlight brightness
interface (_BCM, _BQC, _BCL). It should be used instead of the native
thinkpad backlight brightness control interface when possible.
This patch disables the native brightness support in the driver by default
when we detect that the standard ACPI interface is available. The local
admin can still enable it using the module parameter "brightness_enable".
Note that we need to detect the standard ACPI backlight interface only in
boxes for which we would load the native backlight interface in the first
place, and that no ThinkPad BIOS has _BCL but misses the other methods, so
the detection routines can be really simple.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/thinkpad-acpi.txt | 8 ++++++--
drivers/misc/thinkpad_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index f877c13..bb1c7a6 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -942,11 +942,15 @@ and CMOS. The driver tries to autodetect which interface to use.
When display backlight brightness controls are available through the
standard ACPI interface, it is best to use it instead of this direct
-ThinkPad-specific interface.
+ThinkPad-specific interface. The driver will disable its native
+backlight brightness control interface if it detects that the standard
+ACPI interface is available in the ThinkPad.
The brightness_enable module parameter can be used to control whether
the LCD brightness control feature will be enabled when available.
-brightness_enable=0 forces it to be disabled.
+brightness_enable=0 forces it to be disabled. brightness_enable=1
+forces it to be enabled when available, even if the standard ACPI
+interface is also available.
Procfs notes:
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 56a21e6..109bd27 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3174,6 +3174,39 @@ static int __init brightness_check_levels(void)
return (ACPI_SUCCESS(status) && found_node != NULL);
}
+static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl,
+ void *context, void **rv)
+{
+ char name[ACPI_PATH_SEGMENT_LENGTH];
+ struct acpi_buffer buffer = { sizeof(name), &name };
+
+ if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
+ !strncmp("_BCL", name, sizeof(name) - 1)) {
+ *rv = handle;
+ return AE_CTRL_TERMINATE;
+ } else {
+ return AE_OK;
+ }
+}
+
+static int __init brightness_check_std_acpi_support(void)
+{
+ int status;
+ void *found_node = NULL;
+
+ if (!vid_handle) {
+ IBM_ACPIHANDLE_INIT(vid);
+ }
+ if (!vid_handle)
+ return 0;
+
+ /* Search for a _BCL method, but don't execute it */
+ status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3,
+ brightness_find_bcl, NULL, &found_node);
+
+ return (ACPI_SUCCESS(status) && found_node != NULL);
+}
+
static int __init brightness_init(struct ibm_init_struct *iibm)
{
int b;
@@ -3186,6 +3219,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
dbg_printk(TPACPI_DBG_INIT,
"brightness support disabled by module parameter\n");
return 1;
+ } else if (brightness_enable > 1) {
+ if (brightness_check_std_acpi_support()) {
+ printk(IBM_NOTICE
+ "standard ACPI backlight interface available, not loading native one...\n");
+ return 1;
+ }
}
if (!brightness_mode) {
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 5/7] ACPI: thinkpad-acpi: bump up version to 0.17
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
` (3 preceding siblings ...)
2007-10-30 19:46 ` [PATCH 4/7] ACPI: thinkpad-acpi: prefer standard ACPI backlight level control Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 6/7] ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers Henrique de Moraes Holschuh
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh
The lm-sensors 3.0.0/libsensors4 compatibility changes are reason enough to
bump up the version string. Do it.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/thinkpad-acpi.txt | 4 ++--
drivers/misc/thinkpad_acpi.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index bb1c7a6..10c041c 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -1,7 +1,7 @@
ThinkPad ACPI Extras Driver
- Version 0.16
- August 2nd, 2007
+ Version 0.17
+ October 04th, 2007
Borislav Deianov <borislav@users.sf.net>
Henrique de Moraes Holschuh <hmh@hmh.eng.br>
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 109bd27..251110d 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -21,7 +21,7 @@
* 02110-1301, USA.
*/
-#define IBM_VERSION "0.16"
+#define IBM_VERSION "0.17"
#define TPACPI_SYSFS_VERSION 0x020000
/*
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 6/7] ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
` (4 preceding siblings ...)
2007-10-30 19:46 ` [PATCH 5/7] ACPI: thinkpad-acpi: bump up version to 0.17 Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
2007-10-30 19:46 ` [PATCH 7/7] ACPI: thinkpad-acpi: fix brightness_set error paths Henrique de Moraes Holschuh
[not found] ` <1193773585-17202-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown
Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh,
Jean Delvare, Peter Jordan, Richard Neill
Map an mutex_lock_interruptible() error return into ERESTARTSYS, as the
only possible error from mutex_lock_interruptible is EINTR, and that will
only happen if signal_pending() causes the mutex lock attempt to abort.
This still allows signals to be delivered ASAP, which is much nicer than
just doing mutex_lock, and still shadows userspace from EINTR when
SA_RESTART is active.
Problem reported by Peter Jordan.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Peter Jordan <usernetwork@gmx.info>
Cc: Richard Neill <rn214@hermes.cam.ac.uk>
---
drivers/misc/thinkpad_acpi.c | 40 ++++++++++++++++------------------------
1 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 251110d..306daa5 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p)
return len;
}
- res = mutex_lock_interruptible(&hotkey_mutex);
- if (res < 0)
- return res;
+ if (mutex_lock_interruptible(&hotkey_mutex))
+ return -ERESTARTSYS;
res = hotkey_get(&status, &mask);
mutex_unlock(&hotkey_mutex);
if (res)
@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf)
if (!tp_features.hotkey)
return -ENODEV;
- res = mutex_lock_interruptible(&hotkey_mutex);
- if (res < 0)
- return res;
+ if (mutex_lock_interruptible(&hotkey_mutex))
+ return -ERESTARTSYS;
res = hotkey_get(&status, &mask);
if (res)
@@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev,
/* scale down from 0-255 to 0-7 */
newlevel = (s >> 5) & 0x07;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
rc = fan_get_status(&status);
if (!rc && (status &
@@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status)
int rc;
u8 s;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
rc = fan_get_status(&s);
if (!rc)
fan_update_desired_level(s);
@@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level)
if (!fan_control_allowed)
return -EPERM;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
if (level == TPACPI_FAN_LAST_LEVEL)
level = fan_control_desired_level;
@@ -4179,9 +4174,8 @@ static int fan_set_enable(void)
if (!fan_control_allowed)
return -EPERM;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
switch (fan_control_access_mode) {
case TPACPI_FAN_WR_ACPI_FANS:
@@ -4235,9 +4229,8 @@ static int fan_set_disable(void)
if (!fan_control_allowed)
return -EPERM;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
rc = 0;
switch (fan_control_access_mode) {
@@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed)
if (!fan_control_allowed)
return -EPERM;
- rc = mutex_lock_interruptible(&fan_mutex);
- if (rc < 0)
- return rc;
+ if (mutex_lock_interruptible(&fan_mutex))
+ return -ERESTARTSYS;
rc = 0;
switch (fan_control_access_mode) {
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 7/7] ACPI: thinkpad-acpi: fix brightness_set error paths
2007-10-30 19:46 [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc Henrique de Moraes Holschuh
` (5 preceding siblings ...)
2007-10-30 19:46 ` [PATCH 6/7] ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers Henrique de Moraes Holschuh
@ 2007-10-30 19:46 ` Henrique de Moraes Holschuh
[not found] ` <1193773585-17202-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
7 siblings, 0 replies; 13+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-10-30 19:46 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh
The code calling brightness_set() can't handle EINTR/ERESTARTSYS well, nor
is it checking brightness_set() return status properly.
Fix it.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
drivers/misc/thinkpad_acpi.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 306daa5..8c94307 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3278,6 +3278,8 @@ static void brightness_exit(void)
static int brightness_update_status(struct backlight_device *bd)
{
+ /* it is the backlight class's job (caller) to handle
+ * EINTR and other errors properly */
return brightness_set(
(bd->props.fb_blank == FB_BLANK_UNBLANK &&
bd->props.power == FB_BLANK_UNBLANK) ?
@@ -3318,6 +3320,7 @@ static int brightness_get(struct backlight_device *bd)
return level;
}
+/* May return EINTR which can always be mapped to ERESTARTSYS */
static int brightness_set(int value)
{
int cmos_cmd, inc, i, res;
@@ -3381,29 +3384,34 @@ static int brightness_read(char *p)
static int brightness_write(char *buf)
{
int level;
- int new_level;
+ int rc;
char *cmd;
int max_level = (tp_features.bright_16levels) ? 15 : 7;
- while ((cmd = next_cmd(&buf))) {
- if ((level = brightness_get(NULL)) < 0)
- return level;
+ level = brightness_get(NULL);
+ if (level < 0)
+ return level;
+ while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "up") == 0) {
- new_level = level == (max_level)?
- max_level : level + 1;
+ if (level < max_level)
+ level++;
} else if (strlencmp(cmd, "down") == 0) {
- new_level = level == 0? 0 : level - 1;
- } else if (sscanf(cmd, "level %d", &new_level) == 1 &&
- new_level >= 0 && new_level <= max_level) {
- /* new_level set */
+ if (level > 0)
+ level--;
+ } else if (sscanf(cmd, "level %d", &level) == 1 &&
+ level >= 0 && level <= max_level) {
+ /* new level set */
} else
return -EINVAL;
-
- brightness_set(new_level);
}
- return 0;
+ /*
+ * Now we know what the final level should be, so we try to set it.
+ * Doing it this way makes the syscall restartable in case of EINTR
+ */
+ rc = brightness_set(level);
+ return (rc == -EINTR)? ERESTARTSYS : rc;
}
static struct ibm_struct brightness_driver_data = {
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread[parent not found: <1193773585-17202-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>]
* Re: [GIT PATCH] thinkpad-acpi patches for 2.6.24-rc
[not found] ` <1193773585-17202-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-11-05 19:32 ` Len Brown
[not found] ` <200711051432.27840.lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Len Brown @ 2007-11-05 19:32 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA
I agree that these look post1rc1 worthy,
lets see if the boss thinks so too.
applied.
thanks,
-Len
On Tuesday 30 October 2007 15:46, Henrique de Moraes Holschuh wrote:
> Len,
>
> Here is a bunch of thinkpad-acpi changes that fixes some bugs and add key
> thinkpad models support that should, if at all possible, be merged for
> 2.6.24.
>
> They are really important for ThinkPad X60, T61 and R61 users, and the
> first patch unbreaks the ThinkPad ACPI hotkey map in all IBM ThinkPads on
> several distros.
>
> Please consider sending this patch set to Linus for merging after -rc2 is
> out.
>
> All patches in it have been tested, and all comments the individual patches
> received (some of them are not new) have been addressed.
>
> As usual, the patch set is available at:
> git://repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git for-upstream/acpi-release
>
> Shortlog of the above branch:
>
> Henrique de Moraes Holschuh (7):
> ACPI: thinkpad-acpi: revert keymap changes
> ACPI: thinkpad-acpi: support 16 levels of brightness (v3)
> ACPI: thinkpad-acpi: add brightness_force parameter
> ACPI: thinkpad-acpi: prefer standard ACPI backlight level control
> ACPI: thinkpad-acpi: bump up version to 0.17
> ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers
> ACPI: thinkpad-acpi: fix brightness_set error paths
>
> Thanks.
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 13+ messages in thread