From nobody Mon Feb 9 05:52:57 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB9B3C77B7E for ; Mon, 29 May 2023 05:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbjE2FkT (ORCPT ); Mon, 29 May 2023 01:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjE2FkR (ORCPT ); Mon, 29 May 2023 01:40:17 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2EFEA8; Sun, 28 May 2023 22:40:15 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-530638a60e1so2611673a12.2; Sun, 28 May 2023 22:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685338815; x=1687930815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6FOt6/jNDEYnzLxqC7AoJSZCpvzsH4Kc5a9ChdfDk7g=; b=PXDX3dHrEyzRONErAjdsyLZDZPMMgh3Np79VPYpJAXqhv9G7BHgydjpSXVZNcFsXo8 06L7nLjJvNnPsmOfBsuF/4Q2hzkXL6nQh7znIfXYd8MBVX7STkQj/HQR9rJajEMGDdvE VNppD2fA06s4o7o0PXKC0pT+Zy8NresWbOhI9sqS66eShcHPRo/BPpBwOZA8swnle56K JeCXmg3y9U3w2H/Slb0KUqMphwlwKZ26K286O9rn5NKEvbOEZ6tV+E+EcaFqD3EnGO33 GvPyO2fUU5N6SCUlAf8rY5Pvgm3NMs5pfq9oHu7BuuW87hf7TBMOSowF2RPPgHKfVmiL AJ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685338815; x=1687930815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6FOt6/jNDEYnzLxqC7AoJSZCpvzsH4Kc5a9ChdfDk7g=; b=GiGAEGI9wvSy9QmuKu0EfvTqPXw0SBTbW0uRbuxJDpnwwJdau6xU0rEKhrQ+LEeTCc TuBiXOfq6oRz4CUOt4LBIjUBY1wPgIBxWK0UClNxPu7n66mTstlAVhSe5W6Q6rmkL1zn kEwr7KnysPDo7ySYf+PpTVpHfF7CaTNuAmjCJhpeivtl/d+he4YjE2AEVFDGDWEiITMU w8Rkiwu7lF0VcJsCwxvJrzlZawTKmFn1T3YAl7DwefJG9a035I9m9uut53GMbULlEV0n 50xFoM7+PPloYtofWsCNn8dNKuCfWlyALh/yaczapujbvM3kb1DsZ4XJo0Ee7sJv3ZHW evuQ== X-Gm-Message-State: AC+VfDzilM3gen63tSkXCionA5HGYH6+DsFYiH+hKTlECdeMLjVCZOO2 cX5prPNmUYorm156QmgTCa9pOV55Al8= X-Google-Smtp-Source: ACHHUZ6Do4fvcFcfxjOHXK8o5whrQlGz/usqWsCFS0LW7jg9gHuY+SoWfFQCtERIozPRmf8/ii4Rqw== X-Received: by 2002:a17:902:dac9:b0:1b0:3c1a:1238 with SMTP id q9-20020a170902dac900b001b03c1a1238mr3555125plx.59.1685338815240; Sun, 28 May 2023 22:40:15 -0700 (PDT) Received: from localhost.localdomain ([110.46.146.116]) by smtp.gmail.com with ESMTPSA id p20-20020a170902a41400b001ab39cd885esm7186778plq.212.2023.05.28.22.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 May 2023 22:40:14 -0700 (PDT) From: SungHwan Jung To: Hans de Goede , Mark Gross Cc: SungHwan Jung , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: hp-wmi: Add thermal profile for Victus 16-d1xxx Date: Mon, 29 May 2023 14:39:58 +0900 Message-Id: <20230529053959.4876-1-onenowy@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch includes Platform Profile support (performance, balanced, quiet) for Victus 16-d1xxx (8A25). Signed-off-by: SungHwan Jung --- drivers/platform/x86/hp/hp-wmi.c | 104 +++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 6364ae262705..6259b907ce63 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -66,6 +66,11 @@ static const char *const omen_thermal_profile_force_v0_b= oards[] =3D { "8607", "8746", "8747", "8749", "874A", "8748" }; =20 +/* DMI Board names of Victus laptops */ +static const char * const victus_thermal_profile_boards[] =3D { + "8A25" +}; + enum hp_wmi_radio { HPWMI_WIFI =3D 0x0, HPWMI_BLUETOOTH =3D 0x1, @@ -176,6 +181,12 @@ enum hp_thermal_profile_omen_v1 { HP_OMEN_V1_THERMAL_PROFILE_COOL =3D 0x50, }; =20 +enum hp_thermal_profile_victus { + HP_VICTUS_THERMAL_PROFILE_DEFAULT =3D 0x00, + HP_VICTUS_THERMAL_PROFILE_PERFORMANCE =3D 0x01, + HP_VICTUS_THERMAL_PROFILE_QUIET =3D 0x03, +}; + enum hp_thermal_profile { HP_THERMAL_PROFILE_PERFORMANCE =3D 0x00, HP_THERMAL_PROFILE_DEFAULT =3D 0x01, @@ -1246,6 +1257,70 @@ static int hp_wmi_platform_profile_set(struct platfo= rm_profile_handler *pprof, return 0; } =20 +static bool is_victus_thermal_profile(void) +{ + const char *board_name =3D dmi_get_system_info(DMI_BOARD_NAME); + + if (!board_name) + return false; + + return match_string(victus_thermal_profile_boards, + ARRAY_SIZE(victus_thermal_profile_boards), + board_name) >=3D 0; +} + +static int platform_profile_victus_get(struct platform_profile_handler *pp= rof, + enum platform_profile_option *profile) +{ + int tp; + + tp =3D omen_thermal_profile_get(); + if (tp < 0) + return tp; + + switch (tp) { + case HP_VICTUS_THERMAL_PROFILE_PERFORMANCE: + *profile =3D PLATFORM_PROFILE_PERFORMANCE; + break; + case HP_VICTUS_THERMAL_PROFILE_DEFAULT: + *profile =3D PLATFORM_PROFILE_BALANCED; + break; + case HP_VICTUS_THERMAL_PROFILE_QUIET: + *profile =3D PLATFORM_PROFILE_QUIET; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int platform_profile_victus_set(struct platform_profile_handler *pp= rof, + enum platform_profile_option profile) +{ + int err, tp; + + switch (profile) { + case PLATFORM_PROFILE_PERFORMANCE: + tp =3D HP_VICTUS_THERMAL_PROFILE_PERFORMANCE; + break; + case PLATFORM_PROFILE_BALANCED: + tp =3D HP_VICTUS_THERMAL_PROFILE_DEFAULT; + break; + case PLATFORM_PROFILE_QUIET: + tp =3D HP_VICTUS_THERMAL_PROFILE_QUIET; + break; + default: + return -EOPNOTSUPP; + } + + err =3D omen_thermal_profile_set(tp); + if (err < 0) + return err; + + return 0; +} + static int thermal_profile_setup(void) { int err, tp; @@ -1266,6 +1341,25 @@ static int thermal_profile_setup(void) =20 platform_profile_handler.profile_get =3D platform_profile_omen_get; platform_profile_handler.profile_set =3D platform_profile_omen_set; + + set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); + } else if (is_victus_thermal_profile()) { + tp =3D omen_thermal_profile_get(); + if (tp < 0) + return tp; + + /* + * call thermal profile write command to ensure that the + * firmware correctly sets the OEM variables + */ + err =3D omen_thermal_profile_set(tp); + if (err < 0) + return err; + + platform_profile_handler.profile_get =3D platform_profile_victus_get; + platform_profile_handler.profile_set =3D platform_profile_victus_set; + + set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); } else { tp =3D thermal_profile_get(); =20 @@ -1273,20 +1367,20 @@ static int thermal_profile_setup(void) return tp; =20 /* - * call thermal profile write command to ensure that the - * firmware correctly sets the OEM variables for the DPTF - */ + * call thermal profile write command to ensure that the + * firmware correctly sets the OEM variables for the DPTF + */ err =3D thermal_profile_set(tp); if (err) return err; =20 platform_profile_handler.profile_get =3D hp_wmi_platform_profile_get; platform_profile_handler.profile_set =3D hp_wmi_platform_profile_set; - + set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); + set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } =20 - set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 --=20 2.40.1