Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] suspend_power_down_kb() is never called on ChibiOS platform #16279

Closed
hajimen opened this issue Feb 9, 2022 · 1 comment
Closed

[Bug] suspend_power_down_kb() is never called on ChibiOS platform #16279

hajimen opened this issue Feb 9, 2022 · 1 comment

Comments

@hajimen
Copy link

hajimen commented Feb 9, 2022

I guess suspend_power_down_kb() should be called from suspend_power_down() or suspend_power_down_quantum() but neither on ChibiOS platform.

System Information

Commit e26778c

platforms/chibios/suspend.c:

void suspend_power_down(void) {
    suspend_power_down_quantum();
    // on AVR, this enables the watchdog for 15ms (max), and goes to
    // SLEEP_MODE_PWR_DOWN

    wait_ms(17);
}

quantum/quantum.c:

void suspend_power_down_quantum(void) {
#ifndef NO_SUSPEND_POWER_DOWN
// Turn off backlight
#    ifdef BACKLIGHT_ENABLE
    backlight_set(0);
#    endif

#    ifdef LED_MATRIX_ENABLE
    led_matrix_task();
#    endif
#    ifdef RGB_MATRIX_ENABLE
    rgb_matrix_task();
#    endif

    // Turn off LED indicators
    uint8_t leds_off = 0;
#    if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
    if (is_backlight_enabled()) {
        // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
        leds_off |= (1 << USB_LED_CAPS_LOCK);
    }
#    endif
    led_set(leds_off);

// Turn off audio
#    ifdef AUDIO_ENABLE
    stop_all_notes();
#    endif

// Turn off underglow
#    if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
    rgblight_suspend();
#    endif

#    if defined(LED_MATRIX_ENABLE)
    led_matrix_set_suspend_state(true);
#    endif
#    if defined(RGB_MATRIX_ENABLE)
    rgb_matrix_set_suspend_state(true);
#    endif

#    ifdef OLED_ENABLE
    oled_off();
#    endif
#    ifdef ST7565_ENABLE
    st7565_off();
#    endif
#    if defined(POINTING_DEVICE_ENABLE)
    // run to ensure scanning occurs while suspended
    pointing_device_task();
#    endif
#endif
}

But suspend_wakeup_init_quantum() calls suspend_wakeup_init_kb().

__attribute__((weak)) void suspend_wakeup_init_quantum(void) {
// Turn on backlight
#ifdef BACKLIGHT_ENABLE
    backlight_init();
#endif

    // Restore LED indicators
    led_set(host_keyboard_leds());

// Wake up underglow
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
    rgblight_wakeup();
#endif

#if defined(LED_MATRIX_ENABLE)
    led_matrix_set_suspend_state(false);
#endif
#if defined(RGB_MATRIX_ENABLE)
    rgb_matrix_set_suspend_state(false);
#endif
    suspend_wakeup_init_kb();
}
firetech added a commit to firetech/qmk_firmware that referenced this issue Feb 16, 2022
In qmk#14210, all previous calls to `suspend_power_down_kb()` were replaced
with calls to `suspend_power_down_quantum()`, together with some much
needed deduplication. However, the `_kb` function was never called from
the `_quantum` one (unlike `suspend_power_down_kb()`).

I followed the example of how it was implemented for AVR before qmk#14210,
i.e. called before the rest of the suspend functions, regardless of the
`NO_SUSPEND_POWER_DOWN` setting.

Fixes qmk#16279.
firetech added a commit to firetech/qmk_firmware that referenced this issue Feb 17, 2022
In qmk#14210, all previous calls to `suspend_power_down_kb()` were replaced
with calls to `suspend_power_down_quantum()`, together with some much
needed deduplication. However, the `_kb` function was never called from
the `_quantum` one (unlike `suspend_wakeup_init_kb()`).

I followed the example of how it was implemented for AVR before qmk#14210,
i.e. called before the rest of the suspend functions, regardless of the
`NO_SUSPEND_POWER_DOWN` setting.

Fixes qmk#16279.
@hajimen
Copy link
Author

hajimen commented Feb 21, 2022

Thanks, it looks good.

@hajimen hajimen closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant