mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: corbet@lwn.net, ilpo.jarvinen@linux.intel.com,
	platform-driver-x86@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: Support for mode FN key
Date: Mon, 22 Jan 2024 12:28:15 +0100	[thread overview]
Message-ID: <729d7887-7681-476b-9b5f-c498d78df2cb@redhat.com> (raw)
In-Reply-To: <20240120232949.317337-1-mpearson-lenovo@squebb.ca>

Hi,

On 1/21/24 00:29, Mark Pearson wrote:
> New Thinkpads have added a 'Mode' Function key that on Windows allows
> you to choose the active profile (low-power, balanced, performance)
> 
> Added suppoort for this hotkey (F8), and have it cycle through the
> options available.
> 
> Tested on X1 Carbon G12.
> 
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>  .../admin-guide/laptops/thinkpad-acpi.rst     |  7 ++++++-
>  drivers/platform/x86/thinkpad_acpi.c          | 20 ++++++++++++++++++-
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
> index 98d304010170..7f674a6cfa8a 100644
> --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
> +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
> @@ -444,7 +444,9 @@ event	code	Key		Notes
>  
>  0x1008	0x07	FN+F8		IBM: toggle screen expand
>  				Lenovo: configure UltraNav,
> -				or toggle screen expand
> +				or toggle screen expand.
> +				On newer platforms (2024+)
> +				replaced by 0x131f (see below)
>  
>  0x1009	0x08	FN+F9		-
>  
> @@ -504,6 +506,9 @@ event	code	Key		Notes
>  
>  0x1019	0x18	unknown
>  
> +0x131f	...	FN+F8	        Platform Mode change.
> +				Implemented in driver.
> +
>  ...	...	...
>  
>  0x1020	0x1F	unknown
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c4895e9bc714..ceb22f8d8442 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -166,6 +166,7 @@ enum tpacpi_hkey_event_t {
>  	TP_HKEY_EV_VOL_MUTE		= 0x1017, /* Mixer output mute */
>  	TP_HKEY_EV_PRIVACYGUARD_TOGGLE	= 0x130f, /* Toggle priv.guard on/off */
>  	TP_HKEY_EV_AMT_TOGGLE		= 0x131a, /* Toggle AMT on/off */
> +	TP_HKEY_EV_PROFILE_TOGGLE	= 0x131f, /* Toggle platform profile */
>  
>  	/* Reasons for waking up from S3/S4 */
>  	TP_HKEY_EV_WKUP_S3_UNDOCK	= 0x2304, /* undock requested, S3 */
> @@ -3731,6 +3732,7 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey)
>  	switch (hkey) {
>  	case TP_HKEY_EV_PRIVACYGUARD_TOGGLE:
>  	case TP_HKEY_EV_AMT_TOGGLE:
> +	case TP_HKEY_EV_PROFILE_TOGGLE:
>  		tpacpi_driver_event(hkey);
>  		return true;
>  	}
> @@ -11118,7 +11120,23 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
>  		else
>  			dytc_control_amt(!dytc_amt_active);
>  	}
> -
> +	if (hkey_event == TP_HKEY_EV_PROFILE_TOGGLE) {
> +		switch (dytc_current_profile) {
> +		case PLATFORM_PROFILE_LOW_POWER:
> +			dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED);
> +			break;
> +		case PLATFORM_PROFILE_BALANCED:
> +			dytc_profile_set(NULL, PLATFORM_PROFILE_PERFORMANCE);
> +			break;
> +		case PLATFORM_PROFILE_PERFORMANCE:
> +			dytc_profile_set(NULL, PLATFORM_PROFILE_LOW_POWER);
> +			break;
> +		default:
> +			pr_warn("Profile HKEY unexpected profile %d", dytc_current_profile);
> +		}
> +		/* Notify user space the profile changed */
> +		platform_profile_notify();
> +	}
>  }
>  
>  static void hotkey_driver_event(const unsigned int scancode)


  reply	other threads:[~2024-01-22 11:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20 23:29 Mark Pearson
2024-01-22 11:28 ` Hans de Goede [this message]
2024-01-24 11:02 ` Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=729d7887-7681-476b-9b5f-c498d78df2cb@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=corbet@lwn.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®