public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Elia Devito <eliadevito@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Elia Devito <eliadevito@gmail.com>,
	Philippe Rouquier <bonfire-app@wanadoo.fr>,
	Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] platform/x86: hp-wmi: add support for quiet thermal profile
Date: Sun, 25 Sep 2022 22:42:45 +0200	[thread overview]
Message-ID: <20220925204244.53506-1-eliadevito@gmail.com> (raw)

The quiet profile is available only on models without dGPU,
so we enable it when the device has only one GPU onboard.

Signed-off-by: Elia Devito <eliadevito@gmail.com>
Tested-by: Philippe Rouquier <bonfire-app@wanadoo.fr>
---
 drivers/platform/x86/hp-wmi.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index bc7020e9df9e..3e0e67be8001 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -177,7 +177,8 @@ enum hp_thermal_profile_omen_v1 {
 enum hp_thermal_profile {
 	HP_THERMAL_PROFILE_PERFORMANCE	= 0x00,
 	HP_THERMAL_PROFILE_DEFAULT		= 0x01,
-	HP_THERMAL_PROFILE_COOL			= 0x02
+	HP_THERMAL_PROFILE_COOL			= 0x02,
+	HP_THERMAL_PROFILE_QUIET			= 0x03,
 };
 
 #define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) != HPWMI_POWER_FW_OR_HW)
@@ -1194,6 +1195,9 @@ static int hp_wmi_platform_profile_get(struct platform_profile_handler *pprof,
 	case HP_THERMAL_PROFILE_COOL:
 		*profile =  PLATFORM_PROFILE_COOL;
 		break;
+	case HP_THERMAL_PROFILE_QUIET:
+		*profile =  PLATFORM_PROFILE_QUIET;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1216,6 +1220,9 @@ static int hp_wmi_platform_profile_set(struct platform_profile_handler *pprof,
 	case PLATFORM_PROFILE_COOL:
 		tp =  HP_THERMAL_PROFILE_COOL;
 		break;
+	case PLATFORM_PROFILE_QUIET:
+		tp =  HP_THERMAL_PROFILE_QUIET;
+		break;
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -1230,6 +1237,8 @@ static int hp_wmi_platform_profile_set(struct platform_profile_handler *pprof,
 static int thermal_profile_setup(void)
 {
 	int err, tp;
+	unsigned int n_gpu = 0;
+	const struct dmi_device *dev = NULL;
 
 	if (is_omen_thermal_profile()) {
 		tp = omen_thermal_profile_get();
@@ -1263,6 +1272,16 @@ static int thermal_profile_setup(void)
 
 		platform_profile_handler.profile_get = hp_wmi_platform_profile_get;
 		platform_profile_handler.profile_set = hp_wmi_platform_profile_set;
+
+		/*
+		 * The quiet profile is available only on models without dGPU,
+		 * so we enable it when the device has only one GPU onboard.
+		 */
+		while ((dev = dmi_find_device(DMI_DEV_TYPE_VIDEO, NULL, dev)))
+			n_gpu++;
+
+		if (n_gpu == 1)
+			set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices);
 	}
 
 	set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
-- 
2.37.2


             reply	other threads:[~2022-09-25 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 20:42 Elia Devito [this message]
2022-09-27 10:24 ` [PATCH] platform/x86: hp-wmi: add support for quiet thermal profile Hans de Goede
2022-09-27 15:44   ` Elia Devito

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=20220925204244.53506-1-eliadevito@gmail.com \
    --to=eliadevito@gmail.com \
    --cc=bonfire-app@wanadoo.fr \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --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