[ibm-acpi-devel] [PATCH 03/10] thinkpad-acpi: fix some version quirks

2009-12-08 Thread Henrique de Moraes Holschuh
Update some of the BIOS/EC version quirks.

Signed-off-by: Henrique de Moraes Holschuh 
---
 drivers/platform/x86/thinkpad_acpi.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 1ee734c..6160813 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1779,7 +1779,7 @@ static const struct tpacpi_quirk 
tpacpi_bios_version_qtable[] __initconst = {
 
TPV_QL1('7', '9',  'E', '3',  '5', '0'), /* T60/p */
TPV_QL1('7', 'C',  'D', '2',  '2', '2'), /* R60, R60i */
-   TPV_QL0('7', 'E',  'D', '0'),/* R60e, R60i */
+   TPV_QL1('7', 'E',  'D', '0',  '1', '5'), /* R60e, R60i */
 
/*  BIOS FWBIOS VERS  EC FW EC VERS */
TPV_QI2('1', 'W',  '9', '0',  '1', 'V', '2', '8'), /* R50e (1) */
@@ -1795,8 +1795,8 @@ static const struct tpacpi_quirk 
tpacpi_bios_version_qtable[] __initconst = {
TPV_QI1('7', '4',  '6', '4',  '2', '7'), /* X41 (0) */
TPV_QI1('7', '5',  '6', '0',  '2', '0'), /* X41t (0) */
 
-   TPV_QL0('7', 'B',  'D', '7'),/* X60/s */
-   TPV_QL0('7', 'J',  '3', '0'),/* X60t */
+   TPV_QL1('7', 'B',  'D', '7',  '4', '0'), /* X60/s */
+   TPV_QL1('7', 'J',  '3', '0',  '1', '3'), /* X60t */
 
/* (0) - older versions lack DMI EC fw string and functionality */
/* (1) - older versions known to lack functionality */
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 05/10] thinkpad-acpi: silence bogus complain during rmmod

2009-12-08 Thread Henrique de Moraes Holschuh
Fix this bogus warning during module shutdown, when
backlight event reporting is enabled:

"thinkpad_acpi: required events 0x00018000 not enabled!"

Signed-off-by: Henrique de Moraes Holschuh 
---
 drivers/platform/x86/thinkpad_acpi.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 4406136..86418cd 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2189,7 +2189,8 @@ static int hotkey_mask_set(u32 mask)
   fwmask, hotkey_acpi_mask);
}
 
-   hotkey_mask_warn_incomplete_mask();
+   if (tpacpi_lifecycle != TPACPI_LIFE_EXITING)
+   hotkey_mask_warn_incomplete_mask();
 
return rc;
 }
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [GIT PATCH v2] thinkpad-acpi first set of changes for 2.6.33 (v2)

2009-12-08 Thread Henrique de Moraes Holschuh
Len,

This is the second version of the first batch of changes for thinkpad-acpi, for
the merge window.

Patch 4 is already in linux-next through the backlight tree, but it has a merge
problem there, so I have included it on this batch.  I will coordinate with the
backlight maintainer, so that the patch can be merged in mainline through the
acpi tree.

Changes since the last post:
  patch 08 has been refactored as per comments.
  patches 09 and 10 are new.

Please apply to acpi-test.

Thank you!

Shortlog:
Henrique de Moraes Holschuh (10):
  thinkpad-acpi: fix default brightness_mode for R50e/R51
  thinkpad-acpi: preserve rfkill state across suspend/resume
  thinkpad-acpi: fix some version quirks
  thinkpad-acpi: issue backlight class events
  thinkpad-acpi: silence bogus complain during rmmod
  thinkpad-acpi: adopt input device
  thinkpad-acpi: expose module parameters
  thinkpad-acpi: log temperatures on termal alarm (v2)
  thinkpad-acpi: use input_set_capability
  thinkpad-acpi: sync input device EV_SW state directly

-- 
  "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

--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 01/10] thinkpad-acpi: fix default brightness_mode for R50e/R51

2009-12-08 Thread Henrique de Moraes Holschuh
According to a report, the R50e wants EC-based brightness control,
even if it uses an Intel GPU.  The current driver default was reported
to not work at all.

This bug can be worked around by the "brightness_mode=3" module
parameter.

Change the default of the R50e and R51 2xxx models (which use the same
EC firmware, 1V) to TPACPI_BRGHT_Q_EC, but keep TPACPI_BRGHT_Q_ASK set
for now, as I'd like to get more reports.

This fixes a regression caused by commit
59fe4fe34d7afdf63208124f313be9056feaa2f4,
"thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM"

Kernel 2.6.31 also needs this fix.

Reported-by: Ferenc Wagner 
Tested-by: Ferenc Wagner 
Signed-off-by: Henrique de Moraes Holschuh 
Cc: sta...@kernel.org
---
 drivers/platform/x86/thinkpad_acpi.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index a848c7e..9c6d5a9 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -6123,8 +6123,8 @@ static const struct tpacpi_quirk brightness_quirk_table[] 
__initconst = {
 
/* Models with Intel Extreme Graphics 2 */
TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC),
-   TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
-   TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
+   TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
+   TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
 
/* Models with Intel GMA900 */
TPACPI_Q_IBM('7', '0', TPACPI_BRGHT_Q_NOEC),/* T43, R52 */
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH 10/10] thinkpad-acpi: sync input device EV_SW state directly

2009-12-08 Thread Dmitry Torokhov
On Tuesday 08 December 2009 05:36:30 pm Henrique de Moraes Holschuh wrote:
> Before we register the input device, sync the input layer EV_SW state
> directly by setting the bitmaps, to avoid issuing a gratuitous event
> for the initial state of these switches.
> 
> I will propose a clean input layer API for this and change the driver
> to use it later, but I'd rather get the driver fix in mainline ASAP.
> 

Just do input_report_switch() before registering the device, it will do
the right thing.

Input core guarantees (and will continue doing so) that it is safe to
pass events to the device as soon as it was allocated with
input_allocate_device().

-- 
Dmitry

--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 4/4] thinkpad-acpi: basic ALSA mixer support

