thinkpad-acpi: fix volume/mute hotkey poll handling
commit313c2afa9acda9221d2ce259cbabd6fe0f9564a1
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Fri, 27 May 2011 01:50:57 +0000 (26 22:50 -0300)
committerHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Fri, 27 May 2011 01:50:57 +0000 (26 22:50 -0300)
treefe347310f1ec93299e1647762453f1469836aeef
parentbc9a6644d953919d9d62c5a0e5bd40b18c130b7e
thinkpad-acpi: fix volume/mute hotkey poll handling

The hotkey polling code is supposed to generate hotkey messages as
close to the way the IBM event-based volume hotkey firmware does as
possible, i.e:

* Pressing MUTE issues a mute hotkey event, even if already mute;

* Pressing Volume up/down issues a volume up/down hotkey event,
  even if already at maximum or minumum volume;

* The act of unmuting issues a volume up/down event, depending on
  which hotkey was used to unmute.

Fix the code to do just that (mute handling was incorrect), and handle
multiple hotkey presses between two polling cycles.

The new code uses the volume_toggle bit in NVRAM only to detect
repeated presses of the mute key and multiple presses of the volume
keys trying to go past the end of the volume scale.  This will work
around a bug in recent Lenovo firmware (e.g. T400), which causes the
firmware to not update the volume_toggle bit in certain situations.

Reported-by: Yang Zhe <yangzhe1990@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
drivers/platform/x86/thinkpad_acpi.c