From patchwork Sat Dec 21 05:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917641 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 DC5DF1E9B2E; Sat, 21 Dec 2024 05:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760794; cv=none; b=QxjkLFbq7JyK5w3x+5mcnXKRgBoJa2bG2Ed9Bq9ffAn2qBvKzLnW21/TYnMW5AnAI0K7KE9AeY2tz9px66JppzOJIyC2jL0sUenp3MUhPbbiZfBV3qRe6RZyGQYSL5shUKQ4vyY2r1J3ZsqBvJmald5FVYup3vju7jvKBlCYQHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760794; c=relaxed/simple; bh=e5G5xXJq6UtJYXsJRb+4t7+vqOaLOFU3EPuz/vxGzOM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R6zXkURlMvQkwOcn5LZ7HJOTSiRK6Ibj3dDB/En1Z3IsjDiFsDfOnk7bp/EdS8crLi1w1Eb66hIhawPa47AAbFBFP7VNLFTn2e9nqN+4f+pRiFNHsxf69eN7s/6xScKoqR7o+1reuw1KG+sPEhfdlXE3yQGRpNotsYcvRrA3OhU= 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=avZI0lhf; arc=none smtp.client-ip=209.85.128.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="avZI0lhf" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6eff4f0d627so24064227b3.1; Fri, 20 Dec 2024 21:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760791; x=1735365591; 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=HSkKrNZhzv6sN1j1A6Br5kBbK34HrWwa0EWiD+lc8uk=; b=avZI0lhfhtjkQTQ120+epvHVhwvcWD4ovqJup4a8rjgYaCNHQ8k30QvOMSxkSXXwFc cYjD+b1CXHXnBPyNwCo9ZuUwAgbEkmFWkzFvrQ6m64feKTvHUlu1lyxzemKPLI1VYZjC hwukFyqisB39Aa1jjR+hM7CRShZFm3HLPkHyNDFMtxVaT+irIvw+skDOS5Sk6i/vtyq7 3YvbuYRJDnwzphTN/hrLMco7rJbm8NVQuZ+Z6AIKnGS3yiFhc6fD0cKToAdysvJjTj6o NQ9mdo6OuMM4edOIv1Ng/MQOHhP/ZS1Hax9lHt3RleqORQJGUOQ8eXYciDpFezhAUkiB zgMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760791; x=1735365591; 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=HSkKrNZhzv6sN1j1A6Br5kBbK34HrWwa0EWiD+lc8uk=; b=GnIT8pnM9rYj+SzJUkg3gNOtcclkVjJrKwjpwj74OdHbhk0gWLpyKRCOqfiU5/jlw+ qBV7IipbfB5bx3fdzzF2p9dJ7uJtRaPoRlSCt04iGVuE2kGgvgaI3/OjAn+G8faTYXZw ojgZGlAfk2mcZ7H2ChSPnPlBoDvFDS49diA1gmnAIzAwiC3YABum/x5sVIo8k/bCVYyu t6DdyUZZMVHGkteQbLDdXd9ZKjxYq7pp2MmmRREJgBicVDj4Pj33qYrCOQCBGuKfZcGB EcGpZQlQnFVx5nw2nhvP3suyNOSAQW4k/VNRl1V6c7u3eQn76goXbyhMdkSXDC/8Rgnq hOTw== X-Forwarded-Encrypted: i=1; AJvYcCUb/zjrDsfuTOwfBAq6OoOh287viotQFCvqoJjfrhY3THCKHDRb1ZD4FbjshgSbMYAkR7ld30nACaaCUi0=@vger.kernel.org X-Gm-Message-State: AOJu0YzU3B8FvOBqHE+gh+Ty8+jSQeQDLGEcKILy6G1Ip6HB5+5GNyJZ X7cLv1aOe/wih3mcswO3QMyLoTK/WUTdqeL3I2RZiUrTHKKC91iVGzQd/w== X-Gm-Gg: ASbGncvk8i7Q8awZjxzw+Nht50dRqoKHOSnzWtyH/q7IOo4+wNBw2ZV4+MewafhaNnL 7WUzNhFtmzrdQljoH3uiWFkt7E2pZCj1XZtZD1PFoGJJFFNi8tHgBebJ4Gt7sO4FLFDjfasT5tn 2dT7e/ai53j1mFx3QqTu3wIJWpvLoSjgWwJQjHtZZUK9afG5Q69SHTW7asEd17vaWEV5ffBo1zh 6VDcfBNejq0SY011LevU77xRl4eK+mQwWZ7Uh/Ju5g84etM+nlJgrAtJtZCcZHG X-Google-Smtp-Source: AGHT+IFzne4ymApjaGIaCu0/9Jcb9imKpvRl1NuzMKQPaL68Pl6ZJs/Jd510de5a/v6B+4RxxYh4cg== X-Received: by 2002:a05:690c:4988:b0:6ef:6cdd:57e3 with SMTP id 00721157ae682-6f3f80d6262mr51009917b3.8.1734760791336; Fri, 20 Dec 2024 21:59:51 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.21.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 21:59:50 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 01/20] alienware-wmi: Remove unnecessary check at module exit Date: Sat, 21 Dec 2024 00:58:58 -0500 Message-ID: <20241221055917.10555-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Module initialization fails if platform device fails to register so it's always not NULL at exit. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index e95d22c7b60c..ed66720260ab 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1257,13 +1257,11 @@ module_init(alienware_wmi_init); 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); - } + alienware_zone_exit(platform_device); + remove_hdmi(platform_device); + remove_thermal_profile(); + platform_device_unregister(platform_device); + platform_driver_unregister(&platform_driver); } module_exit(alienware_wmi_exit); From patchwork Sat Dec 21 05:58:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917642 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.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 57B561EC4CF; Sat, 21 Dec 2024 05:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760796; cv=none; b=PyZkfcnmMvRQMOsEoFQnJS4//Q0ImqToni8AGscFOZKs+emSHAcYNPFGbKxV6jY62vq1H+Tl58EOFE/ScuDsqrsO1/VsYvilopcSQFUvZwZ5H1bmOsywACXnAJgbwxE7PtzCoxatBrmXS+yVr9j2cEs/vEmHTsXN62NgtbfDerg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760796; c=relaxed/simple; bh=M2mGLrLA8bJeRYP3SmyaiYpKPe+I8a0fe6+gzjryg8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mmnA/Z37IMVHUuUILlkPcSHyfpRia8PpnfJZu0WemDhE7iPgyrDgcdsFUh9hJFYzAz1hV5FVCrFbrHt/BHDBh/aLOozEuvvfrojmJ3a9TWz17V8yCS13VvpICnjA94uZpnvvuE5SmkPuk/vguON+vV0kICVB+X4oOB8PGovaol4= 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=BFBlto7g; arc=none smtp.client-ip=209.85.219.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="BFBlto7g" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e39841c8fd6so2150906276.3; Fri, 20 Dec 2024 21:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760794; x=1735365594; 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=k1/P3g+wUrQlQ4pdXCe/JNPfNqTjLs97yJufPyiM8nQ=; b=BFBlto7ghwk/3AKMD0xyb5AfzrO46PhfWpaGbYi771q8ZcJOi13395bELvjKlBXcQb a18EgK9LnCrgef1sTve8JQ7pOeMyiVbiFlmBlwCml4OHXRHyIEtPk3zl5JN1K1117dVr /kHjHG0yAMNnJTR18TrnN/kc1ayTmU418+wv7chSxT4lMAfBGhWBUJXWP3AlL55fYuZz PKfKvdZGIEXTQsWcDNXAmdrz+tsVb3lr116V8zmDZXB0zLVtoXfE6hxEXDGgfTRJtZ4D ZCVSB8NdmfXyv+ghCSlwzIBmxU7RJk7Tj3v+93MYJiC01wX2GrilUatQ62oR+kuYLkm+ lZkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760794; x=1735365594; 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=k1/P3g+wUrQlQ4pdXCe/JNPfNqTjLs97yJufPyiM8nQ=; b=lPdTz44SMT0VASqrLko8gHJu8jGxwwKs+PPSQjC7B2FMj9rERoV1QmmmqsbqVD0uUu 7YS/NXz2dOwrYTk3KImfEWNLQvVY5Gnbzv6uroENhPIaKc8LYBnItMb1dT1xoJL+CUJW tCrrY1TZa+n5LW12UrRdooKGu/6qyhBjP64Z46+z3fZfJdvZFseJ7x30K9aNNOY7E3Kj HJ1CjcXhxZiYu+Dqfb2+d/ysb9XDVQ/LxrflXR1Hiyxv8sK8MlDv34d0wilp317/Sidd FuNfILKHES9CzUnL/VjMdDGoIGDPT4QITBZ5VgSVEdImXBwDK0SeuAL0MPh8z2N/xFLK YNew== X-Forwarded-Encrypted: i=1; AJvYcCWxaIzu5A6W5QZ2KMv3tZ6OE3ob2PIAjkmv2te3DW3nz8ag/rhMH55EQ4wwtencZPBVCvmCCWfk+UUmdaU=@vger.kernel.org X-Gm-Message-State: AOJu0YzzzmjRS093e78vHp2KL5jsf8mLODXfyYEXOu6Dh1i1uxoH5HYY bWiKQIxmGEKwV6muUu0sxtNJQueITInJ1hCNgbFwzrWSPNW1EU8jvhTtAQ== X-Gm-Gg: ASbGncvEyQM4Ff2OiUlNKS2CcBBCjqEOB+GIlVktbdexRZnmBd4cqRcWndpMsZbSOD0 0vKvTx7fgUyPK+m1rIcWZ+d0VxaZkA0oWYAbyRItCbp0dqUe4tJL2rGRaJWzlllL8bIaKh3b7yu dJ+1FXNyNbO3bTtw3pD0QmVzaw7jlTw/BBBZ9HFZVBBB1ad8rKHW2a0iQcgHYj05Z4we370rtIT gq3SvNlEe2jil5q5u/dMMNUW4Wnh4V97vE89mk29khusuMb5dam89T+tnvFkCA2 X-Google-Smtp-Source: AGHT+IGAM0W9GN/QwPgwa9ia7Eopn90Y9S2aQ48utvIXU+b6VRyr+7C1lngaYTQXu/O1jVFKjBfQBA== X-Received: by 2002:a05:690c:338c:b0:6ef:3402:9e22 with SMTP id 00721157ae682-6f3f8110182mr52462747b3.15.1734760794081; Fri, 20 Dec 2024 21:59:54 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.21.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 21:59:53 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 02/20] alienware-wmi: Move Lighting Control State Date: Sat, 21 Dec 2024 00:58:59 -0500 Message-ID: <20241221055917.10555-3-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Place Lighting Control State logic next to other attributes of the same sysfs group. While at it, rename: store_control_state() -> lighting_control_state_store() show_control_state() -> lighting_control_state_show() Replace DEVICE_ATTR_RW() with DEVICE_ATTR() and do a general style cleanup. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 74 ++++++++++++----------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index ed66720260ab..c5ad0f95c442 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -545,6 +545,45 @@ static ssize_t zone_set(struct device *dev, struct device_attribute *attr, return ret ? ret : count; } +/* + * Lighting control state device attribute (Global) + */ +static ssize_t lighting_control_state_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + if (lighting_control_state == LEGACY_BOOTING) + return sysfs_emit(buf, "[booting] running suspend\n"); + else if (lighting_control_state == LEGACY_SUSPEND) + return sysfs_emit(buf, "booting running [suspend]\n"); + + return sysfs_emit(buf, "booting [running] suspend\n"); +} + +static ssize_t lighting_control_state_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + u8 val; + + if (strcmp(buf, "booting\n") == 0) + val = LEGACY_BOOTING; + else if (strcmp(buf, "suspend\n") == 0) + val = LEGACY_SUSPEND; + else if (interface == LEGACY) + val = LEGACY_RUNNING; + else + val = WMAX_RUNNING; + + lighting_control_state = val; + pr_debug("alienware-wmi: updated control state to %d\n", + lighting_control_state); + + return count; +} + +static DEVICE_ATTR_RW(lighting_control_state); + /* * LED Brightness (Global) */ @@ -589,41 +628,6 @@ static struct led_classdev global_led = { .name = "alienware::global_brightness", }; -/* - * Lighting control state device attribute (Global) - */ -static ssize_t show_control_state(struct device *dev, - struct device_attribute *attr, char *buf) -{ - if (lighting_control_state == LEGACY_BOOTING) - return sysfs_emit(buf, "[booting] running suspend\n"); - else if (lighting_control_state == LEGACY_SUSPEND) - return sysfs_emit(buf, "booting running [suspend]\n"); - return sysfs_emit(buf, "booting [running] suspend\n"); -} - -static ssize_t store_control_state(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - long unsigned int val; - if (strcmp(buf, "booting\n") == 0) - val = LEGACY_BOOTING; - else if (strcmp(buf, "suspend\n") == 0) - val = LEGACY_SUSPEND; - else if (interface == LEGACY) - val = LEGACY_RUNNING; - else - val = WMAX_RUNNING; - lighting_control_state = val; - pr_debug("alienware-wmi: updated control state to %d\n", - lighting_control_state); - return count; -} - -static DEVICE_ATTR(lighting_control_state, 0644, show_control_state, - store_control_state); - static int alienware_zone_init(struct platform_device *dev) { u8 zone; From patchwork Sat Dec 21 05:59:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917643 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.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 B889028366; Sat, 21 Dec 2024 05:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760799; cv=none; b=JiPnU3RKXw5pO3fzSVBFAWfkhDq0SAKcOUm7N3CdHs79qczeaMmeM54pPnCRrcCsDqiFmO7hB8ehkutnVI6OKbwls4BobCFuIQh8jPf2w4B2sbw3HwOSeUPvw/k+8sJZ+EqQNlJWL/99mmwoSi8WIJt9PYElBt3kN1qp35x7SsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760799; c=relaxed/simple; bh=4NNzJCS6dqZubCbXKxy5ZPIrkzp2CGi7vV0ZMorGyLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b2eqW9596lyBM8AvTxgdhB40IZ+Wsr7cGQE1wcpuFQmKj1ZRLdUq8v8ypKROqcToSrpyVDcilQvFuFVkObH2LyZ255rPVs9JoXLAvNkt5hs0lN9oCFukJ0XMWaTDcET8QruvGFFEhu22QYN0PUJwmX63m4F2nPWHHjwi7aLDNEM= 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=MIzHx8zo; arc=none smtp.client-ip=209.85.219.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="MIzHx8zo" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e460717039fso2062614276.0; Fri, 20 Dec 2024 21:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760797; x=1735365597; 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=679ZZs5M5yhRZZVx57ba0x+NupoeJc1WiRduiJBWPv4=; b=MIzHx8zoay4Kx3zdRg17HSFHPpg69mbvDU891FDaUweky2shrXD0/mVgcHfUACD44b KzqWAQEjfTJ2xvppQn8/lotd2FvnPp+ZVCg9jVZmg79DlAK348ZWcDJN0oSDGucw3WDb H7VLA8pXKopIRLsU41VRD0PKlZDvxA/olXkSFEfHHPk1i5Cqrq586QDvgxUbLxaXzPH2 3OYqHChg+2kCJY3FjGAGh9vBCKtWE8G79rg5QVIFFQroKkhEZfkLcg3PTapqHeEfnFrb ixCrz4sORMKaV7m99Pvis0UFxy38W9x5rJwlMevMCKANx8QvslxLkWBHi9nNI2mz8Zvq SeuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760797; x=1735365597; 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=679ZZs5M5yhRZZVx57ba0x+NupoeJc1WiRduiJBWPv4=; b=CjJnVhZuIPFsAZWnUCd2uSgO0EeK3Yu7U3oS8beP/ysyXqS5jfnRp+IdMdaohAZpex UQcSnDHz1Ht+Y8V2n4h7ljykcY3LrdvSYpqFbwBndh2eDxL5+cqN/q6bVcyFzBDoiNh7 +G9oxbFK6WV/U+opk+6MzRNoUJHvaOOF5nBLWdoaaVxPbkSYP2t+yPcJzzZqN76QZ9GQ SPZM/1Ln2kI5+ySgoWg0O1/pb+Vbkvq7rFp1KDsgDwp90xjHpLXJWpuw7qUO2OIX2Ntw IiekyVlSgFXo9O7q9TX5USUboDPSKeeZhJL6xZmzVqta/bVrsXe8skgyH6o7vG4oeUP9 F7aw== X-Forwarded-Encrypted: i=1; AJvYcCVj5IuAC/vJ8z2QoWvdNkZ0JVDY8cvY6MirIgdx4uIx8xA40T3cvMAB8vDPOguFvhH0w2hrHd6fZ7QNenQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/BOHq//QzZRv3qaZFdLMQW3Zr46jAio0m2Dl7nPqkTtdPoayr UxojcOEbAntGET5u3lQLO2vYcTmoDVDkuKvNg3Z2GFsiaMNqIFToZICAuQ== X-Gm-Gg: ASbGncs/9WlP5mk4Etzo/XDV+Ws/HVMzvQSyxjZobpF0+BywIeXSTR4OHc82dQhv6JV BvAoojur+y1FCIKmeb9B/fyMCtWDua5+l5BPMXn5sNzcZP18x74U9CQfY6PlnJOFvpdPfwUx20a 3+8mxsm0DXvNY0AJ5FmoMc9+iE+3Z4QG/gK66W3mmILI8/JRAfUIwQEIVX5jYto5a+FXewWLpX2 rf3fPrIboY/GoYLknZ1juXYC8Nc0goeO0hVa0Jr1SSUACRRvjxxsXT4fElQnupg X-Google-Smtp-Source: AGHT+IErsKD0rEqeBakNCLsqSS9COS4I4rTyms3NtiF8Gm2Ws/eqmQo4PiAVmWU4CNyQdZhL+EFe3A== X-Received: by 2002:a05:690c:fd2:b0:6ef:7290:d478 with SMTP id 00721157ae682-6f3f823f1e2mr41956647b3.40.1734760796749; Fri, 20 Dec 2024 21:59:56 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.21.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 21:59:56 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 03/20] alienware-wmi: Modify parse_rgb() signature Date: Sat, 21 Dec 2024 00:59:00 -0500 Message-ID: <20241221055917.10555-4-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 parse_rgb() now takes struct color_platform instead of struct platform_zone to support upcoming refactor. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index c5ad0f95c442..273ce9b10765 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -434,7 +434,7 @@ static u8 global_brightness; /* * Helpers used for zone control */ -static int parse_rgb(const char *buf, struct platform_zone *zone) +static int parse_rgb(const char *buf, struct color_platform *colors) { long unsigned int rgb; int ret; @@ -454,7 +454,7 @@ static int parse_rgb(const char *buf, struct platform_zone *zone) repackager.package = rgb & 0x0f0f0f0f; pr_debug("alienware-wmi: r: %d g:%d b: %d\n", repackager.cp.red, repackager.cp.green, repackager.cp.blue); - zone->colors = repackager.cp; + *colors = repackager.cp; return 0; } @@ -538,7 +538,7 @@ static ssize_t zone_set(struct device *dev, struct device_attribute *attr, pr_err("alienware-wmi: invalid target zone\n"); return 1; } - ret = parse_rgb(buf, target_zone); + ret = parse_rgb(buf, &target_zone->colors); if (ret) return ret; ret = alienware_update_led(target_zone); From patchwork Sat Dec 21 05:59:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917644 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 C0A1E1EE7DD; Sat, 21 Dec 2024 06:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760803; cv=none; b=BEdyCC+fiL2uzeSHbQoGIOd52kI3sTPN6zNnd5HJJKExiCCUI4kwFRCazw37fzUC4KYp4Ltot5EP+eyy3GvxclOKP8ir4ccZMKO38Fc7FsI0SQWzEoFYQJUihrCs21WOvyoK8R2p2ObzTwCAMeoma3Fa8GgytC69iljCctVAfUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760803; c=relaxed/simple; bh=E8E8wxxFfTC5oYXh0qFC1FyTDteE+cIe83wwFVwUAyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AwpxADEfeVcUIlSHLmPLatLx5rYZBerqnjp2LgEJQOTObFy1/hxCEdC8txVJLuhu2k6iVZGPFsQMUuU26l6iCNKhizUC6wiiBhnWXNlTWfBEHmslL6tRhOLloHSEJ1ZouhoQRMDymwxuoHq18zrNDlc4L2ZljIj+Alm2FCQXhu4= 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=YBenQXhB; arc=none smtp.client-ip=209.85.128.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="YBenQXhB" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6f0054cb797so21088917b3.0; Fri, 20 Dec 2024 22:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760800; x=1735365600; 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=j06yCL1SGn4M6xGgU0mz4/+MosEfAZ9tu5HVjjwGpNI=; b=YBenQXhB8kLPIuGdmbMrZ1hmDOA0w50SO0m9wQDYqqmARgJNDMlAworGi+3X0J78O+ TavVY2owshti9xX+JbZUH1D5+Wi6VX3e2xOTrmS3PujYvV3ykLnIhFwrB2BFa2RqIzY5 y62PiX/BxCzZ/sMHeO4vqeJf1r6Rc9umj2U+wi9h+ziccamhUJUOdOsSj634NdPFvgzu 5VPaZuJMCSAiuKEsP5F011ILH68xs9KxGKvOagTV/YzPFjkeVjq5RKBr246M3qIfXBD2 54iDo9uOPssXm0HGBUwPbydrc35r4urPOl7mWdhxm1h85wvVz+LuZVT22a/TtPLy3o5q 9FXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760800; x=1735365600; 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=j06yCL1SGn4M6xGgU0mz4/+MosEfAZ9tu5HVjjwGpNI=; b=e2RY73GKr0GX3RBkz/cqfcrtO1q52fX9ULUH3TsPJbbXobkJgtKha7i/sSmgHCRfla lcrLDxNQi42Qp1u0x7S4QJcMcXp51Y5W/pKSfVIhEsmsdh3XrTqT8uxhnJ0QnhBgsjVj ZZ1RYQXHFCcLyf6hpTUempVgwLgWyOFLj+a34dp/YHtSISXPea1jLYNq2x9I3JQeO0tk mvopXMHlvMN88bG2qFtOoc9di6XTWuykDU4V5bh6gIoUjvQz358ZINF8tdrbC20sb1J4 2frOizj+zIt8CQo1Xh/H/AIcgCg+0Mag7hlhwf+eilt3xLdcz+oqn+thDUuzZyFfJ7/2 U/iw== X-Forwarded-Encrypted: i=1; AJvYcCUDLEgFQ+nt8/KU3ZfX8qr60j4JFHDKsJg+R8l2UzWSfdNGg1tcdE58L6YlcX8AFZBUvFrWQIfu4UkZuSg=@vger.kernel.org X-Gm-Message-State: AOJu0YzxK6f5tljRz8yuJfT0cUfWf45MNpALieW2AHNTey8ai+HOp8F4 fQqnBTm8DJpS30miZRXjW7u1jyTDH0rlUuGC3g93HJoWJPuCoXo2y2Kj0g== X-Gm-Gg: ASbGncskGdGriVKeLdT7gsGj0OwRP6AnwVXN5wj1q6suJwlJe6bkwXW2lk4PhJ/mE24 dmn8mOdmtqCk1e29K0IFU/bbuPymduHGZR/VzePJQgcSF4gt3YQocu/dd9bi9L9t83KwDQbtwF+ fsjnIq4kTKPRDdwVKFus5yADDea53tg03wRpDqFfYADlOaRW80eJD6A5Et124JrWs/t3Y1sXGD2 RioB9SO4iAQ+wXNl0Hp8uB7b7eE1TdYase0AKuc6Ng0YOsKeDuoy1PG+g6UGbx+ X-Google-Smtp-Source: AGHT+IEw4TybRL1Bq8vCrFogKLsFgIVPDehHUQULO4z3pq+sSLE+9HVG4O7cbcFRWEJ00cLFTQQk7g== X-Received: by 2002:a05:690c:650a:b0:6ef:81c0:5b56 with SMTP id 00721157ae682-6f3f8125b38mr49502977b3.14.1734760800601; Fri, 20 Dec 2024 22:00:00 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.21.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 21:59:59 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 04/20] alienware-wmi: Improve hdmi_mux, amplifier and deepslp group creation Date: Sat, 21 Dec 2024 00:59:01 -0500 Message-ID: <20241221055917.10555-5-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Devices with hdmi_mux, amplifier or deepslp quirks create a sysfs group for each available feature. To accomplish this, helper create/remove functions were called on module init, but they had the following problems: - Create helpers called remove helpers on failure, which in turn tried to remove the sysfs group that failed to be created - If group creation failed mid way, previous successfully created groups were not cleaned up - Module exit only removed hdmi_mux group To improve this, drop all helpers and let the platform driver manage these sysfs groups, while controlling visibility with their respective quirks. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 114 ++++++++-------------- 1 file changed, 38 insertions(+), 76 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 273ce9b10765..e010c94555e8 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -417,12 +417,6 @@ static struct platform_zone *zone_data; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; -static struct platform_driver platform_driver = { - .driver = { - .name = "alienware-wmi", - } -}; - static struct attribute_group zone_attribute_group = { .name = "rgb_zones", }; @@ -804,6 +798,12 @@ static DEVICE_ATTR(cable, S_IRUGO, show_hdmi_cable, NULL); static DEVICE_ATTR(source, S_IRUGO | S_IWUSR, show_hdmi_source, toggle_hdmi_source); +static bool hdmi_group_visible(struct kobject *kobj) +{ + return quirks->hdmi_mux; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); + static struct attribute *hdmi_attrs[] = { &dev_attr_cable.attr, &dev_attr_source.attr, @@ -812,25 +812,10 @@ static struct attribute *hdmi_attrs[] = { static const struct attribute_group hdmi_attribute_group = { .name = "hdmi", + .is_visible = SYSFS_GROUP_VISIBLE(hdmi), .attrs = hdmi_attrs, }; -static void remove_hdmi(struct platform_device *dev) -{ - if (quirks->hdmi_mux > 0) - sysfs_remove_group(&dev->dev.kobj, &hdmi_attribute_group); -} - -static int create_hdmi(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &hdmi_attribute_group); - if (ret) - remove_hdmi(dev); - return ret; -} - /* * Alienware GFX amplifier support * - Currently supports reading cable status @@ -859,6 +844,12 @@ static ssize_t show_amplifier_status(struct device *dev, static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL); +static bool amplifier_group_visible(struct kobject *kobj) +{ + return quirks->amplifier; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); + static struct attribute *amplifier_attrs[] = { &dev_attr_status.attr, NULL, @@ -866,25 +857,10 @@ static struct attribute *amplifier_attrs[] = { static const struct attribute_group amplifier_attribute_group = { .name = "amplifier", + .is_visible = SYSFS_GROUP_VISIBLE(amplifier), .attrs = amplifier_attrs, }; -static void remove_amplifier(struct platform_device *dev) -{ - if (quirks->amplifier > 0) - sysfs_remove_group(&dev->dev.kobj, &lifier_attribute_group); -} - -static int create_amplifier(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &lifier_attribute_group); - if (ret) - remove_amplifier(dev); - return ret; -} - /* * Deep Sleep Control support * - Modifies BIOS setting for deep sleep control allowing extra wakeup events @@ -937,6 +913,12 @@ static ssize_t toggle_deepsleep(struct device *dev, static DEVICE_ATTR(deepsleep, S_IRUGO | S_IWUSR, show_deepsleep_status, toggle_deepsleep); +static bool deepsleep_group_visible(struct kobject *kobj) +{ + return quirks->deepslp; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); + static struct attribute *deepsleep_attrs[] = { &dev_attr_deepsleep.attr, NULL, @@ -944,25 +926,10 @@ static struct attribute *deepsleep_attrs[] = { static const struct attribute_group deepsleep_attribute_group = { .name = "deepsleep", + .is_visible = SYSFS_GROUP_VISIBLE(deepsleep), .attrs = deepsleep_attrs, }; -static void remove_deepsleep(struct platform_device *dev) -{ - if (quirks->deepslp > 0) - sysfs_remove_group(&dev->dev.kobj, &deepsleep_attribute_group); -} - -static int create_deepsleep(struct platform_device *dev) -{ - int ret; - - ret = sysfs_create_group(&dev->dev.kobj, &deepsleep_attribute_group); - if (ret) - remove_deepsleep(dev); - return ret; -} - /* * Thermal Profile control * - Provides thermal profile control through the Platform Profile API @@ -1172,6 +1139,23 @@ static void remove_thermal_profile(void) platform_profile_remove(&pp_handler); } +/* + * Platform Driver + */ +static const struct attribute_group *alienfx_groups[] = { + &hdmi_attribute_group, + &lifier_attribute_group, + &deepsleep_attribute_group, + NULL +}; + +static struct platform_driver platform_driver = { + .driver = { + .name = "alienware-wmi", + .dev_groups = alienfx_groups, + }, +}; + static int __init alienware_wmi_init(void) { int ret; @@ -1211,24 +1195,6 @@ static int __init alienware_wmi_init(void) if (ret) goto fail_platform_device2; - if (quirks->hdmi_mux > 0) { - ret = create_hdmi(platform_device); - if (ret) - goto fail_prep_hdmi; - } - - if (quirks->amplifier > 0) { - ret = create_amplifier(platform_device); - if (ret) - goto fail_prep_amplifier; - } - - if (quirks->deepslp > 0) { - ret = create_deepsleep(platform_device); - if (ret) - goto fail_prep_deepsleep; - } - if (quirks->thermal) { ret = create_thermal_profile(platform_device); if (ret) @@ -1245,9 +1211,6 @@ static int __init alienware_wmi_init(void) alienware_zone_exit(platform_device); remove_thermal_profile(); fail_prep_thermal_profile: -fail_prep_deepsleep: -fail_prep_amplifier: -fail_prep_hdmi: platform_device_del(platform_device); fail_platform_device2: platform_device_put(platform_device); @@ -1262,7 +1225,6 @@ module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { 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 Dec 21 05:59:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917645 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (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 8437B1DF244; Sat, 21 Dec 2024 06:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760807; cv=none; b=FWvTd4Tx8P0PnH0/tL2G5IfgPL6zFmlL88+mhjOTmD22bCDZOj56RaYBQ5sPdH4YvLqMMbvYN7lguNd7cvXV/10hiv1B4ADK6EjE0tZ36GRYzO9WscIuXAEHcozBk8eaJtosdhN0Afhn8pwBViwc9qoSU5EgEoDrL+4KHCbYC9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760807; c=relaxed/simple; bh=wulRflbPUaW6RKQwczJ+LtaxsUrFR1aLiz6pwPtoGfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I60R0sw0ifK/dm/maiO8X1Zo9LNB4tzSzwErkBhn1yquDYnPhlq4VaSLCxRjocZQfbr9GBHVaV9+QO6xrdKR6EG16KIramjyDvoLJEjVDvsGYtyfaFO9E1Faur4xREmqLd17YyOikZJF7uvnyLrM4tYe+6wyNcN0f3TtqBDp4sU= 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=LJniPTyq; arc=none smtp.client-ip=209.85.128.182 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="LJniPTyq" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6eff8289d0eso24499387b3.0; Fri, 20 Dec 2024 22:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760804; x=1735365604; 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=F7nffjsnSIqpBs0PqW9iXhHcMwuHRA//bqv2uuGdZOM=; b=LJniPTyqdvV6yZ6WrXxK7dsVy8tHANToGAywU7W1C0Iy6cdO+ojxY0+vJ9tWaW/MQB 3EEn9v1oP7IguRC8c/UInxZ76H3xyRQ/OKGDXq2ibzjwloAyI4Emv0XoT8HNiIPsTERs tDqAtoVKoF+QhoWW4PHpA9IvvKxHTeH2pGrrMyVRTYOutHkVujtM7YL7ROlu3MTQxXLj ETIVgZZfcPbcMSZapdaYjKHmV8xcv32zaPD4H/Ik+ZYbETvug3rsupqSUDHoVsuCPbbo t87piQv4RYdsNuNnZF5LtKoZQYVnaZlnTgx0UZ16J2hhwhPh0c3TKxd6UYtD/DVQ2uPJ xeAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760804; x=1735365604; 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=F7nffjsnSIqpBs0PqW9iXhHcMwuHRA//bqv2uuGdZOM=; b=fR4LddqoBy2sPKjNptMMYqVEwzyTgHqwJE9AvRD8ENscywWNb6NkNrlSuIZS7Cqe2b aruJWDJppcNV+PM2QHGse7lMakW96ElXOTGghk941Jx8Lc2fYU7Rf4SGqZT5r3b9tBSZ WSUq3Q1CFPUndSfIvKMbq47HJ6b2vxQfnxbjjpp4QMW93jUnZvtDjXC+TCE1nJjhzFX7 kuDVEd07hGwiO5mT5nJcl/LPAZT/hJKJ/3wH2974LP9YMU2FYBKDmGHxzQrNCAXDFC/2 m2RKlSZ2IQ7zv32qb0YLCRciQCguCRiG8sFui0voLHjwLqCLyMAFxcNw9whgnuyxvNFM kQ7Q== X-Forwarded-Encrypted: i=1; AJvYcCXwxTvsehh7bShhH5DPyNnAnqm8t7oPerXXpvzPAxMddIcemr2XSrabdblrXVlGpNIZ56oAMKAkykGH9+8=@vger.kernel.org X-Gm-Message-State: AOJu0YxefxQwewotfGXRrfqB91XzW02dw0H0HezzqRYW4AT+YvR1+m4s qCn0hjHdDai1efZVrx8qms9XwutwnH0zHoxfCwXMpU8Y95JAELFKkiVWOA== X-Gm-Gg: ASbGncv2bUEU0VKFpsuQGGPDS7bJGmGAX0o7OjyG1GPE5+bxMFJRAJm5cnwbu4Q/ad/ mPi1Uu48h3rE5ZEAqkpAcGl38DoN5CKweHopeBHIM7QA9huyvCw9hSqOTc2ie0smq176mnRrS38 xKxQqUNHv1U9bjLaCX5nu3laCfW8KhgXZyN96Uc/Bq/LQ+2cR8VQTKo7P74hZrH9aig78Z3TXfP ZVIwShMcL168LaMRjsPXmvdAVVOtfByvdL7Vb47snKaZa4RjotyGM94nXt1vNco X-Google-Smtp-Source: AGHT+IEpYmvkqphZrc0H3b+ITTob8eIY5aGbdroyb/RQKprXcVQj2U4T1UOAu6JGCtTBa8JvuZkaOw== X-Received: by 2002:a05:690c:7203:b0:6ee:b6b6:dcac with SMTP id 00721157ae682-6f3f8145f99mr43467427b3.23.1734760803846; Fri, 20 Dec 2024 22:00:03 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:03 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 05/20] alienware-wmi: Improve rgb-zones group creation Date: Sat, 21 Dec 2024 00:59:02 -0500 Message-ID: <20241221055917.10555-6-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Define zone_attrs statically with the use of helper macros and initialize the zone_attribute_group with driver's .dev_groups. Drop match_zone() and instead pass a `location` argument to previous show/store methods to access the correct `zone` LED state. On top of that rename zone_set() -> zone_store() to be more consistent with sysfs conventions. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 179 +++++++++------------- 1 file changed, 72 insertions(+), 107 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index e010c94555e8..a431b1fec9fb 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -376,12 +376,6 @@ struct color_platform { u8 red; } __packed; -struct platform_zone { - u8 location; - struct device_attribute *attr; - struct color_platform colors; -}; - struct wmax_brightness_args { u32 led_mask; u32 percentage; @@ -411,16 +405,10 @@ struct wmax_u32_args { }; 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 color_platform colors[4]; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; -static struct attribute_group zone_attribute_group = { - .name = "rgb_zones", -}; - static u8 interface; static u8 lighting_control_state; static u8 global_brightness; @@ -452,24 +440,10 @@ static int parse_rgb(const char *buf, struct color_platform *colors) return 0; } -static struct platform_zone *match_zone(struct device_attribute *attr) -{ - u8 zone; - - for (zone = 0; zone < quirks->num_zones; zone++) { - if ((struct device_attribute *)zone_data[zone].attr == attr) { - pr_debug("alienware-wmi: matched zone location: %d\n", - zone_data[zone].location); - return &zone_data[zone]; - } - } - return NULL; -} - /* * Individual RGB zone control */ -static int alienware_update_led(struct platform_zone *zone) +static int alienware_update_led(u8 location) { int method_id; acpi_status status; @@ -478,8 +452,8 @@ static int alienware_update_led(struct platform_zone *zone) struct legacy_led_args legacy_args; struct wmax_led_args wmax_basic_args; if (interface == WMAX) { - wmax_basic_args.led_mask = 1 << zone->location; - wmax_basic_args.colors = zone->colors; + wmax_basic_args.led_mask = 1 << location; + wmax_basic_args.colors = colors[location]; wmax_basic_args.state = lighting_control_state; guid = WMAX_CONTROL_GUID; method_id = WMAX_METHOD_ZONE_CONTROL; @@ -487,7 +461,7 @@ static int alienware_update_led(struct platform_zone *zone) input.length = sizeof(wmax_basic_args); input.pointer = &wmax_basic_args; } else { - legacy_args.colors = zone->colors; + legacy_args.colors = colors[location]; legacy_args.brightness = global_brightness; legacy_args.state = 0; if (lighting_control_state == LEGACY_BOOTING || @@ -496,7 +470,7 @@ static int alienware_update_led(struct platform_zone *zone) legacy_args.state = lighting_control_state; } else guid = LEGACY_CONTROL_GUID; - method_id = zone->location + 1; + method_id = location + 1; input.length = sizeof(legacy_args); input.pointer = &legacy_args; @@ -510,35 +484,54 @@ static int alienware_update_led(struct platform_zone *zone) } static ssize_t zone_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf, u8 location) { - struct platform_zone *target_zone; - target_zone = match_zone(attr); - if (target_zone == NULL) - return sprintf(buf, "red: -1, green: -1, blue: -1\n"); return sprintf(buf, "red: %d, green: %d, blue: %d\n", - target_zone->colors.red, - target_zone->colors.green, target_zone->colors.blue); + colors[location].red, colors[location].green, + colors[location].blue); } -static ssize_t zone_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t zone_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count, u8 location) { - struct platform_zone *target_zone; int ret; - target_zone = match_zone(attr); - if (target_zone == NULL) { - pr_err("alienware-wmi: invalid target zone\n"); - return 1; - } - ret = parse_rgb(buf, &target_zone->colors); + + ret = parse_rgb(buf, &colors[location]); if (ret) return ret; - ret = alienware_update_led(target_zone); + + ret = alienware_update_led(location); + return ret ? ret : count; } +#define ALIENWARE_ZONE_SHOW_FUNC(_num) \ + static ssize_t zone0##_num##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return zone_show(dev, attr, buf, _num); \ + } + +#define ALIENWARE_ZONE_STORE_FUNC(_num) \ + static ssize_t zone0##_num##_store(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ + { \ + return zone_store(dev, attr, buf, count, _num); \ + } + +#define ALIENWARE_ZONE_ATTR(_num) \ + ALIENWARE_ZONE_SHOW_FUNC(_num) \ + ALIENWARE_ZONE_STORE_FUNC(_num) \ + static DEVICE_ATTR_RW(zone0##_num) + +ALIENWARE_ZONE_ATTR(0); +ALIENWARE_ZONE_ATTR(1); +ALIENWARE_ZONE_ATTR(2); +ALIENWARE_ZONE_ATTR(3); + /* * Lighting control state device attribute (Global) */ @@ -578,6 +571,33 @@ static ssize_t lighting_control_state_store(struct device *dev, static DEVICE_ATTR_RW(lighting_control_state); +static umode_t zone_attr_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + return n < quirks->num_zones + 1 ? 0644 : 0; +} + +static bool zone_group_visible(struct kobject *kobj) +{ + return quirks->num_zones > 0; +} +DEFINE_SYSFS_GROUP_VISIBLE(zone); + +static struct attribute *zone_attrs[] = { + &dev_attr_lighting_control_state.attr, + &dev_attr_zone00.attr, + &dev_attr_zone01.attr, + &dev_attr_zone02.attr, + &dev_attr_zone03.attr, + NULL +}; + +static struct attribute_group zone_attribute_group = { + .name = "rgb_zones", + .is_visible = SYSFS_GROUP_VISIBLE(zone), + .attrs = zone_attrs, +}; + /* * LED Brightness (Global) */ @@ -606,7 +626,7 @@ static void global_led_set(struct led_classdev *led_cdev, if (interface == WMAX) ret = wmax_brightness(brightness); else - ret = alienware_update_led(&zone_data[0]); + ret = alienware_update_led(0); if (ret) pr_err("LED brightness update failed\n"); } @@ -624,9 +644,6 @@ static struct led_classdev global_led = { static int alienware_zone_init(struct platform_device *dev) { - u8 zone; - char *name; - if (interface == WMAX) { lighting_control_state = WMAX_RUNNING; } else if (interface == LEGACY) { @@ -635,65 +652,12 @@ static int alienware_zone_init(struct platform_device *dev) global_led.max_brightness = 0x0F; global_brightness = global_led.max_brightness; - /* - * - zone_dev_attrs num_zones + 1 is for individual zones and then - * null terminated - * - zone_attrs num_zones + 2 is for all attrs in zone_dev_attrs + - * the lighting control + null terminated - * - zone_data num_zones is for the distinct zones - */ - zone_dev_attrs = - kcalloc(quirks->num_zones + 1, sizeof(struct device_attribute), - GFP_KERNEL); - if (!zone_dev_attrs) - return -ENOMEM; - - zone_attrs = - kcalloc(quirks->num_zones + 2, sizeof(struct attribute *), - GFP_KERNEL); - if (!zone_attrs) - return -ENOMEM; - - zone_data = - kcalloc(quirks->num_zones, sizeof(struct platform_zone), - GFP_KERNEL); - if (!zone_data) - return -ENOMEM; - - for (zone = 0; zone < quirks->num_zones; zone++) { - name = kasprintf(GFP_KERNEL, "zone%02hhX", zone); - if (name == NULL) - return 1; - sysfs_attr_init(&zone_dev_attrs[zone].attr); - zone_dev_attrs[zone].attr.name = name; - zone_dev_attrs[zone].attr.mode = 0644; - zone_dev_attrs[zone].show = zone_show; - zone_dev_attrs[zone].store = zone_set; - zone_data[zone].location = zone; - zone_attrs[zone] = &zone_dev_attrs[zone].attr; - zone_data[zone].attr = &zone_dev_attrs[zone]; - } - zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr; - zone_attribute_group.attrs = zone_attrs; - - led_classdev_register(&dev->dev, &global_led); - - return sysfs_create_group(&dev->dev.kobj, &zone_attribute_group); + return led_classdev_register(&dev->dev, &global_led); } static void alienware_zone_exit(struct platform_device *dev) { - u8 zone; - - sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group); led_classdev_unregister(&global_led); - if (zone_dev_attrs) { - for (zone = 0; zone < quirks->num_zones; zone++) - kfree(zone_dev_attrs[zone].attr.name); - } - kfree(zone_dev_attrs); - kfree(zone_data); - kfree(zone_attrs); } static acpi_status alienware_wmax_command(void *in_args, size_t in_size, @@ -1143,6 +1107,7 @@ static void remove_thermal_profile(void) * Platform Driver */ static const struct attribute_group *alienfx_groups[] = { + &zone_attribute_group, &hdmi_attribute_group, &lifier_attribute_group, &deepsleep_attribute_group, From patchwork Sat Dec 21 05:59:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917646 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 E7DE01F0E2B; Sat, 21 Dec 2024 06:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760808; cv=none; b=bdSi6kSQNhkfjLhDToBiBweSymZVxd+CJ+vrT/6Y9Vx5EzZQqcqXPHD+EdoFRQ2qDwQbd3glvec1rGl9YULH0xBnraPrgeEnyotHgTlQg7y5Twu4Vo7BZaz/s2JIrf5j0ft+8FJpYZFgYL5+OlpjzK+2+xSg5dmgBJDfAdeK5lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760808; c=relaxed/simple; bh=pQ65vHHw1KfkcPhrLO9oZxVlO05EwgMUCzrI0idNl5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ArAfj+3LlceLVbtBRewRiqR9RVNhjlsiL5bf5FKCy5c30zcsROAZC53UuVlw7WLCeKAWy4OGkH++h+ctIA/uxZcC5leEFhB3jJT5xNPmRVXT5stFwLzuG0r+5RwZ8KNpOpIq6xW6IbmQcZOCXOHyYGLbY3g5ZrJk/Z/tspjzkl4= 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=dDcH/LYp; arc=none smtp.client-ip=209.85.128.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="dDcH/LYp" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6ef81222be7so23712577b3.3; Fri, 20 Dec 2024 22:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760806; x=1735365606; 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=0D151A0a1z9BJk2SJvhiNFRuL20PvtPUMAFhgT1XqVU=; b=dDcH/LYpHbAhgaMIMhNT3sj7ca+2FuKih8CCnFj5d4RG03uDPskI0ee9rGGM4lc4Yv aJzZog9iTNUWc9g9vp5pU8KtbChI60plKpFH5e2skbMZR/pkxhrB3XBGtaYl24msLqmy rRt9COFci5nWsRxUZem+6HDNaeTnpAVDqobKpM+kQttw02y1m0q68pr5VyAir6X/T6Ev TrjFpRDiMmreEUTuD17cRNc26C9AQjGc1vyq5EC4YGOMG9LEot1zpFwyWYgH7xwp6wP5 FpEjcBK+cttkw6MhfvOyOiTqg9/8aW67fejFd06FIX8PmE4Z+u0v4H/rRpCcEUwYIrrk QNfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760806; x=1735365606; 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=0D151A0a1z9BJk2SJvhiNFRuL20PvtPUMAFhgT1XqVU=; b=WFaGSh5add45dH/Yr8lUbVLfD33NZA/sPmod1hLDO/W5V1aJej7XcGsxig/zlXzdoK kLsUyxUZVrAuO7QnHUxY2AgxsStZRHRQvrTCwAu+SeleeQbhymc9FW8hMMKk3X8w/IVO WV09MkxBHw+E4ty3QCXK6c9I5dHkUy/SmG9c08eWfO0n0Ii8keK5OmJGCGkRCcjxb7pe vpR0MkrK4RSQ9VTaPpA3HHGWJLaTzdlF3vTCVrHznYsBMH7JCgUY/uORbnqUlYgzPd7x u4nu13t2PB0cQO20g35i8v+I3RCAdcHv4s4bQy888BqfLsya+xOJOw1MlmESxdkpdhqt 4tFg== X-Forwarded-Encrypted: i=1; AJvYcCXNXQConOI72G6olBVYeK28smMEhffQRhOUryM80lQ0OGFig4ECi21EPDs/KotHsRPQkznFBYTfmtIBJUA=@vger.kernel.org X-Gm-Message-State: AOJu0YxgVXq9CAFjQnZQpUWWg2M9n3q2yUlLkMaKqrVrB9btkK1M9EPD cnomUx0NnYZ5RofeqloClpPrAr8hVxgQ/ZLook2go500tVtTKwRWFdheJA== X-Gm-Gg: ASbGncuVPO5/7ZpNRXIj10q373m13p7hFdAvPLKY/69BTFOadpxpGbHlXVDatI47xOP R3Rnk6azFcaDBNX/jDLC8KPOXwj8eNBP2pJCN42aHYW/+klq2HaZP0x3zbZt1nzGn3ZqyX94nPy GSN2js+4pUW9pws9evmYKJf41IYBJslyJjinLt7oPmrjuYtRaOgLmdQFhc98OfHQkzn5j9l9Uem sMnbPLrr1L1nKLf01w60c4vTnnz1YjOx4U5pdZhhCmP/FMRt+14D1AUuDL2QhGi X-Google-Smtp-Source: AGHT+IEnMX5yjNtAOfbd4ycyPAy5XYFLJ3MYeXSOH+vzT+wS8VaqjMGKGUF3llyqIWyshU839qoEmw== X-Received: by 2002:a05:690c:fc2:b0:6ef:68b9:c956 with SMTP id 00721157ae682-6f3f8240672mr44243007b3.39.1734760805703; Fri, 20 Dec 2024 22:00:05 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:05 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 06/20] alienware_wmi: Clean variable declaration in thermal methods Date: Sat, 21 Dec 2024 00:59:03 -0500 Message-ID: <20241221055917.10555-7-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reorder variable declaration from longest to shortest. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a431b1fec9fb..67cf376df0f5 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -923,13 +923,13 @@ static bool is_wmax_thermal_code(u32 code) static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) { - acpi_status status; struct wmax_u32_args in_args = { .operation = operation, .arg1 = arg, .arg2 = 0, .arg3 = 0, }; + acpi_status status; status = alienware_wmax_command(&in_args, sizeof(in_args), WMAX_METHOD_THERMAL_INFORMATION, @@ -946,13 +946,13 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) static int wmax_thermal_control(u8 profile) { - acpi_status status; struct wmax_u32_args in_args = { .operation = WMAX_OPERATION_ACTIVATE_PROFILE, .arg1 = profile, .arg2 = 0, .arg3 = 0, }; + acpi_status status; u32 out_data; status = alienware_wmax_command(&in_args, sizeof(in_args), @@ -970,13 +970,13 @@ static int wmax_thermal_control(u8 profile) static int wmax_game_shift_status(u8 operation, u32 *out_data) { - acpi_status status; struct wmax_u32_args in_args = { .operation = operation, .arg1 = 0, .arg2 = 0, .arg3 = 0, }; + acpi_status status; status = alienware_wmax_command(&in_args, sizeof(in_args), WMAX_METHOD_GAME_SHIFT_STATUS, @@ -1045,11 +1045,11 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, static int create_thermal_profile(struct platform_device *platform_device) { - u32 out_data; + enum platform_profile_option profile; + enum wmax_thermal_mode mode; u8 sys_desc[4]; u32 first_mode; - enum wmax_thermal_mode mode; - enum platform_profile_option profile; + u32 out_data; int ret; ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION, From patchwork Sat Dec 21 05:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917647 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.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 46C5A1F1911; Sat, 21 Dec 2024 06:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760812; cv=none; b=YppyhLEdwjRAXTq8a1E6V5wqf+L46HVSCwBcJqYt7sMKhAWo4eEBhtNrQqg785+2634jnW7XhOg3Jf3KXm2frw8WwTHev/irEBHyQONggRTeBheqtD9fjysUbSY11Xx4S2HdFiGuTpCXxr2Z/RaEnXzzVMRC/JEdegx9JDM0O8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760812; c=relaxed/simple; bh=U64X1LlDQuseKDIy4JNNUn6PtImjDcHyVETZJ74LskU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NhX3x79yW0pDEwJ+SL5zD2SrVtQOMfEmUpCyPHkzYZRZf2/+FXzSt9EDN1iqm4T9gwph7cxqfnh/mM+W+a7UXJu8dgUEwFFeFLU1qNIUuKgVEd04Ov/6vAh2y8Zdslg6jXO3i1T9F/XhiH90U+cUMszjc9nwWLAPDYML6sS2gv8= 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=NZ5fe9uo; arc=none smtp.client-ip=209.85.219.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="NZ5fe9uo" Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e3983426f80so2091804276.1; Fri, 20 Dec 2024 22:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760809; x=1735365609; 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=3ssL+X/fFHGV+LQbx4dvwp2ckIrGOZB1LfrUOjyCS0g=; b=NZ5fe9uoWwBfZkz3B1+fHsSu8fSLyfB6KQnil1jn0uMR2ko8GnzneF7tdmRGVVEciZ ip45beJe8wSptaD/0/nGbAMVAvsV9Ch7ePjdH6K/G2IjULB0XfC9jlMZpVw7AAiTnfN/ V+TQwrmFaTdOcqRMNJnoJB9efWDghYuG1FLOKrYQK8WZIlibXQHO71G8W5r6YhEqH5cr 8PxNQmoEeCcweWVFTCDsFWxxIU1ySk+vl0e7aiY2cB+qljGTnfEn4kktVh24vxStmzue rytAObQXisDBagAy8ij965JsZwlctUPBA5DP7krjvKvOZ4k4j9ADIcTIgScTxdY6gxii df3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760809; x=1735365609; 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=3ssL+X/fFHGV+LQbx4dvwp2ckIrGOZB1LfrUOjyCS0g=; b=Bwzm0fF9jTe++m4tzlcL7J82QegRieRovh67J1F94UoY52cMrw9x9wJp1BC4Cdjy8+ 3TUwB5BIsmdd0ojJ7MKDWUNiQvpMV2/SwsUezg6NmquKjB4tHjAjNQ765lbYEUv5U4gC e1UNpi1W32zRjl+Qmq3Gj+8kFS6BopFjnhrM1l79lKfzmkVM2+TzrbodIw8+KmOkirSO 4vMBOsjlajsyGVpdNGA1u7U5G2t5Rsd6wpWUJwXSSvIPzaDujmQ8dHki8OMLFkjrgJnh /Hr07IB848zbUA0AjW6F/Wj+PbrHOJe21hrvaO1bDCThV7nqWM8epEicMCdKWk/d248U N4cQ== X-Forwarded-Encrypted: i=1; AJvYcCXcwbCAFOdHn+nOfCwb8Xug3tSVq11T5rJ3p/EiQ5BtijezhuofmNr20nSMhkU+M99Cd4zE81RKOGmKQao=@vger.kernel.org X-Gm-Message-State: AOJu0Yyg3LLcKDK7FsDsIdSkINprvMzg+uF+oX19NchG03paSf0y2j/y TUoQ5cJ1dAFQjHT04bIU4hbeZpUaieZMWWHjdSQ1A4PkM5bV5x0itG7+qQ== X-Gm-Gg: ASbGncuHqzClPRxbK4LGgOg1QEqnDrWB06X6uv5pLygPlvc0knEBgejhed6fK8fiMTR dykiWcplgMOenQkjw5cGvnQ2Hf3JdYhzm0EedF3RqbOMQlCL2hhH9bVduRJUFWwyMf+SSoWgjGF UjT4eRCTw5M/Ej5kAYCUcDKnaZi56S5ng1XXTOUsotFY8JDRXKqRljU2EVC6hTpX40HQHv5iis9 qTrftw07tBUAV2KRB0Jwvwj0DIbmwJz5DcNjd+jFB3jtN9O2qbSqkO88ZZPqqeW X-Google-Smtp-Source: AGHT+IH9Ic6HBIkT5QNFK1pF+puaz8lS7wFYcTx2IFB2x3FwwRYQ4TpL1qGPjgFfUBYo5kuRX9F+yg== X-Received: by 2002:a05:690c:7249:b0:6ef:6c57:ddc6 with SMTP id 00721157ae682-6f3f8216b49mr44484657b3.34.1734760808699; Fri, 20 Dec 2024 22:00:08 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:07 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 07/20] alienware-wmi: Add a state container for LED control feature Date: Sat, 21 Dec 2024 00:59:04 -0500 Message-ID: <20241221055917.10555-8-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a state container for the "alienware-wmi" platform device and initialize it on the new alienfx_probe(). Migrate all LED control functions to use this state container. Additionally move the led_classdev registration to the platform driver probe and make it device managed. Drop alienware_zone_init() and alienware_zone_exit() because they are no longer needed. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 128 +++++++++++++--------- 1 file changed, 76 insertions(+), 52 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 67cf376df0f5..4b68d64bd742 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -404,14 +404,19 @@ struct wmax_u32_args { u8 arg3; }; +struct alienfx_priv { + struct platform_device *pdev; + struct led_classdev global_led; + struct color_platform colors[4]; + u8 global_brightness; + u8 lighting_control_state; +}; + static struct platform_device *platform_device; -static struct color_platform colors[4]; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; static u8 interface; -static u8 lighting_control_state; -static u8 global_brightness; /* * Helpers used for zone control @@ -443,7 +448,7 @@ static int parse_rgb(const char *buf, struct color_platform *colors) /* * Individual RGB zone control */ -static int alienware_update_led(u8 location) +static int alienware_update_led(struct alienfx_priv *priv, u8 location) { int method_id; acpi_status status; @@ -453,21 +458,21 @@ static int alienware_update_led(u8 location) struct wmax_led_args wmax_basic_args; if (interface == WMAX) { wmax_basic_args.led_mask = 1 << location; - wmax_basic_args.colors = colors[location]; - wmax_basic_args.state = lighting_control_state; + wmax_basic_args.colors = priv->colors[location]; + wmax_basic_args.state = priv->lighting_control_state; guid = WMAX_CONTROL_GUID; method_id = WMAX_METHOD_ZONE_CONTROL; input.length = sizeof(wmax_basic_args); input.pointer = &wmax_basic_args; } else { - legacy_args.colors = colors[location]; - legacy_args.brightness = global_brightness; + legacy_args.colors = priv->colors[location]; + legacy_args.brightness = priv->global_brightness; legacy_args.state = 0; - if (lighting_control_state == LEGACY_BOOTING || - lighting_control_state == LEGACY_SUSPEND) { + if (priv->lighting_control_state == LEGACY_BOOTING || + priv->lighting_control_state == LEGACY_SUSPEND) { guid = LEGACY_POWER_CONTROL_GUID; - legacy_args.state = lighting_control_state; + legacy_args.state = priv->lighting_control_state; } else guid = LEGACY_CONTROL_GUID; method_id = location + 1; @@ -486,22 +491,32 @@ static int alienware_update_led(u8 location) static ssize_t zone_show(struct device *dev, struct device_attribute *attr, char *buf, u8 location) { + struct color_platform *colors; + struct alienfx_priv *priv; + + priv = dev_get_drvdata(dev); + colors = &priv->colors[location]; + return sprintf(buf, "red: %d, green: %d, blue: %d\n", - colors[location].red, colors[location].green, - colors[location].blue); + colors->red, colors->green, colors->blue); } static ssize_t zone_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, u8 location) { + struct color_platform *colors; + struct alienfx_priv *priv; int ret; - ret = parse_rgb(buf, &colors[location]); + priv = dev_get_drvdata(dev); + colors = &priv->colors[location]; + + ret = parse_rgb(buf, colors); if (ret) return ret; - ret = alienware_update_led(location); + ret = alienware_update_led(priv, location); return ret ? ret : count; } @@ -539,9 +554,13 @@ static ssize_t lighting_control_state_show(struct device *dev, struct device_attribute *attr, char *buf) { - if (lighting_control_state == LEGACY_BOOTING) + struct alienfx_priv *priv; + + priv = dev_get_drvdata(dev); + + if (priv->lighting_control_state == LEGACY_BOOTING) return sysfs_emit(buf, "[booting] running suspend\n"); - else if (lighting_control_state == LEGACY_SUSPEND) + else if (priv->lighting_control_state == LEGACY_SUSPEND) return sysfs_emit(buf, "booting running [suspend]\n"); return sysfs_emit(buf, "booting [running] suspend\n"); @@ -551,8 +570,11 @@ static ssize_t lighting_control_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct alienfx_priv *priv; u8 val; + priv = dev_get_drvdata(dev); + if (strcmp(buf, "booting\n") == 0) val = LEGACY_BOOTING; else if (strcmp(buf, "suspend\n") == 0) @@ -562,9 +584,9 @@ static ssize_t lighting_control_state_store(struct device *dev, else val = WMAX_RUNNING; - lighting_control_state = val; + priv->lighting_control_state = val; pr_debug("alienware-wmi: updated control state to %d\n", - lighting_control_state); + priv->lighting_control_state); return count; } @@ -621,43 +643,26 @@ static int wmax_brightness(int brightness) static void global_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) { + struct alienfx_priv *priv; int ret; - global_brightness = brightness; + + priv = container_of(led_cdev, struct alienfx_priv, global_led); + priv->global_brightness = brightness; if (interface == WMAX) ret = wmax_brightness(brightness); else - ret = alienware_update_led(0); + ret = alienware_update_led(priv, 0); if (ret) pr_err("LED brightness update failed\n"); } static enum led_brightness global_led_get(struct led_classdev *led_cdev) { - return global_brightness; -} - -static struct led_classdev global_led = { - .brightness_set = global_led_set, - .brightness_get = global_led_get, - .name = "alienware::global_brightness", -}; - -static int alienware_zone_init(struct platform_device *dev) -{ - if (interface == WMAX) { - lighting_control_state = WMAX_RUNNING; - } else if (interface == LEGACY) { - lighting_control_state = LEGACY_RUNNING; - } - global_led.max_brightness = 0x0F; - global_brightness = global_led.max_brightness; + struct alienfx_priv *priv; - return led_classdev_register(&dev->dev, &global_led); -} + priv = container_of(led_cdev, struct alienfx_priv, global_led); -static void alienware_zone_exit(struct platform_device *dev) -{ - led_classdev_unregister(&global_led); + return priv->global_brightness; } static acpi_status alienware_wmax_command(void *in_args, size_t in_size, @@ -1106,6 +1111,32 @@ static void remove_thermal_profile(void) /* * Platform Driver */ +static int alienfx_probe(struct platform_device *pdev) +{ + struct alienfx_priv *priv; + struct led_classdev *leds; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + platform_set_drvdata(pdev, priv); + + priv->pdev = pdev; + + if (interface == WMAX) + priv->lighting_control_state = WMAX_RUNNING; + else if (interface == LEGACY) + priv->lighting_control_state = LEGACY_RUNNING; + + leds = &priv->global_led; + leds->name = "alienware::global_brightness"; + leds->brightness_set = global_led_set; + leds->brightness_get = global_led_get; + leds->max_brightness = 0x0F; + + priv->global_brightness = priv->global_led.max_brightness; + + return devm_led_classdev_register(&pdev->dev, &priv->global_led); +} + static const struct attribute_group *alienfx_groups[] = { &zone_attribute_group, &hdmi_attribute_group, @@ -1119,6 +1150,7 @@ static struct platform_driver platform_driver = { .name = "alienware-wmi", .dev_groups = alienfx_groups, }, + .probe = alienfx_probe, }; static int __init alienware_wmi_init(void) @@ -1166,15 +1198,8 @@ static int __init alienware_wmi_init(void) goto fail_prep_thermal_profile; } - ret = alienware_zone_init(platform_device); - if (ret) - goto fail_prep_zones; - return 0; -fail_prep_zones: - alienware_zone_exit(platform_device); - remove_thermal_profile(); fail_prep_thermal_profile: platform_device_del(platform_device); fail_platform_device2: @@ -1189,7 +1214,6 @@ module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { - alienware_zone_exit(platform_device); remove_thermal_profile(); platform_device_unregister(platform_device); platform_driver_unregister(&platform_driver); From patchwork Sat Dec 21 05:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917648 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 75D6B1F239A; Sat, 21 Dec 2024 06:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760814; cv=none; b=bCGEvnRzh6WqaTT0xfPQhLB0UB0sjIC6kjt7/PYIGLEvhXLSdKtpdOHHI8T/GlI7ZLNfbPdlZVKlGoBjlm9WZ6FqfaejqrTy3v+VRcPmnYPAy8+okl8mutRMT2YZyeu3SdQ3O+b4KWGoZOwBLZ6DaGCnNXrasvgKuHTdueQl0pA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760814; c=relaxed/simple; bh=KWSjED2M9VhxuG0YPDnuQVf4o/CtNCseKxfCVgaN0xA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pjP8FEVcTiB3h2fWMNUt9oeuBzJlrJAVpGUYK7yU9S3RAU+0/YY74v35zBTGrGjpfs8SPckrAlmW6QHJ2Hhj3Co0uHbZJV3ChxZlfpurDjvvxhbbbwVSWNR+odHhwPgMDr68l9ujCVfyUsfZ5X4svFZmhNQ5a7oOGmeMVmjyvks= 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=Xx2QYnwz; arc=none smtp.client-ip=209.85.128.174 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="Xx2QYnwz" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6ef66a7ac14so36381967b3.0; Fri, 20 Dec 2024 22:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760811; x=1735365611; 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=EECUPqqs1VW7VoOaUFJwBnnyz+A6MswrqziHXXocFBs=; b=Xx2QYnwzHKESWm/Vx2nWdE4V8Sav0AqNmr88qX07w/uwosp+Xg3Jf+lWo4UEwzSQKY Jn54MReZpoyYY4c9QnokDrm5KVCBghBQTSxt8RAsIIcRbYjnqagAoWvloGIjP3n9H/m6 YhMiHgaZG9/zVCJ6uvLDxifThMtWtAjWBXv2d2zR7xITB1lVtEaPlKE1l5lokPXONq1v aGQGXFQemZXZGzEa/R36Nay4zrYXl9llcXWjWPa1vhc11mdfKtCi/xelJZIOMOlGEyRc W0izJ3tq1MBCL8P1JeyqpUuC5GexZpuBdMu9YO1yMjAZXxucn1GEKijuFVXLuh98f8ji jHrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760811; x=1735365611; 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=EECUPqqs1VW7VoOaUFJwBnnyz+A6MswrqziHXXocFBs=; b=RMwTqEMDoN/vKjmsTklsxASlLiyXsclIIMt7/sqyz+SJsWR5NjfVTb1dvJOzsEqocH U/Qz8Fa1UB5cn0lvJbEMGCAyKnRSnwE75bzW92efFtpxGtPy7tyTXmIxtd+KnNMCDd96 j8K7aoM2KOxK/zMmG2/hAihP76nw84+CLmamy/rjInU90eVxYnvjU5qWFngs/fMp5EIP hpEOS0803rBHkNSTUflgRDooS29hZGIoeHXdnltnoVBMjmYxLvpJDD+Z8wk+wclpPXam AOUsyeEfaa+CetVE6eaUbskb0PKR0YZCc57rJoSEu1OVh/vc8mX1czzehTAw0hpjH3JK S8wA== X-Forwarded-Encrypted: i=1; AJvYcCVap8ntJrPplqD5UNJJ2WmTpxYKcdifNoeNSJln8irtpGemSop7+EllMqNEAo9hMtZZFE4VE1jeI8Dugxo=@vger.kernel.org X-Gm-Message-State: AOJu0YzYw7tJA2MX9J9JgfoFpt/xpesA+cJGmWMv4LLMtxEp+y24h93z Xryx5gFwplO/7Ug5t6y9Oshw5nThEAUAV9dvTHjEFahVfcrRFF+gbH2LuQ== X-Gm-Gg: ASbGncs0xyq2Ry1HB+2z4RCvGcEnNt1PuKq7kvL6sBsGZEHMcHRRJp6ZJe0ZuOcjp7A hKQo8VaJHgC7Sjw2GG8IJptu4QlDJbqRIiSIWxpJeAazKotOcPR6fgtZQ3hejF+5BCP+eHaasCO z9Wms8aGPF7gY9eKznG/oEoOGczTyr4hgrFxga181FA+4mbr6clm3fyq743tA4bJFi86SI+W5rO D19XdJCHO9mK/7EZXaM15mT38mAxHCm30CnbA02zjGjzk1BHvqljO5s20ZgD9Xp X-Google-Smtp-Source: AGHT+IHkz2kHfNrKKA4gxVTu2oa2s67/Xj8hDADRS038Rf9r+2M7hkkNwaO8kt3auFJ0MbsxheVt+w== X-Received: by 2002:a05:690c:6f89:b0:6ef:f1be:5b5f with SMTP id 00721157ae682-6f3e2a8a911mr88283707b3.5.1734760811208; Fri, 20 Dec 2024 22:00:11 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:10 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 08/20] alienware-wmi: Add WMI Drivers Date: Sat, 21 Dec 2024 00:59:05 -0500 Message-ID: <20241221055917.10555-9-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add WMI drivers for LEGACY and WMAX devices. This involves moving platform driver and device registration to a helper function, which is now called from the driver's preferred WMI device driver probe. However this is only done if !quirks->thermal because newer WMAX interface doesn't support any of the features exposed by this device. Only one driver is registered on module initialization to prevent registering duplicate platform driver and device. Aditionally, create_thermal_profile() now takes wmi_device * instead of platform_device *. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 186 +++++++++++++++++----- 1 file changed, 146 insertions(+), 40 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 4b68d64bd742..f2f6842e27e6 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -15,6 +15,7 @@ #include #include #include +#include #define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492" #define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492" @@ -39,8 +40,6 @@ MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID); -MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID); static bool force_platform_profile; module_param_unsafe(force_platform_profile, bool, 0); @@ -412,7 +411,10 @@ struct alienfx_priv { u8 lighting_control_state; }; -static struct platform_device *platform_device; +struct alienfx_platdata { + struct wmi_device *wdev; +}; + static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; @@ -1048,7 +1050,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static int create_thermal_profile(struct platform_device *platform_device) +static int create_thermal_profile(struct wmi_device *wdev) { enum platform_profile_option profile; enum wmax_thermal_mode mode; @@ -1097,7 +1099,7 @@ static int create_thermal_profile(struct platform_device *platform_device) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; pp_handler.name = "alienware-wmi"; - pp_handler.dev = &platform_device->dev; + pp_handler.dev = &wdev->dev; return platform_profile_register(&pp_handler); } @@ -1153,19 +1155,138 @@ static struct platform_driver platform_driver = { .probe = alienfx_probe, }; -static int __init alienware_wmi_init(void) +static int alienware_alienfx_setup(struct alienfx_platdata *pdata) { + struct platform_device *pdev; int ret; - if (wmi_has_guid(LEGACY_CONTROL_GUID)) - interface = LEGACY; - else if (wmi_has_guid(WMAX_CONTROL_GUID)) - interface = WMAX; - else { - pr_warn("alienware-wmi: No known WMI GUID found\n"); - return -ENODEV; + ret = platform_driver_register(&platform_driver); + if (ret < 0) + return ret; + + pdev = platform_device_register_data(NULL, "alienware-wmi", + PLATFORM_DEVID_NONE, pdata, + sizeof(*pdata)); + + if (IS_ERR(pdev)) { + platform_driver_unregister(&platform_driver); + return PTR_ERR(pdev); } + dev_set_drvdata(&pdata->wdev->dev, pdev); + + return 0; +} + +static void alienware_alienfx_exit(struct wmi_device *wdev) +{ + struct platform_device *pdev; + + pdev = dev_get_drvdata(&wdev->dev); + + platform_device_unregister(pdev); + platform_driver_unregister(&platform_driver); +} + +/* + * Legacy WMI driver + */ +static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct alienfx_platdata pdata = { + .wdev = wdev, + }; + + return alienware_alienfx_setup(&pdata); +} + +static void legacy_wmi_remove(struct wmi_device *wdev) +{ + alienware_alienfx_exit(wdev); +} + +static struct wmi_device_id alienware_legacy_device_id_table[] = { + { LEGACY_CONTROL_GUID, NULL }, + { }, +}; +MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table); + +static struct wmi_driver alienware_legacy_wmi_driver = { + .driver = { + .name = "alienware-wmi-alienfx", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = alienware_legacy_device_id_table, + .probe = legacy_wmi_probe, + .remove = legacy_wmi_remove, +}; + +static int __init alienware_legacy_wmi_init(void) +{ + return wmi_driver_register(&alienware_legacy_wmi_driver); +} + +static void __exit alienware_legacy_wmi_exit(void) +{ + wmi_driver_unregister(&alienware_legacy_wmi_driver); +} + +/* + * WMAX WMI driver + */ +static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct alienfx_platdata pdata = { + .wdev = wdev, + }; + int ret = 0; + + if (quirks->thermal) + ret = create_thermal_profile(wdev); + else + ret = alienware_alienfx_setup(&pdata); + + return ret; +} + +static void wmax_wmi_remove(struct wmi_device *wdev) +{ + if (quirks->thermal) + remove_thermal_profile(); + else + alienware_alienfx_exit(wdev); +} + +static struct wmi_device_id alienware_wmax_device_id_table[] = { + { WMAX_CONTROL_GUID, NULL }, + { }, +}; +MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table); + +static struct wmi_driver alienware_wmax_wmi_driver = { + .driver = { + .name = "alienware-wmi-wmax", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = alienware_wmax_device_id_table, + .probe = wmax_wmi_probe, + .remove = wmax_wmi_remove, +}; + +static int __init alienware_wmax_wmi_init(void) +{ + return wmi_driver_register(&alienware_wmax_wmi_driver); +} + +static void __exit alienware_wmax_wmi_exit(void) +{ + wmi_driver_unregister(&alienware_wmax_wmi_driver); +} + +static int __init alienware_wmi_init(void) +{ + int ret; + dmi_check_system(alienware_quirks); if (quirks == NULL) quirks = &quirk_unknown; @@ -1180,43 +1301,28 @@ static int __init alienware_wmi_init(void) pr_warn("force_gmode requires platform profile support\n"); } - ret = platform_driver_register(&platform_driver); - if (ret) - goto fail_platform_driver; - platform_device = platform_device_alloc("alienware-wmi", PLATFORM_DEVID_NONE); - if (!platform_device) { - ret = -ENOMEM; - goto fail_platform_device1; + if (wmi_has_guid(WMAX_CONTROL_GUID)) { + interface = WMAX; + ret = alienware_wmax_wmi_init(); + } else { + interface = LEGACY; + ret = alienware_legacy_wmi_init(); } - ret = platform_device_add(platform_device); - if (ret) - goto fail_platform_device2; - if (quirks->thermal) { - ret = create_thermal_profile(platform_device); - if (ret) - goto fail_prep_thermal_profile; - } + if (ret < 0) + return ret; return 0; - -fail_prep_thermal_profile: - platform_device_del(platform_device); -fail_platform_device2: - platform_device_put(platform_device); -fail_platform_device1: - platform_driver_unregister(&platform_driver); -fail_platform_driver: - return ret; } module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { - remove_thermal_profile(); - platform_device_unregister(platform_device); - platform_driver_unregister(&platform_driver); + if (interface == WMAX) + alienware_wmax_wmi_exit(); + else + alienware_legacy_wmi_exit(); } module_exit(alienware_wmi_exit); From patchwork Sat Dec 21 05:59:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917649 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 497831F2C34; Sat, 21 Dec 2024 06:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760817; cv=none; b=Vg0SfZgw2WKDfLbJWxcwsL4oHxYjyHG6yyQkdMJgckTcmfymwJKWhjfzcMHnmWWt6Ymr8ruqFQxHGJ/tfkwDOj6+a7SWRNS/XR4nsFf5NqNNhnPskqbZAUPw3Mki+l+2lFZrNcEXBShI1pghMCHU5vjnGFnJtHWPjO8e+EWB0pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760817; c=relaxed/simple; bh=1QyptutNKqsCkf9oPPLxnFyYVoHsUn+GChl1LoArlLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TNjIbPWl1S/qXxUGTyzdJYXET6w0TeICM7fdSLaS5Z3DfOedM6UQIONRDX4531kxm9C/5hDSjY12yaZh4fdRmG+fqezZQaJr1ubQDoPrPLImwOLvNeem2lkuULISgqM5ZG10TSEYrFUuMM7uSgqpuxXFIVIPD4ZM8UCf2zKyKik= 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=huPah+j3; arc=none smtp.client-ip=209.85.128.180 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="huPah+j3" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6f0054cb797so21089987b3.0; Fri, 20 Dec 2024 22:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760814; x=1735365614; 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=8Q+n4bgjJqqSac7LlNtb5h3q8ImmgMHiXd3qqoGPL3Q=; b=huPah+j3LtQkbDNf7oCuf7IGM3vlRCt0z7Z3fOpQ5ue5NHGVMtBewBZnq+ocdc7IqU OfcJEaqWqkEj9X4pMHTyWLTA+rnKwUmtuARh/EAlfX1zdB+pHM4DjiF9gi5fbs4ESYxv VulfvOgfE96ZRn36iZgGgx2eHdAnHDjt3TrjScry+8d63uCJjVgccviYC7A4pWzHh59L f3YlQjtHzrJ+wCbsu6I9Hg5McwI42ZZxtK2HZsJ894ZkSE6J7CMGhJ1YMW3Z81ejpk1H QmYDResv2QbpCGcWYF41GisVpAlLNrDhjsU/1daYtA+IeF54jHdrJLtkx/zu0xaXWm8J C3dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760814; x=1735365614; 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=8Q+n4bgjJqqSac7LlNtb5h3q8ImmgMHiXd3qqoGPL3Q=; b=OmaOB7H+0W/EsTo9pf8KY02G7mCEoLH3f1kr3ht2n2MYJAnBkqZxmM6rgN+MZRUIZc BNhP1QalXCMztO4wYXF8UH8X//O/5z/+w5yndhmzx278mcs+hUf/jNx5iOIKdUy11YKS bhkBcAVr+JLs+c6yt000BYFnz9Ex3XSgd8fYK3aA+JuS/Xw0gNG7r2D3jzPiZQuDHGEh acPZxZuuS4CVaxGKTvmVvriba2Oxy3Gmo0g8kroiI5J0Np9MvcBX2C/r91XtMdNKTPo2 9JcEq+cbTd/9AtMm33FCh+Yt6JEPuY0UxkdlI/QFzl6bUQDYrwDpT6bu2Sfl1+XvTNL8 nKuQ== X-Forwarded-Encrypted: i=1; AJvYcCWtwq/XHR6JBVgxq6G7G0AS8txh5H5o7DlA1SU/WXG/KLrZBdFw9GOegpbbe6OVWjqmx9IU4obTtLNNOBs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/kxr7nuET5GA04bQhnTZvEH3EOcXVq7lAQqbxzIsKvumzJ2Fa 8f3/Q7I1ptqPZ9JM5i5DPOHP1TdMJx3k+IO0Q5MKY+2dXG0yv3+8bcKllA== X-Gm-Gg: ASbGnctmxtwWY+XDDRSSU34qV9/TB3PHrk/T/fQQMQegNc4KCs0belTBO7/fk82DHuW FM3PcJTXeUl7sUBQPX1ap7QoXl8+K6pVatBRlll3LTSK6RGUVsl349j2b8EdbFEBrtq6p7sEPgd 4LCkNj+tKRcEe4ZsKj6aDurM0WQDqc46Jfcnjd0tJ4ZAI2iBJDXEJ4KfiCu4h+zpMXWV3sR2Nh2 QyiziqlgmyVF/+SdUc2bJ4qX+hh6y0c4V/4RCzU0FAyfNH6aKVVJGQdtQ7UurrX X-Google-Smtp-Source: AGHT+IFGoOVdlvtDvdkAyQ7ZM16K5i8OV7ZAyAasyQjgWz/JRXVibUl6cU4IVT2255isciNyXjaN1Q== X-Received: by 2002:a05:690c:690b:b0:6ef:7036:3b57 with SMTP id 00721157ae682-6f3f821a2camr49619127b3.28.1734760814064; Fri, 20 Dec 2024 22:00:14 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:13 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 09/20] alienware-wmi: Add a state container for thermal control methods Date: Sat, 21 Dec 2024 00:59:06 -0500 Message-ID: <20241221055917.10555-10-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor all thermal control methods to use the newly defined awcc_priv state container instead of global variables. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 71 +++++++++++++++++------ 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index f2f6842e27e6..c4ca141d628e 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -403,6 +403,12 @@ struct wmax_u32_args { u8 arg3; }; +struct awcc_priv { + struct wmi_device *wdev; + struct platform_profile_handler pp_handler; + enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; +}; + struct alienfx_priv { struct platform_device *pdev; struct led_classdev global_led; @@ -415,9 +421,6 @@ struct alienfx_platdata { struct wmi_device *wdev; }; -static struct platform_profile_handler pp_handler; -static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; - static u8 interface; /* @@ -1027,6 +1030,10 @@ static int thermal_profile_get(struct platform_profile_handler *pprof, static int thermal_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { + struct awcc_priv *priv; + + priv = container_of(pprof, struct awcc_priv, pp_handler); + if (quirks->gmode) { u32 gmode_status; int ret; @@ -1047,18 +1054,21 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, } } - return wmax_thermal_control(supported_thermal_profiles[profile]); + return wmax_thermal_control(priv->supported_thermal_profiles[profile]); } static int create_thermal_profile(struct wmi_device *wdev) { enum platform_profile_option profile; enum wmax_thermal_mode mode; + struct awcc_priv *priv; u8 sys_desc[4]; u32 first_mode; u32 out_data; int ret; + priv = dev_get_drvdata(&wdev->dev); + ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION, 0, (u32 *) &sys_desc); if (ret < 0) @@ -1081,33 +1091,56 @@ static int create_thermal_profile(struct wmi_device *wdev) mode = out_data & WMAX_THERMAL_MODE_MASK; profile = wmax_mode_to_platform_profile[mode]; - supported_thermal_profiles[profile] = out_data; + priv->supported_thermal_profiles[profile] = out_data; - set_bit(profile, pp_handler.choices); + set_bit(profile, priv->pp_handler.choices); } - if (bitmap_empty(pp_handler.choices, PLATFORM_PROFILE_LAST)) + if (bitmap_empty(priv->pp_handler.choices, PLATFORM_PROFILE_LAST)) return -ENODEV; if (quirks->gmode) { - supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = + priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; - set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->pp_handler.choices); } - pp_handler.profile_get = thermal_profile_get; - pp_handler.profile_set = thermal_profile_set; - pp_handler.name = "alienware-wmi"; - pp_handler.dev = &wdev->dev; + priv->pp_handler.profile_get = thermal_profile_get; + priv->pp_handler.profile_set = thermal_profile_set; + priv->pp_handler.name = "alienware-wmi"; + priv->pp_handler.dev = &wdev->dev; - return platform_profile_register(&pp_handler); + return platform_profile_register(&priv->pp_handler); } -static void remove_thermal_profile(void) +static int alienware_awcc_setup(struct wmi_device *wdev) { - if (quirks->thermal) - platform_profile_remove(&pp_handler); + struct awcc_priv *priv; + int ret; + + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + dev_set_drvdata(&wdev->dev, priv); + + priv->wdev = wdev; + + ret = create_thermal_profile(wdev); + if (ret < 0) + return ret; + + return 0; +} + +static void alienware_awcc_exit(struct wmi_device *wdev) +{ + struct awcc_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + + platform_profile_remove(&priv->pp_handler); } /* @@ -1242,7 +1275,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) int ret = 0; if (quirks->thermal) - ret = create_thermal_profile(wdev); + ret = alienware_awcc_setup(wdev); else ret = alienware_alienfx_setup(&pdata); @@ -1252,7 +1285,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) static void wmax_wmi_remove(struct wmi_device *wdev) { if (quirks->thermal) - remove_thermal_profile(); + alienware_awcc_exit(wdev); else alienware_alienfx_exit(wdev); } From patchwork Sat Dec 21 05:59:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917650 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.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 D26191F2C34; Sat, 21 Dec 2024 06:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760823; cv=none; b=uGp3j0ADpKHrr2/gcd39HB5T72vutMSIQb8FihuKe6Pqcu6EgAj0a283blihvB41uS6s31y9HKp+wh7f/awVd2F3PGEZyyZR0bKjPFU8bgmcUcSFxsXU88Y2dqNodYhlM6jU93QJK+SJmxIkuKuO6S/CpbP38kOKaU28dxUxQ5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760823; c=relaxed/simple; bh=+97BEZqSOzUMHZcxl5gy9WNRc/ik8bUMYqhu+MNiJOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=exuCIvSZEDGvq/d+PxYGTEEvSqL9KcY+tUnv74EQ2Cp4+cPgiC0hmbu7Q4RIx4GURnSlwGJQ2WxTvmJV4UkqPK1lNR66oAQyAuPuFE76O+Yhsis4Vn9+oeLeS2MKyslFA4I3miidZmw36l6BtqUiL/cOKOcFrkHELWZNpmLrAQI= 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=kyW0KgCy; arc=none smtp.client-ip=209.85.128.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="kyW0KgCy" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6ef7c9e9592so30036437b3.1; Fri, 20 Dec 2024 22:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760820; x=1735365620; 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=i3JTkPPrMDBh7lvJhQshhnN1kh0URjRj/qqoCrwPV0Q=; b=kyW0KgCyihNr0FmRZALGvy29Q+P/Zvl/l+i1kphQGMF9J+f/BKblwri9xzxr0R0C3G b+GUDOLFJ3cVIySC5DzPk8bb8FdMWqMvTmfTq784ARaVkA7OS/N5jLrj1WDRG6+YF5Fm E8q8FN64CBc9Dp6dl9mleSUeiBAltkJmht8ajterN/9/ZwkDSGU3ZCPVySm35NzQa1Ql rigdo+eWkRC7tPQ84tS7loykCKAQ+uIsLq++bhYF2NiScXsrV0vXjjFH0BUmFWiZEdx8 S+J6OehKn7bf4d/EWWYsiBBSFeDGW9eYfihxYiO9K/hHxB+dWgiHPlcPm8nRHF3v4cTt Dpcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760820; x=1735365620; 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=i3JTkPPrMDBh7lvJhQshhnN1kh0URjRj/qqoCrwPV0Q=; b=sKdAeSJACvHblpxyB+LSlaQ/rtpj05AufcqvRalVjsiU7o9QLgvOahFZnW0rf2bb9R KftxjkjFPaAnS6yaxTLZ4VFc4eoPCHIdwkyz6JqBlPC3a2ak34JyCy5+FNId3zQ4kKdE 22/AhzpcCs4JxWJTDpBstuL9On3+TqM13LOMLGwSPNm4TuZDrhqJlF4zWHsT1jlfbvBl Rt+k+e7chVaCpc9RH1J5uC+vOvSpPAJvU4F4Fk+lz+W+0wZN29PZLlcy33y65LjJL7W2 wX2mJJjVk0JabkTpma8slwbh44thhO6R5TpsD9qQl6LL5Fk6+c1SUJXvltXrynhUt99N /clg== X-Forwarded-Encrypted: i=1; AJvYcCXSOWxA0/PUH8ZLr9AHyfP0c8r0rBCQ1HIOvI+cJiAQ+5+u7Ntj+QXU4l/ITTzUZLBnvkoVvLmkLuThyZo=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+Gfn92Tu3W5a9mwID/okMK8HH7GpEtKRPKhgUKmadtIheIwXB zMbrxquuzAdFXa8lf1PvFJ8DSUWmT2qjfJxUsId+SRVfmm49Z7Z43nPhHw== X-Gm-Gg: ASbGncuwnG417elQevzXGdWcrnAMKEpRj2yieiRNcpBKh06rpVfJSZ3yarxhXg8QQxO OHK7dBJXgnHMn3dd3GUCIaski6m1JAYlUKOOGqSOH3xe/bRL+hMGEHXFw++NeqgLPraNzk9lVGO UpuVcTdv6vgSEixrE4qSp5zH5yWE1POimbHHvjf8xgQn5M/5UPtlJCBW5fXwAPFFdodTL5mCidq tTejv1hG1QVQ8GIx51fHjrKAkycdjtoq+/oJbh2a+SEsXv//0dFBjkPKie2wRm0 X-Google-Smtp-Source: AGHT+IEs4TAvURrZ5KZVyrf1ol73e36QRX6re82NHGCGVm24jRRljex7MOAFDSmKgFEtL3lPX9WY3Q== X-Received: by 2002:a05:690c:88c:b0:6e3:37a7:8a98 with SMTP id 00721157ae682-6f3f8114d78mr52754447b3.14.1734760820539; Fri, 20 Dec 2024 22:00:20 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:20 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 10/20] alienware-wmi: Refactor LED control methods Date: Sat, 21 Dec 2024 00:59:07 -0500 Message-ID: <20241221055917.10555-11-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both WMI devices handled by this module specify a distinct interface for LED control. Previously this module handled this by dynamically adapting arguments passed to wmi_evaluate_method() based on the `interface` global variable. To avoid the use of global variables, and enable the migration to non-deprecated WMI methods, let the WMI drivers define upd_led and upd_brightness operations, which completely replace alienware_update_led() and wmax_brightness(). Also define alienware_wmi_command(), which serves as a wrapper for wmidev_evaluate_method(). This new method is very similar to alienware_wmax_command() but is WMI device agnostic. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 180 ++++++++++++++-------- 1 file changed, 118 insertions(+), 62 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index c4ca141d628e..bcf3b2f80dfd 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -417,12 +417,46 @@ struct alienfx_priv { u8 lighting_control_state; }; +struct alienfx_ops { + int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev, + u8 location); + int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev, + u8 brightness); +}; + struct alienfx_platdata { struct wmi_device *wdev; + struct alienfx_ops ops; }; static u8 interface; +static acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, + void *in_args, size_t in_size, u32 *out_data) +{ + struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer in = {in_size, in_args}; + union acpi_object *obj; + acpi_status ret; + + if (out_data) { + ret = wmidev_evaluate_method(wdev, 0, method_id, &in, &out); + if (ACPI_FAILURE(ret)) + goto out_free_ptr; + + obj = (union acpi_object *)out.pointer; + + if (obj && obj->type == ACPI_TYPE_INTEGER) + *out_data = (u32)obj->integer.value; + } else { + ret = wmidev_evaluate_method(wdev, 0, method_id, &in, NULL); + } + +out_free_ptr: + kfree(out.pointer); + return ret; +} + /* * Helpers used for zone control */ @@ -453,46 +487,6 @@ static int parse_rgb(const char *buf, struct color_platform *colors) /* * Individual RGB zone control */ -static int alienware_update_led(struct alienfx_priv *priv, u8 location) -{ - int method_id; - acpi_status status; - char *guid; - struct acpi_buffer input; - struct legacy_led_args legacy_args; - struct wmax_led_args wmax_basic_args; - if (interface == WMAX) { - wmax_basic_args.led_mask = 1 << location; - wmax_basic_args.colors = priv->colors[location]; - wmax_basic_args.state = priv->lighting_control_state; - guid = WMAX_CONTROL_GUID; - method_id = WMAX_METHOD_ZONE_CONTROL; - - input.length = sizeof(wmax_basic_args); - input.pointer = &wmax_basic_args; - } else { - legacy_args.colors = priv->colors[location]; - legacy_args.brightness = priv->global_brightness; - legacy_args.state = 0; - if (priv->lighting_control_state == LEGACY_BOOTING || - priv->lighting_control_state == LEGACY_SUSPEND) { - guid = LEGACY_POWER_CONTROL_GUID; - legacy_args.state = priv->lighting_control_state; - } else - guid = LEGACY_CONTROL_GUID; - method_id = location + 1; - - input.length = sizeof(legacy_args); - input.pointer = &legacy_args; - } - pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id); - - status = wmi_evaluate_method(guid, 0, method_id, &input, NULL); - if (ACPI_FAILURE(status)) - pr_err("alienware-wmi: zone set failure: %u\n", status); - return ACPI_FAILURE(status); -} - static ssize_t zone_show(struct device *dev, struct device_attribute *attr, char *buf, u8 location) { @@ -510,18 +504,20 @@ static ssize_t zone_show(struct device *dev, struct device_attribute *attr, static ssize_t zone_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, u8 location) { + struct alienfx_platdata *pdata; struct color_platform *colors; struct alienfx_priv *priv; int ret; priv = dev_get_drvdata(dev); + pdata = dev_get_platdata(dev); colors = &priv->colors[location]; ret = parse_rgb(buf, colors); if (ret) return ret; - ret = alienware_update_led(priv, location); + ret = pdata->ops.upd_led(priv, pdata->wdev, location); return ret ? ret : count; } @@ -628,35 +624,19 @@ static struct attribute_group zone_attribute_group = { /* * LED Brightness (Global) */ -static int wmax_brightness(int brightness) -{ - acpi_status status; - struct acpi_buffer input; - struct wmax_brightness_args args = { - .led_mask = 0xFF, - .percentage = brightness, - }; - input.length = sizeof(args); - input.pointer = &args; - status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, - WMAX_METHOD_BRIGHTNESS, &input, NULL); - if (ACPI_FAILURE(status)) - pr_err("alienware-wmi: brightness set failure: %u\n", status); - return ACPI_FAILURE(status); -} - static void global_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) { + struct alienfx_platdata *pdata; struct alienfx_priv *priv; int ret; priv = container_of(led_cdev, struct alienfx_priv, global_led); + pdata = dev_get_platdata(&priv->pdev->dev); + priv->global_brightness = brightness; - if (interface == WMAX) - ret = wmax_brightness(brightness); - else - ret = alienware_update_led(priv, 0); + + ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness); if (ret) pr_err("LED brightness update failed\n"); } @@ -1224,10 +1204,47 @@ static void alienware_alienfx_exit(struct wmi_device *wdev) /* * Legacy WMI driver */ +static int legacy_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + struct legacy_led_args legacy_args; + struct acpi_buffer input; + acpi_status status; + + legacy_args.colors = priv->colors[location]; + legacy_args.brightness = priv->global_brightness; + legacy_args.state = priv->lighting_control_state; + + input.length = sizeof(legacy_args); + input.pointer = &legacy_args; + + if (legacy_args.state == LEGACY_RUNNING) + status = alienware_wmi_command(wdev, location + 1, &legacy_args, + sizeof(legacy_args), NULL); + else + status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0, + location + 1, &input, NULL); + + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + +static int legacy_wmi_update_brightness(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 brightness) +{ + return legacy_wmi_update_led(priv, wdev, 0); +} + static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) { struct alienfx_platdata pdata = { .wdev = wdev, + .ops = { + .upd_led = legacy_wmi_update_led, + .upd_brightness = legacy_wmi_update_brightness, + }, }; return alienware_alienfx_setup(&pdata); @@ -1267,10 +1284,49 @@ static void __exit alienware_legacy_wmi_exit(void) /* * WMAX WMI driver */ +static int wmax_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + struct wmax_led_args in_args = { + .led_mask = 1 << location, + .colors = priv->colors[location], + .state = priv->lighting_control_state, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, + &in_args, sizeof(in_args), NULL); + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + +static int wmax_wmi_update_brightness(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 brightness) +{ + struct wmax_brightness_args in_args = { + .led_mask = 0xFF, + .percentage = brightness, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args, + sizeof(in_args), NULL); + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) { struct alienfx_platdata pdata = { .wdev = wdev, + .ops = { + .upd_led = wmax_wmi_update_led, + .upd_brightness = wmax_wmi_update_brightness, + }, }; int ret = 0; From patchwork Sat Dec 21 05:59:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917651 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 6ADC21F37B2; Sat, 21 Dec 2024 06:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760826; cv=none; b=uqpP8FCXYRjX2BvU6FykqP0entkB3tRl9YRIEhfaYnLXjMsGkMuWQwapLRGlxCgd59L6olfyge+InnJW5MlizekpHuIUweScSMgyGR7ugbPKV9VVOkeEEarIiW/EABA9x+naYB29frGTst53hMNlaNQWhvn1Y+MVx98KRJdLyFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760826; c=relaxed/simple; bh=xPA6R5La2E+9MfodB0Sl2AfXcf5WmAYv7SEq+INex6Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hnoodZ9BGZZQh3UlNcv6AWz5I9GsOcG+lLayy3wBTJsIhOZKMgMgg7gx0AsJv9i8hA4cnV4iw8B1EaOF6BImWiun1AGAETPlZhSbzpgKKoBLaFuofT2QrmOGy4jgGjmbVziKcjdv55oNMdOeeiwptT760OJIqsusZZGCkUTtIV8= 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=HnQpEMXv; arc=none smtp.client-ip=209.85.128.180 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="HnQpEMXv" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6ef9b8b4f13so22989017b3.2; Fri, 20 Dec 2024 22:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760823; x=1735365623; 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=P216bbBhvCShPSkXdAJnbA17pOkwI5/lxUifQLEloWc=; b=HnQpEMXvFB3vow7XfFMrVGzXHPgqyq7Qj9w7dBeX1SD3KV3IXzl0NLaAj6MpVcUgvW iHjrEkFHk9jrAVZBdROzEdKav1SNzJCy0NOEakOfAPvFvCDh0cf9+2N9+ytk//rpcA35 L61RniRLiSyNf0os+cV6dQAUsABI9u/7WMUjE8HhzG7AdwLn7ZbCjBesde0va3TFXz+G sSshxy8TZ07qGVrAJiDHYvQfUwzICLn2fbWbptNnUqNITpU8UQE6hQFx17Sr22gEmGXz 7+bpGNS9Kwu2uKpUHr6nw91JG8vRZjqMY4TWiq4Ju2LeR1lY/hIhazYeGNAR8iMvGar8 p8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760823; x=1735365623; 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=P216bbBhvCShPSkXdAJnbA17pOkwI5/lxUifQLEloWc=; b=MdurSFjdxc3WYxf6yt1ihOK4puxb+MAodZKeOm+1H/aLk439Yfggs166vclMAytggM jVUZQhwx07VeOT+/MuhmBZcwNkxy6xLsVs5qyI5iP8MPJV2mLMVj2jilPmfK5EG2PMbs L2UKFk09T00JYe48JLEc34Ri+16uwrm2TPJcqpiVJv4rqjrls2U38D5mhzDXwanAAFTu 2uh8RwIPTsi7GkgdAVyhTfKZKOybO/aGCfXonHgrqNv43M6VOR9yOppiMfG/5f3SjyZF 6LLIA6/cPUSfAbbDLBt2XcjqmAN24vjwyz0cp395Yc2kKEw0c/IJaMCjxmJlUKXgH0HF +cbg== X-Forwarded-Encrypted: i=1; AJvYcCUkQEEHn+yiQ+gQcCBAUYme2Q4C4AoCaLHEf/tcRv48sNiGTE8MPm5fWEjSHm7uAwKLlKgXBgl8wZw5CiU=@vger.kernel.org X-Gm-Message-State: AOJu0YyhF6FjV1cTb+Ts4P5VKf77DwpWnRTW1eSC91xykfsjuvQw2y5f kgx1vQf+evu+fFCU+hH7mzG4f4PX1YMTihOyT8q+JqqGl7ViZy+RYTe83g== X-Gm-Gg: ASbGncuhmvvMjTjlbbrA03OoaxzCNzqQFfljuvUur5ykgtgHB0arHUtpOZH5BYnhR34 0Z13kNzWi6T1OlC4TkI8gSTavvYoVn4AQtwvfm4Bqi1N5Rww3KnzZeDmD/4VicYyc45B3r7GOe/ +kHukO3gFTIgKKdMwuIZ5e9w10wA5KcKiE2bF+jWjfgyWpUCpASANgq/98z7KTh54h39QL2qtpq sN5enTVKCFokhPYA//jyw+1zZEpgHWodrAvgphp6MTfig+oLeVjOlAsKIL4eHPz X-Google-Smtp-Source: AGHT+IGJuUFiCMVGVKQTTNlgbP4ncdLIcpJ1thDVDBYNVTfdKdcPZYe7bOPWY8WA64rgAX747YG0PA== X-Received: by 2002:a05:690c:10c:b0:6ef:579c:38f4 with SMTP id 00721157ae682-6f3f8134cbfmr38387527b3.21.1734760822882; Fri, 20 Dec 2024 22:00:22 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:22 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 11/20] alienware-wmi: Refactor hdmi, amplifier, deepslp methods Date: Sat, 21 Dec 2024 00:59:08 -0500 Message-ID: <20241221055917.10555-12-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor show/store methods for hdmi, amplifier, deepslp sysfs groups to use alienware_wmi_command() instead of alienware_wmax_command() which uses deprecated WMI methods. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 51 ++++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index bcf3b2f80dfd..b9da5fe657a9 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -685,14 +685,18 @@ static acpi_status alienware_wmax_command(void *in_args, size_t in_size, static ssize_t show_hdmi_cable(struct device *dev, struct device_attribute *attr, char *buf) { + struct alienfx_platdata *pdata; acpi_status status; u32 out_data; struct wmax_basic_args in_args = { .arg = 0, }; - status = - alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_HDMI_CABLE, &out_data); + + pdata = dev_get_platdata(dev); + + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_CABLE, + &in_args, sizeof(in_args), &out_data); + if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -706,14 +710,17 @@ static ssize_t show_hdmi_cable(struct device *dev, static ssize_t show_hdmi_source(struct device *dev, struct device_attribute *attr, char *buf) { + struct alienfx_platdata *pdata; acpi_status status; u32 out_data; struct wmax_basic_args in_args = { .arg = 0, }; - status = - alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_HDMI_STATUS, &out_data); + + pdata = dev_get_platdata(dev); + + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_STATUS, + &in_args, sizeof(in_args), &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 1) @@ -729,8 +736,12 @@ static ssize_t toggle_hdmi_source(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct alienfx_platdata *pdata; acpi_status status; struct wmax_basic_args args; + + pdata = dev_get_platdata(dev); + if (strcmp(buf, "gpu\n") == 0) args.arg = 1; else if (strcmp(buf, "input\n") == 0) @@ -739,8 +750,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, sizeof(args), - WMAX_METHOD_HDMI_SOURCE, NULL); + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_SOURCE, + &args, sizeof(args), NULL); if (ACPI_FAILURE(status)) pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", @@ -778,14 +789,17 @@ static const struct attribute_group hdmi_attribute_group = { static ssize_t show_amplifier_status(struct device *dev, struct device_attribute *attr, char *buf) { + struct alienfx_platdata *pdata; acpi_status status; u32 out_data; struct wmax_basic_args in_args = { .arg = 0, }; - status = - alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_AMPLIFIER_CABLE, &out_data); + + pdata = dev_get_platdata(dev); + + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_AMPLIFIER_CABLE, + &in_args, sizeof(in_args), &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[unconnected] connected unknown\n"); @@ -822,13 +836,17 @@ static const struct attribute_group amplifier_attribute_group = { static ssize_t show_deepsleep_status(struct device *dev, struct device_attribute *attr, char *buf) { + struct alienfx_platdata *pdata; acpi_status status; u32 out_data; struct wmax_basic_args in_args = { .arg = 0, }; - status = alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_DEEP_SLEEP_STATUS, &out_data); + + pdata = dev_get_platdata(dev); + + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_STATUS, + &in_args, sizeof(in_args), &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); @@ -845,9 +863,12 @@ static ssize_t toggle_deepsleep(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct alienfx_platdata *pdata; acpi_status status; struct wmax_basic_args args; + pdata = dev_get_platdata(dev); + if (strcmp(buf, "disabled\n") == 0) args.arg = 0; else if (strcmp(buf, "s5\n") == 0) @@ -856,8 +877,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, sizeof(args), - WMAX_METHOD_DEEP_SLEEP_CONTROL, NULL); + status = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_CONTROL, + &args, sizeof(args), NULL); if (ACPI_FAILURE(status)) pr_err("alienware-wmi: deep sleep control failed: results: %u\n", From patchwork Sat Dec 21 05:59:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917652 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 B77051EC4E0; Sat, 21 Dec 2024 06:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760828; cv=none; b=Zo/sTQpNpWWHIVLA/etPhKQkllgR6St5POkDAJoKQhxOP9B1BYFGoHuEvhAmTpS4XdhmcACZ9Gk1MQK9nV/2vrtIESePVoT8goqlqDkWVVLJZzY9ACClmLIzM8Da/OoLNBJu3kH2DJfWl1ESUskI8lctA73mskdYuG3MLS/Mzk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760828; c=relaxed/simple; bh=psLckmhsobLJeOO/dpIkLth2Me8zNx+vLLptUHAcOos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gxDeLYAVsMd4WME1VZFCJVvEnQV0ft8kZ+Ntm4uLBNfjrJFo0bJuOiS/k1M4e4uUpuYLrInz+InRhulnKZjE9fGUjmrmKj/SQxvET/92GbIgrvgeltd+4q7e+xGKmK9YI865g0hJgfB/TpFZ3te11pdBowqsoE4BOn1bPDNQxY4= 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=GF9pATbW; arc=none smtp.client-ip=209.85.128.173 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="GF9pATbW" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6f27bbe8fc3so20451747b3.2; Fri, 20 Dec 2024 22:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760825; x=1735365625; 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=gXI8QbnRrPpL1WzHc5LtEEypsL+PMy3TXkjv2gjKxtk=; b=GF9pATbWtvRzwm+rDIIX5n0kBUgZeqyejyiqY9rBve70QMYImwY6u7XoLV8ptPssS8 9CNy2m6csG/BTBvvcC+YbqmHaY274+i51Xs7TcV35XuCNhdYnS2FFEvAxqdGRKV72wPt MVu/zYbtH3Xnx0/bkRNkLXV/LDUZDAadr3Juc2cHilwHonYd2LIjwHiJKW7A0piLowYb VP+sNWldrbqhpTwKUsRzKZ0HOhvK+UGH3Mn/ezZB4ZfCBf8jGKmX+5EybOjSquqZchla ZiJDvCrVZ7trHYC0SAie/iJtC/ONGOrhtU8UTpCzh4uw77SokQIgs/xTfIMENKki/Zrv WhLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760825; x=1735365625; 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=gXI8QbnRrPpL1WzHc5LtEEypsL+PMy3TXkjv2gjKxtk=; b=vsazUq6NyghYpv1ilh8TPHKSdg7oRS8aekCUHxybLS+xLr5LJfFtaBTDp+d8KDRQxh XNS6jbW2bbsLrQta2z+DPGj44OwdiRBkBSLOnK1LR8BxDQMJ7pP6U80hm/1/mFq5qtM+ peQbK2k3q6z9tFEr2wfKVryG7T/dkCY2LSsVp6b0xuDjH9OwnL6TU8T4TofxYne5VwhT IDq7jyxWGgy2qaVFlffFoj2ZXr17Q4A2x/ZtQ3Vj+XokV0/y9GFqzjlJJR9pc3Qq07xd vhXZgC9yGoAx9u1HO2cgYUj3AY9jzkmyrTXIA2NZoieKKOHGE7iX3RcIFb7IL6FzgckL cNxQ== X-Forwarded-Encrypted: i=1; AJvYcCVBtXcNbjh8XMPv7/SqbPkdwczPag54mRlWHLXETv078OQXmqcibleRVDcBMWEi+lzirrqHsjUt4kH6bFM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8shCLFfOixwfyiQRDMSenVKdUHlWlLAi4sws5HcD2R/0Spo5O KmbbicrnieTbFmCxUp5pLJGJLg97Pb7oHiPRlI08h7TvJUWPsphqzxu60Q== X-Gm-Gg: ASbGncuidHzKnuzy9PLDBnN0mbXAON03cTLU5kZm8p1DUFcvNP4AoCk4CibgAizAanM qiYJJdY8V6mZKaPZL6xcWKpNWocfjXqGEq3CdUhRwdGLrjMxHeINewiMW7tK+X7A1bvfrnEee4G dyOBWwxAGlELiCcaCrL43LoukuDTqhUNV5n9/kCxl5QGFOP/D1R/Ol3dsYiu8QBYcXbJGxpuS7p hacoZ88iQI5vdIUtuz3xBJWP6nR1rlNRCLdpNPllbYHWY+17z4u05E9jwYUzjVe X-Google-Smtp-Source: AGHT+IEg42d9AWTXB7WZWBMpPRRDbMvg8D2vl05bSWpXAtUVhlyR9QdrN+tqj6Y/NmU8Bjs1ZZQi5w== X-Received: by 2002:a05:690c:6388:b0:6ef:6d61:c249 with SMTP id 00721157ae682-6f3f825a643mr51531917b3.39.1734760825358; Fri, 20 Dec 2024 22:00:25 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:24 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 12/20] alienware-wmi: Refactor thermal control methods Date: Sat, 21 Dec 2024 00:59:09 -0500 Message-ID: <20241221055917.10555-13-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor thermal control methods to use alienware_wmi_command() instead of alienware_wmax_command(). Drop alienware_wmax_command() as there is no more users left. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 69 ++++++++--------------- 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index b9da5fe657a9..0a0b72dc61ea 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -650,34 +650,6 @@ static enum led_brightness global_led_get(struct led_classdev *led_cdev) return priv->global_brightness; } -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 = in_size; - input.pointer = in_args; - if (out_data) { - output.length = ACPI_ALLOCATE_BUFFER; - output.pointer = NULL; - status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, - command, &input, &output); - if (ACPI_SUCCESS(status)) { - obj = (union acpi_object *)output.pointer; - if (obj && obj->type == ACPI_TYPE_INTEGER) - *out_data = (u32)obj->integer.value; - } - kfree(output.pointer); - } else { - status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, - command, &input, NULL); - } - return status; -} - /* * The HDMI mux sysfs node indicates the status of the HDMI input mux. * It can toggle between standard system GPU output and HDMI input. @@ -932,7 +904,8 @@ static bool is_wmax_thermal_code(u32 code) return false; } -static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) +static int wmax_thermal_information(struct wmi_device *wdev, u8 operation, + u8 arg, u32 *out_data) { struct wmax_u32_args in_args = { .operation = operation, @@ -942,9 +915,8 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) }; acpi_status status; - status = alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_THERMAL_INFORMATION, - out_data); + status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION, + &in_args, sizeof(in_args), out_data); if (ACPI_FAILURE(status)) return -EIO; @@ -955,7 +927,7 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) return 0; } -static int wmax_thermal_control(u8 profile) +static int wmax_thermal_control(struct wmi_device *wdev, u8 profile) { struct wmax_u32_args in_args = { .operation = WMAX_OPERATION_ACTIVATE_PROFILE, @@ -966,9 +938,8 @@ static int wmax_thermal_control(u8 profile) acpi_status status; u32 out_data; - status = alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_THERMAL_CONTROL, - &out_data); + status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL, + &in_args, sizeof(in_args), &out_data); if (ACPI_FAILURE(status)) return -EIO; @@ -979,7 +950,8 @@ static int wmax_thermal_control(u8 profile) return 0; } -static int wmax_game_shift_status(u8 operation, u32 *out_data) +static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation, + u32 *out_data) { struct wmax_u32_args in_args = { .operation = operation, @@ -989,9 +961,8 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data) }; acpi_status status; - status = alienware_wmax_command(&in_args, sizeof(in_args), - WMAX_METHOD_GAME_SHIFT_STATUS, - out_data); + status = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS, + &in_args, sizeof(in_args), out_data); if (ACPI_FAILURE(status)) return -EIO; @@ -1005,10 +976,13 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data) static int thermal_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { + struct awcc_priv *priv; u32 out_data; int ret; - ret = wmax_thermal_information(WMAX_OPERATION_CURRENT_PROFILE, + priv = container_of(pprof, struct awcc_priv, pp_handler); + + ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE, 0, &out_data); if (ret < 0) @@ -1039,7 +1013,8 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, u32 gmode_status; int ret; - ret = wmax_game_shift_status(WMAX_OPERATION_GET_GAME_SHIFT_STATUS, + ret = wmax_game_shift_status(priv->wdev, + WMAX_OPERATION_GET_GAME_SHIFT_STATUS, &gmode_status); if (ret < 0) @@ -1047,7 +1022,8 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) || (profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) { - ret = wmax_game_shift_status(WMAX_OPERATION_TOGGLE_GAME_SHIFT, + ret = wmax_game_shift_status(priv->wdev, + WMAX_OPERATION_TOGGLE_GAME_SHIFT, &gmode_status); if (ret < 0) @@ -1055,7 +1031,8 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, } } - return wmax_thermal_control(priv->supported_thermal_profiles[profile]); + return wmax_thermal_control(priv->wdev, + priv->supported_thermal_profiles[profile]); } static int create_thermal_profile(struct wmi_device *wdev) @@ -1070,7 +1047,7 @@ static int create_thermal_profile(struct wmi_device *wdev) priv = dev_get_drvdata(&wdev->dev); - ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION, + ret = wmax_thermal_information(wdev, WMAX_OPERATION_SYS_DESCRIPTION, 0, (u32 *) &sys_desc); if (ret < 0) return ret; @@ -1078,7 +1055,7 @@ static int create_thermal_profile(struct wmi_device *wdev) first_mode = sys_desc[0] + sys_desc[1]; for (u32 i = 0; i < sys_desc[3]; i++) { - ret = wmax_thermal_information(WMAX_OPERATION_LIST_IDS, + ret = wmax_thermal_information(wdev, WMAX_OPERATION_LIST_IDS, i + first_mode, &out_data); if (ret == -EIO) From patchwork Sat Dec 21 05:59:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917653 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.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 9DA6B1F37DC; Sat, 21 Dec 2024 06:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760830; cv=none; b=JSsoxl/132suctb5MvnGu+hF1zVJJNjzJQGtZnNPIzkCPMG5m8RJAx8L4juDMjCssRZsNbIfLOuKeCbz0ILxCEqOkFOlJgjbk4S947wpWiFN7tA46FIccuk1KQFiQqL9D40p3WZhtMxN2izFdAxBH2RCb0Oi+P66iQz4uH4pwdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760830; c=relaxed/simple; bh=DrIzIV1DMACll/OF0N6phO/F5/9wq841zETNjYE8dXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLKDCRtWERf7hfFA1WJM5jLIz8BulcAu9UZpXF1w0BwYJ/v6ZZSqumH4K8vV0wEkiCkVTJ3dMfz4mxJc896uVyNbI172AFSrwpzeV0WlNPQsjVaSIU3mAdtUzTy5O5BUOk+2kwpECDVPjJcJ/Tc2erZP8jOH4lwBNm00MU679EQ= 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=L440XUCx; arc=none smtp.client-ip=209.85.128.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="L440XUCx" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6efe5c1dea4so21652527b3.3; Fri, 20 Dec 2024 22:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760827; x=1735365627; 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=4d9+5jU/06hhg53vfZZYAG7VCLl+nPUljN1BJ6IP4O4=; b=L440XUCxxSEAOSEInu3cah6BSGyBLmtUeSWCzi0uj8bennmVJtdQw2rVCAPX+IFfyO fX79w7Ip6dsJ79L0kfYURCpJJVNu1nfgxiy6l9V+1npXt+GjAAGQHFfQIoAgf/QQvNsO ZTMOJ+oI+0CRL4t5om+8PiC9bO4nxDEbjAKAyEzaWzwcq3nc3RoSj38JfXoyUS3Z441t Znx/xEPvwn/X8rxDsdVZXB3bMNb0M5tlAepmE0h+7Wnl1EM+fli6z1KJpXIDOdPNLoCH IhnU2gvsJCbcb2PW8o7nPVkyFVcJhp/kHkxfMT4uO0cDVQh90rdsiq8c8RWLlZi++64k mazA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760827; x=1735365627; 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=4d9+5jU/06hhg53vfZZYAG7VCLl+nPUljN1BJ6IP4O4=; b=dJ+JsxZiUF4XaHnYKYK2fMuuOP0gPNA/+8jAQaNqaNX6dHR6plge6PiMr5rZVbpIlq wmTIVAgbWRSltwMp94ZszPnAttYAlQd/SvLm95275gqHcdVWKws5IWegCOuW0hjJSE8W hYovuJxgrGcTS0bq9PH8mXrnhiGxtkBH+Ms7UmEUzIyKEftcjNmJkC9kNfw0SQ+pIUPH IecSmPxH7Qzm4bK2/bfKPd8nc+g+9Sou7nfqwMehnt8h7O70k3B5D8+DIDE03+Q5jwgU ChRO0ALovrY1hzm/4l/GsnHssnApr+9urC24XAjMdk61xBfPbnNDDpx7hyBDCqfbD/it 8TOw== X-Forwarded-Encrypted: i=1; AJvYcCV7Qx8htxzNDLAn2blhNXEw/6UkmDldX8gS92ZFfEhe5zaGNrWg64Q9BnNDmoeyoxzJGvA+lf3XE+EZC1I=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6RGR2vu/KTlfQ9E76LU1S+7UvKxqv8plHKOQsCA3SJXoJBefF S/Mt3z+GojlrhmvIKPVhdClDW1h4Vvslb5Y34dsfFurcHnEdf6mDqKirSw== X-Gm-Gg: ASbGncucdO6H+dw+B9Yknt/r2TAwtFn2Wu6TP3h72nUxMcgxX8kSYrLnJ/NavsimDmW DfBb4n5u2qMV9VlQGHQxnWopiwH3CwZubzrGjtdfc2xfMjSIj/OrVn9iUHjPc4HcPuGzNpbyXGG 4HaLmi/YOGQTF/eLZUA5ouba0i+UywJmn8pQ8ydKARnJne/AbfzE/JgIu5ITYvlWhEb40K3zzVv 5iStakyz654Vvq0m+gu/1vGDnNtwqNTHD5iRTPWPvkpgR1XCRRifxDUj4uMebPS X-Google-Smtp-Source: AGHT+IGYHXK8OgoPW7YtLt97lf3dPrx340ZG88wSbdB6E9+yt+i/AF12i36R8oKqSLgxDED3zpwTAw== X-Received: by 2002:a05:690c:6213:b0:6ef:c4e3:1837 with SMTP id 00721157ae682-6f3f8143472mr41761987b3.20.1734760827215; Fri, 20 Dec 2024 22:00:27 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:26 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 13/20] alienware-wmi: Split DMI table Date: Sat, 21 Dec 2024 00:59:10 -0500 Message-ID: <20241221055917.10555-14-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split thermal features into a new DMI table to support upcoming file split. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 163 +++++++++------------- 1 file changed, 69 insertions(+), 94 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 0a0b72dc61ea..8ea08f5f8810 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -118,8 +118,6 @@ struct quirk_entry { u8 hdmi_mux; u8 amplifier; u8 deepslp; - bool thermal; - bool gmode; }; static struct quirk_entry *quirks; @@ -130,8 +128,6 @@ static struct quirk_entry quirk_inspiron5675 = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_unknown = { @@ -139,8 +135,6 @@ static struct quirk_entry quirk_unknown = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_x51_r1_r2 = { @@ -148,8 +142,6 @@ static struct quirk_entry quirk_x51_r1_r2 = { .hdmi_mux = 0, .amplifier = 0, .deepslp = 0, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_x51_r3 = { @@ -157,8 +149,6 @@ static struct quirk_entry quirk_x51_r3 = { .hdmi_mux = 0, .amplifier = 1, .deepslp = 0, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_asm100 = { @@ -166,8 +156,6 @@ static struct quirk_entry quirk_asm100 = { .hdmi_mux = 1, .amplifier = 0, .deepslp = 0, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_asm200 = { @@ -175,8 +163,6 @@ static struct quirk_entry quirk_asm200 = { .hdmi_mux = 1, .amplifier = 0, .deepslp = 1, - .thermal = false, - .gmode = false, }; static struct quirk_entry quirk_asm201 = { @@ -184,26 +170,6 @@ static struct quirk_entry quirk_asm201 = { .hdmi_mux = 1, .amplifier = 1, .deepslp = 1, - .thermal = false, - .gmode = false, -}; - -static struct quirk_entry quirk_g_series = { - .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = true, - .gmode = true, -}; - -static struct quirk_entry quirk_x_series = { - .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = true, - .gmode = false, }; static int __init dmi_matched(const struct dmi_system_id *dmi) @@ -242,133 +208,140 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { }, { .callback = dmi_matched, - .ident = "Alienware m17 R5", + .ident = "Alienware X51 R1", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51"), }, - .driver_data = &quirk_x_series, + .driver_data = &quirk_x51_r1_r2, }, { .callback = dmi_matched, - .ident = "Alienware m18 R2", + .ident = "Alienware X51 R2", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R2"), }, - .driver_data = &quirk_x_series, + .driver_data = &quirk_x51_r1_r2, }, { .callback = dmi_matched, - .ident = "Alienware x15 R1", + .ident = "Alienware X51 R3", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R3"), }, - .driver_data = &quirk_x_series, + .driver_data = &quirk_x51_r3, }, { .callback = dmi_matched, - .ident = "Alienware x17 R2", + .ident = "Dell Inc. Inspiron 5675", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5675"), + }, + .driver_data = &quirk_inspiron5675, + }, + {} +}; + +struct awcc_features { + bool gmode; +}; + +static struct awcc_features g_series_features = { + .gmode = true, +}; + +static struct awcc_features x_series_features = { + .gmode = false, +}; + +static const struct dmi_system_id awcc_dmi_table[] __initconst = { + { + .ident = "Alienware m17 R5", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), }, - .driver_data = &quirk_x_series, + .driver_data = &x_series_features, }, { - .callback = dmi_matched, - .ident = "Alienware X51 R1", + .ident = "Alienware m18 R2", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), }, - .driver_data = &quirk_x51_r1_r2, + .driver_data = &x_series_features, }, { - .callback = dmi_matched, - .ident = "Alienware X51 R2", + .ident = "Alienware x15 R1", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R2"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), }, - .driver_data = &quirk_x51_r1_r2, + .driver_data = &x_series_features, }, { - .callback = dmi_matched, - .ident = "Alienware X51 R3", + .ident = "Alienware x17 R2", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R3"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), }, - .driver_data = &quirk_x51_r3, + .driver_data = &x_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G15 5510", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"), }, - .driver_data = &quirk_g_series, + .driver_data = &g_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G15 5511", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"), }, - .driver_data = &quirk_g_series, + .driver_data = &g_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G15 5515", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), }, - .driver_data = &quirk_g_series, + .driver_data = &g_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G3 3500", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"), }, - .driver_data = &quirk_g_series, + .driver_data = &g_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G3 3590", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"), }, - .driver_data = &quirk_g_series, + .driver_data = &g_series_features, }, { - .callback = dmi_matched, .ident = "Dell Inc. G5 5500", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"), }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. Inspiron 5675", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5675"), - }, - .driver_data = &quirk_inspiron5675, + .driver_data = &g_series_features, }, - {} }; +struct awcc_features *awcc; + struct color_platform { u8 blue; u8 green; @@ -1009,7 +982,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, priv = container_of(pprof, struct awcc_priv, pp_handler); - if (quirks->gmode) { + if (awcc->gmode) { u32 gmode_status; int ret; @@ -1077,7 +1050,7 @@ static int create_thermal_profile(struct wmi_device *wdev) if (bitmap_empty(priv->pp_handler.choices, PLATFORM_PROFILE_LAST)) return -ENODEV; - if (quirks->gmode) { + if (awcc->gmode) { priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; @@ -1328,7 +1301,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) }; int ret = 0; - if (quirks->thermal) + if (awcc) ret = alienware_awcc_setup(wdev); else ret = alienware_alienfx_setup(&pdata); @@ -1338,7 +1311,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) static void wmax_wmi_remove(struct wmi_device *wdev) { - if (quirks->thermal) + if (awcc) alienware_awcc_exit(wdev); else alienware_alienfx_exit(wdev); @@ -1362,6 +1335,18 @@ static struct wmi_driver alienware_wmax_wmi_driver = { static int __init alienware_wmax_wmi_init(void) { + const struct dmi_system_id *id; + + id = dmi_first_match(awcc_dmi_table); + if (id) + awcc = id->driver_data; + + if (force_platform_profile) + awcc = &x_series_features; + + if (force_gmode) + awcc = &g_series_features; + return wmi_driver_register(&alienware_wmax_wmi_driver); } @@ -1378,16 +1363,6 @@ static int __init alienware_wmi_init(void) if (quirks == NULL) quirks = &quirk_unknown; - if (force_platform_profile) - quirks->thermal = true; - - if (force_gmode) { - if (quirks->thermal) - quirks->gmode = true; - else - pr_warn("force_gmode requires platform profile support\n"); - } - if (wmi_has_guid(WMAX_CONTROL_GUID)) { interface = WMAX; ret = alienware_wmax_wmi_init(); From patchwork Sat Dec 21 05:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917654 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.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 B97FA1339A4; Sat, 21 Dec 2024 06:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760833; cv=none; b=RfM2Uh+EpycRBvlCjQX56nIOOM64pdlJL9dkacKef1JQND6i8abJ3xQbYmx3XRAcdfVovCvFQxD1tQ4j4cdb+qebg+xHf7GAvQfUvxCE6k4jOvgEXk8/AWXCIAKC+zatgm+CpWCa/Jq0zyT+KzHQ7g+9kgm9kpAelUW3i3KdB8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760833; c=relaxed/simple; bh=zLPKxOlAI21p5WIQ9JT49JD0QdiKfToAL02o0UZK9nE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f/l7xv5Ordl7EtEJ6htGX15nvQawSl1dymOY+MjydYG26Vc/bB0DWaIP4MeYfvftN07SpcvCedDObIezLF2wiHNFWFhFcIC8KBBl0VFTzcBPwtiHrSTHROq40hHpIW0BvvK7JBZ+iLvyNdc0fPI4wr9z5qNfP2RYHHgd8YkxBYU= 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=fPlkLfTl; arc=none smtp.client-ip=209.85.128.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="fPlkLfTl" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6eff5f99de4so22884987b3.1; Fri, 20 Dec 2024 22:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760830; x=1735365630; 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=G/6Fu5kwIqTD/F9OQau8gJqzRjheJ0dK8d8lE4LCvKs=; b=fPlkLfTla0ppy4SKaZLxcOOceCKN0Hoyst4r8u0pBxP9k5dkjQzwlfPaiy18XapBYn VoKU6/jL257AIBXgv0taB/xkmTOsEQ3/ZlW7+xiWG0/3SItWbqDYLzCkFtZDrQRyc1MT AfcQTDA/RLTRH4dMlU2EJck+ryzq+RA94dQviKQrglcXfRh/MCzwWG+5h2A9mByCM6jp K9lCIOP9dpO6I3GpaCf6P+RyCq1ClicDPI8pUCZy5JliK5FMJVTdfAe7VL5CP1Niv70R QartpRDA3iFU1KxlOqkEb38NNY+N9W5Wm7BuwtgsirmDu62Ia9siCwJjc4qcDJK5lxMv Y3EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760830; x=1735365630; 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=G/6Fu5kwIqTD/F9OQau8gJqzRjheJ0dK8d8lE4LCvKs=; b=ORKiKC1fwDIP7t6kPqwA1xiHDR+ffzFj90dHX78vOsZ80l+h3eg3SY0HE5ZZl+RlTs h0Uy9fPXEd6Jj3hBxEqF5R65iYI2H8K9EIkYtQBIPSUl5lXDkLEUT0zONrSVjYVlEMg7 inL2q8VtHqBL+XOV2/EEynZ22+lyYF71tZcNKhCe1UAzZZrq3HCKBRwsHqd5sgn9I0uM 2WVbtoTh/LauuGDmldc1Fh/4hw9o5OHssQv6HxLgpo49BV33l7rFc+8UT1dPlEfDIMZV AAbyELNVcdwwdeE3kLlRHkSb+mff5UWMmKtDp3pevxDYxbZjfxGQrNPmKa0fFuYuxKwQ G3Jg== X-Forwarded-Encrypted: i=1; AJvYcCVr66wzs4aOyNBuOMHG8hqMc2xKVeHKy0lWt1HmJiyzTAvRzhTDNrjRrMFwojCfGeJqrjtWCnJwb6iM6oI=@vger.kernel.org X-Gm-Message-State: AOJu0YyOKwLFzF50dRe62ziN+jPnvnHmfMeTUS5SMFmpTETHFAX+2jjg Gdht0ELok3uP5fxCSbl72kAHljkajfDF9MJ7SSC4ghCXiigy9M5/5BHEyw== X-Gm-Gg: ASbGncs+3Y8fqPbOIsEAqi3PIIFGZrwqrzMc4+NRVtqmIEoAJHTPpKY+bVeQU1R7PuE NXmSGYttEP9XgpDFQM2xfoag+N4BnSz/IlhieTcgETfaEhdk6xgLMiNZ/6UoU2Mb2duWXIkYul4 X8Z986u6Rlq0eGie4q1zvlIyKYpv+wiFmy1qn/XC6icSRca56zEuOWWGtM44dRG40GtG/nQBIeg 1omt0u0H8f8otsBI8YbW3/VwIIvk2MHOyaeY6QaNBX0K35Zd8ex0QAFNgmIgOpO X-Google-Smtp-Source: AGHT+IECVUni8W1czdmslGXHGsZRuA9zcq/zi9/kmzZY2MEstg1jl8xgIhZ4e8Th/F/r8fwv5iF/Vw== X-Received: by 2002:a05:690c:dd2:b0:6ef:90a7:16ce with SMTP id 00721157ae682-6f3f823c74emr37157667b3.42.1734760830253; Fri, 20 Dec 2024 22:00:30 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:29 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 14/20] MAINTAINERS: Update ALIENWARE WMI DRIVER entry Date: Sat, 21 Dec 2024 00:59:11 -0500 Message-ID: <20241221055917.10555-15-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Dell has been inactive in its maintainership role of this driver since around 2021. Due to this, add myself as a maintainer. Signed-off-by: Kurt Borja --- MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 3809931b9240..596c6a46478c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -784,10 +784,12 @@ F: Documentation/admin-guide/perf/alibaba_pmu.rst F: drivers/perf/alibaba_uncore_drw_pmu.c ALIENWARE WMI DRIVER +M: Kurt Borja +L: platform-driver-x86@vger.kernel.org L: Dell.Client.Kernel@dell.com S: Maintained F: Documentation/wmi/devices/alienware-wmi.rst -F: drivers/platform/x86/dell/alienware-wmi.c +F: drivers/platform/x86/dell/alienware-wmi* ALLEGRO DVT VIDEO IP CORE DRIVER M: Michael Tretter From patchwork Sat Dec 21 05:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917655 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.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 3DDBA1FA179; Sat, 21 Dec 2024 06:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760835; cv=none; b=Ys3qjQ4tmdyHqhzxoXvVWWoH+KsUoN03R/3Shz1Q2jS9YEqfYH/Xq95S2leB7IFfQOucw/MqNV/MQ81A7zkR4BFX8oed6mjv4ak8eeZ7vB5PZt1x+RdelmTVrfk40d6NjMM7qFwLyh3LDYuW7ocqgfAikYgLGizEKFkJua6KfRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760835; c=relaxed/simple; bh=bA9TBWS2aTHuSdMlpTKbWZA9iDppBuPiCTaK8L7s0T0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rT22kLP8gPANNLMnfLIkLCTZccqcSTzyCM3LE7VfGb0eLYt61WS5FPtV/d3v/nzZeadlz6Nzz6mAoDUU7f5k6pxfiDN3PKUIM6ddwtQz1wdHieo9BtTxv6LGL3Lv0Ga6rMfKQntI2glLJSR+hc6FneVYLu/5JJDzzfgiQmhmbCs= 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=VWNO3CJv; arc=none smtp.client-ip=209.85.128.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="VWNO3CJv" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6f0054cb797so21091317b3.0; Fri, 20 Dec 2024 22:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760833; x=1735365633; 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=ljg3BoRyYpx5o9XmoLjmEYfCq25szUxIdIdXguDttik=; b=VWNO3CJvJCs9woFtN/xvCegTct401GYT1W9Ix2ktHl1OTHVgvpfsislR37QhVgf4fV tCDi2PlNmdy+LDBzhNRzxfjfTpNo99ESVsLNiXnTG3DRPn8RobgF5gfdK9cD38lOXuWU HQqBrhq2TbdG4Sg/J6i1qsMHHysLI1Xhd++Ypeil+gf7WmsjjJyzuDticsLoSy3inaMm 6nxDhuAZX7L5YmrfB7yaEYAKIDl1KC+jNJNxy3Sn/S/nPJHAXGdh+DErXQsnwXhuF0D/ b7oFlj0/TizokYQpwQWxx7QQsnGSpXcBRmX3IZehl74k/iRTXiuEe92iUrNrRpSwEJAW iJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760833; x=1735365633; 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=ljg3BoRyYpx5o9XmoLjmEYfCq25szUxIdIdXguDttik=; b=YYczud31b6EcdUfPj0v0LQPys8j0uViw1TG1FLxVP11GW/DfgJzTEmLZqJIrsxy1/S 4r87JEHzU0bH4eOGG8O1UVm02vBlldXzRpDqoRy5UUzoUiPOsUegH/d99pozDKYbN1+V MwNdzV3lLMhH8dqTKq7XNjKiBPLcPe/FQjQjFQSWY7ErSCRaxtZHRjl29Wjj7l88UMtY o7waIsnSRqJAVb9cZjJ6o0SHlNiMDsoEr7VjpckbqkKC6pZ2yiEY6HBVp5WqgKTN8DpO B8hsOiZWDHRVUdcE2omIXzp1qiqQ8g8YAKHKDN/3l+5J9HbM/r2VioxOD0wWYJJnXbH5 6Q0Q== X-Forwarded-Encrypted: i=1; AJvYcCWwEEY94e1CJPe2VMMm0flDBEDz13JESuNDICW/Ax0rYQGj9Opvo4AgH2wlkNYSX1oN8bvAJMn3+lIwaR8=@vger.kernel.org X-Gm-Message-State: AOJu0YwEMt693XlLroVtrsn7fY/H2FFRxNUrhQjDt5GT+z8RpE5Y8VoQ 8uFVg67MQl0ESvxCyZy9+X9v68fmhri2KJsR2D1IryZGyK+JeZPPprEuGg== X-Gm-Gg: ASbGncvg96XRNdTxjDJSJQf1INgyJdaGYJ8MWWh+HfnplvRyevLO3qH963DJF0tcnWk ATT6uui3lezRMdHK1sqttIghFR4f7ByRj0orpkGJ43uJPXk6gb6eZGxC0jxfmUJjRB8ao/wzg5V oTefZhm7aU5TfcYqNNjzgvXBIc2IqZHX0xMBwZKS6TS0UyPh1OzF5NgsqAN9VJjNYMi4Sa8AhF8 Ni12JZuzIpKIy2t8wctzwZ3TBjOghYcJuIgvWd14jbb9DlW1bg7q6tV9mMbN/Vz X-Google-Smtp-Source: AGHT+IFufvSROmzOLw2iVLnPUip9ePZzpqz4NB69kO8++YGylw4f7U+0KxW/KALPM5ReH7UrDSzvGg== X-Received: by 2002:a05:690c:4988:b0:6f0:21d6:44a4 with SMTP id 00721157ae682-6f3f81229b2mr43144187b3.10.1734760833126; Fri, 20 Dec 2024 22:00:33 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:32 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 15/20] platform/x86: Rename alienware-wmi.c Date: Sat, 21 Dec 2024 00:59:12 -0500 Message-ID: <20241221055917.10555-16-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename alienware-wmi to support upcoming split. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Makefile | 1 + .../platform/x86/dell/{alienware-wmi.c => alienware-wmi-base.c} | 0 2 files changed, 1 insertion(+) rename drivers/platform/x86/dell/{alienware-wmi.c => alienware-wmi-base.c} (100%) diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index bb3cbd470a46..f8aec8502c2f 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -5,6 +5,7 @@ # obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o +alienware-wmi-objs := alienware-wmi-base.o obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi-base.c similarity index 100% rename from drivers/platform/x86/dell/alienware-wmi.c rename to drivers/platform/x86/dell/alienware-wmi-base.c From patchwork Sat Dec 21 05:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917656 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.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 D44341FBC98; Sat, 21 Dec 2024 06:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760839; cv=none; b=c5oTw7E0aRbc0zFzyuWHyra+Thi7z49fN6VN0v7jNCB/wjqbavnrU97Psv+PNW2y3vxXmzIbtHgAVWYqiV26ypIg57lSAeJX7sbu7sZLlG1c1hMrasHGgQJ9l74BQzG0qTcnrZjqB7p9zHlB2mfNa78KOzjHACiOpI85L+QJmSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760839; c=relaxed/simple; bh=5CnBe9kWF5Xd3kzhKNbLWhDPJqjruzdfhp+fY5+JcRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=htrCpw2K0CEVPFProN3Iy++hqM4g34ZzFYGsqhueQcIhFP6hu3/h9YRSYdHtZxfryfMRHYpjFnXdBVmPrTsBX5ZRGDM3Y+yAee0zPOsRjxuhoTbp7QSLbwL3yRyXyOQHK1ClYDYGYYRrgmSNkWcG14zFFdVGkwzpqmZprNFu7AE= 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=b58WHhll; arc=none smtp.client-ip=209.85.128.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="b58WHhll" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6efed201f1dso18687507b3.0; Fri, 20 Dec 2024 22:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760836; x=1735365636; 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=sJ2DwnO5k7IhHUoiagUS22J7YGxdemfg2FtjCjbXNzw=; b=b58WHhllSkDEKiLnVNAEMtoOPYf2mfT1YT6dWM2hE9Ei5hw79p2ke763YuVCWdA0Jn 3aMaPx8bZloIv/FkefhGaI1Iz3CKRPZ+8ssD1J3zcwWpStYQQFy9f+IINQ9/Q2uEMHlZ XSHSV1lCZCyMW4/snnPs2onIGrRJE5R7t/eIbKXBG+NmKCd1ln/QmKfES55m3BJbz3E+ DmkViZ0lXhkfFuiAuHURDiwSE4lVVv9sBHyKkZ2RtWNEmMBzwpqyS3dYloyJfqujfI8U Sx0EdxVpeC1mL8Xpah5MZqG8MuSwy/3uw9QVxmHIO47uGXYT+ZuLSCMYjv+LwvJ8G46B GrIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760836; x=1735365636; 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=sJ2DwnO5k7IhHUoiagUS22J7YGxdemfg2FtjCjbXNzw=; b=xP+6dZ62ZjlymczfXXH/teyT88YfWAAQCWpp/zphrQMVdm0seiOqkWc3cPI0GfA3JD WBWWNp8vzJC00lYFyWNC2wLt4gBK1TDzbdXGJj3MvS6Wv8bkHX0pjW+bhFfFgmmsjtXR mwz7WXP7aZdeXBaScUsNtOSmbB5s4sHm7RFr10YJ693n2sFsv5jcol970Qi3l2zZeuwC Lo+G/W4WFON4qgO7jeZWKA94FFT3X8P0cmpP8bmffzZNU7CrIjamrgIedM/STZ/anbYz IWu7460/dkiJ5clXZziY/ngkLs7POipa0YbLoj4eN4w6L6tWGUhwIcCePgujD1NrNdbD EdMA== X-Forwarded-Encrypted: i=1; AJvYcCW5cxBAHsspOJfEmFV72620gS5PpR2HQvJb88ZWUllOHU0jSJmUlHq3S1W+QZZKqifjTmbtqFauVEl7aS8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw87m68ku2PMWsCMfWmFb7F18+MaSLbA0Sn8TRbeCLDUAL43F97 PGemT/q32Lc1hfG0AgEas+3WRXzWr56g9ABEyHYQQO1ZM749+tS7ISX95g== X-Gm-Gg: ASbGncsG2sZNo9y4P//On8d+gR0zJiOS5rR4PmYsTM83vfkJxlp7ozcU7LwnDsqKXRR lfXqeHrIflfey0iTrgezPQotoLTZp546y8fqBCW3XVeuA5kirNxnhqu5VJaNysbJv+UdFofNGBN 9Pv7LCHrBNJ1dkM+t18CJ/iVNB37EU9VwsBn0h2E3TxJ63d5ZzELzYr/w5Wx2PO4jZP2ODwQJyu GJRqQnCN1998PxGxNN5h+0OzBVXlx25Nn/E9yXqA4ieNx+mLtvfIXu2RzWoJ66I X-Google-Smtp-Source: AGHT+IHau542g2q5qfb1affosnkKSWj4STsRwvndbP3MxFhnQJXn7J6jvIW/ULh1VgN2pIp5KqRDiA== X-Received: by 2002:a05:690c:88c:b0:6e3:37a7:8a98 with SMTP id 00721157ae682-6f3f8114d78mr52760527b3.14.1734760836349; Fri, 20 Dec 2024 22:00:36 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:35 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 16/20] platform/x86: Add alienware-wmi.h Date: Sat, 21 Dec 2024 00:59:13 -0500 Message-ID: <20241221055917.10555-17-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a header file for alienware-wmi with shared resources to support the upcoming file split. Signed-off-by: Kurt Borja --- .../platform/x86/dell/alienware-wmi-base.c | 93 ++-------------- drivers/platform/x86/dell/alienware-wmi.h | 103 ++++++++++++++++++ 2 files changed, 112 insertions(+), 84 deletions(-) create mode 100644 drivers/platform/x86/dell/alienware-wmi.h diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c index 8ea08f5f8810..e8d470bbb608 100644 --- a/drivers/platform/x86/dell/alienware-wmi-base.c +++ b/drivers/platform/x86/dell/alienware-wmi-base.c @@ -16,26 +16,7 @@ #include #include #include - -#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492" -#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492" -#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492" - -#define WMAX_METHOD_HDMI_SOURCE 0x1 -#define WMAX_METHOD_HDMI_STATUS 0x2 -#define WMAX_METHOD_BRIGHTNESS 0x3 -#define WMAX_METHOD_ZONE_CONTROL 0x4 -#define WMAX_METHOD_HDMI_CABLE 0x5 -#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 +#include "alienware-wmi.h" MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); @@ -54,18 +35,6 @@ enum INTERFACE_FLAGS { WMAX, }; -enum LEGACY_CONTROL_STATES { - LEGACY_RUNNING = 1, - LEGACY_BOOTING = 0, - LEGACY_SUSPEND = 3, -}; - -enum WMAX_CONTROL_STATES { - WMAX_RUNNING = 0xFF, - WMAX_BOOTING = 0, - WMAX_SUSPEND = 3, -}; - enum WMAX_THERMAL_INFORMATION_OPERATIONS { WMAX_OPERATION_SYS_DESCRIPTION = 0x02, WMAX_OPERATION_LIST_IDS = 0x03, @@ -122,7 +91,6 @@ struct quirk_entry { static struct quirk_entry *quirks; - static struct quirk_entry quirk_inspiron5675 = { .num_zones = 2, .hdmi_mux = 0, @@ -342,33 +310,10 @@ static const struct dmi_system_id awcc_dmi_table[] __initconst = { struct awcc_features *awcc; -struct color_platform { - u8 blue; - u8 green; - u8 red; -} __packed; - -struct wmax_brightness_args { - u32 led_mask; - u32 percentage; -}; - struct wmax_basic_args { u8 arg; }; -struct legacy_led_args { - struct color_platform colors; - u8 brightness; - u8 state; -} __packed; - -struct wmax_led_args { - u32 led_mask; - struct color_platform colors; - u8 state; -} __packed; - struct wmax_u32_args { u8 operation; u8 arg1; @@ -382,30 +327,10 @@ struct awcc_priv { enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; }; -struct alienfx_priv { - struct platform_device *pdev; - struct led_classdev global_led; - struct color_platform colors[4]; - u8 global_brightness; - u8 lighting_control_state; -}; - -struct alienfx_ops { - int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev, - u8 location); - int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev, - u8 brightness); -}; - -struct alienfx_platdata { - struct wmi_device *wdev; - struct alienfx_ops ops; -}; - static u8 interface; -static acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, - void *in_args, size_t in_size, u32 *out_data) +acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, + void *in_args, size_t in_size, u32 *out_data) { struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_buffer in = {in_size, in_args}; @@ -1139,7 +1064,7 @@ static struct platform_driver platform_driver = { .probe = alienfx_probe, }; -static int alienware_alienfx_setup(struct alienfx_platdata *pdata) +int alienware_alienfx_setup(struct alienfx_platdata *pdata) { struct platform_device *pdev; int ret; @@ -1162,7 +1087,7 @@ static int alienware_alienfx_setup(struct alienfx_platdata *pdata) return 0; } -static void alienware_alienfx_exit(struct wmi_device *wdev) +void alienware_alienfx_exit(struct wmi_device *wdev) { struct platform_device *pdev; @@ -1242,12 +1167,12 @@ static struct wmi_driver alienware_legacy_wmi_driver = { .remove = legacy_wmi_remove, }; -static int __init alienware_legacy_wmi_init(void) +int __init alienware_legacy_wmi_init(void) { return wmi_driver_register(&alienware_legacy_wmi_driver); } -static void __exit alienware_legacy_wmi_exit(void) +void __exit alienware_legacy_wmi_exit(void) { wmi_driver_unregister(&alienware_legacy_wmi_driver); } @@ -1333,7 +1258,7 @@ static struct wmi_driver alienware_wmax_wmi_driver = { .remove = wmax_wmi_remove, }; -static int __init alienware_wmax_wmi_init(void) +int __init alienware_wmax_wmi_init(void) { const struct dmi_system_id *id; @@ -1350,7 +1275,7 @@ static int __init alienware_wmax_wmi_init(void) return wmi_driver_register(&alienware_wmax_wmi_driver); } -static void __exit alienware_wmax_wmi_exit(void) +void __exit alienware_wmax_wmi_exit(void) { wmi_driver_unregister(&alienware_wmax_wmi_driver); } diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h new file mode 100644 index 000000000000..78ac10122155 --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi.h @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Alienware WMI special features driver + * + * Copyright (C) 2014 Dell Inc + * Copyright (C) 2024 Kurt Borja + */ + +#ifndef _ALIENWARE_WMI_H_ +#define _ALIENWARE_WMI_H_ + +#include +#include +#include + +#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492" +#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492" +#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492" + +#define WMAX_METHOD_HDMI_SOURCE 0x1 +#define WMAX_METHOD_HDMI_STATUS 0x2 +#define WMAX_METHOD_BRIGHTNESS 0x3 +#define WMAX_METHOD_ZONE_CONTROL 0x4 +#define WMAX_METHOD_HDMI_CABLE 0x5 +#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 + +enum LEGACY_CONTROL_STATES { + LEGACY_RUNNING = 1, + LEGACY_BOOTING = 0, + LEGACY_SUSPEND = 3, +}; + +enum WMAX_CONTROL_STATES { + WMAX_RUNNING = 0xFF, + WMAX_BOOTING = 0, + WMAX_SUSPEND = 3, +}; + +struct color_platform { + u8 blue; + u8 green; + u8 red; +} __packed; + +struct wmax_brightness_args { + u32 led_mask; + u32 percentage; +}; + +struct legacy_led_args { + struct color_platform colors; + u8 brightness; + u8 state; +} __packed; + +struct wmax_led_args { + u32 led_mask; + struct color_platform colors; + u8 state; +} __packed; + +struct alienfx_priv { + struct platform_device *pdev; + struct led_classdev global_led; + struct color_platform colors[4]; + u8 global_brightness; + u8 lighting_control_state; +}; + +struct alienfx_ops { + int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev, + u8 location); + int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev, + u8 brightness); +}; + +struct alienfx_platdata { + struct wmi_device *wdev; + struct alienfx_ops ops; +}; + +acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, + void *in_args, size_t in_size, u32 *out_data); + +int alienware_alienfx_setup(struct alienfx_platdata *pdata); +void alienware_alienfx_exit(struct wmi_device *wdev); + +int __init alienware_legacy_wmi_init(void); +void __exit alienware_legacy_wmi_exit(void); + +int __init alienware_wmax_wmi_init(void); +void __exit alienware_wmax_wmi_exit(void); + +#endif From patchwork Sat Dec 21 05:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917657 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 AB8D01FC0F4; Sat, 21 Dec 2024 06:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760844; cv=none; b=gx0AEkon+SDwXt7rw6ikRXV7GozLp5U+QVh6NsAnbI8DPxpS7YFKyn1yw5XYb8kvOzcH7GXjfwwQYwQJEHnGGbSOkIjvx2/EhVCPgUtE6vcazsgomr9wYbNXf4QiRSZqyLXSKaex0eHI5r95OMPUbomiP9JJOlDqXuvcWQbXySg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760844; c=relaxed/simple; bh=U0ZociPc7NkHcP7tQQwcyLerTBGDWblBB7NZMGevoP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ku45S8i/42axjnKnrzUeJh1PSRx7zHrqxwUelrGRZOtVJqer3Ol/4XvsQ6wstusHBgxAo07nbDzWTNuRCzpDTBXN7Y3X2JU/d2HCAr1PE7069aMo8UBQ2R1Bzz2bay2mZSlCh2m1gumVHFqWyBrrIKX0Vdqq+24w5duUd6pgh7U= 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=mcKaqyQP; arc=none smtp.client-ip=209.85.128.178 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="mcKaqyQP" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6f150ddc86dso21554217b3.1; Fri, 20 Dec 2024 22:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760840; x=1735365640; 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=mPNkvL/R8QYxLzw1K623aBRkK8IaDv1TB39CxPOYPAY=; b=mcKaqyQPur7DjPhxD6XvUD+p3FzZgJw3Ke93VY78Bp7rmoh1bX2wT8C6+Q27SHpvi/ 0E23g1pmtc7WZrh4bzWUY11O/dGd8JzsF0reKaNLbW1BLX3+Yo1vCqwZXR4aYfFC22n5 RZMQmDvqaYDmKIZy7KHfeeS/aLY8DFTrN2OxyMP5uoxN5EvXrd14nbND8zgc/m1/YbE0 ElhQLVhvzrQ33M/pPKwDeCaaOvuEPGVyNajyARyf2Ih45sMcGSNV3VV999pqUyDPCtO2 hZ0e9pZbY5VMuxkPD/BQDIpZv78bZqiML/CCAIkWBevKOOR+C0b/weoXgmzleDCqzcFE 1U4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760840; x=1735365640; 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=mPNkvL/R8QYxLzw1K623aBRkK8IaDv1TB39CxPOYPAY=; b=oshZJv+7CRFAwy3S+VoCWM8Zfef7pfL8TrlKIVTfylsFryqtdLdWqojsasvn7VbXA0 gIaP2PD/wowr7vveDokvps6lsUxxmmENvTS7bTeleCkjqHLFEywfWmV5VBYvCaCtjE4i TLPqxuPqBoxAURFLHxJb1K4kspgIdEtZz+FM23qGXI4huX3xG2EZUsNgigy34SlDcOF7 VnouhiBVZ6Wt8D0eC5/ezRNie6ZrxWtRWobVEpuPPeSg7CDV/AljLwv8GOWNAmfuGzIV M7CyBdjj23ozUUg5+0NomOtY8F0t/h1QtZMNSqe6+Pj3VmYAZWla2LFkOrEMsnkvW/Dz IrwA== X-Forwarded-Encrypted: i=1; AJvYcCU8jqSFOYxnLw0ad7OJT57Hk8j7RIZOftRQ27ouovm43jieCqPExodAmFVnTU7qhJo4sy/nul5lz3albvk=@vger.kernel.org X-Gm-Message-State: AOJu0YxGw7irvX58F4ggPLDZC5bOdIRlwulPuZU4oWg5mk0KdhJVa5Bm nmRNf8zFNX9OuBTlCpg2D7K/yxFDHBAPSNFfY8jycPlCzKgN4jIm5lvm3g== X-Gm-Gg: ASbGncuGnx1bMm5K3dxPnKI6vk4wHKiMn0xAjpHBk2LLnBX8R4DBhNgWpKmf/fBuSMV +z/1EPtqVMM0MfRtf07ovSqOM6OuG8lswGH7kDV6Xc2pITobCLEXf+LQ+oy5NoN1Doj6PwBOD8k QFzoM/Sjd3FJgp5PBMnzVKBpwEStwDlXBZZDOYnAEbOUzGCg8cfoqvVVXub6EUFAMxlafCYQA3P 5RgH0djSPQQAYknYa6Ld7oQER9utq3lnwH5K560eSYbtsjhvTBAbPZTXKIYkF4K X-Google-Smtp-Source: AGHT+IHXEIaPUxYAVad6YwV2XEYloCkQVqf9vkn7O3BVZSO2hL1jm+dBO3GC6AB8lACuufIRrUOpxg== X-Received: by 2002:a05:690c:6911:b0:6ef:53bb:a83a with SMTP id 00721157ae682-6f3f814b16amr54164087b3.24.1734760839953; Fri, 20 Dec 2024 22:00:39 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:39 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 17/20] platform-x86: Split the alienware-wmi driver Date: Sat, 21 Dec 2024 00:59:14 -0500 Message-ID: <20241221055917.10555-18-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split alienware-wmi WMI drivers into different files. This is done seamlessly by copying and pasting. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Makefile | 2 + .../platform/x86/dell/alienware-wmi-base.c | 596 ------------------ .../platform/x86/dell/alienware-wmi-legacy.c | 89 +++ .../platform/x86/dell/alienware-wmi-wmax.c | 526 ++++++++++++++++ 4 files changed, 617 insertions(+), 596 deletions(-) create mode 100644 drivers/platform/x86/dell/alienware-wmi-legacy.c create mode 100644 drivers/platform/x86/dell/alienware-wmi-wmax.c diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index f8aec8502c2f..03ba459f3d31 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -6,6 +6,8 @@ obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o alienware-wmi-objs := alienware-wmi-base.o +alienware-wmi-y += alienware-wmi-legacy.o +alienware-wmi-y += alienware-wmi-wmax.o obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c index e8d470bbb608..450ba0a48004 100644 --- a/drivers/platform/x86/dell/alienware-wmi-base.c +++ b/drivers/platform/x86/dell/alienware-wmi-base.c @@ -8,80 +8,21 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include -#include #include #include -#include #include #include -#include #include "alienware-wmi.h" MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); MODULE_LICENSE("GPL"); -static bool force_platform_profile; -module_param_unsafe(force_platform_profile, bool, 0); -MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal profiles 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 selected"); - enum INTERFACE_FLAGS { LEGACY, WMAX, }; -enum WMAX_THERMAL_INFORMATION_OPERATIONS { - WMAX_OPERATION_SYS_DESCRIPTION = 0x02, - WMAX_OPERATION_LIST_IDS = 0x03, - WMAX_OPERATION_CURRENT_PROFILE = 0x0B, -}; - -enum WMAX_THERMAL_CONTROL_OPERATIONS { - WMAX_OPERATION_ACTIVATE_PROFILE = 0x01, -}; - -enum WMAX_GAME_SHIFT_STATUS_OPERATIONS { - WMAX_OPERATION_TOGGLE_GAME_SHIFT = 0x01, - WMAX_OPERATION_GET_GAME_SHIFT_STATUS = 0x02, -}; - -enum WMAX_THERMAL_TABLES { - WMAX_THERMAL_TABLE_BASIC = 0x90, - WMAX_THERMAL_TABLE_USTT = 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[THERMAL_MODE_LAST] = { - [THERMAL_MODE_USTT_BALANCED] = PLATFORM_PROFILE_BALANCED, - [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE, - [THERMAL_MODE_USTT_COOL] = PLATFORM_PROFILE_COOL, - [THERMAL_MODE_USTT_QUIET] = PLATFORM_PROFILE_QUIET, - [THERMAL_MODE_USTT_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE, - [THERMAL_MODE_USTT_LOW_POWER] = PLATFORM_PROFILE_LOW_POWER, - [THERMAL_MODE_BASIC_QUIET] = PLATFORM_PROFILE_QUIET, - [THERMAL_MODE_BASIC_BALANCED] = PLATFORM_PROFILE_BALANCED, - [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE, - [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE, -}; - struct quirk_entry { u8 num_zones; u8 hdmi_mux; @@ -213,120 +154,10 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { {} }; -struct awcc_features { - bool gmode; -}; - -static struct awcc_features g_series_features = { - .gmode = true, -}; - -static struct awcc_features x_series_features = { - .gmode = false, -}; - -static const struct dmi_system_id awcc_dmi_table[] __initconst = { - { - .ident = "Alienware m17 R5", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), - }, - .driver_data = &x_series_features, - }, - { - .ident = "Alienware m18 R2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), - }, - .driver_data = &x_series_features, - }, - { - .ident = "Alienware x15 R1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), - }, - .driver_data = &x_series_features, - }, - { - .ident = "Alienware x17 R2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), - }, - .driver_data = &x_series_features, - }, - { - .ident = "Dell Inc. G15 5510", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"), - }, - .driver_data = &g_series_features, - }, - { - .ident = "Dell Inc. G15 5511", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"), - }, - .driver_data = &g_series_features, - }, - { - .ident = "Dell Inc. G15 5515", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), - }, - .driver_data = &g_series_features, - }, - { - .ident = "Dell Inc. G3 3500", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"), - }, - .driver_data = &g_series_features, - }, - { - .ident = "Dell Inc. G3 3590", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"), - }, - .driver_data = &g_series_features, - }, - { - .ident = "Dell Inc. G5 5500", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"), - }, - .driver_data = &g_series_features, - }, -}; - -struct awcc_features *awcc; - struct wmax_basic_args { u8 arg; }; -struct wmax_u32_args { - u8 operation; - u8 arg1; - u8 arg2; - u8 arg3; -}; - -struct awcc_priv { - struct wmi_device *wdev; - struct platform_profile_handler pp_handler; - enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; -}; - static u8 interface; acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, @@ -775,250 +606,6 @@ static const struct attribute_group deepsleep_attribute_group = { .attrs = deepsleep_attrs, }; -/* - * 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) >= THERMAL_MODE_LAST) - return false; - - if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_BASIC && - (code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_BASIC_QUIET) - return true; - - if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_USTT && - (code & WMAX_THERMAL_MODE_MASK) <= THERMAL_MODE_USTT_LOW_POWER) - return true; - - return false; -} - -static int wmax_thermal_information(struct wmi_device *wdev, u8 operation, - u8 arg, u32 *out_data) -{ - struct wmax_u32_args in_args = { - .operation = operation, - .arg1 = arg, - .arg2 = 0, - .arg3 = 0, - }; - acpi_status status; - - status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION, - &in_args, sizeof(in_args), out_data); - - if (ACPI_FAILURE(status)) - return -EIO; - - if (*out_data == WMAX_FAILURE_CODE) - return -EBADRQC; - - return 0; -} - -static int wmax_thermal_control(struct wmi_device *wdev, u8 profile) -{ - struct wmax_u32_args in_args = { - .operation = WMAX_OPERATION_ACTIVATE_PROFILE, - .arg1 = profile, - .arg2 = 0, - .arg3 = 0, - }; - acpi_status status; - u32 out_data; - - status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL, - &in_args, sizeof(in_args), &out_data); - - if (ACPI_FAILURE(status)) - return -EIO; - - if (out_data == WMAX_FAILURE_CODE) - return -EBADRQC; - - return 0; -} - -static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation, - u32 *out_data) -{ - struct wmax_u32_args in_args = { - .operation = operation, - .arg1 = 0, - .arg2 = 0, - .arg3 = 0, - }; - acpi_status status; - - status = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS, - &in_args, sizeof(in_args), out_data); - - if (ACPI_FAILURE(status)) - return -EIO; - - if (*out_data == WMAX_FAILURE_CODE) - return -EOPNOTSUPP; - - return 0; -} - -static int thermal_profile_get(struct platform_profile_handler *pprof, - enum platform_profile_option *profile) -{ - struct awcc_priv *priv; - u32 out_data; - int ret; - - priv = container_of(pprof, struct awcc_priv, pp_handler); - - ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE, - 0, &out_data); - - if (ret < 0) - return ret; - - if (out_data == WMAX_THERMAL_MODE_GMODE) { - *profile = PLATFORM_PROFILE_PERFORMANCE; - return 0; - } - - if (!is_wmax_thermal_code(out_data)) - return -ENODATA; - - out_data &= WMAX_THERMAL_MODE_MASK; - *profile = wmax_mode_to_platform_profile[out_data]; - - return 0; -} - -static int thermal_profile_set(struct platform_profile_handler *pprof, - enum platform_profile_option profile) -{ - struct awcc_priv *priv; - - priv = container_of(pprof, struct awcc_priv, pp_handler); - - if (awcc->gmode) { - u32 gmode_status; - int ret; - - ret = wmax_game_shift_status(priv->wdev, - WMAX_OPERATION_GET_GAME_SHIFT_STATUS, - &gmode_status); - - if (ret < 0) - return ret; - - if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) || - (profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) { - ret = wmax_game_shift_status(priv->wdev, - WMAX_OPERATION_TOGGLE_GAME_SHIFT, - &gmode_status); - - if (ret < 0) - return ret; - } - } - - return wmax_thermal_control(priv->wdev, - priv->supported_thermal_profiles[profile]); -} - -static int create_thermal_profile(struct wmi_device *wdev) -{ - enum platform_profile_option profile; - enum wmax_thermal_mode mode; - struct awcc_priv *priv; - u8 sys_desc[4]; - u32 first_mode; - u32 out_data; - int ret; - - priv = dev_get_drvdata(&wdev->dev); - - ret = wmax_thermal_information(wdev, WMAX_OPERATION_SYS_DESCRIPTION, - 0, (u32 *) &sys_desc); - if (ret < 0) - return ret; - - first_mode = sys_desc[0] + sys_desc[1]; - - for (u32 i = 0; i < sys_desc[3]; i++) { - ret = wmax_thermal_information(wdev, WMAX_OPERATION_LIST_IDS, - i + first_mode, &out_data); - - if (ret == -EIO) - return ret; - - if (ret == -EBADRQC) - break; - - if (!is_wmax_thermal_code(out_data)) - continue; - - mode = out_data & WMAX_THERMAL_MODE_MASK; - profile = wmax_mode_to_platform_profile[mode]; - priv->supported_thermal_profiles[profile] = out_data; - - set_bit(profile, priv->pp_handler.choices); - } - - if (bitmap_empty(priv->pp_handler.choices, PLATFORM_PROFILE_LAST)) - return -ENODEV; - - if (awcc->gmode) { - priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = - WMAX_THERMAL_MODE_GMODE; - - set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->pp_handler.choices); - } - - priv->pp_handler.profile_get = thermal_profile_get; - priv->pp_handler.profile_set = thermal_profile_set; - priv->pp_handler.name = "alienware-wmi"; - priv->pp_handler.dev = &wdev->dev; - - return platform_profile_register(&priv->pp_handler); -} - -static int alienware_awcc_setup(struct wmi_device *wdev) -{ - struct awcc_priv *priv; - int ret; - - priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - dev_set_drvdata(&wdev->dev, priv); - - priv->wdev = wdev; - - ret = create_thermal_profile(wdev); - if (ret < 0) - return ret; - - return 0; -} - -static void alienware_awcc_exit(struct wmi_device *wdev) -{ - struct awcc_priv *priv; - - priv = dev_get_drvdata(&wdev->dev); - - platform_profile_remove(&priv->pp_handler); -} - /* * Platform Driver */ @@ -1097,189 +684,6 @@ void alienware_alienfx_exit(struct wmi_device *wdev) platform_driver_unregister(&platform_driver); } -/* - * Legacy WMI driver - */ -static int legacy_wmi_update_led(struct alienfx_priv *priv, - struct wmi_device *wdev, u8 location) -{ - struct legacy_led_args legacy_args; - struct acpi_buffer input; - acpi_status status; - - legacy_args.colors = priv->colors[location]; - legacy_args.brightness = priv->global_brightness; - legacy_args.state = priv->lighting_control_state; - - input.length = sizeof(legacy_args); - input.pointer = &legacy_args; - - if (legacy_args.state == LEGACY_RUNNING) - status = alienware_wmi_command(wdev, location + 1, &legacy_args, - sizeof(legacy_args), NULL); - else - status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0, - location + 1, &input, NULL); - - if (ACPI_FAILURE(status)) - return -EIO; - - return 0; -} - -static int legacy_wmi_update_brightness(struct alienfx_priv *priv, - struct wmi_device *wdev, u8 brightness) -{ - return legacy_wmi_update_led(priv, wdev, 0); -} - -static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) -{ - struct alienfx_platdata pdata = { - .wdev = wdev, - .ops = { - .upd_led = legacy_wmi_update_led, - .upd_brightness = legacy_wmi_update_brightness, - }, - }; - - return alienware_alienfx_setup(&pdata); -} - -static void legacy_wmi_remove(struct wmi_device *wdev) -{ - alienware_alienfx_exit(wdev); -} - -static struct wmi_device_id alienware_legacy_device_id_table[] = { - { LEGACY_CONTROL_GUID, NULL }, - { }, -}; -MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table); - -static struct wmi_driver alienware_legacy_wmi_driver = { - .driver = { - .name = "alienware-wmi-alienfx", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, - }, - .id_table = alienware_legacy_device_id_table, - .probe = legacy_wmi_probe, - .remove = legacy_wmi_remove, -}; - -int __init alienware_legacy_wmi_init(void) -{ - return wmi_driver_register(&alienware_legacy_wmi_driver); -} - -void __exit alienware_legacy_wmi_exit(void) -{ - wmi_driver_unregister(&alienware_legacy_wmi_driver); -} - -/* - * WMAX WMI driver - */ -static int wmax_wmi_update_led(struct alienfx_priv *priv, - struct wmi_device *wdev, u8 location) -{ - struct wmax_led_args in_args = { - .led_mask = 1 << location, - .colors = priv->colors[location], - .state = priv->lighting_control_state, - }; - acpi_status status; - - status = alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, - &in_args, sizeof(in_args), NULL); - if (ACPI_FAILURE(status)) - return -EIO; - - return 0; -} - -static int wmax_wmi_update_brightness(struct alienfx_priv *priv, - struct wmi_device *wdev, u8 brightness) -{ - struct wmax_brightness_args in_args = { - .led_mask = 0xFF, - .percentage = brightness, - }; - acpi_status status; - - status = alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args, - sizeof(in_args), NULL); - if (ACPI_FAILURE(status)) - return -EIO; - - return 0; -} - -static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) -{ - struct alienfx_platdata pdata = { - .wdev = wdev, - .ops = { - .upd_led = wmax_wmi_update_led, - .upd_brightness = wmax_wmi_update_brightness, - }, - }; - int ret = 0; - - if (awcc) - ret = alienware_awcc_setup(wdev); - else - ret = alienware_alienfx_setup(&pdata); - - return ret; -} - -static void wmax_wmi_remove(struct wmi_device *wdev) -{ - if (awcc) - alienware_awcc_exit(wdev); - else - alienware_alienfx_exit(wdev); -} - -static struct wmi_device_id alienware_wmax_device_id_table[] = { - { WMAX_CONTROL_GUID, NULL }, - { }, -}; -MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table); - -static struct wmi_driver alienware_wmax_wmi_driver = { - .driver = { - .name = "alienware-wmi-wmax", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, - }, - .id_table = alienware_wmax_device_id_table, - .probe = wmax_wmi_probe, - .remove = wmax_wmi_remove, -}; - -int __init alienware_wmax_wmi_init(void) -{ - const struct dmi_system_id *id; - - id = dmi_first_match(awcc_dmi_table); - if (id) - awcc = id->driver_data; - - if (force_platform_profile) - awcc = &x_series_features; - - if (force_gmode) - awcc = &g_series_features; - - return wmi_driver_register(&alienware_wmax_wmi_driver); -} - -void __exit alienware_wmax_wmi_exit(void) -{ - wmi_driver_unregister(&alienware_wmax_wmi_driver); -} - static int __init alienware_wmi_init(void) { int ret; diff --git a/drivers/platform/x86/dell/alienware-wmi-legacy.c b/drivers/platform/x86/dell/alienware-wmi-legacy.c new file mode 100644 index 000000000000..38dd2a602f34 --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi-legacy.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Alienware LEGACY WMI device driver + * + * Copyright (C) 2024 Kurt Borja + */ + +#include +#include "alienware-wmi.h" + +/* + * Legacy WMI driver + */ +static int legacy_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + struct legacy_led_args legacy_args; + struct acpi_buffer input; + acpi_status status; + + legacy_args.colors = priv->colors[location]; + legacy_args.brightness = priv->global_brightness; + legacy_args.state = priv->lighting_control_state; + + input.length = sizeof(legacy_args); + input.pointer = &legacy_args; + + if (legacy_args.state == LEGACY_RUNNING) + status = alienware_wmi_command(wdev, location + 1, &legacy_args, + sizeof(legacy_args), NULL); + else + status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0, + location + 1, &input, NULL); + + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + +static int legacy_wmi_update_brightness(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 brightness) +{ + return legacy_wmi_update_led(priv, wdev, 0); +} + +static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct alienfx_platdata pdata = { + .wdev = wdev, + .ops = { + .upd_led = legacy_wmi_update_led, + .upd_brightness = legacy_wmi_update_brightness, + }, + }; + + return alienware_alienfx_setup(&pdata); +} + +static void legacy_wmi_remove(struct wmi_device *wdev) +{ + alienware_alienfx_exit(wdev); +} + +static struct wmi_device_id alienware_legacy_device_id_table[] = { + { LEGACY_CONTROL_GUID, NULL }, + { }, +}; +MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table); + +static struct wmi_driver alienware_legacy_wmi_driver = { + .driver = { + .name = "alienware-wmi-alienfx", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = alienware_legacy_device_id_table, + .probe = legacy_wmi_probe, + .remove = legacy_wmi_remove, +}; + +int __init alienware_legacy_wmi_init(void) +{ + return wmi_driver_register(&alienware_legacy_wmi_driver); +} + +void __exit alienware_legacy_wmi_exit(void) +{ + wmi_driver_unregister(&alienware_legacy_wmi_driver); +} diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c new file mode 100644 index 000000000000..75b9a1f029b2 --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -0,0 +1,526 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Alienware WMAX WMI device driver + * + * Copyright (C) 2024 Kurt Borja + */ + +#include +#include +#include +#include +#include +#include +#include "alienware-wmi.h" + +#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 force_platform_profile; +module_param_unsafe(force_platform_profile, bool, 0); +MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal profiles 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 selected"); + +enum WMAX_THERMAL_INFORMATION_OPERATIONS { + WMAX_OPERATION_SYS_DESCRIPTION = 0x02, + WMAX_OPERATION_LIST_IDS = 0x03, + WMAX_OPERATION_CURRENT_PROFILE = 0x0B, +}; + +enum WMAX_THERMAL_CONTROL_OPERATIONS { + WMAX_OPERATION_ACTIVATE_PROFILE = 0x01, +}; + +enum WMAX_GAME_SHIFT_STATUS_OPERATIONS { + WMAX_OPERATION_TOGGLE_GAME_SHIFT = 0x01, + WMAX_OPERATION_GET_GAME_SHIFT_STATUS = 0x02, +}; + +enum WMAX_THERMAL_TABLES { + WMAX_THERMAL_TABLE_BASIC = 0x90, + WMAX_THERMAL_TABLE_USTT = 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, +}; + +struct wmax_u32_args { + u8 operation; + u8 arg1; + u8 arg2; + u8 arg3; +}; + +struct awcc_priv { + struct wmi_device *wdev; + struct platform_profile_handler pp_handler; + enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; +}; + +struct awcc_features { + bool gmode; +}; + +static struct awcc_features g_series_features = { + .gmode = true, +}; + +static struct awcc_features x_series_features = { + .gmode = false, +}; + +static const struct dmi_system_id awcc_dmi_table[] __initconst = { + { + .ident = "Alienware m17 R5", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), + }, + .driver_data = &x_series_features, + }, + { + .ident = "Alienware m18 R2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), + }, + .driver_data = &x_series_features, + }, + { + .ident = "Alienware x15 R1", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), + }, + .driver_data = &x_series_features, + }, + { + .ident = "Alienware x17 R2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), + }, + .driver_data = &x_series_features, + }, + { + .ident = "Dell Inc. G15 5510", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"), + }, + .driver_data = &g_series_features, + }, + { + .ident = "Dell Inc. G15 5511", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"), + }, + .driver_data = &g_series_features, + }, + { + .ident = "Dell Inc. G15 5515", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), + }, + .driver_data = &g_series_features, + }, + { + .ident = "Dell Inc. G3 3500", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"), + }, + .driver_data = &g_series_features, + }, + { + .ident = "Dell Inc. G3 3590", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"), + }, + .driver_data = &g_series_features, + }, + { + .ident = "Dell Inc. G5 5500", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"), + }, + .driver_data = &g_series_features, + }, +}; + +static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_MODE_LAST] = { + [THERMAL_MODE_USTT_BALANCED] = PLATFORM_PROFILE_BALANCED, + [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE, + [THERMAL_MODE_USTT_COOL] = PLATFORM_PROFILE_COOL, + [THERMAL_MODE_USTT_QUIET] = PLATFORM_PROFILE_QUIET, + [THERMAL_MODE_USTT_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE, + [THERMAL_MODE_USTT_LOW_POWER] = PLATFORM_PROFILE_LOW_POWER, + [THERMAL_MODE_BASIC_QUIET] = PLATFORM_PROFILE_QUIET, + [THERMAL_MODE_BASIC_BALANCED] = PLATFORM_PROFILE_BALANCED, + [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE, + [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE, +}; + +struct awcc_features *awcc; + +/* + * Thermal Profile control + * - Provides thermal profile control through the Platform Profile API + */ +static bool is_wmax_thermal_code(u32 code) +{ + if (code & WMAX_SENSOR_ID_MASK) + return false; + + if ((code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_LAST) + return false; + + if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_BASIC && + (code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_BASIC_QUIET) + return true; + + if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_USTT && + (code & WMAX_THERMAL_MODE_MASK) <= THERMAL_MODE_USTT_LOW_POWER) + return true; + + return false; +} + +static int wmax_thermal_information(struct wmi_device *wdev, u8 operation, + u8 arg, u32 *out_data) +{ + struct wmax_u32_args in_args = { + .operation = operation, + .arg1 = arg, + .arg2 = 0, + .arg3 = 0, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION, + &in_args, sizeof(in_args), out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (*out_data == WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int wmax_thermal_control(struct wmi_device *wdev, u8 profile) +{ + struct wmax_u32_args in_args = { + .operation = WMAX_OPERATION_ACTIVATE_PROFILE, + .arg1 = profile, + .arg2 = 0, + .arg3 = 0, + }; + acpi_status status; + u32 out_data; + + status = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL, + &in_args, sizeof(in_args), &out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (out_data == WMAX_FAILURE_CODE) + return -EBADRQC; + + return 0; +} + +static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation, + u32 *out_data) +{ + struct wmax_u32_args in_args = { + .operation = operation, + .arg1 = 0, + .arg2 = 0, + .arg3 = 0, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS, + &in_args, sizeof(in_args), out_data); + + if (ACPI_FAILURE(status)) + return -EIO; + + if (*out_data == WMAX_FAILURE_CODE) + return -EOPNOTSUPP; + + return 0; +} + +static int thermal_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + struct awcc_priv *priv; + u32 out_data; + int ret; + + priv = container_of(pprof, struct awcc_priv, pp_handler); + + ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE, + 0, &out_data); + + if (ret < 0) + return ret; + + if (out_data == WMAX_THERMAL_MODE_GMODE) { + *profile = PLATFORM_PROFILE_PERFORMANCE; + return 0; + } + + if (!is_wmax_thermal_code(out_data)) + return -ENODATA; + + out_data &= WMAX_THERMAL_MODE_MASK; + *profile = wmax_mode_to_platform_profile[out_data]; + + return 0; +} + +static int thermal_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + struct awcc_priv *priv; + + priv = container_of(pprof, struct awcc_priv, pp_handler); + + if (awcc->gmode) { + u32 gmode_status; + int ret; + + ret = wmax_game_shift_status(priv->wdev, + WMAX_OPERATION_GET_GAME_SHIFT_STATUS, + &gmode_status); + + if (ret < 0) + return ret; + + if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) || + (profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) { + ret = wmax_game_shift_status(priv->wdev, + WMAX_OPERATION_TOGGLE_GAME_SHIFT, + &gmode_status); + + if (ret < 0) + return ret; + } + } + + return wmax_thermal_control(priv->wdev, + priv->supported_thermal_profiles[profile]); +} + +static int create_thermal_profile(struct wmi_device *wdev) +{ + enum platform_profile_option profile; + enum wmax_thermal_mode mode; + struct awcc_priv *priv; + u8 sys_desc[4]; + u32 first_mode; + u32 out_data; + int ret; + + priv = dev_get_drvdata(&wdev->dev); + + ret = wmax_thermal_information(wdev, WMAX_OPERATION_SYS_DESCRIPTION, + 0, (u32 *) &sys_desc); + if (ret < 0) + return ret; + + first_mode = sys_desc[0] + sys_desc[1]; + + for (u32 i = 0; i < sys_desc[3]; i++) { + ret = wmax_thermal_information(wdev, WMAX_OPERATION_LIST_IDS, + i + first_mode, &out_data); + + if (ret == -EIO) + return ret; + + if (ret == -EBADRQC) + break; + + if (!is_wmax_thermal_code(out_data)) + continue; + + mode = out_data & WMAX_THERMAL_MODE_MASK; + profile = wmax_mode_to_platform_profile[mode]; + priv->supported_thermal_profiles[profile] = out_data; + + set_bit(profile, priv->pp_handler.choices); + } + + if (bitmap_empty(priv->pp_handler.choices, PLATFORM_PROFILE_LAST)) + return -ENODEV; + + if (awcc->gmode) { + priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = + WMAX_THERMAL_MODE_GMODE; + + set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->pp_handler.choices); + } + + priv->pp_handler.profile_get = thermal_profile_get; + priv->pp_handler.profile_set = thermal_profile_set; + priv->pp_handler.name = "alienware-wmi"; + priv->pp_handler.dev = &wdev->dev; + + return platform_profile_register(&priv->pp_handler); +} + +static int alienware_awcc_setup(struct wmi_device *wdev) +{ + struct awcc_priv *priv; + int ret; + + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + dev_set_drvdata(&wdev->dev, priv); + + priv->wdev = wdev; + + ret = create_thermal_profile(wdev); + if (ret < 0) + return ret; + + return 0; +} + +static void alienware_awcc_exit(struct wmi_device *wdev) +{ + struct awcc_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + + platform_profile_remove(&priv->pp_handler); +} + +/* + * WMAX WMI driver + */ +static int wmax_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + struct wmax_led_args in_args = { + .led_mask = 1 << location, + .colors = priv->colors[location], + .state = priv->lighting_control_state, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, + &in_args, sizeof(in_args), NULL); + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + +static int wmax_wmi_update_brightness(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 brightness) +{ + struct wmax_brightness_args in_args = { + .led_mask = 0xFF, + .percentage = brightness, + }; + acpi_status status; + + status = alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args, + sizeof(in_args), NULL); + if (ACPI_FAILURE(status)) + return -EIO; + + return 0; +} + +static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct alienfx_platdata pdata = { + .wdev = wdev, + .ops = { + .upd_led = wmax_wmi_update_led, + .upd_brightness = wmax_wmi_update_brightness, + }, + }; + int ret = 0; + + if (awcc) + ret = alienware_awcc_setup(wdev); + else + ret = alienware_alienfx_setup(&pdata); + + return ret; +} + +static void wmax_wmi_remove(struct wmi_device *wdev) +{ + if (awcc) + alienware_awcc_exit(wdev); + else + alienware_alienfx_exit(wdev); +} + +static struct wmi_device_id alienware_wmax_device_id_table[] = { + { WMAX_CONTROL_GUID, NULL }, + { }, +}; +MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table); + +static struct wmi_driver alienware_wmax_wmi_driver = { + .driver = { + .name = "alienware-wmi-wmax", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = alienware_wmax_device_id_table, + .probe = wmax_wmi_probe, + .remove = wmax_wmi_remove, +}; + +int __init alienware_wmax_wmi_init(void) +{ + const struct dmi_system_id *id; + + id = dmi_first_match(awcc_dmi_table); + if (id) + awcc = id->driver_data; + + if (force_platform_profile) + awcc = &x_series_features; + + if (force_gmode) + awcc = &g_series_features; + + return wmi_driver_register(&alienware_wmax_wmi_driver); +} + +void __exit alienware_wmax_wmi_exit(void) +{ + wmi_driver_unregister(&alienware_wmax_wmi_driver); +} From patchwork Sat Dec 21 05:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917658 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 D715C1FC10E; Sat, 21 Dec 2024 06:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760847; cv=none; b=bQ6BBLyp7O2+PovuJruS0iR7+BSU1Bzf+wIB+l3FlKhwDWtIqevR7PeefWKdueGdKP0eN14jc6MtkweenoCRojdvwk3049Z+cb/nUcHKyLPeYmYb3HR6V2K2zsaRZVtdH4xWtba6fiEq4+rHF5oEbjE5tUUiOmwooHQjyg6CB8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760847; c=relaxed/simple; bh=0Ol98yanXeWX9fyvOuEG32Z+T7TEskXKvNHu+TZpsdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fQ3/LrDB0vJd5y33I+MjG7EYkQspJuVsXd/4lxydLZVyNVu4Vx8AnQn7lH+4KHM4DxvEKq+y/SWFT/irq6vKULzfNSqql3aWdtgqLa5tfP0+a/+93a48nlzlT/hJP8EWSKZNi/+yLqhgN2LFTTbbf1YfFw/xC6k/YMNuEKr2a3I= 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=kX1ssSyp; arc=none smtp.client-ip=209.85.128.180 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="kX1ssSyp" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6f26c517979so18946087b3.2; Fri, 20 Dec 2024 22:00:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760844; x=1735365644; 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=pE/mHc4880U3TEq+abwprJmPUuj7m7Y8jQWGzsnApFs=; b=kX1ssSypY0DCUQT/9w/wB6t7wrmtCLuhH1jwimHhH1uLEsxO3Ul8XrTZUDTq50DCKD 21opWm2Ha+NbM068tcc2oiHBEdWWquZi1rcN+cfEbILN4TiD3o8PIupl9/QJuB50wMWb Lq+i4wmRAzGMkr3EYeNyCBnY0gPBhkbiSBw7NajHeVqRb4ANX++bZd5Q4ttJyJ40kMv4 PGjmMFRnzVDe7TmbPtEMTnWi+Gk9+q2+VXYm3hjmM78wYehiRemigUEQgaPgGc6TfU/u sCHXky+wfyC2seX5iGnu3VglZF4Jx0Sl2LUKLr6GTLFJbHbusbivVQX0PJJH36PBavC9 hG/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760844; x=1735365644; 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=pE/mHc4880U3TEq+abwprJmPUuj7m7Y8jQWGzsnApFs=; b=dWLg1pzIhFB8MOcfMsXUKkavlE0s6Ks04Pi9xL5ZOHWvURAiHwfNSqlihswRsDXcub Nwg3d5wvagIHMZ5+0Ps8vHKntYuupY9NUs6KEXyTSFRes16pMUOPSleC3F0pGZVQpYuK c5bjGO2CEQ15xS+m9Yq/CIa6dmWgthGGVswGN/24LJagDfF7OwitSgGWkPmcptM1H/d+ fFhzbNkUckDxjzXeIt/AQsNPMpQ2kInznoCH9wg88BGg6lBCsScQl0/dVsjMCZo7eIA+ eJ7IFTUdi9SariyhKQByaZ+DaicioyzKeMdi5C97SswAwVzIQd73YUKh2TOKPPlpgg2E rk6A== X-Forwarded-Encrypted: i=1; AJvYcCU3DH6Ow62xS1mTynkRfzMCNKuO5KCj8UDitv4JbS+k+Lk1EWkUZyis/boiO08B9iXkbDPzyP8tMJmw0eI=@vger.kernel.org X-Gm-Message-State: AOJu0YwbvrzYhn9UtmVlqGdcPKCe/njV9lIHUxcgBLY1wyVBL6nrqbfK Pc1ChbcTnZvyQT3xqQUnUf2u5QFpN5yaBY46HyWqdvAxODrShciE/Y4RTw== X-Gm-Gg: ASbGncv+DEFDemuNPHE+5GdzOODmjjeIoIqTJSj95ub6RQFk5TFbWqQVeUdPI/9nMvd nbjUwOHHRLkLegIWOUffehWrarrsG0/7X/E6NHqW0Ke/f4463y89lhriKtIF1fJ1YZ3qtKG7wlO 6+TdHzlJb6fzkQLebQqfeK7uScgmfmJbkz6zTS/uAU3+/9G7mFiYCO3DPl2j+EFxDbHHu/TKlmi VyAYPm0Cf6/kUYz5icUth8nHEJ962ApiiYOvk0nDxUbfm89I2P6uVv6HsdoFGXU X-Google-Smtp-Source: AGHT+IGfzR/Es13SIC6hbrczZh+5y1AapA4IwSz3o8FxxDX/AGInVgaBFzoY2a67Vzu69MSibluXcQ== X-Received: by 2002:a05:690c:4983:b0:6ef:4fba:8158 with SMTP id 00721157ae682-6f3f7f45af0mr42053377b3.0.1734760844194; Fri, 20 Dec 2024 22:00:44 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:43 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 18/20] platform/x86: dell: Modify Makefile alignment Date: Sat, 21 Dec 2024 00:59:15 -0500 Message-ID: <20241221055917.10555-19-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add one more TAB to each line to support upcoming changes. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Makefile | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index 03ba459f3d31..d5718ef34c48 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -4,27 +4,27 @@ # Dell x86 Platform-Specific Drivers # -obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o -alienware-wmi-objs := alienware-wmi-base.o -alienware-wmi-y += alienware-wmi-legacy.o -alienware-wmi-y += alienware-wmi-wmax.o -obj-$(CONFIG_DCDBAS) += dcdbas.o -obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o -obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o -obj-$(CONFIG_DELL_RBU) += dell_rbu.o -obj-$(CONFIG_DELL_PC) += dell-pc.o -obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o -dell-smbios-objs := dell-smbios-base.o -dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o -dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o -obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o -obj-$(CONFIG_DELL_SMO8800) += dell-lis3lv02d.o -obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o -obj-$(CONFIG_DELL_WMI) += dell-wmi.o -dell-wmi-objs := dell-wmi-base.o -dell-wmi-$(CONFIG_DELL_WMI_PRIVACY) += dell-wmi-privacy.o -obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o -obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o -obj-$(CONFIG_DELL_WMI_DDV) += dell-wmi-ddv.o -obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o -obj-$(CONFIG_DELL_WMI_SYSMAN) += dell-wmi-sysman/ +obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o +alienware-wmi-objs := alienware-wmi-base.o +alienware-wmi-y += alienware-wmi-legacy.o +alienware-wmi-y += alienware-wmi-wmax.o +obj-$(CONFIG_DCDBAS) += dcdbas.o +obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o +obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o +obj-$(CONFIG_DELL_RBU) += dell_rbu.o +obj-$(CONFIG_DELL_PC) += dell-pc.o +obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o +dell-smbios-objs := dell-smbios-base.o +dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o +dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o +obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o +obj-$(CONFIG_DELL_SMO8800) += dell-lis3lv02d.o +obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o +obj-$(CONFIG_DELL_WMI) += dell-wmi.o +dell-wmi-objs := dell-wmi-base.o +dell-wmi-$(CONFIG_DELL_WMI_PRIVACY) += dell-wmi-privacy.o +obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o +obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o +obj-$(CONFIG_DELL_WMI_DDV) += dell-wmi-ddv.o +obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o +obj-$(CONFIG_DELL_WMI_SYSMAN) += dell-wmi-sysman/ From patchwork Sat Dec 21 05:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917659 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.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 8C6A01EE7B9; Sat, 21 Dec 2024 06:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760850; cv=none; b=IcDisr49GqNXzu4Ups5jO79IGTfHXy14ufzDZzq7qUmR7NJzeUAoxuOs0QBwmAj9gV0zQ+qw3iiIxv1t+F15+UyCJ3KYjQ/enjAhHgtpPhkqubptxAP3aN/Nu9Ltl1fi+KQPdgivPxlHpxBexEue5CvstNqVQ9DBvKVcup10kIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760850; c=relaxed/simple; bh=3CEvQPYouDEXkZWfuJ6qjewj+SI5X4iK+eXr1RpnnFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mt1hg7lOC4ZlQMkY29ORQz3O5v/nNmzlscza7YXG/O8vKu+M3rUL9ph5+OJlyNg2hdm3rTzOZQPh/7jugK2c36Ec7U6lX3Mb9hU8HVRbTXHXIanJ5NQeG/umBpoMqVhih4hXiTzmmP0V9k320RTSyccjLi3CfWa+XDM3vjtbvjE= 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=LKQxAyQH; arc=none smtp.client-ip=209.85.128.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="LKQxAyQH" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6efc58fae20so22628927b3.0; Fri, 20 Dec 2024 22:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760847; x=1735365647; 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=H5/pJG+VdN3oh+ueecu+Yb7zNrojEE6yI7k/7ZR+Cow=; b=LKQxAyQHt6+WskSkmT/WWf8GzSqlpVZafJff5+pdMkqGdxoRyxFZut8/XzSLJqysjV 5yYn08n2vg0OB5FRxiN9XVDSoAUIpgUBq8Q/yaOEQXnJTMj/FNuJRbnWAqdo/vCx3x1J naUo82YxW1kA+ZS/wfufuJM+v0mUSzSb2N1+qWDkoVuoX2UajoI6ZS4j/ax+71NGzHa4 QINUiyK7yK+Qym/YGhNAsf7eG3GI7jb3Fo01VBGAo0N+b7NiGeRgyBp4Tm/4P1yLH/Hs eRz7WovVv9mmqDVxYjrM3w+VgDjIOUc3HjS7PQRMTDXsKXGNzGCDvmGk/Y75BZ8osflc wUGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760847; x=1735365647; 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=H5/pJG+VdN3oh+ueecu+Yb7zNrojEE6yI7k/7ZR+Cow=; b=Qzbmcqo14J4mfkSmODrnoBAE5gWVdO1N4Vi/ywxJDfWU/nMHZDIg3Bizc2WElpMDnY aGwYj/2st7SrApMjMPOXce32KY2TMF35NLMJ9XicKW8Fe2fz3pdYdYvnmE+Hp0zWYcVh JJD6acyB2MUoJVE+2a+G3JvnGKCwurrlrEvq6gaw+dtAqlWGbqJI2ratpK0ykYGHZe5h z72xNadfonflJMZWWwqrrUzGsxm5RoNeFi5RaS7tlNx1eTgDooGcf69r5Kg8bWCH8HbO WvAv7pDmHP2NRZRTcqnPIW+2y5+p/GD9krU8ItRMPWtUy58pOpJRJu1jSa24XjGScga2 T58w== X-Forwarded-Encrypted: i=1; AJvYcCXPVd7D8gFfPuNLMucLPBOrwUJUkUOF3EtUhputUZouXob8l+ynAIqXw36+Qj59oTXsWfT6IivfZLEHn8E=@vger.kernel.org X-Gm-Message-State: AOJu0YxiFoIwM2xClp8dG9ie7xdimTvNHc9agmUQdnK9b8leCsyDSuMy g6Te55KtvuqLmC1t8UUgQCQzud4Zcg7K6wB+u+mOZVCw+jEQPh80l2RbKA== X-Gm-Gg: ASbGncst7GPc8SdbRJvdoIxVIkD/BhUp0bZ2eCplwoByt37p/u5YN6eHT43RbaWY3N4 KJ3b7fxD4jTSm7XBTqdMkDnQa1wtLk9RxlQkH7ykFRYv/E1OsbXzVcbmS7g2C9bdOkHEmVopWoZ SFx6FPoSOtZqSimLj2XqoI/SAVwrtkezVkq+UsekXmxCNBwukN0v7aZlRQYD30zGjN1Fbj7dLKZ hERlrG+vuCA7G9edUFoakVCLX7vMRfS2pGdNj1HaRgHdq7EnPiQKTnmlVCRaQ9v X-Google-Smtp-Source: AGHT+IGiMgzYNvaUHdPBS2HMNK0HAXa2jXfU9qWgsJ//zkuIQmSJ7TnHOn8D14WzKHa+gP9mudfpaw== X-Received: by 2002:a05:690c:c1e:b0:6ee:4ce9:b33e with SMTP id 00721157ae682-6f3f8118d17mr40133257b3.12.1734760846999; Fri, 20 Dec 2024 22:00:46 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:46 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 19/20] platform/x86: Update alienware-wmi config entries Date: Sat, 21 Dec 2024 00:59:16 -0500 Message-ID: <20241221055917.10555-20-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add config entries for each WMI driver managed by the alienware-wmi module to be able to conditionally compile them. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Kconfig | 30 +++++++++++++++++++---- drivers/platform/x86/dell/Makefile | 4 +-- drivers/platform/x86/dell/alienware-wmi.h | 23 +++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig index d09060aedd3f..f8a0dffcaab7 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -18,15 +18,35 @@ config ALIENWARE_WMI tristate "Alienware Special feature control" default m depends on ACPI + depends on ACPI_WMI + depends on DMI depends on LEDS_CLASS depends on NEW_LEDS - depends on ACPI_WMI + help + This is a driver for controlling Alienware WMI driven features. + + On legacy devices, it exposes an interface for controlling the AlienFX + zones on Alienware machines that don't contain a dedicated + AlienFX USB MCU such as the X51 and X51-R2. + + On newer devices, it exposes the AWCC thermal control interface through + known Kernel APIs. + +config ALIENWARE_WMI_LEGACY + bool "Alienware Legacy WMI device driver" + default y + depends on ALIENWARE_WMI + help + Legacy Alienware WMI driver with AlienFX LED control capabilities. + +config ALIENWARE_WMI_WMAX + bool "Alienware WMAX WMI device driver" + default y + depends on ALIENWARE_WMI select ACPI_PLATFORM_PROFILE help - This is a driver for controlling Alienware BIOS driven - features. It exposes an interface for controlling the AlienFX - zones on Alienware machines that don't contain a dedicated AlienFX - USB MCU such as the X51 and X51-R2. + Alienware WMI driver with AlienFX LED, HDMI, amplifier, deep sleep and + AWCC thermal control capabilities. config DCDBAS tristate "Dell Systems Management Base Driver" diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index d5718ef34c48..8ac9a933c770 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -6,8 +6,8 @@ obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o alienware-wmi-objs := alienware-wmi-base.o -alienware-wmi-y += alienware-wmi-legacy.o -alienware-wmi-y += alienware-wmi-wmax.o +alienware-wmi-$(CONFIG_ALIENWARE_WMI_LEGACY) += alienware-wmi-legacy.o +alienware-wmi-$(CONFIG_ALIENWARE_WMI_WMAX) += alienware-wmi-wmax.o obj-$(CONFIG_DCDBAS) += dcdbas.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h index 78ac10122155..97b52e51cd7d 100644 --- a/drivers/platform/x86/dell/alienware-wmi.h +++ b/drivers/platform/x86/dell/alienware-wmi.h @@ -94,10 +94,33 @@ acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, int alienware_alienfx_setup(struct alienfx_platdata *pdata); void alienware_alienfx_exit(struct wmi_device *wdev); +#if IS_ENABLED(CONFIG_ALIENWARE_WMI_LEGACY) int __init alienware_legacy_wmi_init(void); void __exit alienware_legacy_wmi_exit(void); +#else +int __init alienware_legacy_wmi_init(void) +{ + return 0; +} + +void __exit alienware_legacy_wmi_exit(void) +{ +} +#endif +#if IS_ENABLED(CONFIG_ALIENWARE_WMI_WMAX) int __init alienware_wmax_wmi_init(void); void __exit alienware_wmax_wmi_exit(void); +#else +int __init alienware_wmax_wmi_init(void) +{ + return 0; +} + + +void __exit alienware_wmax_wmi_exit(void) +{ +} +#endif #endif From patchwork Sat Dec 21 05:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13917660 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 432381FCD0B; Sat, 21 Dec 2024 06:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760852; cv=none; b=PtS1CqbSdUJ079Iz17s8iHYcW7vVUTYH5sNCJ7f8/4vwiyRfXiZi8wpPdD/jocX8zJN0+Rw1mZqf6Xti8rbaj2dOQrNps7qU9sgsYAYyYbQMAOz5iXA4mlfS+XIzB2XkXGWvoOFMXPP4ZhgCwU30RLkezSJaKWItZF3mC+uEzKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734760852; c=relaxed/simple; bh=d9pkZie7/X4Kq8x/mBdPdCbimEn3JP8xoDkk/9g+UcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HOdnn99TuGyaxBfE1U85Mo7+14WRgHf6Z3xSY63cStyXD6WwG3AAQc6WWZkMBUgWI7vASjpDKfjh/Hccu6kuLN31d2VHCzMB68Um6pxPIOs4WD9xPEbBCnXEmd6R9kOTfjru3zLbwXFMjy6/jEXkOwLPppMtyR0xOhXZrsmrH7w= 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=bIdhuGIf; arc=none smtp.client-ip=209.85.128.180 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="bIdhuGIf" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6efeb120f4dso20840887b3.0; Fri, 20 Dec 2024 22:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734760850; x=1735365650; 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=fOe3tFzr486FUFWzDp/MXqTTC9KDER087+s+B7B0lGU=; b=bIdhuGIfrfcqgkpIiox336uaHjAjxOieGRv1pmVn0RUuWoeOfM0tQetZm/4PW8sq16 lCXnqwWKXwO5kP7/2BmwJBBZr0+NUgEPsO/uIMqOYXTQCcsrINuHGEG4mly/ukIIcD+l MTZ+J/UbHb2iUYURTwrWqaTRIZeW5PktwZlpWJKA7nq+/LXc/9cc08BEHBPOlPhDavz1 BYyL5n+6bEA2JJie4MYLGkMoqDeWjt7LI0j+tNSW4jMprCq/fsbMuKxTqwbvTFjiTcC/ GReXGiNsjWMguiVXXYpHkhuvHC9Kh6l8G5c3Q/Mp5O+CeqkPFsuP3Dj3L0TPR+s+vzbX 3REg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734760850; x=1735365650; 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=fOe3tFzr486FUFWzDp/MXqTTC9KDER087+s+B7B0lGU=; b=rVtX6xMceaLdEgFDKi3KQyhhVPYquvzGlLclWFZexmJ4Fo1LC64TjVYeU2CU2lG0Qs wqblpyvyDY7n/EW7GTmwd+1E1YHrwV6ThGxivB1oJiB0FSZLRE1FUjzhodonluwxkBXd lst3qHWuAVyamDZBC924Wh+JIIRIfHaWAmmPAI00GbueR+fjdeFNZ//o25ePE0nk9Ezv XnuwgE66PXTG3VfTc6elmeFKWNWQAhUJhg5+QYvJNTgwMQfU9VqnHJ+hw0YPiIOs0mVs AI0ApH/B8WSu2tuRchFg7CoqHLpv7xWtVkhye7rkwpvbjEu/TI0Rx6fin80Jq9MHMJFE NLNw== X-Forwarded-Encrypted: i=1; AJvYcCXLGKlxpPEMR1akCFMciVCSi9bn4eVpGytK/T2xIAp+Zluv0it1/R7/rw7OMdBAK9lNZAI/t19H3Pa2N8w=@vger.kernel.org X-Gm-Message-State: AOJu0YzM0L7UAgsJIJU7xBoC26Ai3ms9EX+foCe5Gt5yWyfIcT/KVt2D s3Y8iHLn96WuILwTIyP1/7JPxI0Tux1NtvZhZEl4LyiiIql/+myjB0jQEA== X-Gm-Gg: ASbGncvn+w3hiIIYjwXjDOb2tPdGVW2UO9KqKgiBcALzltmZKS0sQy/noIjux4q8FMJ FUK6FkuD/gGYTJ0mNIqeEtxCmJVnhSINP/3yVKelIJm5u6GkrDlpQ1SRiNvgZ8RoBDUm7vzMA1f zgdjB0SmNOwGPUV/jxYJBZpxncC8/80O2qcUjSWa1cZVAM4CedbNxlqWUdB2Lh3STQ8TMICEQcN eQdmWrEVjjraZWw3L4EOlJUGVQ6vxekxeXDWzN8Ukkvu7A8hLAVeGre17auPXcS X-Google-Smtp-Source: AGHT+IGr9lRx/TV6KfrBZ7yjuXnyCThETkHmsTUuBlIwJEPyDo7vDXP4rWwmVFkljeLbgx6JPCOsoQ== X-Received: by 2002:a05:690c:6213:b0:6b1:61e0:5359 with SMTP id 00721157ae682-6f3f8136aa5mr43068657b3.21.1734760849831; Fri, 20 Dec 2024 22:00:49 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f3e783ab9dsm12164077b3.119.2024.12.20.22.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 22:00:49 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com, w_armin@gmx.de, hdegoede@redhat.com, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, Kurt Borja Subject: [PATCH 20/20] alienware-wmi: Update header and module information Date: Sat, 21 Dec 2024 00:59:17 -0500 Message-ID: <20241221055917.10555-21-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241221055917.10555-1-kuurtb@gmail.com> References: <20241221055917.10555-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update module description and add myself as a module author. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi-base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c index 450ba0a48004..e8ccf9b277fa 100644 --- a/drivers/platform/x86/dell/alienware-wmi-base.c +++ b/drivers/platform/x86/dell/alienware-wmi-base.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Alienware AlienFX control + * Alienware special feature control * * Copyright (C) 2014 Dell Inc + * Copyright (C) 2024 Kurt Borja */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -15,6 +16,7 @@ #include "alienware-wmi.h" MODULE_AUTHOR("Mario Limonciello "); +MODULE_AUTHOR("Kurt Borja "); MODULE_DESCRIPTION("Alienware special feature control"); MODULE_LICENSE("GPL");