From patchwork Sat Oct 12 02:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13833922 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 2C5E6C133; Sat, 12 Oct 2024 02:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698504; cv=none; b=QOcTxxbjlhsrH5mDz7GapG9ZwPEoBkG67zjSxkmojbzbhOpi6UnL34RMdzueIlhwvGlzhwByKEsTHUgoexpZF2pwtslS7+hv8C6Lz48j4+eIEnYLEvt4GYufADVGgm39suCWKCOAF62RREw8Pq8rHnDsb0foQ4OtsPeZYWPNUVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698504; c=relaxed/simple; bh=XmdlGaiTzRtw5oFDVqQhG4l0U3fF3Bb9A36hf7tcoiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HIrfOH1ZD9Bsz9eKTstQh1pQsIFJL4FllzPJ2He28Z9qkMniumVJBjZSGb0DEDV+t0SdoHGXmKSYctzMQl5U8uPZTyP8HRebsq0AgcuQKGAl/ysX0c/J+olMwWyh+lu9danokoEFm7n8SfstDOxV+3hECyx1Hm81lIn7jFgV+hc= 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=e/oue67r; arc=none smtp.client-ip=209.85.210.175 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="e/oue67r" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71df67c67fcso1891866b3a.2; Fri, 11 Oct 2024 19:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728698502; x=1729303302; 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=/kUTee/EwDKbhKkD7rEW0ZuZKhssUXJ82VeD3DcDvJk=; b=e/oue67rCsNETsWwAmBFb2uuWmg4rh6kivd8HcwukZzO0LqkhakyKDrHIVFiUy062E B1mv4hd8Smt0Hfck3e4orZMxqJn690LOpIMwk+tdTB407aP1+ct+cAe5J9ehkwWnUNwo mo9CU5PemgJdyIp7pnBwMmIqf4PUX+ejrEW0joVqckb1oZmziFXlVBrTa9rMvIDU+x9C i7SzzMbNV3SS1G4GHRxkVvaCSlSdx++U/63nHKLGe9F+8gdJvpgChsURmhBFux7woeM6 Zl2aSwG9avg+QqB39yONVLVbIW11bl5VF5VBE4ANGxiGLgjwJJd53up4TxbsOujJC3Ow YlpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728698502; x=1729303302; 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=/kUTee/EwDKbhKkD7rEW0ZuZKhssUXJ82VeD3DcDvJk=; b=Y93peRcaXRzAyVxJEn003D+Co6PkxqwFeYnl2jIRiZJdInWi2NJe0mFyTp7I7o6RMw 7GfEj9O7GvQp/J2GYGb0EBfeR8C+Ceyk+iO8RoxSlf2nGTLJjz5Q5N4Rcjm0xll7Hibq RQ+JEIV+V1e3ErUXYQQM7Z7izP1q01p2pUV3TgFMqzkZG9T+KxWx24HPCA/WbRDKXrzQ ZSyrKvCZFYngd+A45t9kTdFDwrS5FqqJoQOVhX7RXOIqrrsmdT7XbN9oBtdekHdIBlQy nJT6dPtPK5L5GxagwzlYL6ajAwA0C5rAmI4YzppsDrPPRFDgfUU6mMRWkcwE0n8Qb68e 6mRQ== X-Forwarded-Encrypted: i=1; AJvYcCXCXOcc4vUdVW2H6i/3SRoaTP0zHQtyxfLQ2XQ9jt5DLtI8l2rLMxdsjN+jXvP1ywKFuUHiagnRoCgHA2LAQmSWH8VIQw==@vger.kernel.org, AJvYcCXUstW6mqcxMycOQB5o3FLD16cUkC+X6oksfThwKRtUqZdHGrPKUjDjDDofOkAcT7ZQ5/LO+KhYiAtKEXE=@vger.kernel.org X-Gm-Message-State: AOJu0YyFe2WPZvLytZ6eJyH2w7DVjrlb5wcs2Qu8EHGIZGRe9gXDtDkx uky4cDIJGQtgI8sdR18O/TPEdXhspOdK97LRwzhnFoZpQWMMVwKj X-Google-Smtp-Source: AGHT+IHmphhDz492aFTizyr4HIrLKVrDEoTYtTbEwX7SWlbFqf1n7tsp3xYcTt8xT0nzJRnT0hJ83g== X-Received: by 2002:a05:6a00:10c5:b0:71d:f15e:d023 with SMTP id d2e1a72fcca58-71e4c152644mr2566715b3a.11.1728698502299; Fri, 11 Oct 2024 19:01:42 -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-71e2a9f5491sm3302405b3a.70.2024.10.11.19.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 19:01:41 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v5 1/4] alienware-wmi: fixed indentation and clean up Date: Fri, 11 Oct 2024 23:01:25 -0300 Message-ID: <20241012020124.19444-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241012015849.19036-3-kuurtb@gmail.com> References: <20241012015849.19036-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fixed inconsistent indentation and removed unnecessary (acpi_size) and (u32 *) casts. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf colors; @@ -306,7 +306,7 @@ static int alienware_update_led(struct platform_zone *zone) guid = LEGACY_CONTROL_GUID; method_id = zone->location + 1; - input.length = (acpi_size) sizeof(legacy_args); + input.length = sizeof(legacy_args); input.pointer = &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 = 0xFF, .percentage = brightness, }; - input.length = (acpi_size) sizeof(args); + input.length = sizeof(args); input.pointer = &args; status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, WMAX_METHOD_BRIGHTNESS, &input, NULL); @@ -508,7 +508,7 @@ static acpi_status alienware_wmax_command(struct wmax_basic_args *in_args, struct acpi_buffer input; struct acpi_buffer output; - input.length = (acpi_size) sizeof(*in_args); + input.length = sizeof(*in_args); input.pointer = in_args; if (out_data) { output.length = ACPI_ALLOCATE_BUFFER; @@ -542,7 +542,7 @@ static ssize_t show_hdmi_cable(struct device *dev, }; status = alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_CABLE, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -563,7 +563,7 @@ static ssize_t show_hdmi_source(struct device *dev, }; status = alienware_wmax_command(&in_args, WMAX_METHOD_HDMI_STATUS, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 1) @@ -643,7 +643,7 @@ static ssize_t show_amplifier_status(struct device *dev, }; status = alienware_wmax_command(&in_args, WMAX_METHOD_AMPLIFIER_CABLE, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -695,7 +695,7 @@ static ssize_t show_deepsleep_status(struct device *dev, .arg = 0, }; status = alienware_wmax_command(&in_args, WMAX_METHOD_DEEP_SLEEP_STATUS, - (u32 *) &out_data); + &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); From patchwork Sat Oct 12 02:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13833923 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 5AE78C13C; Sat, 12 Oct 2024 02:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698545; cv=none; b=DlF9pfYp2G7zXgpolZjmYtJybI174hpHl6FUmgMgUeaLehVOrH93aBr+u2Ji8CmktVWPEQ8M0QeuX4iAN7nPULLAkGK7YiY4lKwx66h+MQLOxONcjy98AWnzlspWMLCtCW3DkMjSJrXM+Y12gUM64Ro8ZErBHmH97w8rYYx4s0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698545; c=relaxed/simple; bh=QvqU/0s0+p7NCiBslJKW6/r/0xfhfdgPKOda1IKowok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ivQh1Gq49SU/o9n9GCxFMkR3yWqwzwUa9RPZ62uSD3dkrz6qh45YJ25jnYXpypUjpSHKwoOoGKKj4CF4+nJBFonNQsXw3FFIOH4hYpEtZ7kKzx7fJci3MEu/3Soq67/P6GJ0lbpJEv7DqYN8gVUcd+sizoMd1KGuqQJeweg55+U= 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=Ze9M/3Fk; arc=none smtp.client-ip=209.85.215.169 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="Ze9M/3Fk" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7db90a28cf6so2638273a12.0; Fri, 11 Oct 2024 19:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728698544; x=1729303344; 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=rVRKELwveqjnsA00akqlt37wgG9GG+cgl7++DvV05WU=; b=Ze9M/3FkFsNDJcxUEPla3GMvWevc5NiGyu+i4fl+DTTVANQ26d53IuK1/1NwYCCMMb FkX0G0N68h+a12DHMholDkQlrXM/g8BCQos+tjh+Ysp3GvC2Q3/WKOV3hoKVxJQd84sG T7FR2UvgksJNJ6dm8sijU60prF45tjfnKKyTJqZ5qidoqhw5tpUTaB9Sa+j2x0N3U+Kj wSrPj569BnmVFbhDLyeV8OcAdwU3vlcVwz5vZEWSOzWt0SsdmMuqrdY6VOruEFlf0E3N +k/nFYaLMsZhYrjrU2U2rKGp9Nf+A3BLg5dU5WbBIERbLWURC/JntavAxMXOOTLnE8kt c9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728698544; x=1729303344; 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=rVRKELwveqjnsA00akqlt37wgG9GG+cgl7++DvV05WU=; b=Be+TMLer9vr1uMkN88cbnpeiorvy3rwyb9GtMQljL2Rywd9KvWKNj2E5siw5MTD+vA 335wOLnpCCKT5zm7VE4nGXi+SWDMYxYet5BYl65MaJK2DIFoBM7uMiRummkEd03xFKxs bqkaE/gYy3PJrIsWSYjxl5WyfLeLk6vdmX6VQn+RRJk28mLomAG8/ZbskbcG4VWGs/XM pNg4E1TjjzNOCXDtvOTOnu28DIpdxGbqTqFzi5qpg1vzljHG74MJkyGoWssdFgEWi3ty G+GvvkUNLF8VeoNRnAovT+PfmhaGCOybibIb1ZCzJho6ttGHXKrl0d8Y8J9JrN0+LciG JxtA== X-Forwarded-Encrypted: i=1; AJvYcCUt7uhpwAwMUSbZptZFZKEhkfrdeYF3yP3m8WqbpzEmKjpmp7L4yGWmblv3mnFTOMW98cvT5nHWOX7BQtzOzFNexwgjnw==@vger.kernel.org, AJvYcCWeUUOByZEXRDD1TUE4aqncOX/dxGXnlwBiZvXCuYItB08SOthhcufYC8uFe92oO3/LH3lD45iTUdLBmiY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6VKxaFimWpL0/NqXOrGfrU2CFTxj4/jkr2O27u/WsIHcRaoem uoT4SpfbSiRZg8+Sk0LijcvcDkyqxOwzjdJsOr66E751c86Ty2a7RQikI4qi X-Google-Smtp-Source: AGHT+IHibgcahLPA7a8tFKlvj5+G20WvzV7fHlR4IR8gRLzfKbXNqt90qxtcuvUSU4de0EHe6DRj3A== X-Received: by 2002:a05:6a21:e86:b0:1d7:e62:ea94 with SMTP id adf61e73a8af0-1d8bc85d4e3mr6735703637.14.1728698543645; Fri, 11 Oct 2024 19:02:23 -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-71e2a9f5104sm3309373b3a.61.2024.10.11.19.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 19:02:22 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v5 2/4] alienware-wmi: alienware_wmax_command() is now input size agnostic Date: Fri, 11 Oct 2024 23:01:51 -0300 Message-ID: <20241012020149.19700-3-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241012015849.19036-3-kuurtb@gmail.com> References: <20241012015849.19036-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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/x86/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_device *dev) kfree(zone_attrs); } -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; - input.length = sizeof(*in_args); + input.length = in_size; input.pointer = in_args; if (out_data) { output.length = ACPI_ALLOCATE_BUFFER; @@ -541,8 +541,8 @@ static ssize_t show_hdmi_cable(struct device *dev, .arg = 0, }; status = - 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 == 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -562,8 +562,8 @@ static ssize_t show_hdmi_source(struct device *dev, .arg = 0, }; status = - 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); if (ACPI_SUCCESS(status)) { if (out_data == 1) @@ -589,7 +589,8 @@ static ssize_t toggle_hdmi_source(struct device *dev, args.arg = 3; pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf); - status = alienware_wmax_command(&args, WMAX_METHOD_HDMI_SOURCE, NULL); + status = alienware_wmax_command(&args, sizeof(args), + WMAX_METHOD_HDMI_SOURCE, NULL); 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 = 0, }; status = - 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 == 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 = { .arg = 0, }; - status = alienware_wmax_command(&in_args, WMAX_METHOD_DEEP_SLEEP_STATUS, - &out_data); + status = alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_DEEP_SLEEP_STATUS, &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); @@ -723,8 +724,8 @@ static ssize_t toggle_deepsleep(struct device *dev, args.arg = 2; pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf); - status = alienware_wmax_command(&args, WMAX_METHOD_DEEP_SLEEP_CONTROL, - NULL); + status = alienware_wmax_command(&args, sizeof(args), + WMAX_METHOD_DEEP_SLEEP_CONTROL, NULL); if (ACPI_FAILURE(status)) pr_err("alienware-wmi: deep sleep control failed: results: %u\n", From patchwork Sat Oct 12 02:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13833924 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 5593CDDAB; Sat, 12 Oct 2024 02:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698595; cv=none; b=Npip1t9PH0JxKIt7Jb43+8p09rJ0RhM1/dcbEUvkIDoJyuzzgWSW4PlpsPYNt3eiPio7nqbzR3ONmbXydtnl3YwZDNATOIBWtwk8ki6lISpxoKxZVYIhjbc6rX72ZhgWTSTe6He5khGQvFXXx70mXR+PcF8CviJoqARprJJ7baw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698595; c=relaxed/simple; bh=lWz8Z5uX6RChaZLi+ypEaFiUBvVBw5nE6aP+D0ICjUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yas6zS4WWK7KjH88e8lr5qlF0XQ+E9/gyEL/fVgpgEJxRZ1sXcsi+1ENdMFh6JTno7o2KJFYR6wA5X1vqrlEIIUOcPqMSvRDoGRJC+bp4sQKc7M6xhVKC7lfwfwpNUPplkwayMJ3j44cbFR84152SMGDrTM1zlQa/46KNuirgOo= 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=DPbnkRSC; arc=none smtp.client-ip=209.85.214.172 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="DPbnkRSC" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b93887decso24223735ad.3; Fri, 11 Oct 2024 19:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728698592; x=1729303392; 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=FGBbpSyDzxvkBFLRkjuldRmz7eKj2V2RMU8AliydPwI=; b=DPbnkRSCS1DdU+lMccZZC3cpNk04AyEe1UYChB0rcMHe9o1PE59A9D24D2Mx73EAnO hZj4hfs94DNyB9855YHp9GhXZqoaeJV2AH/sTbV5hMPP3WJEDR7/AN5csJ9KNWDjCdQo Fy+JRaUuOHNx6VFmpQE4pR3z75/FjLnwO6Qni5RXSZEO20XRXAowATt0NDuhPKmN3dsd Z0PaJM5BtmTPXatd4rCX4E8c2uwgoGpBPkf4qvBCRcPOEEQqIXpk/cv38eEVvNKgc6i3 ifv57rbUnfZuleOcp+vaHWgp4HYn91XgGjDw+6a3WAXu6Y4KwGn+KPRVgWJAAFxI3p94 1CvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728698592; x=1729303392; 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=FGBbpSyDzxvkBFLRkjuldRmz7eKj2V2RMU8AliydPwI=; b=p4ibBwx3M2fk5W0WrzJY82Ewn1IihUJm5VXrOpL23AIa6y3D5EaR2VgysQW0ou0snB htDAQlIBL34uu2w8om4TsATEa2VOD1uXxc6xKZmS9Rnvkz/KHegw//8JYtf6M5g85pjG ELhmWE594Rbh8XgHfcxrbsZQzTCZr59A8fvhOELJMuiS823Gf1RhFGw+i0c5KeEAByxh aCV0eo/QfvcWvJXiZ3ViHg0SjXSRLswASqfC6kofPIiM/sb8aRNn9S3ABmthl/rYdXOJ yLWLgGvAjWYCPi0ewxfRF5qjt31/5dZILbsJ7Am9Z6IiEHHTyZIpIXdH6+ARmSGUq2SS ibpw== X-Forwarded-Encrypted: i=1; AJvYcCUcKCK/v8z7S7pSD7W4OZnwqLmdQOOJHshQFnMyH4gLFWadd/hBr9SDzXB2bCAqd6nKSgdCLsU/EM32k1g=@vger.kernel.org, AJvYcCVF2QYtcElNdGiJdmo167i5Y4U/PZGJzqFpnKOthtUg5HQC3yvFvzypJGXrJGFaJny3X/ifYjKW4CR9N5wT5+W2Y711fQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzJaHF0zoaNM+hNqs86iXtkmV1laXA/zFtsiYFkA3j9zFm8wTsU FkHmKCP/jUvG5a1tjVmU1udlAuO7hGujq+c7FvLITgJkqapkE4Yc X-Google-Smtp-Source: AGHT+IFMxWHbmLU7a3tivX7UPYNLb4QUOYFWmlnmbDOwVNbVicfxO7Um2fK4aplLM22ds3BwMwI2jw== X-Received: by 2002:a17:902:e548:b0:20c:a7db:97bc with SMTP id d9443c01a7336-20cbb183517mr27396825ad.12.1728698592456; Fri, 11 Oct 2024 19:03:12 -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-7ea6e09eb1fsm259397a12.67.2024.10.11.19.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 19:03:11 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v5 3/4] alienware-wmi: added platform profile support Date: Fri, 11 Oct 2024 23:02:38 -0300 Message-ID: <20241012020237.20057-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241012015849.19036-3-kuurtb@gmail.com> References: <20241012015849.19036-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 implementation supports two sets of thermal profile codes, namely *thermal* and *thermal_ustt*, plus additional quirk *gmode* for Dell's G-Series laptops. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Kconfig | 1 + drivers/platform/x86/dell/alienware-wmi.c | 236 ++++++++++++++++++++++ 2 files changed, 237 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/x86/dell/alienware-wmi.c index b27f3b64c..6e30e9376 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 #include +#include +#include #include #include +#include #include #include @@ -25,6 +28,12 @@ #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_ARG_GET_CURRENT_PROF 0x0B + +#define WMAX_FAILURE_CODE 0xFFFFFFFF MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); @@ -49,11 +58,27 @@ enum WMAX_CONTROL_STATES { WMAX_SUSPEND = 3, }; +enum WMAX_THERMAL_PROFILE { + WMAX_THERMAL_QUIET = 0x96, + WMAX_THERMAL_BALANCED = 0x97, + WMAX_THERMAL_BALANCED_PERFORMANCE = 0x98, + WMAX_THERMAL_PERFORMANCE = 0x99, + WMAX_THERMAL_USTT_LOW_POWER = 0xA5, + WMAX_THERMAL_USTT_QUIET = 0xA3, + WMAX_THERMAL_USTT_BALANCED = 0xA0, + WMAX_THERMAL_USTT_BALANCED_PERFORMANCE = 0xA1, + WMAX_THERMAL_USTT_PERFORMANCE = 0xA4, + WMAX_THERMAL_GMODE = 0xAB, +}; + struct quirk_entry { u8 num_zones; u8 hdmi_mux; u8 amplifier; u8 deepslp; + u8 thermal; + u8 thermal_ustt; + u8 gmode; }; static struct quirk_entry *quirks; @@ -64,6 +89,9 @@ static struct quirk_entry quirk_inspiron5675 = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_unknown = { @@ -71,6 +99,9 @@ static struct quirk_entry quirk_unknown = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_x51_r1_r2 = { @@ -78,6 +109,9 @@ static struct quirk_entry quirk_x51_r1_r2 = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_x51_r3 = { @@ -85,6 +119,9 @@ static struct quirk_entry quirk_x51_r3 = { .hdmi_mux = 0, .amplifier = 1, .deepslp = 0, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_asm100 = { @@ -92,6 +129,9 @@ static struct quirk_entry quirk_asm100 = { .hdmi_mux = 1, .amplifier = 0, .deepslp = 0, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_asm200 = { @@ -99,6 +139,9 @@ static struct quirk_entry quirk_asm200 = { .hdmi_mux = 1, .amplifier = 0, .deepslp = 1, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, }; static struct quirk_entry quirk_asm201 = { @@ -106,6 +149,19 @@ static struct quirk_entry quirk_asm201 = { .hdmi_mux = 1, .amplifier = 1, .deepslp = 1, + .thermal = 0, + .thermal_ustt = 0, + .gmode = 0, +}; + +static struct quirk_entry quirk_x15_r1 = { + .num_zones = 2, + .hdmi_mux = 0, + .amplifier = 0, + .deepslp = 0, + .thermal = 0, + .thermal_ustt = 1, + .gmode = 0, }; static int __init dmi_matched(const struct dmi_system_id *dmi) @@ -169,6 +225,15 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { }, .driver_data = &quirk_asm201, }, + { + .callback = dmi_matched, + .ident = "Alienware x15 R1", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1") + }, + .driver_data = &quirk_x15_r1, + }, { .callback = dmi_matched, .ident = "Dell Inc. Inspiron 5675", @@ -218,6 +283,7 @@ 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 struct platform_driver platform_driver = { .driver = { @@ -761,6 +827,168 @@ static int create_deepsleep(struct platform_device *dev) return ret; } +/* + * Thermal Profile control + * - Provides thermal profile control through the Platform Profile API + */ +#define WMAX_PROFILE_MASK GENMASK(15, 8) +#define WMAX_PROFILE_ACTIVATE BIT(0) + +static u32 profile_to_wmax_arg(enum WMAX_THERMAL_PROFILE prof) +{ + return FIELD_PREP(WMAX_PROFILE_MASK, prof) | WMAX_PROFILE_ACTIVATE; +} + +static int thermal_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + acpi_status status; + u32 in_args = WMAX_ARG_GET_CURRENT_PROF; + u32 out_data; + + status = alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_THERMAL_INFORMATION, &out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (out_data == WMAX_FAILURE_CODE) + return -EBADRQC; + + switch (out_data) { + case WMAX_THERMAL_USTT_LOW_POWER: + *profile = PLATFORM_PROFILE_LOW_POWER; + break; + case WMAX_THERMAL_QUIET: + case WMAX_THERMAL_USTT_QUIET: + *profile = PLATFORM_PROFILE_QUIET; + break; + case WMAX_THERMAL_BALANCED: + case WMAX_THERMAL_USTT_BALANCED: + *profile = PLATFORM_PROFILE_BALANCED; + break; + case WMAX_THERMAL_BALANCED_PERFORMANCE: + case WMAX_THERMAL_USTT_BALANCED_PERFORMANCE: + *profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE; + break; + case WMAX_THERMAL_GMODE: + case WMAX_THERMAL_PERFORMANCE: + case WMAX_THERMAL_USTT_PERFORMANCE: + *profile = PLATFORM_PROFILE_PERFORMANCE; + break; + default: + return -ENODATA; + } + + return 0; +} + +static int thermal_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + acpi_status status; + u32 in_args; + u32 out_data; + + switch (profile) { + case PLATFORM_PROFILE_QUIET: + in_args = profile_to_wmax_arg(WMAX_THERMAL_QUIET); + break; + case PLATFORM_PROFILE_BALANCED: + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED); + break; + case PLATFORM_PROFILE_BALANCED_PERFORMANCE: + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED_PERFORMANCE); + break; + case PLATFORM_PROFILE_PERFORMANCE: + if (quirks->gmode > 0) + in_args = profile_to_wmax_arg(WMAX_THERMAL_GMODE); + else + in_args = profile_to_wmax_arg(WMAX_THERMAL_PERFORMANCE); + break; + default: + return -EOPNOTSUPP; + } + + status = alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_THERMAL_CONTROL, &out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (out_data == WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int thermal_profile_set_ustt(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + acpi_status status; + u32 in_args; + u32 out_data; + + switch (profile) { + case PLATFORM_PROFILE_LOW_POWER: + in_args = profile_to_wmax_arg(WMAX_THERMAL_USTT_LOW_POWER); + break; + case PLATFORM_PROFILE_QUIET: + in_args = profile_to_wmax_arg(WMAX_THERMAL_USTT_QUIET); + break; + case PLATFORM_PROFILE_BALANCED: + in_args = profile_to_wmax_arg(WMAX_THERMAL_USTT_BALANCED); + break; + case PLATFORM_PROFILE_BALANCED_PERFORMANCE: + in_args = profile_to_wmax_arg(WMAX_THERMAL_USTT_BALANCED_PERFORMANCE); + break; + case PLATFORM_PROFILE_PERFORMANCE: + if (quirks->gmode > 0) + in_args = profile_to_wmax_arg(WMAX_THERMAL_GMODE); + else + in_args = profile_to_wmax_arg(WMAX_THERMAL_USTT_PERFORMANCE); + break; + default: + return -EOPNOTSUPP; + } + + status = alienware_wmax_command(&in_args, sizeof(in_args), + WMAX_METHOD_THERMAL_CONTROL, &out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (out_data == WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int create_thermal_profile(void) +{ + pp_handler.profile_get = thermal_profile_get; + + if (quirks->thermal > 0) + pp_handler.profile_set = thermal_profile_set; + else { + pp_handler.profile_set = thermal_profile_set_ustt; + set_bit(PLATFORM_PROFILE_LOW_POWER, pp_handler.choices); + } + + set_bit(PLATFORM_PROFILE_QUIET, pp_handler.choices); + set_bit(PLATFORM_PROFILE_BALANCED, pp_handler.choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pp_handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); + + return platform_profile_register(&pp_handler); +} + +static void remove_thermal_profile(void) +{ + if (quirks->thermal > 0) + platform_profile_remove(); +} + static int __init alienware_wmi_init(void) { int ret; @@ -808,6 +1036,12 @@ static int __init alienware_wmi_init(void) goto fail_prep_deepsleep; } + if (quirks->thermal > 0 || quirks->thermal_ustt > 0) { + ret = create_thermal_profile(); + if (ret) + goto fail_prep_thermal_profile; + } + ret = alienware_zone_init(platform_device); if (ret) goto fail_prep_zones; @@ -818,6 +1052,7 @@ static int __init alienware_wmi_init(void) alienware_zone_exit(platform_device); fail_prep_deepsleep: fail_prep_amplifier: +fail_prep_thermal_profile: fail_prep_hdmi: platform_device_del(platform_device); fail_platform_device2: @@ -835,6 +1070,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); } From patchwork Sat Oct 12 02:03:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13833925 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 DFB8BCA6B; Sat, 12 Oct 2024 02:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698644; cv=none; b=GBNGbblazyLuP598ZcV5PthDvM6F8iZr9CYGTS+W+3u1uRxWtyM8hOin5hW+sc/3sID9g4yNgIb63/D1Qlum/dXwVgpHZBI3TlnS/K2NaN5VsJuz9/rnmz0vpVWedUBV/q4jxxhvutRDb7GphlHxDHDWl4RCu4lit/ZB4oCHI+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728698644; c=relaxed/simple; bh=uHTVNDHNzMdHEszGkpOtgg8HfLd1Ay6FO1JIqardStQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tA5bwNHTtiHRNCx9ci6Rs46b9sKDgc1MHpVapB26JUP6I1fnTO1vGl+dvzoJ+/ObBolSBkCMsN5bUOB6BoywMoEcuwQSJM/ICSYZMg+DQ7Pa492L7Y7c62AcZe2I1cRnObHO593Q/XJjCG5XWdXP/Urqt/csU8jyejaP46gEaIE= 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=ixfNIvSM; arc=none smtp.client-ip=209.85.210.175 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="ixfNIvSM" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71df04d3cd1so2245325b3a.2; Fri, 11 Oct 2024 19:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728698642; x=1729303442; 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=gWU58bMH8D3m63RV4wVHw9YRua6XCRL3HRZAWvufV1A=; b=ixfNIvSMn9AjbONtl+DA/a8y49JzfXzyZP/APyNP2blOnzbk3dgAf7rXxklBTE7QYl TEw2ducaNGIrtcSLpwZT82YRmPxukdFFkmRP2pci9AL0uL+8+/42ijmgox2yMmcYhkQq S86uj35QPac7gvtlO6bVGJQDfuxJGO+DMorV49pSDghnG7d6e5JgqR5A7z5z5l8WpPyW oACPPddsYu/vErOW6H6SBUHiPXTuo84xDSkpX3u0SG7iEaDkbgGtcyATZ/biqRv3XDLo fItqA55696O+BbvzBKR5/1joGrHbF2xGe1BPL/Mof0kbnjqEEPU15QNVcsz4iI2efL2O nXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728698642; x=1729303442; 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=gWU58bMH8D3m63RV4wVHw9YRua6XCRL3HRZAWvufV1A=; b=M46dWzfOm+N9AcjTanA43bYC7mSwZESsH/KCU4ySrtcREy0PoNTsqxsIJdzPF3IXYg VJIP9PGYELpt/4Mw3OUBlEE2qa9dOwZalzAWRxWjSZRZSB0YZpsOFacAQGc1oNIMo3j8 e5zjXjBeaDEPZtrSheE/Kt0RziAGXgb2rePNYYWrjBEg8Syr8ZGrGno5GnkElVWYhTOL S7fET7F0fDVvifjXd3l+FUMKN9Ll9nvnlwGqnh6nFgG/926N2pF7tSDo3Yn0c08E2COu Oaq08tZuMfv/cPMuMSoyw2ENNcAoHEBOwC151ZB/drnWPC4454Z5wegKpZOYWkDqv1K7 73jw== X-Forwarded-Encrypted: i=1; AJvYcCUBDamJ1/0VbpDWp+RtPGNLNwaE8U0YV1rWFwjFZXcvuYYxpKipTPv0C2bHaz3UE9JxhgJ6SICOOwRQy/gbVzx1uZBaCQ==@vger.kernel.org, AJvYcCUbOdVTVj1aHo2QQahvCCgd8lM7rgx6vynhu1gZJv81UMnaW3+BtFY4TuxytOq7FVUfQxOfL/V4YKMOazM=@vger.kernel.org X-Gm-Message-State: AOJu0YzkHB3MpTMiHSC+ybVo2dHbxU3qPsefx4Ko5UolWJymQd9ogyrs weeFF+DfRpRSYYtO/M6hTNimkZpXtEjJTW1ubgpeMjs405w3gkez/sxfGfta X-Google-Smtp-Source: AGHT+IHCRTRn/D4B9dbrCS7rOOPcPT9EdqvUfRgWiaSC7nI8av82kcl2Irbt5yHSMR4BC49Dwja9AQ== X-Received: by 2002:a05:6a21:38c:b0:1d7:76d:7ff with SMTP id adf61e73a8af0-1d8c96bbcd1mr1819207637.45.1728698642070; Fri, 11 Oct 2024 19:04:02 -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-7ea65fae62fsm1101646a12.39.2024.10.11.19.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 19:04:01 -0700 (PDT) From: Kurt Borja To: kuurtb@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v5 4/4] alienware-wmi: WMAX interface documentation Date: Fri, 11 Oct 2024 23:03:31 -0300 Message-ID: <20241012020330.20278-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241012015849.19036-3-kuurtb@gmail.com> References: <20241012015849.19036-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- Documentation/wmi/devices/alienware-wmi.rst | 366 ++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 Documentation/wmi/devices/alienware-wmi.rst diff --git a/Documentation/wmi/devices/alienware-wmi.rst b/Documentation/wmi/devices/alienware-wmi.rst new file mode 100644 index 000000000..77460b91c --- /dev/null +++ b/Documentation/wmi/devices/alienware-wmi.rst @@ -0,0 +1,366 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +============================================== +Dell AWCC WMI interface driver (alienware-wmi) +============================================== + +Introduction +============ + +The WMI device WMAX has been implemented for many Alienware and Dell's G-Series +models. Throughout these models, two implementations have been identified. The +first one, used by older systems, deals with HDMI, brightness, RGB, amplifier +and deep sleep control. The second one used by newer systems deals primarily +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 Platform +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 vary between models. + +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 Overclocking Report.")] void Return_OverclockingReport([out] uint32 argr); + [WmiMethodId(14), Implemented, read, write, Description("Set OCUIBIOS Control.")] void Set_OCUIBIOSControl([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(15), Implemented, read, write, Description("Clear OC FailSafe Flag.")] void Clear_OCFailSafeFlag([out] uint32 argr); + [WmiMethodId(19), Implemented, read, write, Description("Get Fan Sensors.")] void GetFanSensors([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(20), Implemented, read, write, Description("Thermal Information.")] void Thermal_Information([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(21), Implemented, read, write, Description("Thermal Control.")] void Thermal_Control([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(23), Implemented, read, write, Description("MemoryOCControl.")] void MemoryOCControl([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(26), Implemented, read, write, Description("System Information.")] void SystemInformation([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(28), Implemented, read, write, Description("Power Information.")] 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 Color.")] void ReadChassisColor([out] uint32 argr); + [WmiMethodId(36), Implemented, read, write, Description("Read Platform Properties.")] void ReadPlatformProperties([out] uint32 argr); + [WmiMethodId(128), Implemented, read, write, Description("Caldera SW installation.")] 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 Connection Status.")] void CalderaConnectionStatus([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(131), Implemented, read, write, Description("Surprise Unplugged Flag Status.")] void SurpriseUnpluggedFlagStatus([out] uint32 argr); + [WmiMethodId(132), Implemented, read, write, Description("Clear Surprise 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 Caldera.")] void DevicesInCaldera([in] uint32 arg2, [out] uint32 argr); + [WmiMethodId(136), Implemented, read, write, Description("Notify BIOS for SW ready to disconnect Caldera.")] void NotifyBIOSForSWReadyToDisconnectCaldera([out] uint32 argr); + [WmiMethodId(160), Implemented, read, write, Description("Tobii SW installation.")] void TobiiSWinstallation([out] uint32 argr); + [WmiMethodId(161), Implemented, read, write, Description("Tobii SW Released.")] 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. + +Argument Structure +------------------ + +All input arguments have type **uint32** and their structure is very similar +between methods. Usually, the first byte corresponds to a specific *operation* +the method performs, and the subsequent bytes correspond to *arguments* passed +to this *operation*. For example, if an operation has code 0x01 and requires an +ID 0xA0, the argument you would pass to the method is 0xA001. + + +Thermal Methods +=============== + +WMI method Thermal_Information([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------- + +:: + + if BYTE_0(arg2) == 0x01: + argr = 1 + + if BYTE_0(arg2) == 0x02: + argr = UNKNOWN_CONSTANT + + if BYTE_0(arg2) == 0x03: + if BYTE_1(arg2) == 0x00: + argr = FAN_ID_0 + + if BYTE_1(arg2) == 0x01: + argr = FAN_ID_1 + + if BYTE_1(arg2) == 0x02: + argr = FAN_ID_2 + + if BYTE_1(arg2) == 0x03: + argr = FAN_ID_3 + + if BYTE_1(arg2) == 0x04: + argr = SENSOR_ID_CPU | 0x0100 + + if BYTE_1(arg2) == 0x05: + argr = SENSOR_ID_GPU | 0x0100 + + if BYTE_1(arg2) == 0x06: + argr = THERMAL_MODE_QUIET_ID + + if BYTE_1(arg2) == 0x07: + argr = THERMAL_MODE_BALANCED_ID + + if BYTE_1(arg2) == 0x08: + argr = THERMAL_MODE_BALANCED_PERFORMANCE_ID + + if BYTE_1(arg2) == 0x09: + argr = THERMAL_MODE_PERFORMANCE_ID + + if BYTE_1(arg2) == 0x0A: + argr = THERMAL_MODE_LOW_POWER_ID + + if BYTE_1(arg2) == 0x0B: + argr = THERMAL_MODE_GMODE_ID + + else: + argr = 0xFFFFFFFF + + if BYTE_0(arg2) == 0x04: + if is_valid_sensor(BYTE_1(arg2)): + argr = SENSOR_TEMP_C + else: + argr = 0xFFFFFFFF + + if BYTE_0(arg2) == 0x05: + if is_valid_fan(BYTE_1(arg2)): + argr = FAN_RPM() + + if BYTE_0(arg2) == 0x06: + skip + + if BYTE_0(arg2) == 0x07: + argr = 0 + + If BYTE_0(arg2) == 0x08: + if is_valid_fan(BYTE_1(arg2)): + argr = 0 + else: + argr = 0xFFFFFFFF + + if BYTE_0(arg2) == 0x09: + if is_valid_fan(BYTE_1(arg2)): + argr = FAN_UNKNOWN_STAT_0() + + else: + argr = 0xFFFFFFFF + + if BYTE_0(arg2) == 0x0A: + argr = THERMAL_MODE_BALANCED_ID + + if BYTE_0(arg2) == 0x0B: + argr = CURRENT_THERMAL_MODE() + + if BYTE_0(arg2) == 0x0C: + if is_valid_fan(BYTE_1(arg2)): + argr = FAN_UNKNOWN_STAT_1() + else: + argr = 0xFFFFFFFF + +WMI method Thermal_Control([in] uint32 arg2, [out] uint32 argr) +--------------------------------------------------------------- + +:: + + if BYTE_0(arg2) == 0x01: + if is_valid_thermal_profile(BYTE_1(arg2)): + SET_THERMAL_PROFILE(BYTE_1(arg2)) + argr = 0 + + if BYTE_0(arg2) == 0x02: + if is_valid_fan(BYTE_1(arg2)): + SET_FAN_SPEED_MULTIPLIER(BYTE_2(arg2)) + argr = 0 + else: + argr = 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 + + QUIET 0x96 + BALANCED 0x97 + BALANCED_PERFORMANCE 0x98 + PERFORMANCE 0x99 + + QUIET_USTT 0xA3 + BALANCED_USTT 0xA0 + BALANCED_PERFORMANCE_USTT 0xA1 + PERFORMANCE_USTT 0xA4 + LOW_POWER_USTT 0xA5 + + GMODE 0xAB + +Usually if a model doesn't support the first four profiles they will support +the User Selectable Thermal Tables (USTT) profiles and vice-versa. + +GMODE replaces PERFORMANCE in G-Series laptops. + +WMI method GetFanSensors([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------- + +:: + + if BYTE_0(arg2) == 1: + if is_valid_fan(BYTE_1(arg2)): + argr = 1 + else: + argr = 0 + + if BYTE_0(arg2) == 2: + if is_valid_fan(BYTE_1(arg2)): + if BYTE_2(arg2) == 0: + argr == SENSOR_ID + else + argr == 0xFFFFFFFF + else: + argr = 0 + +Overclocking Methods +==================== + +.. warning:: + These methods have not been tested and are only partially reverse + engineered. + +WMI method Return_OverclockingReport([out] uint32 argr) +------------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr = 0 + +CSMI is an unknown operation. + +WMI method Set_OCUIBIOSControl([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr = 0 + +CSMI is an unknown operation + +WMI method Clear_OCFailSafeFlag([out] uint32 argr) +-------------------------------------------------- + +:: + + CSMI (0xE3, 0x99) + argr = 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 has +not been deciphered yet. + +GPIO methods +============ + +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) == 0: + if BYTE_1(arg2) == 1: + SET_PIN_A_HIGH() + else: + SET_PIN_A_LOW() + + if BYTE_0(arg2) == 1: + if BYTE_1(arg2) == 1: + SET_PIN_B_HIGH() + + else: + SET_PIN_B_LOW() + + else: + argr = 1 + +WMI method ReadTotalofGPIOs([out] uint32 argr) +---------------------------------------------- + +:: + + argr = 0x02 + +WMI method ReadGPIOpPinStatus([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------ + +:: + + if BYTE_0(arg2) == 0: + argr = PIN_A_STATUS + + if BYTE_0(arg2) == 1: + argr = PIN_B_STATUS + +Other information Methods +========================= + +WMI method SystemInformation([in] uint32 arg2, [out] uint32 argr) +----------------------------------------------------------------- + +Returns unknown information. + +WMI method PowerInformation([in] uint32 arg2, [out] uint32 argr) +---------------------------------------------------------------- + +Returns unknown information. + +WMI method ReadChassisColor([out] uint32 argr) +---------------------------------------------- + +:: + + argr = CHASSIS_COLOR_ID + +WMI method ReadPlatformProperties([out] uint32 argr) +---------------------------------------------------- + +Returns unknown information. + +Acknowledgements +================ + +Kudos to `AlexIII `_ for documenting +and testing avaliable thermal profile codes. +