thinkpad-acpi: fix brightness hotkey poll handling

Handle multiple brightness hotkey presses between two polling cycles.
Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
上级 77775838
...@@ -2340,6 +2340,21 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, ...@@ -2340,6 +2340,21 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
} }
} }
void issue_brightnesschange(const unsigned int oldbrt,
const unsigned int newbrt)
{
unsigned int i = oldbrt;
while (i > newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
i--;
}
while (i < newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
i++;
}
}
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle); 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,19 +2409,16 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
} }
/* handle brightness */ /* handle brightness */
if (oldn->brightness_toggle != newn->brightness_toggle) { if (oldn->brightness_level != newn->brightness_level) {
if (oldn->brightness_level < newn->brightness_level) { issue_brightnesschange(oldn->brightness_level,
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME); newn->brightness_level);
} else if (oldn->brightness_level > newn->brightness_level) { } else if (oldn->brightness_toggle != newn->brightness_toggle) {
/* repeated key presses that didn't change state */
if (newn->brightness_level == 0)
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
} else { else if (newn->brightness_level >= bright_maxlvl
/* repeated key presses that didn't change state */ && !tp_features.bright_unkfw)
if (newn->brightness_level != 0) { TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
} else {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
}
}
} }
#undef TPACPI_COMPARE_KEY #undef TPACPI_COMPARE_KEY
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册