2009-12-08 Thread Henrique de Moraes Holschuh
Add the basic ALSA mixer functionality.  The mixer is event-driven,
and will work fine on IBM ThinkPads.  I expect Lenovo ThinkPads will
cause some trouble with the event interface.

Heavily based on work by Lorne Applebaum 
and ideas from Matthew Garrett .

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Lorne Applebaum 
Cc: Matthew Garrett 
---
 Documentation/laptops/thinkpad-acpi.txt |7 +-
 drivers/platform/x86/thinkpad_acpi.c|  230 ++-
 2 files changed, 232 insertions(+), 5 deletions(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt 
b/Documentation/laptops/thinkpad-acpi.txt
index 6a58143..b4ed30c 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1096,6 +1096,7 @@ Volume control
 --
 
 procfs: /proc/acpi/ibm/volume
+ALSA: "ThinkPad Console Audio Control", default ID: "ThinkPadEC"
 
 NOTE: by default, the volume control interface operates in read-only
 mode, as it is supposed to be used for on-screen-display purposes.
@@ -1144,9 +1145,8 @@ The driver will operate in volume_mode=3 by default. If 
that does not
 work well on your ThinkPad model, please report this to
 ibm-acpi-de...@lists.sourceforge.net.
 
-The ALSA mixer interface to this feature is still missing, but patches
-to add it exist.  That problem should be addressed in the not so
-distant future.
+The driver supports the standard ALSA module parameters.  If the ALSA
+mixer is disabled, the driver will disable all volume functionality.
 
 
 Fan control and monitoring: fan speed, fan enable/disable
@@ -1478,3 +1478,4 @@ Sysfs interface changelog:
 
 0x020700:  Support for mute-only mixers.
Volume control in read-only mode by default.
+   Marker for ALSA mixer support.
diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index c1b45d4..8fefcd7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -76,6 +76,10 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include 
 
 #include 
@@ -6397,6 +6401,22 @@ static struct ibm_struct brightness_driver_data = {
  * and we leave them unchanged.
  */
 
+#define TPACPI_ALSA_DRVNAME  "ThinkPad EC"
+#define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"
+#define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME
+
+static int alsa_index = SNDRV_DEFAULT_IDX1;
+static char *alsa_id = "ThinkPadEC";
+static int alsa_enable = SNDRV_DEFAULT_ENABLE1;
+
+struct tpacpi_alsa_data {
+   struct snd_card *card;
+   struct snd_ctl_elem_id *ctl_mute_id;
+   struct snd_ctl_elem_id *ctl_vol_id;
+};
+
+static struct snd_card *alsa_card;
+
 enum {
TP_EC_AUDIO = 0x30,
 
@@ -6591,9 +6611,175 @@ static void volume_shutdown(void)
 
 static void volume_exit(void)
 {
+   if (alsa_card) {
+   snd_card_free(alsa_card);
+   alsa_card = NULL;
+   }
+
tpacpi_volume_checkpoint_nvram();
 }
 
+static void volume_alsa_notify_change(void)
+{
+   struct tpacpi_alsa_data *d;
+
+   if (alsa_card && alsa_card->private_data) {
+   d = alsa_card->private_data;
+   if (d->ctl_mute_id)
+   snd_ctl_notify(alsa_card,
+   SNDRV_CTL_EVENT_MASK_VALUE,
+   d->ctl_mute_id);
+   if (d->ctl_vol_id)
+   snd_ctl_notify(alsa_card,
+   SNDRV_CTL_EVENT_MASK_VALUE,
+   d->ctl_vol_id);
+   }
+}
+
+static int volume_alsa_vol_info(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_info *uinfo)
+{
+   uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+   uinfo->count = 1;
+   uinfo->value.integer.min = 0;
+   uinfo->value.integer.max = TP_EC_VOLUME_MAX;
+   return 0;
+}
+
+static int volume_alsa_vol_get(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   u8 s;
+   int rc;
+
+   rc = volume_get_status(&s);
+   if (rc < 0)
+   return rc;
+
+   ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK;
+   return 0;
+}
+
+static int volume_alsa_vol_put(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   return volume_set_volume(ucontrol->value.integer.value[0]);
+}
+
+#define volume_alsa_mute_info snd_ctl_boolean_mono_info
+
+static int volume_alsa_mute_get(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   u8 s;
+   int rc;
+
+   rc = volume_get_status(&s);
+   if (rc < 0)
+   return rc;
+
+   ucontrol->value.integer.value[0] =
+   (s & TP_EC_AUDIO_MUTESW_MSK) ? 0 : 1;
+   return 0;
+}
+
+static int volume_alsa_mute_put(struct snd_kcontrol *kcontr

[ibm-acpi-devel] [PATCH 3/4] thinkpad-acpi: disable volume control

2009-12-08 Thread Henrique de Moraes Holschuh
Disable volume control by default.  It can be enabled at module load
time by a module parameter (volume_control=1).

The audio control mixer that thinkpad-acpi interacts with is fully
functional without any drivers, and operated by hotkeys.

The idea behind the console audio control is that the human operator
is the only one that can interact with it.  The ThinkVantage suite in
Windows does not allow any software-based overrides, and only does OSD
(on-screen-display) functions.

The Linux driver will, with the addition of the ALSA interface, try to
follow and enforce the ThinkVantage UI design:

The user is supposed to use the keyboard hotkeys to interact with the
console audio control.  The kernel and the desktop environment is
supposed to cooperate to provide proper user feedback through
on-screen-display functions.

Distros are urged to not to enable volume control by default.
Enabling this must be a local admin's decision.  This is the reason
why there is no Kconfig option.

Keep in mind that all ThinkPads have a normal, main mixer (AC97 or
HDA) for regular software-based audio control.  We are not talking
about that mixer here.

Advanced users are, of course, free to enable volume control and do as
they please.

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Lorne Applebaum 
Cc: Matthew Garrett 
---
 Documentation/laptops/thinkpad-acpi.txt |   13 
 drivers/platform/x86/thinkpad_acpi.c|   47 +++---
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt 
b/Documentation/laptops/thinkpad-acpi.txt
index bd87682..6a58143 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1097,6 +1097,18 @@ Volume control
 
 procfs: /proc/acpi/ibm/volume
 
+NOTE: by default, the volume control interface operates in read-only
+mode, as it is supposed to be used for on-screen-display purposes.
+The read/write mode can be enabled through the use of the
+"volume_control=1" module parameter.
+
+NOTE: distros are urged to not enable volume_control by default, this
+should be done by the local admin only.  The ThinkPad UI is for the
+console audio control to be done through the volume keys only, and for
+the desktop environment to just provide on-screen-display feedback.
+Software volume control should be done only in the main AC97/HDA
+mixer.
+
 This feature allows volume control on ThinkPad models with a digital
 volume knob (when available, not all models have it), as well as
 mute/unmute control.  The available commands are:
@@ -1465,3 +1477,4 @@ Sysfs interface changelog:
 0x020600:  Marker for backlight change event support.
 
 0x020700:  Support for mute-only mixers.
+   Volume control in read-only mode by default.
diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 1b7e7f8..c1b45d4 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -311,6 +311,7 @@ static struct {
 
 static struct {
u16 hotkey_mask_ff:1;
+   u16 volume_ctrl_forbidden:1;
 } tp_warned;
 
 struct thinkpad_id_data {
@@ -6429,6 +6430,7 @@ static enum tpacpi_volume_access_mode volume_mode =
TPACPI_VOL_MODE_MAX;
 
 static enum tpacpi_volume_capabilities volume_capabilities;
+static int volume_control_allowed;
 
 /*
  * Used to syncronize writers to TP_EC_AUDIO and
@@ -6444,6 +6446,8 @@ static void tpacpi_volume_checkpoint_nvram(void)
 
if (volume_mode != TPACPI_VOL_MODE_ECNVRAM)
return;
+   if (!volume_control_allowed)
+   return;
 
vdbg_printk(TPACPI_DBG_MIXER,
"trying to checkpoint mixer state to NVRAM...\n");
@@ -6686,6 +6690,12 @@ static int __init volume_init(struct ibm_init_struct 
*iibm)
"mute is supported, volume control is %s\n",
str_supported(!tp_features.mixer_no_level_control));
 
+   printk(TPACPI_INFO
+   "Console audio control enabled, mode: %s\n",
+   (volume_control_allowed) ?
+   "override (read/write)" :
+   "monitor (read only)");
+
return 0;
 }
 
@@ -6706,11 +6716,16 @@ static int volume_read(char *p)
len += sprintf(p + len, "mute:\t\t%s\n",
onoff(status, TP_EC_AUDIO_MUTESW));
 
-   len += sprintf(p + len, "commands:\tunmute, mute\n");
-   if (!tp_features.mixer_no_level_control) {
-   len += sprintf(p + len, "commands:\tup, down\n");
-   len += sprintf(p + len, "commands:\tlevel "
-  " ( is 0-%d)\n", TP_EC_VOLUME_MAX);
+   if (volume_control_allowed) {
+   len += sprintf(p + len, "commands:\tunmute, mute\n");
+   if (!tp_features.mixer_no_level_control) {
+   len += sprintf(p + 

[ibm-acpi-devel] [PATCH 2/4] thinkpad-acpi: support MUTE-only ThinkPads

2009-12-08 Thread Henrique de Moraes Holschuh
Lenovo removed the extra mixer since the T61 and thereabouts.
Newer Lenovo models only have the mute gate function, and leave
the volume control to the HDA mixer.

Until a way to automatically query the firmware about its audio
control capabilities is discovered (there might not be any), use a
white/black list.

We will likely need to ask T60 (old and new model) and Z60/Z61 users
whether they have volume control to populate the black/white list.
Meanwhile, provide a volume_capabilities parameter that can be used to
override the defaults.

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Lorne Applebaum 
Cc: Matthew Garrett 
---
 Documentation/laptops/thinkpad-acpi.txt |   19 -
 drivers/platform/x86/thinkpad_acpi.c|  159 +-
 2 files changed, 149 insertions(+), 29 deletions(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt 
b/Documentation/laptops/thinkpad-acpi.txt
index 96687d0..bd87682 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1098,18 +1098,31 @@ Volume control
 procfs: /proc/acpi/ibm/volume
 
 This feature allows volume control on ThinkPad models with a digital
-volume knob, as well as mute/unmute control.  The available commands are:
+volume knob (when available, not all models have it), as well as
+mute/unmute control.  The available commands are:
 
echo up   >/proc/acpi/ibm/volume
echo down >/proc/acpi/ibm/volume
echo mute >/proc/acpi/ibm/volume
+   echo unmute >/proc/acpi/ibm/volume
echo 'level ' >/proc/acpi/ibm/volume
 
 The  number range is 0 to 14 although not all of them may be
 distinct. The unmute the volume after the mute command, use either the
-up or down command (the level command will not unmute the volume).
+up or down command (the level command will not unmute the volume), or
+the unmute command.
+
 The current volume level and mute state is shown in the file.
 
+You can use the volume_capabilities parameter to tell the driver
+whether your thinkpad has volume control or mute-only control:
+volume_capabilities=1 for mixers with mute and volume control,
+volume_capabilities=2 for mixers with only mute control.
+
+If the driver misdetects the capabilities for your ThinkPad model,
+please report this to ibm-acpi-devel@lists.sourceforge.net, so that we
+can update the driver.
+
 There are two strategies for volume control.  To select which one
 should be used, use the volume_mode module parameter: volume_mode=1
 selects EC mode, and volume_mode=3 selects EC mode with NVRAM backing
@@ -1450,3 +1463,5 @@ Sysfs interface changelog:
is deprecated and marked for removal.
 
 0x020600:  Marker for backlight change event support.
+
+0x020700:  Support for mute-only mixers.
diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index c7400b4..1b7e7f8 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -22,7 +22,7 @@
  */
 
 #define TPACPI_VERSION "0.23"
-#define TPACPI_SYSFS_VERSION 0x020600
+#define TPACPI_SYSFS_VERSION 0x020700
 
 /*
  *  Changelog:
@@ -299,6 +299,7 @@ static struct {
u32 fan_ctrl_status_undef:1;
u32 second_fan:1;
u32 beep_needs_two_args:1;
+   u32 mixer_no_level_control:1;
u32 input_device_registered:1;
u32 platform_drv_registered:1;
u32 platform_drv_attrs_registered:1;
@@ -426,6 +427,12 @@ static void tpacpi_log_usertask(const char * const what)
  .ec = TPACPI_MATCH_ANY,   \
  .quirks = (__quirk) }
 
+#define TPACPI_QEC_LNV(__id1, __id2, __quirk)  \
+   { .vendor = PCI_VENDOR_ID_LENOVO,   \
+ .bios = TPACPI_MATCH_ANY, \
+ .ec = TPID(__id1, __id2), \
+ .quirks = (__quirk) }
+
 struct tpacpi_quirk {
unsigned int vendor;
u16 bios;
@@ -6411,9 +6418,17 @@ enum tpacpi_volume_access_mode {
TPACPI_VOL_MODE_MAX
 };
 
+enum tpacpi_volume_capabilities {
+   TPACPI_VOL_CAP_AUTO = 0,/* Use white/blacklist */
+   TPACPI_VOL_CAP_VOLMUTE, /* Output vol and mute */
+   TPACPI_VOL_CAP_MUTEONLY,/* Output mute only */
+   TPACPI_VOL_CAP_MAX
+};
+
 static enum tpacpi_volume_access_mode volume_mode =
TPACPI_VOL_MODE_MAX;
 
+static enum tpacpi_volume_capabilities volume_capabilities;
 
 /*
  * Used to syncronize writers to TP_EC_AUDIO and
@@ -6425,7 +6440,7 @@ static void tpacpi_volume_checkpoint_nvram(void)
 {
u8 lec = 0;
u8 b_nvram;
-   const u8 ec_mask = TP_EC_AUDIO_LVL_MSK | TP_EC_AUDIO_MUTESW_MSK;
+   u8 ec_mask;
 
if (volume_mode != TPACPI_VOL_MODE_ECNVRAM)
return;
@@ -6433,6 +6448,11 @@ static void tpacpi_volume_checkpoint_nvram(void)
vdbg_printk(TPACPI_DBG_MIXER,
"trying to checkpoint mixer state to NVRAM...\n");
 
+   if (tp_features.mixer_no_level_control)
+   ec_ma

[ibm-acpi-devel] [PATCH 1/4] thinkpad-acpi: volume subdriver rewrite

2009-12-08 Thread Henrique de Moraes Holschuh
I don't trust the coupled EC writes and SMI calls the current volume
control code does very much, although it is exactly what the IBM DSDTs
seem to do (they never do more than a single step though).

Change the driver to stop issuing SMIs, and just drive the EC directly
to the desired level (DSDTs seem to confirm this will work even on
very old models like the 570 and 600e/x).

We checkpoint directly to NVRAM (this can be turned off) at
suspend/shutdown/driver unload, which from what I can see in tbp,
should also work on every ThinkPad.

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Lorne Applebaum 
Cc: Matthew Garrett 
---
 Documentation/laptops/thinkpad-acpi.txt |   22 ++-
 drivers/platform/x86/thinkpad_acpi.c|  340 +--
 2 files changed, 299 insertions(+), 63 deletions(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt 
b/Documentation/laptops/thinkpad-acpi.txt
index f5056c7..96687d0 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1092,22 +1092,33 @@ WARNING:
 its level up and down at every change.
 
 
-Volume control -- /proc/acpi/ibm/volume

+Volume control
+--
+
+procfs: /proc/acpi/ibm/volume
 
-This feature allows volume control on ThinkPad models which don't have
-a hardware volume knob. The available commands are:
+This feature allows volume control on ThinkPad models with a digital
+volume knob, as well as mute/unmute control.  The available commands are:
 
echo up   >/proc/acpi/ibm/volume
echo down >/proc/acpi/ibm/volume
echo mute >/proc/acpi/ibm/volume
echo 'level ' >/proc/acpi/ibm/volume
 
-The  number range is 0 to 15 although not all of them may be
+The  number range is 0 to 14 although not all of them may be
 distinct. The unmute the volume after the mute command, use either the
 up or down command (the level command will not unmute the volume).
 The current volume level and mute state is shown in the file.
 
+There are two strategies for volume control.  To select which one
+should be used, use the volume_mode module parameter: volume_mode=1
+selects EC mode, and volume_mode=3 selects EC mode with NVRAM backing
+(so that volume/mute changes are remembered across shutdown/reboot).
+
+The driver will operate in volume_mode=3 by default. If that does not
+work well on your ThinkPad model, please report this to
+ibm-acpi-de...@lists.sourceforge.net.
+
 The ALSA mixer interface to this feature is still missing, but patches
 to add it exist.  That problem should be addressed in the not so
 distant future.
@@ -1376,6 +1387,7 @@ to enable more than one output class, just add their 
values.
0x0008  HKEY event interface, hotkeys
0x0010  Fan control
0x0020  Backlight brightness
+   0x0040  Audio mixer/volume control
 
 There is also a kernel build option to enable more debugging
 information, which may be necessary to debug driver problems.
diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index e7ff6c7..c7400b4 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -231,6 +231,7 @@ enum tpacpi_hkey_event_t {
 #define TPACPI_DBG_HKEY0x0008
 #define TPACPI_DBG_FAN 0x0010
 #define TPACPI_DBG_BRGHT   0x0020
+#define TPACPI_DBG_MIXER   0x0040
 
 #define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
 #define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -6370,21 +6371,260 @@ static struct ibm_struct brightness_driver_data = {
  * Volume subdriver
  */
 
-static int volume_offset = 0x30;
+/*
+ * IBM ThinkPads have a simple volume controller with MUTE gating.
+ * Very early Lenovo ThinkPads follow the IBM ThinkPad spec.
+ *
+ * Since the *61 series (and probably also the later *60 series), Lenovo
+ * ThinkPads only implement the MUTE gate.
+ *
+ * EC register 0x30
+ *   Bit 6: MUTE (1 mutes sound)
+ *   Bit 3-0: Volume
+ *   Other bits should be zero as far as we know.
+ *
+ * This is also stored in CMOS NVRAM, byte 0x60, bit 6 (MUTE), and
+ * bits 3-0 (volume).  Other bits in NVRAM may have other functions,
+ * such as bit 7 which is used to detect repeated presses of MUTE,
+ * and we leave them unchanged.
+ */
+
+enum {
+   TP_EC_AUDIO = 0x30,
+
+   /* TP_EC_AUDIO bits */
+   TP_EC_AUDIO_MUTESW = 6,
+
+   /* TP_EC_AUDIO bitmasks */
+   TP_EC_AUDIO_LVL_MSK = 0x0F,
+   TP_EC_AUDIO_MUTESW_MSK = (1 << TP_EC_AUDIO_MUTESW),
+
+   /* Maximum volume */
+   TP_EC_VOLUME_MAX = 14,
+};
+
+enum tpacpi_volume_access_mode {
+   TPACPI_VOL_MODE_AUTO = 0,   /* Not implemented yet */
+   TPACPI_VOL_MODE_EC, /* Pure EC control */
+   TPACPI_VOL_MODE_UCMS_STEP,  /* UCMS step-based control: N/A */
+   TPACPI_VOL_MODE_ECNVRAM,/* 

[ibm-acpi-devel] [RFC] thinkpad-acpi volume subdriver rework

2009-12-08 Thread Henrique de Moraes Holschuh
This patchset shoud be applied on top of the first set I just sent to
the mailinglists.   It has seen some testing on 2.6.31.7.

It contains the volume subdriver rewrite, and the basic ALSA mixer
support.  Thanks to Lorne Applebaum and Matthew Garrett for doing much
of the grunt work.

Comments?  I'd like to submit it to Len during this merge window...


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 08/10] thinkpad-acpi: log temperatures on termal alarm (v2)

2009-12-08 Thread Henrique de Moraes Holschuh
Log temperatures on any of the EC thermal alarms.  It could be
useful to help tracking down what is happening...

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Pavel Machek 
---
 drivers/platform/x86/thinkpad_acpi.c |   57 ++---
 1 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 4b96a96..b3e256b 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3546,49 +3546,57 @@ static bool hotkey_notify_usrevent(const u32 hkey,
}
 }
 
+static void thermal_dump_all_sensors(void);
+
 static bool hotkey_notify_thermal(const u32 hkey,
 bool *send_acpi_ev,
 bool *ignore_acpi_ev)
 {
+   bool known = true;
+
/* 0x6000-0x6FFF: thermal alarms */
*send_acpi_ev = true;
*ignore_acpi_ev = false;
 
switch (hkey) {
+   case TP_HKEY_EV_THM_TABLE_CHANGED:
+   printk(TPACPI_INFO
+   "EC reports that Thermal Table has changed\n");
+   /* recommended action: do nothing, we don't have
+* Lenovo ATM information */
+   return true;
case TP_HKEY_EV_ALARM_BAT_HOT:
printk(TPACPI_CRIT
"THERMAL ALARM: battery is too hot!\n");
/* recommended action: warn user through gui */
-   return true;
+   break;
case TP_HKEY_EV_ALARM_BAT_XHOT:
printk(TPACPI_ALERT
"THERMAL EMERGENCY: battery is extremely hot!\n");
/* recommended action: immediate sleep/hibernate */
-   return true;
+   break;
case TP_HKEY_EV_ALARM_SENSOR_HOT:
printk(TPACPI_CRIT
"THERMAL ALARM: "
"a sensor reports something is too hot!\n");
/* recommended action: warn user through gui, that */
/* some internal component is too hot */
-   return true;
+   break;
case TP_HKEY_EV_ALARM_SENSOR_XHOT:
printk(TPACPI_ALERT
"THERMAL EMERGENCY: "
"a sensor reports something is extremely hot!\n");
/* recommended action: immediate sleep/hibernate */
-   return true;
-   case TP_HKEY_EV_THM_TABLE_CHANGED:
-   printk(TPACPI_INFO
-   "EC reports that Thermal Table has changed\n");
-   /* recommended action: do nothing, we don't have
-* Lenovo ATM information */
-   return true;
+   break;
default:
printk(TPACPI_ALERT
 "THERMAL ALERT: unknown thermal alarm received\n");
-   return false;
+   known = false;
}
+
+   thermal_dump_all_sensors();
+
+   return known;
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -5462,8 +5470,11 @@ enum { /* TPACPI_THERMAL_TPEC_* */
TP_EC_THERMAL_TMP0 = 0x78,  /* ACPI EC regs TMP 0..7 */
TP_EC_THERMAL_TMP8 = 0xC0,  /* ACPI EC regs TMP 8..15 */
TP_EC_THERMAL_TMP_NA = -128,/* ACPI EC sensor not available */
+
+   TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
 };
 
+
 #define TPACPI_MAX_THERMAL_SENSORS 16  /* Max thermal sensors supported */
 struct ibm_thermal_sensors_struct {
s32 temp[TPACPI_MAX_THERMAL_SENSORS];
@@ -5553,6 +5564,28 @@ static int thermal_get_sensors(struct 
ibm_thermal_sensors_struct *s)
return n;
 }
 
+static void thermal_dump_all_sensors(void)
+{
+   int n, i;
+   struct ibm_thermal_sensors_struct t;
+
+   n = thermal_get_sensors(&t);
+   if (n <= 0)
+   return;
+
+   printk(TPACPI_NOTICE
+   "temperatures (Celsius):");
+
+   for (i = 0; i < n; i++) {
+   if (t.temp[i] != TPACPI_THERMAL_SENSOR_NA)
+   printk(KERN_CONT " %d", (int)(t.temp[i] / 1000));
+   else
+   printk(KERN_CONT " N/A");
+   }
+
+   printk(KERN_CONT "\n");
+}
+
 /* sysfs temp##_input -- */
 
 static ssize_t thermal_temp_input_show(struct device *dev,
@@ -5568,7 +5601,7 @@ static ssize_t thermal_temp_input_show(struct device *dev,
res = thermal_get_sensor(idx, &value);
if (res)
return res;
-   if (value == TP_EC_THERMAL_TMP_NA * 1000)
+   if (value == TPACPI_THERMAL_SENSOR_NA)
return -ENXIO;
 
return snprintf(buf, PAGE_SIZE, "%d\n", value);
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_

[ibm-acpi-devel] [PATCH 09/10] thinkpad-acpi: use input_set_capability

2009-12-08 Thread Henrique de Moraes Holschuh
Use input_set_capability() instead of set_bit.

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Dmitry Torokhov 
---
 drivers/platform/x86/thinkpad_acpi.c |   14 +-
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index b3e256b..53d6c33 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3348,16 +3348,14 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
TPACPI_HOTKEY_MAP_SIZE);
}
 
-   set_bit(EV_KEY, tpacpi_inputdev->evbit);
-   set_bit(EV_MSC, tpacpi_inputdev->evbit);
-   set_bit(MSC_SCAN, tpacpi_inputdev->mscbit);
+   input_set_capability(tpacpi_inputdev, EV_MSC, MSC_SCAN);
tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE;
tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN;
tpacpi_inputdev->keycode = hotkey_keycode_map;
for (i = 0; i < TPACPI_HOTKEY_MAP_LEN; i++) {
if (hotkey_keycode_map[i] != KEY_RESERVED) {
-   set_bit(hotkey_keycode_map[i],
-   tpacpi_inputdev->keybit);
+   input_set_capability(tpacpi_inputdev, EV_KEY,
+   hotkey_keycode_map[i]);
} else {
if (i < sizeof(hotkey_reserved_mask)*8)
hotkey_reserved_mask |= 1 << i;
@@ -3365,12 +3363,10 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
}
 
if (tp_features.hotkey_wlsw) {
-   set_bit(EV_SW, tpacpi_inputdev->evbit);
-   set_bit(SW_RFKILL_ALL, tpacpi_inputdev->swbit);
+   input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
}
if (tp_features.hotkey_tablet) {
-   set_bit(EV_SW, tpacpi_inputdev->evbit);
-   set_bit(SW_TABLET_MODE, tpacpi_inputdev->swbit);
+   input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
}
 
/* Do not issue duplicate brightness change events to
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 10/10] thinkpad-acpi: sync input device EV_SW state directly

2009-12-08 Thread Henrique de Moraes Holschuh
Before we register the input device, sync the input layer EV_SW state
directly by setting the bitmaps, to avoid issuing a gratuitous event
for the initial state of these switches.

I will propose a clean input layer API for this and change the driver
to use it later, but I'd rather get the driver fix in mainline ASAP.

This fixes some annoyances caused by the interaction with rfkill and
EV_SW SW_RFKILL_ALL events.

Reported-by: Kevin Locke 
Signed-off-by: Henrique de Moraes Holschuh 
Cc: Alan Jenkins 
Cc: Johannes Berg 
Cc: Dmitry Torokhov 
---
 drivers/platform/x86/thinkpad_acpi.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 53d6c33..e7ff6c7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3186,6 +3186,8 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
int res, i;
int status;
int hkeyv;
+   bool radiosw_state  = false;
+   bool tabletsw_state = false;
 
unsigned long quirks;
 
@@ -3291,6 +3293,7 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
if (dbg_wlswemul) {
tp_features.hotkey_wlsw = 1;
+   radiosw_state = !!tpacpi_wlsw_emulstate;
printk(TPACPI_INFO
"radio switch emulation enabled\n");
} else
@@ -3298,6 +3301,7 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
/* Not all thinkpads have a hardware radio switch */
if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
tp_features.hotkey_wlsw = 1;
+   radiosw_state = !!status;
printk(TPACPI_INFO
"radio switch found; radios are %s\n",
enabled(status, 0));
@@ -3309,11 +3313,11 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
/* For X41t, X60t, X61t Tablets... */
if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) {
tp_features.hotkey_tablet = 1;
+   tabletsw_state = !!(status & TP_HOTKEY_TABLET_MASK);
printk(TPACPI_INFO
"possible tablet mode switch found; "
"ThinkPad in %s mode\n",
-   (status & TP_HOTKEY_TABLET_MASK)?
-   "tablet" : "laptop");
+   (tabletsw_state) ? "tablet" : "laptop");
res = add_to_attr_set(hotkey_dev_attributes,
&dev_attr_hotkey_tablet_mode.attr);
}
@@ -3364,9 +3368,13 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
 
if (tp_features.hotkey_wlsw) {
input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
+   if (radiosw_state)
+   __set_bit(SW_RFKILL_ALL, tpacpi_inputdev->sw);
}
if (tp_features.hotkey_tablet) {
input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
+   if (tabletsw_state)
+   __set_bit(SW_TABLET_MODE, tpacpi_inputdev->sw);
}
 
/* Do not issue duplicate brightness change events to
@@ -3433,8 +3441,6 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
tpacpi_inputdev->close = &hotkey_inputdev_close;
 
hotkey_poll_setup_safe(true);
-   tpacpi_send_radiosw_update();
-   tpacpi_input_send_tabletsw();
 
return 0;
 
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 06/10] thinkpad-acpi: adopt input device

2009-12-08 Thread Henrique de Moraes Holschuh
Properly init the parent field of the input device.  Thanks to Alan
Jenkins, who noted this problem in a different driver.

Reported-by: Alan Jenkins 
Signed-off-by: Henrique de Moraes Holschuh 
---
 drivers/platform/x86/thinkpad_acpi.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 86418cd..dd8bd07 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8375,6 +8375,7 @@ static int __init thinkpad_acpi_module_init(void)
PCI_VENDOR_ID_IBM;
tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
+   tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev;
}
for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
ret = ibm_init(&ibms_init[i]);
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 04/10] thinkpad-acpi: issue backlight class events

2009-12-08 Thread Henrique de Moraes Holschuh
Take advantage of the new events capabilities of the backlight class to
notify userspace of backlight changes.

This depends on "backlight: Allow drivers to update the core, and
generate events on changes", by Matthew Garrett.

Signed-off-by: Henrique de Moraes Holschuh 
Cc: Matthew Garrett 
Cc: Richard Purdie 
---
 Documentation/laptops/thinkpad-acpi.txt |   51 +++---
 drivers/platform/x86/thinkpad_acpi.c|   24 ++-
 2 files changed, 35 insertions(+), 40 deletions(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt 
b/Documentation/laptops/thinkpad-acpi.txt
index aafcaa6..f5056c7 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -460,6 +460,8 @@ event   codeKey Notes
For Lenovo ThinkPads with a new
BIOS, it has to be handled either
by the ACPI OSI, or by userspace.
+   The driver does the right thing,
+   never mess with this.
 0x1011 0x10FN+END  Brightness down.  See brightness
up for details.
 
@@ -582,46 +584,15 @@ with hotkey_report_mode.
 
 Brightness hotkey notes:
 
-These are the current sane choices for brightness key mapping in
-thinkpad-acpi:
+Don't mess with the brightness hotkeys in a Thinkpad.  If you want
+notifications for OSD, use the sysfs backlight class event support.
 
-For IBM and Lenovo models *without* ACPI backlight control (the ones on
-which thinkpad-acpi will autoload its backlight interface by default,
-and on which ACPI video does not export a backlight interface):
-
-1. Don't enable or map the brightness hotkeys in thinkpad-acpi, as
-   these older firmware versions unfortunately won't respect the hotkey
-   mask for brightness keys anyway, and always reacts to them.  This
-   usually work fine, unless X.org drivers are doing something to block
-   the BIOS.  In that case, use (3) below.  This is the default mode of
-   operation.
-
-2. Enable the hotkeys, but map them to something else that is NOT
-   KEY_BRIGHTNESS_UP/DOWN or any other keycode that would cause
-   userspace to try to change the backlight level, and use that as an
-   on-screen-display hint.
-
-3. IF AND ONLY IF X.org drivers find a way to block the firmware from
-   automatically changing the brightness, enable the hotkeys and map
-   them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN, and feed that to
-   something that calls xbacklight.  thinkpad-acpi will not be able to
-   change brightness in that case either, so you should disable its
-   backlight interface.
-
-For Lenovo models *with* ACPI backlight control:
-
-1. Load up ACPI video and use that.  ACPI video will report ACPI
-   events for brightness change keys.  Do not mess with thinkpad-acpi
-   defaults in this case.  thinkpad-acpi should not have anything to do
-   with backlight events in a scenario where ACPI video is loaded:
-   brightness hotkeys must be disabled, and the backlight interface is
-   to be kept disabled as well.  This is the default mode of operation.
-
-2. Do *NOT* load up ACPI video, enable the hotkeys in thinkpad-acpi,
-   and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN.  Process
-   these keys on userspace somehow (e.g. by calling xbacklight).
-   The driver will do this automatically if it detects that ACPI video
-   has been disabled.
+The driver will issue KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN events
+automatically for the cases were userspace has to do something to
+implement brightness changes.  When you override these events, you will
+either fail to handle properly the ThinkPads that require explicit
+action to change backlight brightness, or the ThinkPads that require
+that no action be taken to work properly.
 
 
 Bluetooth
@@ -1465,3 +1436,5 @@ Sysfs interface changelog:
and it is always able to disable hot keys.  Very old
thinkpads are properly supported.  hotkey_bios_mask
is deprecated and marked for removal.
+
+0x020600:  Marker for backlight change event support.
diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 6160813..4406136 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -22,7 +22,7 @@
  */
 
 #define TPACPI_VERSION "0.23"
-#define TPACPI_SYSFS_VERSION 0x020500
+#define TPACPI_SYSFS_VERSION 0x020600
 
 /*
  *  Changelog:
@@ -6073,6 +6073,12 @@ static int brightness_get(struct backlight_device *bd)
return status & TP_EC_BACKLIGHT_LVLMSK;
 }
 
+static void tpacpi_brightness_notify_change(void)
+{
+   backlight_force_update(ibm_backlight_device,
+  BACKLIGHT_UPDATE_HOTKEY);
+}
+
 static struct backlight_ops ibm_backlight_data = {
.get_brightness = brightness_get,
.update_status  = brightne

[ibm-acpi-devel] [PATCH 02/10] thinkpad-acpi: preserve rfkill state across suspend/resume

2009-12-08 Thread Henrique de Moraes Holschuh
Since the rfkill rework in 2.6.31, the driver is always resuming with
the radios disabled.

Change thinkpad-acpi to ask the firmware to resume with the radios in
the last state.  This fixes the Bluetooth and WWAN rfkill switches.

Note that it means we respect the firmware's oddities.  Should the
user toggle the hardware rfkill switch on and off, it might cause the
radios to resume enabled.

UWB is an unknown quantity since it has nowhere the same level of
firmware support (no control over state storage in NVRAM, for
example), and might need further fixing.  Testers welcome.

This change fixes a regression from 2.6.30.

Reported-by: Jerone Young 
Reported-by: Ian Molton 
Signed-off-by: Henrique de Moraes Holschuh 
Tested-by: Ian Molton 
Cc: sta...@kernel.org
---
 drivers/platform/x86/thinkpad_acpi.c |   32 +---
 1 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index 9c6d5a9..1ee734c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3866,15 +3866,6 @@ enum {
 
 #define TPACPI_RFK_BLUETOOTH_SW_NAME   "tpacpi_bluetooth_sw"
 
-static void bluetooth_suspend(pm_message_t state)
-{
-   /* Try to make sure radio will resume powered off */
-   if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
-  TP_ACPI_BLTH_PWR_OFF_ON_RESUME))
-   vdbg_printk(TPACPI_DBG_RFKILL,
-   "bluetooth power down on resume request failed\n");
-}
-
 static int bluetooth_get_status(void)
 {
int status;
@@ -3908,10 +3899,9 @@ static int bluetooth_set_status(enum tpacpi_rfkill_state 
state)
 #endif
 
/* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
+   status = TP_ACPI_BLUETOOTH_RESUMECTRL;
if (state == TPACPI_RFK_RADIO_ON)
-   status = TP_ACPI_BLUETOOTH_RADIOSSW;
-   else
-   status = 0;
+   status |= TP_ACPI_BLUETOOTH_RADIOSSW;
 
if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
return -EIO;
@@ -4050,7 +4040,6 @@ static struct ibm_struct bluetooth_driver_data = {
.read = bluetooth_read,
.write = bluetooth_write,
.exit = bluetooth_exit,
-   .suspend = bluetooth_suspend,
.shutdown = bluetooth_shutdown,
 };
 
@@ -4068,15 +4057,6 @@ enum {
 
 #define TPACPI_RFK_WWAN_SW_NAME"tpacpi_wwan_sw"
 
-static void wan_suspend(pm_message_t state)
-{
-   /* Try to make sure radio will resume powered off */
-   if (!acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
-  TP_ACPI_WGSV_PWR_OFF_ON_RESUME))
-   vdbg_printk(TPACPI_DBG_RFKILL,
-   "WWAN power down on resume request failed\n");
-}
-
 static int wan_get_status(void)
 {
int status;
@@ -4109,11 +4089,10 @@ static int wan_set_status(enum tpacpi_rfkill_state 
state)
}
 #endif
 
-   /* We make sure to keep TP_ACPI_WANCARD_RESUMECTRL off */
+   /* We make sure to set TP_ACPI_WANCARD_RESUMECTRL */
+   status = TP_ACPI_WANCARD_RESUMECTRL;
if (state == TPACPI_RFK_RADIO_ON)
-   status = TP_ACPI_WANCARD_RADIOSSW;
-   else
-   status = 0;
+   status |= TP_ACPI_WANCARD_RADIOSSW;
 
if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
return -EIO;
@@ -4251,7 +4230,6 @@ static struct ibm_struct wan_driver_data = {
.read = wan_read,
.write = wan_write,
.exit = wan_exit,
-   .suspend = wan_suspend,
.shutdown = wan_shutdown,
 };
 
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[ibm-acpi-devel] [PATCH 07/10] thinkpad-acpi: expose module parameters

2009-12-08 Thread Henrique de Moraes Holschuh
Export the normal (non-command) module paramenters as mode 0444, so
that they will show up in sysfs.

These parameters must not be changed at runtime as a rule, with very
few exceptions.

Reported-by: Ferenc Wagner 
Signed-off-by: Henrique de Moraes Holschuh 
---
 drivers/platform/x86/thinkpad_acpi.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index dd8bd07..4b96a96 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8116,32 +8116,32 @@ static int __init set_ibm_param(const char *val, struct 
kernel_param *kp)
return -EINVAL;
 }
 
-module_param(experimental, int, 0);
+module_param(experimental, int, 0444);
 MODULE_PARM_DESC(experimental,
 "Enables experimental features when non-zero");
 
 module_param_named(debug, dbg_level, uint, 0);
 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
 
-module_param(force_load, bool, 0);
+module_param(force_load, bool, 0444);
 MODULE_PARM_DESC(force_load,
 "Attempts to load the driver even on a "
 "mis-identified ThinkPad when true");
 
-module_param_named(fan_control, fan_control_allowed, bool, 0);
+module_param_named(fan_control, fan_control_allowed, bool, 0444);
 MODULE_PARM_DESC(fan_control,
 "Enables setting fan parameters features when true");
 
-module_param_named(brightness_mode, brightness_mode, uint, 0);
+module_param_named(brightness_mode, brightness_mode, uint, 0444);
 MODULE_PARM_DESC(brightness_mode,
 "Selects brightness control strategy: "
 "0=auto, 1=EC, 2=UCMS, 3=EC+NVRAM");
 
-module_param(brightness_enable, uint, 0);
+module_param(brightness_enable, uint, 0444);
 MODULE_PARM_DESC(brightness_enable,
 "Enables backlight control when 1, disables when 0");
 
-module_param(hotkey_report_mode, uint, 0);
+module_param(hotkey_report_mode, uint, 0444);
 MODULE_PARM_DESC(hotkey_report_mode,
 "used for backwards compatibility with userspace, "
 "see documentation");
