Skip to content

Commit

Permalink
Merge pull request #17 from flukejones/6.9/chimeraos
Browse files Browse the repository at this point in the history
6.9/chimeraos - ROG Ally Sleep
  • Loading branch information
NeroReflex authored Aug 28, 2024
2 parents f1de1b2 + 08952ed commit 41a9a35
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions drivers/acpi/x86/s2idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/dmi.h>
#include <linux/power_supply.h>
#include <linux/suspend.h>

#include "../sleep.h"
Expand Down Expand Up @@ -53,13 +54,15 @@ static const struct acpi_device_id lps0_device_ids[] = {
#define ACPI_LPS0_SCREEN_OFF_AMD 4
#define ACPI_LPS0_SCREEN_ON_AMD 5

static struct acpi_device *lps0_device;
static acpi_handle lps0_device_handle;
static guid_t lps0_dsm_guid;
static int lps0_dsm_func_mask;

static guid_t lps0_dsm_guid_microsoft;
static int lps0_dsm_func_mask_microsoft;
static int lps0_dsm_state;
static int lps0_ac_state;

/* Device constraint entry structure */
struct lpi_device_info {
Expand Down Expand Up @@ -507,6 +510,8 @@ static int lps0_device_attach(struct acpi_device *adev,
return 0; //function evaluation failed

lps0_device_handle = adev->handle;
lps0_device = adev;
device_set_wakeup_capable(&adev->dev, true);

if (acpi_s2idle_vendor_amd())
lpi_device_get_constraints_amd();
Expand Down Expand Up @@ -605,6 +610,9 @@ int acpi_s2idle_prepare_late(void)
if (pm_debug_messages_on)
lpi_check_constraints();

/* capture AC adapter state */
lps0_ac_state = power_supply_is_system_supplied();

/* LPS0 entry */
if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd())
acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD,
Expand Down Expand Up @@ -641,6 +649,15 @@ void acpi_s2idle_check(void)
if (handler->check)
handler->check();
}

/* if configured, wake system from AC adapter changes */
if (device_may_wakeup(&lps0_device->dev) &&
power_supply_is_system_supplied() != lps0_ac_state) {
if (pm_debug_messages_on)
acpi_handle_info(lps0_device_handle,
"AC adapter state changed\n");
acpi_pm_wakeup_event(&lps0_device->dev);
}
}

void acpi_s2idle_restore_early(void)
Expand Down Expand Up @@ -704,6 +721,8 @@ int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg)

sleep_flags = lock_system_sleep();
list_add(&arg->list_node, &lps0_s2idle_devops_head);
if (arg->wake_on_ac)
device_set_wakeup_enable(&lps0_device->dev, true);
unlock_system_sleep(sleep_flags);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hid-asus-ally.c
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ static int ally_gamepad_register_brightness(struct hid_device *hdev,
struct led_classdev *led_cdev;

led_cdev = &led_rgb->led_bright_dev;
led_cdev->name = "ally:kbd_backlight"; /* Let a desktop control it also */
led_cdev->name = "asus::kbd_backlight"; /* Let a desktop control it also */
led_cdev->max_brightness = 3;
led_cdev->brightness_set = ally_backlight_set;
led_cdev->brightness_get = ally_backlight_get;
Expand Down Expand Up @@ -2059,7 +2059,7 @@ static int ally_gamepad_register_rgb_leds(struct hid_device *hdev,
led_rgb->led_rgb_dev.num_colors = 3 * 4;

led_cdev = &led_rgb->led_rgb_dev.led_cdev;
led_cdev->name = "ally:rgb:gamepad";
led_cdev->name = "ally:rgb:joystick_rings";
led_cdev->brightness = 128;
led_cdev->max_brightness = 255;
led_cdev->brightness_set = ally_set_rgb_brightness;
Expand Down
3 changes: 2 additions & 1 deletion drivers/platform/x86/asus-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5084,7 +5084,7 @@ static void asus_ally_s2idle_check(void)

/* Wake the device fully if AC plugged in. Prevents many issues */
if (power_state > 0 && ally_suspended_power_state != power_state) {
pm_system_wakeup();
// pm_system_wakeup();
return;
}

Expand Down Expand Up @@ -5119,6 +5119,7 @@ static int asus_hotk_prepare(struct device *device)
static struct acpi_s2idle_dev_ops asus_ally_s2idle_dev_ops = {
.restore = asus_ally_s2idle_restore,
.check = asus_ally_s2idle_check,
.wake_on_ac = true,
};

static const struct dev_pm_ops asus_pm_ops = {
Expand Down
1 change: 1 addition & 0 deletions include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ struct acpi_s2idle_dev_ops {
void (*prepare)(void);
void (*check)(void);
void (*restore)(void);
bool wake_on_ac;
};
int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg);
void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg);
Expand Down

0 comments on commit 41a9a35

Please sign in to comment.