Skip to content

Commit

Permalink
AOSCOS: platform: x86: ideapad-laptop: add fixes for ThinkBook 14+ (2…
Browse files Browse the repository at this point in the history
…024 G6+)

This is a patch taken from ideapad-laptop-tb2024g6plus in an attempt to
incorporate these changes in the mainline kernel. This patch fixes
the following issues:

- Laptop shuts down unexpectedly after closing the lid.
- The Fn-F5 combination shuts down or resets AMD models.
- Keyboard backlight status resets after waking up from S3 suspend.

Signed-off-by: Terry <[email protected]>
Link: https://github.com/ty2/ideapad-laptop-tb2024g6plus/blob/6d934407981294d05a6a4e4ed0e59d3c6c964990/ideapad-laptop.patch
Signed-off-by: Mingcong Bai <[email protected]>
Signed-off-by: Kexy Biscuit <[email protected]>
  • Loading branch information
MingcongBai committed Nov 18, 2024
1 parent 59a0c47 commit 518cb91
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions drivers/platform/x86/ideapad-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ struct ideapad_private {
struct led_classdev led;
unsigned int last_brightness;
} fn_lock;
bool suspended;
};

static bool no_bt_rfkill;
Expand Down Expand Up @@ -1297,6 +1298,8 @@ static const struct key_entry ideapad_keymap[] = {
/* Specific to some newer models */
{ KE_KEY, 0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } },
{ KE_KEY, 0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } },
/* Touchpad Toggle */
{ KE_KEY, 0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } },

{ KE_END },
};
Expand Down Expand Up @@ -1846,6 +1849,16 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
unsigned long vpc1, vpc2, bit;

scoped_guard(mutex, &priv->vpc_mutex) {
acpi_handle_info(handle, "event: %lu\n",
(unsigned long)event);

if(!data)
acpi_handle_info(handle, "no data");
return;

if (priv->suspended)
return;

if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1))
return;

Expand Down Expand Up @@ -1892,6 +1905,7 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
ideapad_backlight_notify_power(priv);
break;
case KBD_BL_KBLC_CHANGED_EVENT:
case 0:
case 1:
/*
* Some IdeaPads report event 1 every ~20
Expand All @@ -1901,8 +1915,6 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
* backlight has changed.
*/
ideapad_kbd_bl_notify(priv);
break;
case 0:
ideapad_check_special_buttons(priv);
break;
default:
Expand Down Expand Up @@ -2106,6 +2118,8 @@ static const struct wmi_device_id ideapad_wmi_ids[] = {
{ "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", &ideapad_wmi_context_esc }, /* Yoga 3 */
{ "56322276-8493-4CE8-A783-98C991274F5E", &ideapad_wmi_context_esc }, /* Yoga 700 */
{ "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", &ideapad_wmi_context_fn_keys }, /* Legion 5 */
{ "46f16367-fb9d-11ee-a4f6-40c2ba4a5625", &ideapad_wmi_context_esc }, /* ThinkBook 16+ 2024 IMH */
{ "077c4a1f-e344-11ee-a4f6-40c2ba413e67", &ideapad_wmi_context_esc }, /* ThinkBook 2024 AMD */
{},
};
MODULE_DEVICE_TABLE(wmi, ideapad_wmi_ids);
Expand Down Expand Up @@ -2296,10 +2310,19 @@ static int ideapad_acpi_resume(struct device *dev)
if (priv->dytc)
dytc_profile_refresh(priv);

priv->suspended = false;

return 0;
}

static int ideapad_acpi_suspended(struct device *dev)
{
struct ideapad_private *priv = dev_get_drvdata(dev);
priv->suspended = true;
return 0;
}
#endif
static SIMPLE_DEV_PM_OPS(ideapad_pm, NULL, ideapad_acpi_resume);
static SIMPLE_DEV_PM_OPS(ideapad_pm, ideapad_acpi_suspended, ideapad_acpi_resume);

static const struct acpi_device_id ideapad_device_ids[] = {
{"VPC2004", 0},
Expand Down

0 comments on commit 518cb91

Please sign in to comment.