Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197545
b: refs/heads/master
c: 5d756db
h: refs/heads/master
i:
  197543: f47e5ed
v: v3
  • Loading branch information
Henrique de Moraes Holschuh committed May 16, 2010
1 parent 63985f0 commit 82fb306
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a318930d06a7a93bd50000c7112f995b459adda7
refs/heads/master: 5d756db99a7382d5cd173e912d527e9ee73d0596
71 changes: 57 additions & 14 deletions trunk/drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ enum {
TP_NVRAM_POS_LEVEL_VOLUME = 0,
};

/* Misc NVRAM-related */
enum {
TP_NVRAM_LEVEL_VOLUME_MAX = 14,
};

/* ACPI HIDs */
#define TPACPI_ACPI_HKEY_HID "IBM0068"

Expand Down Expand Up @@ -2418,6 +2423,21 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
tpacpi_hotkey_send_key(__scancode); \
} while (0)

void issue_volchange(const unsigned int oldvol,
const unsigned int newvol)
{
unsigned int i = oldvol;

while (i > newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
i--;
}
while (i < newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
i++;
}
}

TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
Expand All @@ -2427,24 +2447,47 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,

TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF8, displayexp_toggle);

/* handle volume */
if (oldn->volume_toggle != newn->volume_toggle) {
if (oldn->mute != newn->mute) {
/*
* Handle volume
*
* This code is supposed to duplicate the IBM firmware behaviour:
* - Pressing MUTE issues mute hotkey message, even when already mute
* - Pressing Volume up/down issues volume up/down hotkey messages,
* even when already at maximum or minumum volume
* - The act of unmuting issues volume up/down notification,
* depending which key was used to unmute
*
* We are constrained to what the NVRAM can tell us, which is not much
* and certainly not enough if more than one volume hotkey was pressed
* since the last poll cycle.
*
* Just to make our life interesting, some newer Lenovo ThinkPads have
* bugs in the BIOS and may fail to update volume_toggle properly.
*/
if (newn->mute) {
/* muted */
if (!oldn->mute ||
oldn->volume_toggle != newn->volume_toggle ||
oldn->volume_level != newn->volume_level) {
/* recently muted, or repeated mute keypress, or
* multiple presses ending in mute */
issue_volchange(oldn->volume_level, newn->volume_level);
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
}
if (oldn->volume_level > newn->volume_level) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
} else if (oldn->volume_level < newn->volume_level) {
} else {
/* unmute */
if (oldn->mute) {
/* recently unmuted, issue 'unmute' keypress */
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
} else if (oldn->mute == newn->mute) {
/* repeated key presses that didn't change state */
if (newn->mute) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
} else if (newn->volume_level != 0) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
} else {
}
if (oldn->volume_level != newn->volume_level) {
issue_volchange(oldn->volume_level, newn->volume_level);
} else if (oldn->volume_toggle != newn->volume_toggle) {
/* repeated vol up/down keypress at end of scale ? */
if (newn->volume_level == 0)
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
}
else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX)
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
}
}

Expand Down

0 comments on commit 82fb306

Please sign in to comment.