From nobody Mon Nov 25 04:34:39 2024 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF97E79D2; Wed, 30 Oct 2024 00:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247049; cv=none; b=IJLSFrrzu4eZCCaoqhcvBNpHbqMrkjSDpFS2qrZL9ahNkvuFrtjUzvHWIR8dvcPUtz6d1L2l9kua1g94jKU3tbyMPZQ5IQcI4tkI3Y6V62KhiKNAVsXGuSv5o0X78YwS/rH5WaT/SYmMLl/dRtlHeaE8zyctAswnusNRKZpdxAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247049; c=relaxed/simple; bh=1Pxh1pyMDQnlkEd4p4KsoDm6IGcNHIPrg+dxp3S4+mQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jMMvWARqmHUk1dr9X2IsbvmzF/lkqDm9Ij8WjCwmijDCdH2ua4tkNSDsYDEAG5LC2+uXUj8LkhsN5v1zoXyaRNfWVJxdJZk2YNRgZ0Ou1UNda2oG/Kl3D4OVYmo8Z2h2o6dSk3R4Wj71d9SfmvxCk1ZQoyxen/hluMMj+IULQ0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pv/ylyDE; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pv/ylyDE" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20cbca51687so56770025ad.1; Tue, 29 Oct 2024 17:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730247046; x=1730851846; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lnhrTQhjmp/plopFDNAE0Rx2S5Oi1kD7CR2cs1JiPrw=; b=Pv/ylyDEyomHX9gDNzOtaDGRmANWsgqjWxuF6GzqaejW4K2bFEIMITuuMgvNcbqJuB OJWhynru7M+rAYqOtCvMUNh/2fTRZ8JG766QSX+1EWyE3jc9p9PQjrcc+DeFfsSlbLIv f9c/JiktSj/WdX1sYvJbuSL1MSHRAyzZKRJXklgH374L41MdxUCydaZniRtTuFZYbOlo Ixv1Sk8g3OG5uzWhe9ndiaZYi+sIb9FVEzggsMIw07BxpLPjhLAoHcOy73R0sPDtzwxl DN+AHt4dLXzzTNTwb1gExqShx5d/EtP3hb0rekYkj0OYsZKHq/d3O7+ms9j6hJoh11PD kbVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730247046; x=1730851846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lnhrTQhjmp/plopFDNAE0Rx2S5Oi1kD7CR2cs1JiPrw=; b=fHzkVIWADZ2TK9xqx0AZwRUTC+GiPKrMSZyFfkS5bAmCONE8upj5mZDV46SQOOwL5K a66LdaZsdxNBegYRIBLjB0rx9ri0hhJu7QYyQ8Ox4eDZTSQiEGGh94TjxqHah21PxVRZ d1MChPTk/72Fb66sddUn1XM94fo3+rF1PSQZ5wIdIuu0YMNcvVIEkyUXjA8Dm6nYWBDE qZ9/edm7HC02jToiYaGI6tO8SesGNjG7rsAUOBnBEJOw1i0iHVluAyML9r8CYkFc+Mnu ySTzT+sOt0lnh/Zps8LfsquDgrIfwmp7kaYLPaRl9tGo8QWsJV4M14NCJvCAOWiDnF1R L8Sw== X-Forwarded-Encrypted: i=1; AJvYcCWDuj2iizGJyhsA2tr+EJWSMk/1seqjGLsJVaI+OgtBvPPBiri1PDsQAKfjy97NmxloPA6JRFsyt6CD8MmrTtAope5JWw==@vger.kernel.org, AJvYcCXR42tkXtt6HaHiI+8WQDYnNzptZ0YhIHPW4YiZqkn5hjG9cFVtujhbrOpteXdp58q7UEG8+ix8Nl6xyD8=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv9Ic/HxccfEqQpVwp7LGAor8ylCkhPuEUxiUer16kf0r3rEIc zZFbR0NqkFkn21sh40V5VCowPhOCOuanW7BzpeXIKGNSq5cCfrV6FSp7Ng== X-Google-Smtp-Source: AGHT+IGnGw4p6dDOolEQqW1GXjVWCJ1pBA6DNUgdPA78SlfVUEsFyyJxAbLtGaYWPcUYnGdvquC4WQ== X-Received: by 2002:a17:903:2312:b0:205:8407:6321 with SMTP id d9443c01a7336-210c6879f49mr174544765ad.9.1730247046053; Tue, 29 Oct 2024 17:10:46 -0700 (PDT) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bbf8849bsm71742275ad.117.2024.10.29.17.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 17:10:45 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: W_Armin@gmx.de, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v11 1/5] alienware-wmi: fixed indentation and clean up Date: Tue, 29 Oct 2024 21:10:27 -0300 Message-ID: <20241030001028.7402-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030000904.7205-2-kuurtb@gmail.com> References: <20241030000904.7205-2-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Fixed inconsistent indentation and removed unnecessary (acpi_size) and (u32 *) casts. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen --- v11: - Unchanged v10: - Unchanged v9: - Unchanged v8: - Unchanged v7: - Unchanged v6: - Unchanged --- drivers/platform/x86/dell/alienware-wmi.c | 134 +++++++++++----------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index f5ee62ce1..16a3fe9ac 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -116,68 +116,68 @@ static int __init dmi_matched(const struct dmi_system= _id *dmi) =20 static const struct dmi_system_id alienware_quirks[] __initconst =3D { { - .callback =3D dmi_matched, - .ident =3D "Alienware X51 R3", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R3"), - }, - .driver_data =3D &quirk_x51_r3, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware X51 R3", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R3"), + }, + .driver_data =3D &quirk_x51_r3, + }, { - .callback =3D dmi_matched, - .ident =3D "Alienware X51 R2", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R2"), - }, - .driver_data =3D &quirk_x51_r1_r2, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware X51 R2", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R2"), + }, + .driver_data =3D &quirk_x51_r1_r2, + }, { - .callback =3D dmi_matched, - .ident =3D "Alienware X51 R1", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51"), - }, - .driver_data =3D &quirk_x51_r1_r2, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware X51 R1", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51"), + }, + .driver_data =3D &quirk_x51_r1_r2, + }, { - .callback =3D dmi_matched, - .ident =3D "Alienware ASM100", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "ASM100"), - }, - .driver_data =3D &quirk_asm100, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware ASM100", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "ASM100"), + }, + .driver_data =3D &quirk_asm100, + }, { - .callback =3D dmi_matched, - .ident =3D "Alienware ASM200", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "ASM200"), - }, - .driver_data =3D &quirk_asm200, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware ASM200", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "ASM200"), + }, + .driver_data =3D &quirk_asm200, + }, { - .callback =3D dmi_matched, - .ident =3D "Alienware ASM201", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "ASM201"), - }, - .driver_data =3D &quirk_asm201, - }, - { - .callback =3D dmi_matched, - .ident =3D "Dell Inc. Inspiron 5675", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5675"), - }, - .driver_data =3D &quirk_inspiron5675, - }, + .callback =3D dmi_matched, + .ident =3D "Alienware ASM201", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "ASM201"), + }, + .driver_data =3D &quirk_asm201, + }, + { + .callback =3D dmi_matched, + .ident =3D "Dell Inc. Inspiron 5675", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5675"), + }, + .driver_data =3D &quirk_inspiron5675, + }, {} }; =20 @@ -221,8 +221,8 @@ static struct platform_zone *zone_data; =20 static struct platform_driver platform_driver =3D { .driver =3D { - .name =3D "alienware-wmi", - } + .name =3D "alienware-wmi", + } }; =20 static struct attribute_group zone_attribute_group =3D { @@ -292,7 +292,7 @@ static int alienware_update_led(struct platform_zone *z= one) guid =3D WMAX_CONTROL_GUID; method_id =3D WMAX_METHOD_ZONE_CONTROL; =20 - input.length =3D (acpi_size) sizeof(wmax_basic_args); + input.length =3D sizeof(wmax_basic_args); input.pointer =3D &wmax_basic_args; } else { legacy_args.colors =3D zone->colors; @@ -306,7 +306,7 @@ static int alienware_update_led(struct platform_zone *z= one) guid =3D LEGACY_CONTROL_GUID; method_id =3D zone->location + 1; =20 - input.length =3D (acpi_size) sizeof(legacy_args); + input.length =3D sizeof(legacy_args); input.pointer =3D &legacy_args; } pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id); @@ -358,7 +358,7 @@ static int wmax_brightness(int brightness) .led_mask =3D 0xFF, .percentage =3D brightness, }; - input.length =3D (acpi_size) sizeof(args); + input.length =3D sizeof(args); input.pointer =3D &args; status =3D wmi_evaluate_method(WMAX_CONTROL_GUID, 0, WMAX_METHOD_BRIGHTNESS, &input, NULL); @@ -508,7 +508,7 @@ static acpi_status alienware_wmax_command(struct wmax_b= asic_args *in_args, struct acpi_buffer input; struct acpi_buffer output; =20 - input.length =3D (acpi_size) sizeof(*in_args); + input.length =3D sizeof(*in_args); input.pointer =3D in_args; if (out_data) { output.length =3D ACPI_ALLOCATE_BUFFER; @@ -542,7 +542,7 @@ static ssize_t show_hdmi_cable(struct device *dev, }; status =3D alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_CABLE, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -563,7 +563,7 @@ static ssize_t show_hdmi_source(struct device *dev, }; status =3D alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_STATUS, - (u32 *) &out_data); + &out_data); =20 if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 1) @@ -643,7 +643,7 @@ static ssize_t show_amplifier_status(struct device *dev, }; status =3D alienware_wmax_command(&in_args, WMAX_METHOD_AMPLIFIER_CABLE, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -695,7 +695,7 @@ static ssize_t show_deepsleep_status(struct device *dev, .arg =3D 0, }; status =3D alienware_wmax_command(&in_args, WMAX_METHOD_DEEP_SLEEP_STATUS, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); --=20 2.47.0 From nobody Mon Nov 25 04:34:39 2024 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E277746B5; Wed, 30 Oct 2024 00:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247072; cv=none; b=AFp2+BPmzPV3IMzkDvOLDKI+1NCeOA6SKz6TTGWS3m1aqteglRK5AuqvJgcjnmCkA7NK+P+WfcA9F4cHNgNs1EdwQQmkWnvcgigURsPk56eJHzaz3JkWk1KxIiwtrTcCC53CCDfSowonTEk/pk3fnMJgcngt7FDfv6qsDMd0xe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247072; c=relaxed/simple; bh=7u/OFN1yXsp4cJJlZm3f5UlsirPjmdUjNWNg0AeoDJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PlzBCOzsyUjZ504/pfSTIVe5AFCNaafaclaaKLPOqFE5Aj/aPdo9R8zaMIv5tzcSeo0N6n3RKngYOFmmGUoJjGAjZWHDa3g8Ot4bGrA8a/XHxaD5zhpWCm5XWAYRvU5SUe9PHXDnVo5icNZmq1tdZ0+jG0eyQbKcjP6HmVr98iA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OHXXnJv0; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OHXXnJv0" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20cb47387ceso56580325ad.1; Tue, 29 Oct 2024 17:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730247070; x=1730851870; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G58WRMncaeRsV0bfmq4FxysQ28GG1wpQqetEZqN0dmo=; b=OHXXnJv0SdQAamRurC3Ub4d2zMNK7xGFaMMzQ/KGUaSacjT7NTOt3xKQQdVA5bjbm3 huGy1NGo1asIEov9bAQwA8rsNrqYTnKv5lLd/DrVZiQu2MY4yoff0tbH/PqMLuQCnjCI 5poUvwINLZDytSh9RfpN1dvaLIgYVEGIIAqoOMztj1T5bGp/OoDDzd2DEaYWxHDnX5/k QBFcTfOMwZ+u+eqi2ZcA40kFwQqMe7aXZa0cYfqLsk5/2ojvG4HGteJ3tYZBEeVp373C D0pp5xa3fyHnIE1xmldjIYnCBrB6X/PSTSEPuI4/j97Rtg/UAikDtyXhEdMEpBeyC7uf /QPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730247070; x=1730851870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G58WRMncaeRsV0bfmq4FxysQ28GG1wpQqetEZqN0dmo=; b=MwPyYByp/y8ifzHcVyhvJQh8eF2qPhSeLgj7RWu0PGoqo0H0aM7AQ9pK8wvQDOvT2l 7d4FTvilGHREipTL8UEVYLTIa+snxVFUFQgzkKN7OQfun0OIFbnhjz6MAnwhbfH7wCU2 kLpdspN/+g480sF4njVIezbAf8HsO/GcrOBTgM6E2b0gylPvBAgNJ/QMdk+DZ5f298sU CyKFVgnYO98Joj+2igjva4lo29BKXiKmj5XpQW04p6eTzmITJwc2ueEyEuSXPUMJU069 VdKUnvsFMny8PCcRICpgGoy9EKr1MQbFhco4DsazBnQUilt6hKbG7vygWTIG/ZmQVDdd 6CoQ== X-Forwarded-Encrypted: i=1; AJvYcCUWq73vIMa5a9+Lm9nfFr7X2bfzvU8P/yQHoWsfHoGbqswvbb5P5mJOnKzbTtyG1nNphvdQan7m263r67w=@vger.kernel.org, AJvYcCWGtqJaIZzXizsVvthwkSUh4IyilAjT/Kq8Yrb5F0GRNBzcwLESUtnDLPcppdPpkZDbWLYKfodPD9Et7J5D0M7WVKphLg==@vger.kernel.org X-Gm-Message-State: AOJu0YyZkbOHuNpNle1WCPy9WvBhDXjfUCZ8JeCVqYraVD40LQFrJaJY 6lqorrtD+K9/NKfupi/YZ90fyjzns1kMbwFVDLN7KegM8ak5prmH X-Google-Smtp-Source: AGHT+IEgdxmQmW2bofQSGJNEPcEK+AzOSzSBDLnMLlHw3WcT13wc5SQkHjmZngNg7U9OimYv2kyhtg== X-Received: by 2002:a17:902:e745:b0:20b:c1e4:2d6c with SMTP id d9443c01a7336-210c6cdde01mr168552145ad.57.1730247070202; Tue, 29 Oct 2024 17:11:10 -0700 (PDT) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bbf6d3cfsm71965055ad.82.2024.10.29.17.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 17:11:09 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: W_Armin@gmx.de, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v11 2/5] alienware-wmi: alienware_wmax_command() is now input size agnostic Date: Tue, 29 Oct 2024 21:10:56 -0300 Message-ID: <20241030001057.7562-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030000904.7205-2-kuurtb@gmail.com> References: <20241030000904.7205-2-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable alienware_wmax_command() now takes void * and size_t instead of struct wmax_basic_args to extend support to new WMAX methods. Also int *out_data was changed to u32 *out_data, because new interface specifies u32 as output parameter and all previous callers would pass u32 * regardless. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen --- v11: - Unchanged v10: - Unchanged v9: - Unchanged v8: - Unchanged v7: - Unchanged v6: - Unchanged --- drivers/platform/x86/dell/alienware-wmi.c | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index 16a3fe9ac..b27f3b64c 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -500,15 +500,15 @@ static void alienware_zone_exit(struct platform_devic= e *dev) kfree(zone_attrs); } =20 -static acpi_status alienware_wmax_command(struct wmax_basic_args *in_args, - u32 command, int *out_data) +static acpi_status alienware_wmax_command(void *in_args, size_t in_size, + u32 command, u32 *out_data) { acpi_status status; union acpi_object *obj; struct acpi_buffer input; struct acpi_buffer output; =20 - input.length =3D sizeof(*in_args); + input.length =3D in_size; input.pointer =3D in_args; if (out_data) { output.length =3D ACPI_ALLOCATE_BUFFER; @@ -541,8 +541,8 @@ static ssize_t show_hdmi_cable(struct device *dev, .arg =3D 0, }; status =3D - alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_CABLE, - &out_data); + alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_HDMI_CABLE, &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -562,8 +562,8 @@ static ssize_t show_hdmi_source(struct device *dev, .arg =3D 0, }; status =3D - alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_STATUS, - &out_data); + alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_HDMI_STATUS, &out_data); =20 if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 1) @@ -589,7 +589,8 @@ static ssize_t toggle_hdmi_source(struct device *dev, args.arg =3D 3; pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf); =20 - status =3D alienware_wmax_command(&args, WMAX_METHOD_HDMI_SOURCE, NULL); + status =3D alienware_wmax_command(&args, sizeof(args), + WMAX_METHOD_HDMI_SOURCE, NULL); =20 if (ACPI_FAILURE(status)) pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", @@ -642,8 +643,8 @@ static ssize_t show_amplifier_status(struct device *dev, .arg =3D 0, }; status =3D - alienware_wmax_command(&in_args, WMAX_METHOD_AMPLIFIER_CABLE, - &out_data); + alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_AMPLIFIER_CABLE, &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -694,8 +695,8 @@ static ssize_t show_deepsleep_status(struct device *dev, struct wmax_basic_args in_args =3D { .arg =3D 0, }; - status =3D alienware_wmax_command(&in_args, WMAX_METHOD_DEEP_SLEEP_STATUS, - &out_data); + status =3D alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_DEEP_SLEEP_STATUS, &out_data); if (ACPI_SUCCESS(status)) { if (out_data =3D=3D 0) return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); @@ -723,8 +724,8 @@ static ssize_t toggle_deepsleep(struct device *dev, args.arg =3D 2; pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf); =20 - status =3D alienware_wmax_command(&args, WMAX_METHOD_DEEP_SLEEP_CONTROL, - NULL); + status =3D alienware_wmax_command(&args, sizeof(args), + WMAX_METHOD_DEEP_SLEEP_CONTROL, NULL); =20 if (ACPI_FAILURE(status)) pr_err("alienware-wmi: deep sleep control failed: results: %u\n", --=20 2.47.0 From nobody Mon Nov 25 04:34:39 2024 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2AC14C70; Wed, 30 Oct 2024 00:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247097; cv=none; b=qttFYTAB9pzxvbg9LfOhRjtzb1fCjbkML2E5djv/3n7zEhVlAjCUokkWcTxS2yddiRFammM/0pJ83GSS2xg60AJYmGLZ1vppttgAimG55Mr9qNnKXQb+Gx1hXZQx7QD2k7W8qWv0vX0xSaNgs8d52R3Oi1K0P1wK6ijuVSYwl7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247097; c=relaxed/simple; bh=pf3sD3MbYCSYQxm9zHw0EJiDdh0mVdrLmFweyGjc7aU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vD9zvqqBWaHfaD2mDs0PavJX7Q2x3gDn8b86ZXuymKedynC8dyo5hsQ/cZINMktn6wMw6aqnb0q/BSzX8K4DyUTW/0Ojfxq5J9wtE6VVtfo5IyCIeoojUT/LVr10EsmAdI2WteSbZwS6ILQ2gmfeeyClHCTUwlzbZuOJtoMp8xQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PMrJprMZ; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PMrJprMZ" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7203c431f93so4890354b3a.1; Tue, 29 Oct 2024 17:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730247093; x=1730851893; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=taYRR4OSUfkeJSEK5UMigfxVi7OPabjSOJE8RJIip0Y=; b=PMrJprMZE90hJTC2dcJTeIwl+dQlSwkDIgXN00kM6xGFTNee0WB7mQU2wFLuwWjvhR O1TMrvGE4VA01QzQ1lulk6/k9QMc0JuD4RFYQJD4wMaWNrATiMuNvOccQ+UtNGYCICyo XcesZjzPhFxN8ru7TgD3cgLQxQ+JQeaz6pdt/ny9eufpB7SQ1IJQ+E71aDdb8t/fN2mg htgNji9xCyuTYkZR+HHrtK+qCqJGMYfv77J5JJdlvAem+woKKJyfvFnOGenfaDdbZ8RV pFkjVhwA2b8jUWa+PzcjjbNjkW/eJqtKsF+GhUTdakhWuUhoxgrWOkQC04ZRztdQupn+ NneA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730247093; x=1730851893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=taYRR4OSUfkeJSEK5UMigfxVi7OPabjSOJE8RJIip0Y=; b=WzDM4hj6PaPPEcbkFTkQ5Z5jYwn9yMYcfbWOYgFykbqezX3I5R95EUGV4neRfzIwEU 3krGWVJVbyq+0ISV9pE+4/l5adJE4CDs0Q1NKqdCnE2UrvjLa8YJmmP/4K4gHM2BTsvF DMGCC8xmGhpG+opg4EvBgc8nAeeQfIyvJRtMRUVwNGdJNivG0yf0uHtFvu1LeCAks7CS rtSFKfk2UzDhpy+4wsYGv4BptsxgPSlKvJqVdHzjEpCcL1TFCXiSLsV3JGRJeABS9m4T 88337vj7I9wL1zSKLcP/UrttgKdt4GCGTUKvW8Ts14mCXZdm8QNEzTSlfy/C87VA8cGK 87pg== X-Forwarded-Encrypted: i=1; AJvYcCVpupiDJfQqUkiSOfWAGhBW/kMVWkJgtxmmv7ZAukiA6qZGv6jnPS3Mdm1xeAaLTbRxJLYl+zRQVBAbnH78HcIc6zt0GQ==@vger.kernel.org, AJvYcCW+AYDfY/RlAShLfGLZBKkNo305B5ja/DInR4TIjBo0Tlt76y5te8LS8VBYnv/Of69is47oMWhRBcvUrGE=@vger.kernel.org X-Gm-Message-State: AOJu0YzqCKgA39gCjxK8CEDoGbOkSjVWVpGICXlR0uCeWsA4dND/54l+ aZNqGeZsL/x4rGLF81hI+sdKGhid51JJgrQKsPXazoUkgorWbt+aE30XzQ== X-Google-Smtp-Source: AGHT+IFKTlrDIS1aIHvVLt0pQOiL87MN0EDOf71BZBUmVK2Lw2joUswXZL808utAjyPJFdSpPUJcCg== X-Received: by 2002:a05:6a00:1790:b0:71e:6f32:df07 with SMTP id d2e1a72fcca58-72062f81e60mr17193489b3a.1.1730247092676; Tue, 29 Oct 2024 17:11:32 -0700 (PDT) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057a3fddbsm8176003b3a.209.2024.10.29.17.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 17:11:32 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: W_Armin@gmx.de, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v11 3/5] alienware-wmi: added platform profile support Date: Tue, 29 Oct 2024 21:11:23 -0300 Message-ID: <20241030001124.7589-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030000904.7205-2-kuurtb@gmail.com> References: <20241030000904.7205-2-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Implements platform profile support for Dell laptops with new WMAX thermal interface, present on some Alienware X-Series, Alienware M-Series and Dell's G-Series laptops. This interface is suspected to be used by Alienware Command Center (AWCC), which is not available for linux systems, to manage thermal profiles. This implementation makes use of three WMI methods, namely THERMAL_CONTROL, THERMAL_INFORMATION and GAME_SHIFT_STATUS, which take u32 as input and output arguments. Each method has a set of supported operations specified in their respective enums. Not all models with WMAX WMI interface support these methods. Because of this, models have to manually declare support through new quirks `thermal` for THERMAL_CONTROL and THERMAL_INFORMATION and `gmode` for GAME_SHIFT_STATUS. Wrappers written for these methods support multiple operations. THERMAL_CONTROL switches thermal modes through operation ACTIVATE_PROFILE. Available thermal codes are auto-detected at runtime and matched against a list of known thermal codes: Thermal Table "User Selectable Thermal Tables" (USTT): BALANCED 0xA0 BALANCED_PERFORMANCE 0xA1 COOL 0xA2 QUIET 0xA3 PERFORMANCE 0xA4 LOW_POWER 0xA5 Thermal Table Basic: QUIET 0x96 BALANCED 0x97 BALANCED_PERFORMANCE 0x98 PERFORMANCE 0x99 Devices are known to implement only one of these tables without mixing their thermal codes. The fact that the least significant digit of every thermal code is consecutive of one another is exploited to efficiently match codes through arrays. Autodetection of available codes is done through operation LIST_IDS of method THERMAL_INFORMATION. This operation lists fan IDs, CPU sensor ID, GPU sensor ID and available thermal profile codes, *in that order*. As number of fans and thermal codes is very model dependent, almost every ID is scanned and matched based on conditions found on is_wmax_thermal_code(). The known upper bound for the number of IDs is 13, corresponding to a device that have 4 fans, 2 sensors and 7 thermal codes. Additionally G-Series laptops have a key called G-key, which (with AWCC proprietary driver) switches the thermal mode to an special mode named GMODE with code 0xAB and changes Game Shift Status to 1. Game Shift is a mode the manufacturer claims, increases gaming performance. GAME_SHIFT_STATUS method is used to mimic this behavior when selecting PLATFORM_PROFILE_PERFORMANCE option. All of these profiles are known to only change fan speed profiles, although there are untested claims that some of them also change power profiles. Activating a thermal mode with method THERMAL_CONTROL may cause short hangs. This is a known problem present on every platform. Signed-off-by: Kurt Borja Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf --- v11: - Unchanged v10: - Corrected THERMAL_MODE_BASIC_BALANCED -> THERMAL_MODE_BASIC_QUIET in is_wmax_thermal_code() logic - `thermal` and `gmode` quirks now have to be manually selected, because not all Dell devices posses the new WMI thermal methods. - Because of the above reason, errors in create_thermal_profile are now propagated v9: - Bool comparisons are now coherent with their type v8: - Fixed alignment in wmax_mode_to_platform_profile[] - Quirk thermal and gmode changed from u8 -> bool - Autodetected quirk entries are not initialized - is_wmax_thermal_code refactored to increase readibility - is_wmax_thermal_code now covers all possibilities - Better commit message v7: - Method operations are now clearly listed as separate enums - wmax_thermal_modes are now listed without codes in order to support autodetection, as well as getting and setting thermal profiles cleanly through arrays - Added wmax_mode_to_platform_profile[] - Added struct wmax_u32_args to replace bit mask approach of constructing arguments for wmax methods - create_thermal_profile now autodetects available thermal codes through operation 0x03 of THERMAL_INFORMATION method. These are codes are stored in supported_thermal_profiles[] - thermal_profile_get now uses wmax_mode_to_platform_profile[] instead of switch-case approach - thermal_profile_set now uses supported_thermal_profiles[] instead of switch-case approach - When gmode is autodetected, thermal_profile_set also sets Game Shift status accordingly v6: - Fixed alignment on some function definitions - Fixed braces on if statment - Removed quirk thermal_ustt - Now quirk thermal can take values defined in enum WMAX_THERMAL_TABLE. - Proper removal of thermal_profile --- drivers/platform/x86/dell/Kconfig | 1 + drivers/platform/x86/dell/alienware-wmi.c | 306 ++++++++++++++++++++++ 2 files changed, 307 insertions(+) diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/= Kconfig index 68a49788a..b06d634cd 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -21,6 +21,7 @@ config ALIENWARE_WMI depends on LEDS_CLASS depends on NEW_LEDS depends on ACPI_WMI + select ACPI_PLATFORM_PROFILE help This is a driver for controlling Alienware BIOS driven features. It exposes an interface for controlling the AlienFX diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index b27f3b64c..1d62c2ce7 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -8,8 +8,11 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include +#include +#include #include #include +#include #include #include =20 @@ -25,6 +28,13 @@ #define WMAX_METHOD_AMPLIFIER_CABLE 0x6 #define WMAX_METHOD_DEEP_SLEEP_CONTROL 0x0B #define WMAX_METHOD_DEEP_SLEEP_STATUS 0x0C +#define WMAX_METHOD_THERMAL_INFORMATION 0x14 +#define WMAX_METHOD_THERMAL_CONTROL 0x15 +#define WMAX_METHOD_GAME_SHIFT_STATUS 0x25 + +#define WMAX_THERMAL_MODE_GMODE 0xAB + +#define WMAX_FAILURE_CODE 0xFFFFFFFF =20 MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); @@ -49,11 +59,59 @@ enum WMAX_CONTROL_STATES { WMAX_SUSPEND =3D 3, }; =20 +enum WMAX_THERMAL_INFORMATION_OPERATIONS { + WMAX_OPERATION_LIST_IDS =3D 0x03, + WMAX_OPERATION_CURRENT_PROFILE =3D 0x0B, +}; + +enum WMAX_THERMAL_CONTROL_OPERATIONS { + WMAX_OPERATION_ACTIVATE_PROFILE =3D 0x01, +}; + +enum WMAX_GAME_SHIFT_STATUS_OPERATIONS { + WMAX_OPERATION_TOGGLE_GAME_SHIFT =3D 0x01, + WMAX_OPERATION_GET_GAME_SHIFT_STATUS =3D 0x02, +}; + +enum WMAX_THERMAL_TABLES { + WMAX_THERMAL_TABLE_BASIC =3D 0x90, + WMAX_THERMAL_TABLE_USTT =3D 0xA0, +}; + +enum wmax_thermal_mode { + THERMAL_MODE_USTT_BALANCED, + THERMAL_MODE_USTT_BALANCED_PERFORMANCE, + THERMAL_MODE_USTT_COOL, + THERMAL_MODE_USTT_QUIET, + THERMAL_MODE_USTT_PERFORMANCE, + THERMAL_MODE_USTT_LOW_POWER, + THERMAL_MODE_BASIC_QUIET, + THERMAL_MODE_BASIC_BALANCED, + THERMAL_MODE_BASIC_BALANCED_PERFORMANCE, + THERMAL_MODE_BASIC_PERFORMANCE, + THERMAL_MODE_LAST, +}; + +static const enum platform_profile_option wmax_mode_to_platform_profile[TH= ERMAL_MODE_LAST] =3D { + [THERMAL_MODE_USTT_BALANCED] =3D PLATFORM_PROFILE_BALANCED, + [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_PE= RFORMANCE, + [THERMAL_MODE_USTT_COOL] =3D PLATFORM_PROFILE_COOL, + [THERMAL_MODE_USTT_QUIET] =3D PLATFORM_PROFILE_QUIET, + [THERMAL_MODE_USTT_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, + [THERMAL_MODE_USTT_LOW_POWER] =3D PLATFORM_PROFILE_LOW_POWER, + [THERMAL_MODE_BASIC_QUIET] =3D PLATFORM_PROFILE_QUIET, + [THERMAL_MODE_BASIC_BALANCED] =3D PLATFORM_PROFILE_BALANCED, + [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_P= ERFORMANCE, + [THERMAL_MODE_BASIC_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, +}; + struct quirk_entry { u8 num_zones; u8 hdmi_mux; u8 amplifier; u8 deepslp; + bool thermal; + bool gmode; }; =20 static struct quirk_entry *quirks; @@ -64,6 +122,8 @@ static struct quirk_entry quirk_inspiron5675 =3D { .hdmi_mux =3D 0, .amplifier =3D 0, .deepslp =3D 0, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_unknown =3D { @@ -71,6 +131,8 @@ static struct quirk_entry quirk_unknown =3D { .hdmi_mux =3D 0, .amplifier =3D 0, .deepslp =3D 0, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_x51_r1_r2 =3D { @@ -78,6 +140,8 @@ static struct quirk_entry quirk_x51_r1_r2 =3D { .hdmi_mux =3D 0, .amplifier =3D 0, .deepslp =3D 0, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_x51_r3 =3D { @@ -85,6 +149,8 @@ static struct quirk_entry quirk_x51_r3 =3D { .hdmi_mux =3D 0, .amplifier =3D 1, .deepslp =3D 0, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_asm100 =3D { @@ -92,6 +158,8 @@ static struct quirk_entry quirk_asm100 =3D { .hdmi_mux =3D 1, .amplifier =3D 0, .deepslp =3D 0, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_asm200 =3D { @@ -99,6 +167,8 @@ static struct quirk_entry quirk_asm200 =3D { .hdmi_mux =3D 1, .amplifier =3D 0, .deepslp =3D 1, + .thermal =3D false, + .gmode =3D false, }; =20 static struct quirk_entry quirk_asm201 =3D { @@ -106,6 +176,17 @@ static struct quirk_entry quirk_asm201 =3D { .hdmi_mux =3D 1, .amplifier =3D 1, .deepslp =3D 1, + .thermal =3D false, + .gmode =3D false, +}; + +static struct quirk_entry quirk_x_series =3D { + .num_zones =3D 2, + .hdmi_mux =3D 0, + .amplifier =3D 0, + .deepslp =3D 0, + .thermal =3D true, + .gmode =3D false, }; =20 static int __init dmi_matched(const struct dmi_system_id *dmi) @@ -178,6 +259,15 @@ static const struct dmi_system_id alienware_quirks[] _= _initconst =3D { }, .driver_data =3D &quirk_inspiron5675, }, + { + .callback =3D dmi_matched, + .ident =3D "Alienware x15 R1", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), + }, + .driver_data =3D &quirk_x_series, + }, {} }; =20 @@ -214,10 +304,19 @@ struct wmax_led_args { u8 state; } __packed; =20 +struct wmax_u32_args { + u8 operation; + u8 arg1; + u8 arg2; + u8 arg3; +}; + static struct platform_device *platform_device; static struct device_attribute *zone_dev_attrs; static struct attribute **zone_attrs; static struct platform_zone *zone_data; +static struct platform_profile_handler pp_handler; +static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_= LAST]; =20 static struct platform_driver platform_driver =3D { .driver =3D { @@ -761,6 +860,204 @@ static int create_deepsleep(struct platform_device *d= ev) return ret; } =20 +/* + * Thermal Profile control + * - Provides thermal profile control through the Platform Profile API + */ +#define WMAX_THERMAL_TABLE_MASK GENMASK(7, 4) +#define WMAX_THERMAL_MODE_MASK GENMASK(3, 0) +#define WMAX_SENSOR_ID_MASK BIT(8) + +static bool is_wmax_thermal_code(u32 code) +{ + if (code & WMAX_SENSOR_ID_MASK) + return false; + + if ((code & WMAX_THERMAL_MODE_MASK) >=3D THERMAL_MODE_LAST) + return false; + + if ((code & WMAX_THERMAL_TABLE_MASK) =3D=3D WMAX_THERMAL_TABLE_BASIC && + (code & WMAX_THERMAL_MODE_MASK) >=3D THERMAL_MODE_BASIC_QUIET) + return true; + + if ((code & WMAX_THERMAL_TABLE_MASK) =3D=3D WMAX_THERMAL_TABLE_USTT && + (code & WMAX_THERMAL_MODE_MASK) <=3D THERMAL_MODE_USTT_LOW_POWER) + return true; + + return false; +} + +static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) +{ + acpi_status status; + struct wmax_u32_args in_args =3D { + .operation =3D operation, + .arg1 =3D arg, + .arg2 =3D 0, + .arg3 =3D 0, + }; + + status =3D alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_THERMAL_INFORMATION, + out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (*out_data =3D=3D WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int wmax_thermal_control(u8 profile) +{ + acpi_status status; + struct wmax_u32_args in_args =3D { + .operation =3D WMAX_OPERATION_ACTIVATE_PROFILE, + .arg1 =3D profile, + .arg2 =3D 0, + .arg3 =3D 0, + }; + u32 out_data; + + status =3D alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_THERMAL_CONTROL, + &out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (out_data =3D=3D WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int wmax_game_shift_status(u8 operation, u32 *out_data) +{ + acpi_status status; + struct wmax_u32_args in_args =3D { + .operation =3D operation, + .arg1 =3D 0, + .arg2 =3D 0, + .arg3 =3D 0, + }; + + status =3D alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_GAME_SHIFT_STATUS, + out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (*out_data =3D=3D WMAX_FAILURE_CODE) + return -EOPNOTSUPP; + + return 0; +} + +static int thermal_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + u32 out_data; + int ret; + + ret =3D wmax_thermal_information(WMAX_OPERATION_CURRENT_PROFILE, + 0, &out_data); + + if (ret < 0) + return ret; + + if (out_data =3D=3D WMAX_THERMAL_MODE_GMODE) { + *profile =3D PLATFORM_PROFILE_PERFORMANCE; + return 0; + } + + if (!is_wmax_thermal_code(out_data)) + return -ENODATA; + + out_data &=3D WMAX_THERMAL_MODE_MASK; + *profile =3D wmax_mode_to_platform_profile[out_data]; + + return 0; +} + +static int thermal_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + if (quirks->gmode) { + u32 gmode_status; + int ret; + + ret =3D wmax_game_shift_status(WMAX_OPERATION_GET_GAME_SHIFT_STATUS, + &gmode_status); + + if (ret < 0) + return ret; + + if ((profile =3D=3D PLATFORM_PROFILE_PERFORMANCE && !gmode_status) || + (profile !=3D PLATFORM_PROFILE_PERFORMANCE && gmode_status)) { + ret =3D wmax_game_shift_status(WMAX_OPERATION_TOGGLE_GAME_SHIFT, + &gmode_status); + + if (ret < 0) + return ret; + } + } + + return wmax_thermal_control(supported_thermal_profiles[profile]); +} + +static int create_thermal_profile(void) +{ + u32 out_data; + enum wmax_thermal_mode mode; + enum platform_profile_option profile; + int ret; + + for (u8 i =3D 0x2; i <=3D 0xD; i++) { + ret =3D wmax_thermal_information(WMAX_OPERATION_LIST_IDS, + i, &out_data); + + if (ret =3D=3D -EIO) + return ret; + + if (ret =3D=3D -EBADRQC) + break; + + if (!is_wmax_thermal_code(out_data)) + continue; + + mode =3D out_data & WMAX_THERMAL_MODE_MASK; + profile =3D wmax_mode_to_platform_profile[mode]; + supported_thermal_profiles[profile] =3D out_data; + + set_bit(profile, pp_handler.choices); + } + + if (bitmap_empty(pp_handler.choices, PLATFORM_PROFILE_LAST)) + return -ENODEV; + + if (quirks->gmode) { + supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =3D + WMAX_THERMAL_MODE_GMODE; + + set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); + } + + pp_handler.profile_get =3D thermal_profile_get; + pp_handler.profile_set =3D thermal_profile_set; + + return platform_profile_register(&pp_handler); +} + +static void remove_thermal_profile(void) +{ + if (quirks->thermal) + platform_profile_remove(); +} + static int __init alienware_wmi_init(void) { int ret; @@ -808,6 +1105,12 @@ static int __init alienware_wmi_init(void) goto fail_prep_deepsleep; } =20 + if (quirks->thermal) { + ret =3D create_thermal_profile(); + if (ret) + goto fail_prep_thermal_profile; + } + ret =3D alienware_zone_init(platform_device); if (ret) goto fail_prep_zones; @@ -816,6 +1119,8 @@ static int __init alienware_wmi_init(void) =20 fail_prep_zones: alienware_zone_exit(platform_device); + remove_thermal_profile(); +fail_prep_thermal_profile: fail_prep_deepsleep: fail_prep_amplifier: fail_prep_hdmi: @@ -835,6 +1140,7 @@ static void __exit alienware_wmi_exit(void) if (platform_device) { alienware_zone_exit(platform_device); remove_hdmi(platform_device); + remove_thermal_profile(); platform_device_unregister(platform_device); platform_driver_unregister(&platform_driver); } --=20 2.47.0 From nobody Mon Nov 25 04:34:39 2024 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 418EF440C; Wed, 30 Oct 2024 00:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247138; cv=none; b=FIuNW64rSA0C36rYFKAv7GaLdGhXntgFa++Y1UIP2QVru5upPrqUlFWv8i+NwrEfef+BwYnWmmKeu/FJmTwvxg+MZZImkbnrwyblaknvw2Gxy4Vtc44GkluO7Jdn+a+Znex1gV0uB1dPbAvX8ZbtTDJUcOHhWd61C4x2ZLxR57I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247138; c=relaxed/simple; bh=KIpxIg/fnyHZfZG3oyQ2rRPQXhqDdJpGUafpYV4GJDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L0OzeV7kVeWt+uvXplbS027o7CS5qupcEoGrJhx8VQ88N4EhyUxndQurz36Fr0miD8f17j/oGppuDOgd/iw4JKptbUZy1C9Ft3Jp8T9Bq2UlxQHt5zL8KLz+vwlGrBcIebxO7UCtLYwlxosQjLoQIU5dt22oOWdsXgaPlYuarMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JS/rZlWL; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JS/rZlWL" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20ce5e3b116so43416805ad.1; Tue, 29 Oct 2024 17:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730247135; x=1730851935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q4FHs2xo7SoGaE1iiSF7N0/21QZQb33Tz/rJ8tzfDxE=; b=JS/rZlWLPSxY3oIHWZIWnA0I76FQyLQ5UOvwdCmvjtmhv3pcBhLF4qvYJCJL4fXU7y NhbifZ/mAK0FT/+adOgBMH8VxjYWLqhWuVZjEWRe3e1gzzhikL0UojyTNiqxcSYHoNiq FTmj8noF60CrH9MdCh2PzLQBQIiQsYKn50wTvYYLhuTEydNG2HYqjK6pUYZ2aDUg96x/ dayHsVfGQxd4qsn2Zhs2QLl0qnBgj/HiTsOrcVD7PRy9Bk0Om0c6trrfd/LHU2HDunpC Y56eFcNMMJtRKmI+0NhIZ5Ih6DydR0r4ezRtB7jmG1Lvfw3CvOevegq6mU0wS0CTfcYe BCzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730247135; x=1730851935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q4FHs2xo7SoGaE1iiSF7N0/21QZQb33Tz/rJ8tzfDxE=; b=mmfHtlZ3KvY17MM/ZOj4vRLmwUF5+vgDjMBpFtPTc+mRnqJcA84GepJRpn6Xbp4qoP deMXTYFw2GATD0G19+EJRlwQctEanyruHwK4p8cdQWtX4cR4+19TST4hlnf4J9WdFcNQ 2E7bN4Il8QpnfW1rNrKsREF5oW5GFMPDz1czzm/WcEAtmUH7PGZHOVyjHYhwtAA604ko yPvn1nJuFvHSRiNwJbOfKjk6dIuO2t/vdduYy9CzLux0ms1JqMttszfhVCZtRByQeqSI ylgYxGGZUmvsjkhw8i1EZKWchCpfqbbuKyw9Lv7TgcWleNdJrTz5bdVG2rKqL4WxptAc y1kw== X-Forwarded-Encrypted: i=1; AJvYcCVXCKA011plF5XPasucsCL6Ls8X75WbUn44tCsIpNMIvsAod4ntz8eLnkIMrApQaeYPigXNHCaEAtGlwxA=@vger.kernel.org, AJvYcCWAQXLBLynao2PTDxEL6mUDTQTvLxsWAvLxzqDlxWsKehWBPeS0Std+KSfaCJzZvXUlAtnNEIMD/P1jUTHG3oTnCIds6Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yxd3PbOybT07ikDX3i8j5UYQ6fW9XgIpzKaTGe1TMxhaUFlbFYP pPOLvovHsPanLaiaj0rBZ5edoCQ96qzVTLXUf9MFt/78oSRHxkSX X-Google-Smtp-Source: AGHT+IHNoCah/wFxLMx1qtL536pU9PZINhr9LJEWr6qIyog9JRNVDaSLVg3c5Fgz4YI2kdxNbzBY/g== X-Received: by 2002:a17:903:32c4:b0:20c:a1a3:5373 with SMTP id d9443c01a7336-210c6c90e6cmr168617105ad.55.1730247135440; Tue, 29 Oct 2024 17:12:15 -0700 (PDT) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bc013462sm72165255ad.178.2024.10.29.17.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 17:12:15 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: W_Armin@gmx.de, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v11 4/5] alienware-wmi: added force module parameters Date: Tue, 29 Oct 2024 21:11:49 -0300 Message-ID: <20241030001148.7623-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030000904.7205-2-kuurtb@gmail.com> References: <20241030000904.7205-2-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added force_platform_profile and force_gmode unsafe module parameters, allowing users to force `thermal` and `gmode` quirks respectively. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- v11: - Removed unnecessary 'alienware-wmi' in pr_warn v10: - Introduced --- drivers/platform/x86/dell/alienware-wmi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index 1d62c2ce7..d74c6edef 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -42,6 +42,14 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID); MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID); =20 +static bool force_platform_profile; +module_param_unsafe(force_platform_profile, bool, 0); +MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal pr= ofiles without checking if WMI thermal backend is available"); + +static bool force_gmode; +module_param_unsafe(force_gmode, bool, 0); +MODULE_PARM_DESC(force_gmode, "Forces G-Mode when performance profile is s= elected"); + enum INTERFACE_FLAGS { LEGACY, WMAX, @@ -1075,6 +1083,16 @@ static int __init alienware_wmi_init(void) if (quirks =3D=3D NULL) quirks =3D &quirk_unknown; =20 + if (force_platform_profile) + quirks->thermal =3D true; + + if (force_gmode) { + if (quirks->thermal) + quirks->gmode =3D true; + else + pr_warn("force_gmode requieres platform profile support"); + } + ret =3D platform_driver_register(&platform_driver); if (ret) goto fail_platform_driver; --=20 2.47.0 From nobody Mon Nov 25 04:34:39 2024 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 656DE8F7D; Wed, 30 Oct 2024 00:12:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247163; cv=none; b=fPoQo+iFj/HFMI1Vfv+qz74VzBCsQcH+sParaI4ywXlGG/y84NdSley4awjyuT54zJ+jc7HJIv660VXpbxKQKCc3cXe4anBCzQl76f7No2DZOb07+hQ8KBBRdeb5Ia1q6WNNMeh6bl8xu1knBCwL3n+edNrbzhpNX1JIfxvDDXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730247163; c=relaxed/simple; bh=oM3u2WVAQSIAum0Ph7PBMigUeUH/81+gqOATbgG1+7Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X6YSi7fjVVCAR61nOjx9P5gxag3+NdkaFlgMXX1zfxQJPzRBjrCrUhe5Uo6u9fTeaxmu5gqTCbC6QYiZ3HfuZ7wGsEoY19SjWi4pcdeWNePNm1DsIETsN5v6gkE5SARy/ySOCY0svWmnqwB/1wQEgdEzJAfplqQRuzHHrFaZmgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U8nRElhX; arc=none smtp.client-ip=209.85.160.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U8nRElhX" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-288a90e4190so2869176fac.0; Tue, 29 Oct 2024 17:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730247159; x=1730851959; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UusaGnSZrxtVofmA3qEh8juOM0Ft+inRjY1u3Zb3B/8=; b=U8nRElhXMy8nW3Q+u5qNxXtIqo3FX1fOP7Z2Ue0FOqMOnpBf8a9QOVWpkmFTcmgRzY YGaZS3Q87F0xUO6GLaGVsJi7omgbc8od33dPwtRVYVHRBekmNfKILdXgn9KS/d6GbPQM 0FZK0BXFM3yRD6BK3x68aN5BZhrn6Pg3gPz7BywF6wYgSHn+DJ+d2HZtfP34Nj7s4Nju hMcG38Z/k/xFi2ErWcjad4igwSPr5UCkZiva+Ro0TkzC4B10d6s1lpXX7q591UsC82SB HOUWEdqfHZIKMliyS1Kp6sMC3DaWrE9l6tlq094ZEZJYA5+PnkcfCrsXW+huyV8qP9XG MfTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730247159; x=1730851959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UusaGnSZrxtVofmA3qEh8juOM0Ft+inRjY1u3Zb3B/8=; b=DYAFKsBwnPLhHP23o846nJ22wCzdHviBZgsPLJVbw0bwtKn7UOcfc2Kj9eG34DbLP/ NWGVXhPoaPVGWNJg5O2ZrDfRGIMWbE2ASAHqODQNLNlUz8aHshMCEaMfkdGUPAuLW6Jx d1Xiz5LpePXS0ooQlDcTHGTTYUCdb3YgxAq5z4MBCWUNqiassgWt4lpRsrTwaWHHcfRZ 6ZIk6PP39eASPVMSLksULzVEEHoGsx8ACHteGUs3sLhT5VuJQB4J+o8fpmL0bml9nR+t HrEM+cuUF4+IvpwFQlvvI+r2AFa70mFRNCmLYH+qOOoprXmldrnv/4ZccVi101O1ST6U 1Cbw== X-Forwarded-Encrypted: i=1; AJvYcCU/r3qpt/NgnO3KU1PTK5EqB9/6PgwaRZczghmRnq92+GUFBZ0otf7WBg2ceReX0gY+t+ZoSokrnyHCYVDBaUyp9cQ8Ug==@vger.kernel.org, AJvYcCV1HfuHCAlP/mogK1avdkiukwPSVQKQEOGoT1PcOPGFd10lF2De274yOtSvpw5AOMIemIN3Em9qW+YMAPg=@vger.kernel.org X-Gm-Message-State: AOJu0YwYwe61rHLOY/e3bWZwLAYnEV5buDc4Tmb+wcwr1PCRHlZDhrJa Wmfosq1aYLr1eQUyyqwgZYC4asCJ8TDgNBIGg2H1lfyKlMHsssAGKghXNA== X-Google-Smtp-Source: AGHT+IFsFgP4z65kZW904ljvoPw93JO7CVEzBvT1Bi51mqCgNFXMCEanWaNSxDpYYmSK8gnIxiIGSQ== X-Received: by 2002:a05:6870:b50e:b0:25e:24a0:4c96 with SMTP id 586e51a60fabf-29051b73021mr12481633fac.11.1730247159422; Tue, 29 Oct 2024 17:12:39 -0700 (PDT) Received: from localhost.localdomain (host95.181-12-202.telecom.net.ar. [181.12.202.95]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7edc8661070sm8164217a12.3.2024.10.29.17.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 17:12:39 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: W_Armin@gmx.de, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v11 5/5] alienware-wmi: WMAX interface documentation Date: Tue, 29 Oct 2024 21:12:27 -0300 Message-ID: <20241030001228.7770-1-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241030000904.7205-2-kuurtb@gmail.com> References: <20241030000904.7205-2-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Added documentation for new WMAX interface, present on some Alienware X-Series, Alienware M-Series and Dell's G-Series laptops. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen --- v11: - Unchanged v10: - Unchanged v9: - Unchanged v8: - Unchanged v7: - Added GameShiftStatus method to documentation - Added remark about operation 0x03 of Thermal_Information method - Removed undocumented methods v6: - Fixed typos - Included new file in MAINTAINERS --- Documentation/wmi/devices/alienware-wmi.rst | 388 ++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 389 insertions(+) create mode 100644 Documentation/wmi/devices/alienware-wmi.rst diff --git a/Documentation/wmi/devices/alienware-wmi.rst b/Documentation/wm= i/devices/alienware-wmi.rst new file mode 100644 index 000000000..36a67ff9a --- /dev/null +++ b/Documentation/wmi/devices/alienware-wmi.rst @@ -0,0 +1,388 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Dell AWCC WMI interface driver (alienware-wmi) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The WMI device WMAX has been implemented for many Alienware and Dell's G-S= eries +models. Throughout these models, two implementations have been identified.= The +first one, used by older systems, deals with HDMI, brightness, RGB, amplif= ier +and deep sleep control. The second one used by newer systems deals primari= ly +with thermal, overclocking, and GPIO control. + +It is suspected that the latter is used by Alienware Command Center (AWCC)= to +manage manufacturer predefined thermal profiles. The alienware-wmi driver +exposes Thermal_Information and Thermal_Control methods through the Platfo= rm +Profile API to mimic AWCC's behavior. + +This newer interface, named AWCCMethodFunction has been reverse engineered= , as +Dell has not provided any official documentation. We will try to describe = to the +best of our ability its discovered inner workings. + +.. note:: + The following method description may be incomplete and some operations = have + different implementations between devices. + +WMI interface description +------------------------- + +The WMI interface description can be decoded from the embedded binary MOF = (bmof) +data using the `bmfdec `_ utility: + +:: + + [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x409"), Description("WMI= Function"), guid("{A70591CE-A997-11DA-B012-B622A1EF5492}")] + class AWCCWmiMethodFunction { + [key, read] string InstanceName; + [read] boolean Active; + + [WmiMethodId(13), Implemented, read, write, Description("Return Overclo= cking Report.")] void Return_OverclockingReport([out] uint32 argr); + [WmiMethodId(14), Implemented, read, write, Description("Set OCUIBIOS C= ontrol.")] void Set_OCUIBIOSControl([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(15), Implemented, read, write, Description("Clear OC FailS= afe Flag.")] void Clear_OCFailSafeFlag([out] uint32 argr); + [WmiMethodId(19), Implemented, read, write, Description("Get Fan Sensor= s.")] void GetFanSensors([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(20), Implemented, read, write, Description("Thermal Inform= ation.")] void Thermal_Information([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(21), Implemented, read, write, Description("Thermal Contro= l.")] void Thermal_Control([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(23), Implemented, read, write, Description("MemoryOCContro= l.")] void MemoryOCControl([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(26), Implemented, read, write, Description("System Informa= tion.")] void SystemInformation([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(28), Implemented, read, write, Description("Power Informat= ion.")] void PowerInformation([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(32), Implemented, read, write, Description("FW Update GPIO= toggle.")] void FWUpdateGPIOtoggle([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(33), Implemented, read, write, Description("Read Total of = GPIOs.")] void ReadTotalofGPIOs([out] uint32 argr); + [WmiMethodId(34), Implemented, read, write, Description("Read GPIO pin = Status.")] void ReadGPIOpPinStatus([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(35), Implemented, read, write, Description("Read Chassis C= olor.")] void ReadChassisColor([out] uint32 argr); + [WmiMethodId(36), Implemented, read, write, Description("Read Platform = Properties.")] void ReadPlatformProperties([out] uint32 argr); + [WmiMethodId(37), Implemented, read, write, Description("Game Shift Sta= tus.")] void GameShiftStatus([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(128), Implemented, read, write, Description("Caldera SW in= stallation.")] void CalderaSWInstallation([out] uint32 argr); + [WmiMethodId(129), Implemented, read, write, Description("Caldera SW is= released.")] void CalderaSWReleased([out] uint32 argr); + [WmiMethodId(130), Implemented, read, write, Description("Caldera Conne= ction Status.")] void CalderaConnectionStatus([in] uint32 arg2, [out] uint3= 2 argr); + [WmiMethodId(131), Implemented, read, write, Description("Surprise Unpl= ugged Flag Status.")] void SurpriseUnpluggedFlagStatus([out] uint32 argr); + [WmiMethodId(132), Implemented, read, write, Description("Clear Surpris= e Unplugged Flag.")] void ClearSurpriseUnpluggedFlag([out] uint32 argr); + [WmiMethodId(133), Implemented, read, write, Description("Cancel Undock= Request.")] void CancelUndockRequest([out] uint32 argr); + [WmiMethodId(135), Implemented, read, write, Description("Devices in Ca= ldera.")] void DevicesInCaldera([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(136), Implemented, read, write, Description("Notify BIOS f= or SW ready to disconnect Caldera.")] void NotifyBIOSForSWReadyToDisconnect= Caldera([out] uint32 argr); + [WmiMethodId(160), Implemented, read, write, Description("Tobii SW inst= allation.")] void TobiiSWinstallation([out] uint32 argr); + [WmiMethodId(161), Implemented, read, write, Description("Tobii SW Rele= ased.")] void TobiiSWReleased([out] uint32 argr); + [WmiMethodId(162), Implemented, read, write, Description("Tobii Camera = Power Reset.")] void TobiiCameraPowerReset([out] uint32 argr); + [WmiMethodId(163), Implemented, read, write, Description("Tobii Camera = Power On.")] void TobiiCameraPowerOn([out] uint32 argr); + [WmiMethodId(164), Implemented, read, write, Description("Tobii Camera = Power Off.")] void TobiiCameraPowerOff([out] uint32 argr); + }; + +Some of these methods get quite intricate so we will describe them using +pseudo-code that vaguely resembles the original ASL code. + +Methods not described in the following document have unknown behavior. + +Argument Structure +------------------ + +All input arguments have type **uint32** and their structure is very simil= ar +between methods. Usually, the first byte corresponds to a specific *operat= ion* +the method performs, and the subsequent bytes correspond to *arguments* pa= ssed +to this *operation*. For example, if an operation has code 0x01 and requir= es an +ID 0xA0, the argument you would pass to the method is 0xA001. + + +Thermal Methods +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +WMI method Thermal_Information([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------- + +:: + + if BYTE_0(arg2) =3D=3D 0x01: + argr =3D 1 + + if BYTE_0(arg2) =3D=3D 0x02: + argr =3D UNKNOWN_CONSTANT + + if BYTE_0(arg2) =3D=3D 0x03: + if BYTE_1(arg2) =3D=3D 0x00: + argr =3D FAN_ID_0 + + if BYTE_1(arg2) =3D=3D 0x01: + argr =3D FAN_ID_1 + + if BYTE_1(arg2) =3D=3D 0x02: + argr =3D FAN_ID_2 + + if BYTE_1(arg2) =3D=3D 0x03: + argr =3D FAN_ID_3 + + if BYTE_1(arg2) =3D=3D 0x04: + argr =3D SENSOR_ID_CPU | 0x0100 + + if BYTE_1(arg2) =3D=3D 0x05: + argr =3D SENSOR_ID_GPU | 0x0100 + + if BYTE_1(arg2) =3D=3D 0x06: + argr =3D THERMAL_MODE_QUIET_ID + + if BYTE_1(arg2) =3D=3D 0x07: + argr =3D THERMAL_MODE_BALANCED_ID + + if BYTE_1(arg2) =3D=3D 0x08: + argr =3D THERMAL_MODE_BALANCED_PERFORMANCE_ID + + if BYTE_1(arg2) =3D=3D 0x09: + argr =3D THERMAL_MODE_PERFORMANCE_ID + + if BYTE_1(arg2) =3D=3D 0x0A: + argr =3D THERMAL_MODE_LOW_POWER_ID + + if BYTE_1(arg2) =3D=3D 0x0B: + argr =3D THERMAL_MODE_GMODE_ID + + else: + argr =3D 0xFFFFFFFF + + if BYTE_0(arg2) =3D=3D 0x04: + if is_valid_sensor(BYTE_1(arg2)): + argr =3D SENSOR_TEMP_C + else: + argr =3D 0xFFFFFFFF + + if BYTE_0(arg2) =3D=3D 0x05: + if is_valid_fan(BYTE_1(arg2)): + argr =3D FAN_RPM() + + if BYTE_0(arg2) =3D=3D 0x06: + skip + + if BYTE_0(arg2) =3D=3D 0x07: + argr =3D 0 + + If BYTE_0(arg2) =3D=3D 0x08: + if is_valid_fan(BYTE_1(arg2)): + argr =3D 0 + else: + argr =3D 0xFFFFFFFF + + if BYTE_0(arg2) =3D=3D 0x09: + if is_valid_fan(BYTE_1(arg2)): + argr =3D FAN_UNKNOWN_STAT_0() + + else: + argr =3D 0xFFFFFFFF + + if BYTE_0(arg2) =3D=3D 0x0A: + argr =3D THERMAL_MODE_BALANCED_ID + + if BYTE_0(arg2) =3D=3D 0x0B: + argr =3D CURRENT_THERMAL_MODE() + + if BYTE_0(arg2) =3D=3D 0x0C: + if is_valid_fan(BYTE_1(arg2)): + argr =3D FAN_UNKNOWN_STAT_1() + else: + argr =3D 0xFFFFFFFF + +Operation 0x03 list all available fan IDs, sensor IDs and thermal profile +codes in order, but different models may have different number of fans and +thermal profiles. These are the known ranges: + +* Fan IDs: from 2 up to 4 +* Sensor IDs: 2 +* Thermal profile codes: from 1 up to 7 + +In total BYTE_1(ARG2) may range from 0x5 up to 0xD depending on the model. + +WMI method Thermal_Control([in] uint32 arg2, [out] uint32 argr) +--------------------------------------------------------------- + +:: + + if BYTE_0(arg2) =3D=3D 0x01: + if is_valid_thermal_profile(BYTE_1(arg2)): + SET_THERMAL_PROFILE(BYTE_1(arg2)) + argr =3D 0 + + if BYTE_0(arg2) =3D=3D 0x02: + if is_valid_fan(BYTE_1(arg2)): + SET_FAN_SPEED_MULTIPLIER(BYTE_2(arg2)) + argr =3D 0 + else: + argr =3D 0xFFFFFFFF + +.. note:: + While you can manually change the fan speed multiplier with this method, + Dell's BIOS tends to overwrite this changes anyway. + +These are the known thermal profile codes: + +:: + + CUSTOM 0x00 + + BALANCED_USTT 0xA0 + BALANCED_PERFORMANCE_USTT 0xA1 + COOL_USTT 0xA2 + QUIET_USTT 0xA3 + PERFORMANCE_USTT 0xA4 + LOW_POWER_USTT 0xA5 + + QUIET 0x96 + BALANCED 0x97 + BALANCED_PERFORMANCE 0x98 + PERFORMANCE 0x99 + + GMODE 0xAB + +Usually if a model doesn't support the first four profiles they will suppo= rt +the User Selectable Thermal Tables (USTT) profiles and vice-versa. + +GMODE replaces PERFORMANCE in G-Series laptops. + +WMI method GameShiftStatus([in] uint32 arg2, [out] uint32 argr) +--------------------------------------------------------------- + +:: + + if BYTE_0(arg2) =3D=3D 0x1: + TOGGLE_GAME_SHIFT() + argr =3D GET_GAME_SHIFT_STATUS() + + if BYTE_0(arg2) =3D=3D 0x2: + argr =3D GET_GAME_SHIFT_STATUS() + +Game Shift Status does not change the fan speed profile but it could be so= me +sort of CPU/GPU power profile. Benchmarks have not been done. + +This method is only present on Dell's G-Series laptops and it's implementa= tion +implies GMODE thermal profile is available, even if operation 0x03 of +Thermal_Information does not list it. + +G-key on Dell's G-Series laptops also changes Game Shift status, so both a= re +directly related. + +WMI method GetFanSensors([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------- + +:: + + if BYTE_0(arg2) =3D=3D 0x1: + if is_valid_fan(BYTE_1(arg2)): + argr =3D 1 + else: + argr =3D 0 + + if BYTE_0(arg2) =3D=3D 0x2: + if is_valid_fan(BYTE_1(arg2)): + if BYTE_2(arg2) =3D=3D 0: + argr =3D=3D SENSOR_ID + else + argr =3D=3D 0xFFFFFFFF + else: + argr =3D 0 + +Overclocking Methods +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. warning:: + These methods have not been tested and are only partially reverse + engineered. + +WMI method Return_OverclockingReport([out] uint32 argr) +------------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr =3D 0 + +CSMI is an unknown operation. + +WMI method Set_OCUIBIOSControl([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr =3D 0 + +CSMI is an unknown operation. + +WMI method Clear_OCFailSafeFlag([out] uint32 argr) +-------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr =3D 0 + +CSMI is an unknown operation. + + +WMI method MemoryOCControl([in] uint32 arg2, [out] uint32 argr) +--------------------------------------------------------------- + +AWCC supports memory overclocking, but this method is very intricate and h= as +not been deciphered yet. + +GPIO methods +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +These methods are probably related to some kind of firmware update system, +through a GPIO device. + +.. warning:: + These methods have not been tested and are only partially reverse + engineered. + +WMI method FWUpdateGPIOtoggle([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------ + +:: + + if BYTE_0(arg2) =3D=3D 0: + if BYTE_1(arg2) =3D=3D 1: + SET_PIN_A_HIGH() + else: + SET_PIN_A_LOW() + + if BYTE_0(arg2) =3D=3D 1: + if BYTE_1(arg2) =3D=3D 1: + SET_PIN_B_HIGH() + + else: + SET_PIN_B_LOW() + + else: + argr =3D 1 + +WMI method ReadTotalofGPIOs([out] uint32 argr) +---------------------------------------------- + +:: + + argr =3D 0x02 + +WMI method ReadGPIOpPinStatus([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------ + +:: + + if BYTE_0(arg2) =3D=3D 0: + argr =3D PIN_A_STATUS + + if BYTE_0(arg2) =3D=3D 1: + argr =3D PIN_B_STATUS + +Other information Methods +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +WMI method ReadChassisColor([out] uint32 argr) +---------------------------------------------- + +:: + + argr =3D CHASSIS_COLOR_ID + +Acknowledgements +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Kudos to `AlexIII `_ for documenting +and testing available thermal profile codes. + diff --git a/MAINTAINERS b/MAINTAINERS index c27f31907..25f6de4c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -792,6 +792,7 @@ F: drivers/perf/alibaba_uncore_drw_pmu.c ALIENWARE WMI DRIVER L: Dell.Client.Kernel@dell.com S: Maintained +F: Documentation/wmi/devices/alienware-wmi.rst F: drivers/platform/x86/dell/alienware-wmi.c =20 ALLEGRO DVT VIDEO IP CORE DRIVER --=20 2.47.0