diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2010-05-16 18:45:36 -0400 |
---|---|---|
committer | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2010-05-16 18:45:36 -0400 |
commit | 289990228155cbc58a35c1b266af00f387caa595 (patch) | |
tree | 4d65cbdb02e2032b6a71378deb908eb166b31633 /drivers/platform | |
parent | 77775838bb76173d7a1ed28f75dfe388962aceca (diff) |
thinkpad-acpi: fix brightness hotkey poll handling
Handle multiple brightness hotkey presses between two polling cycles.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index b03bf5153b0f..fa412a43f5e0 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -2340,6 +2340,21 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, | |||
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | 2342 | ||
2343 | void issue_brightnesschange(const unsigned int oldbrt, | ||
2344 | const unsigned int newbrt) | ||
2345 | { | ||
2346 | unsigned int i = oldbrt; | ||
2347 | |||
2348 | while (i > newbrt) { | ||
2349 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); | ||
2350 | i--; | ||
2351 | } | ||
2352 | while (i < newbrt) { | ||
2353 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME); | ||
2354 | i++; | ||
2355 | } | ||
2356 | } | ||
2357 | |||
2343 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); | 2358 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); |
2344 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); | 2359 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); |
2345 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle); | 2360 | TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle); |
@@ -2394,19 +2409,16 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, | |||
2394 | } | 2409 | } |
2395 | 2410 | ||
2396 | /* handle brightness */ | 2411 | /* handle brightness */ |
2397 | if (oldn->brightness_toggle != newn->brightness_toggle) { | 2412 | if (oldn->brightness_level != newn->brightness_level) { |
2398 | if (oldn->brightness_level < newn->brightness_level) { | 2413 | issue_brightnesschange(oldn->brightness_level, |
2399 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME); | 2414 | newn->brightness_level); |
2400 | } else if (oldn->brightness_level > newn->brightness_level) { | 2415 | } else if (oldn->brightness_toggle != newn->brightness_toggle) { |
2416 | /* repeated key presses that didn't change state */ | ||
2417 | if (newn->brightness_level == 0) | ||
2401 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); | 2418 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); |
2402 | } else { | 2419 | else if (newn->brightness_level >= bright_maxlvl |
2403 | /* repeated key presses that didn't change state */ | 2420 | && !tp_features.bright_unkfw) |
2404 | if (newn->brightness_level != 0) { | 2421 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME); |
2405 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME); | ||
2406 | } else { | ||
2407 | TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); | ||
2408 | } | ||
2409 | } | ||
2410 | } | 2422 | } |
2411 | 2423 | ||
2412 | #undef TPACPI_COMPARE_KEY | 2424 | #undef TPACPI_COMPARE_KEY |