Only send hotkey SCI if ACPI OS is loaded

This commit is contained in:
Jeremy Soller 2020-09-23 10:52:20 -06:00 committed by Jeremy Soller
parent 343722e350
commit 00043ebfaf
3 changed files with 29 additions and 18 deletions

View File

@ -221,26 +221,32 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
break; break;
case (KT_SCI): case (KT_SCI):
if (pressed) { if (pressed) {
uint8_t sci = (uint8_t)(key & 0xFF); // Send SCI if ACPI OS is loaded
if (acpi_ecos != EC_OS_NONE) {
if (!pmc_sci(&PMC_1, sci)) { uint8_t sci = (uint8_t)(key & 0xFF);
// In the case of ignored SCI, reset bit if (!pmc_sci(&PMC_1, sci)) {
return false; // In the case of ignored SCI, reset bit
return false;
}
} }
// Handle hardware hotkeys
hardware_hotkey(key); hardware_hotkey(key);
} }
break; break;
case (KT_SCI_EXTRA): case (KT_SCI_EXTRA):
if (pressed) { if (pressed) {
uint8_t sci = SCI_EXTRA; // Send SCI if ACPI OS is loaded
sci_extra = (uint8_t)(key & 0xFF); if (acpi_ecos != EC_OS_NONE) {
uint8_t sci = SCI_EXTRA;
if (!pmc_sci(&PMC_1, sci)) { sci_extra = (uint8_t)(key & 0xFF);
// In the case of ignored SCI, reset bit if (!pmc_sci(&PMC_1, sci)) {
return false; // In the case of ignored SCI, reset bit
return false;
}
} }
// Handle hardware hotkeys
hardware_hotkey(key); hardware_hotkey(key);
} }
break; break;

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
#include <arch/delay.h> #include <arch/delay.h>
#include <board/acpi.h>
#include <board/gpio.h> #include <board/gpio.h>
#include <board/lid.h> #include <board/lid.h>
#include <board/pmc.h> #include <board/pmc.h>
@ -33,15 +34,17 @@ void lid_event(void) {
DEBUG("closed\n"); DEBUG("closed\n");
} }
// Send SCI // Send SCI if ACPI OS is loaded
send_sci = true; send_sci = true;
} }
lid_state = new; lid_state = new;
if (send_sci) { if (send_sci) {
// Send SCI 0x1B for lid event // Send SCI 0x1B for lid event if ACPI OS is loaded
if (pmc_sci(&PMC_1, 0x1B)) { if (acpi_ecos != EC_OS_NONE) {
send_sci = false; if (pmc_sci(&PMC_1, 0x1B)) {
send_sci = false;
}
} }
} }
} }

View File

@ -370,9 +370,11 @@ void power_event(void) {
ac_send_sci = true; ac_send_sci = true;
} }
if (ac_send_sci) { if (ac_send_sci) {
// Send SCI 0x16 for AC detect event // Send SCI 0x16 for AC detect event if ACPI OS is loaded
if (pmc_sci(&PMC_1, 0x16)) { if (acpi_ecos != EC_OS_NONE) {
ac_send_sci = false; if (pmc_sci(&PMC_1, 0x16)) {
ac_send_sci = false;
}
} }
} }
ac_last = ac_new; ac_last = ac_new;