@@ -8164,25 +8164,25 @@ TPACPI_PARAM(volume);
 TPACPI_PARAM(fan);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
-module_param(dbg_wlswemul, uint, 0);
+module_param(dbg_wlswemul, uint, 0444);
 MODULE_PARM_DESC(dbg_wlswemul, "Enables WLSW emulation");
 module_param_named(wlsw_state, tpacpi_wlsw_emulstate, bool, 0);
 MODULE_PARM_DESC(wlsw_state,
 "Initial state of the emulated WLSW switch");
 
-module_param(dbg_bluetoothemul, uint, 0);
+module_param(dbg_bluetoothemul, uint, 0444);
 MODULE_PARM_DESC(dbg_bluetoothemul, "Enables bluetooth switch emulation");
 module_param_named(bluetooth_state, tpacpi_bluetooth_emulstate, bool, 0);
 MODULE_PARM_DESC(bluetooth_state,
 "Initial state of the emulated bluetooth switch");
 
-module_param(dbg_wwanemul, uint, 0);
+module_param(dbg_wwanemul, uint, 0444);
 MODULE_PARM_DESC(dbg_wwanemul, "Enables WWAN switch emulation");
 module_param_named(wwan_state, tpacpi_wwan_emulstate, bool, 0);
 MODULE_PARM_DESC(wwan_state,
 "Initial state of the emulated WWAN switch");
 
-module_param(dbg_uwbemul, uint, 0);
+module_param(dbg_uwbemul, uint, 0444);
 MODULE_PARM_DESC(dbg_uwbemul, "Enables UWB switch emulation");
 module_param_named(uwb_state, tpacpi_uwb_emulstate, bool, 0);
 MODULE_PARM_DESC(uwb_state,
-- 
1.6.5.4


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel