From patchwork Thu Dec 5 00:38: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: 13894621 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 0E12B10E9; Thu, 5 Dec 2024 00:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359111; cv=none; b=hwEb1Aevajc6Q+WccHYTQS8o+FMz94Y8y0Huizg2lqhT+kHTyCgpECga1J+c7/jzMmTntHL7G4RDpflmeq26VQXykEYKVKeSZfTl2NJJTNDABJFrmEtQC/zVz2pXawR10yGtUhHdR0tnFgS0W2VIwMpK0eJXu+1YXMtWcHndEDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359111; c=relaxed/simple; bh=CVtGeYGQ2lsIhDmByOC3VmZ9h8mcsqIVHwZTa60EnLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rs7PbZtkJ1fhS7cTnPrVmiFL6iq8sWMLP3gr+aWOTtWdkHC7fiPsIRi9gtc45JiknPN4lGbVOreodTyBHcJeEHVf9QMGhg5fOu+TKxCt2Zx/bv8iaUrDNmfUhzNT6591uNo1orkMu6JS6d3AUXf3K4SWKR1eQkXgcf1VYn7B+gk= 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=CFmsIKhk; arc=none smtp.client-ip=209.85.215.177 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="CFmsIKhk" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7fd10cd5b10so336105a12.2; Wed, 04 Dec 2024 16:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359109; x=1733963909; 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=9TaqAnQ9e84EfyCGFY27XE5cu/57VweM6gLIO9TxviE=; b=CFmsIKhkOCPqeS98oKWoFO5zo2feDy75fr+q34YeV7lDVwctX2/rbRKW1N9QZvJNAU o4VgW2wK+Aos2a+wPEexI53Og5Svtl/ByWavl8QQCgqXW3dkMME0yQRSPgBNMgDNg5Bk Yv9W3TiSer00ljVvI7pArE4YjjumtM7PAVOucmaMX4by5YvhKJV90/cGhj+Idwx6eJBE b7ZKv/ke+1YaU6A8VCIJ+UOBkLRKxXqecpn+9zO+E6pay0TW0YqZT95jQ/zxtHbCM3EG FH4cwihynyfx3U1RGJfa950YlkaoTuWveNxVsPBSO4UtQ38oqsASGkuvRlk4n3zXgW5p WREg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359109; x=1733963909; 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=9TaqAnQ9e84EfyCGFY27XE5cu/57VweM6gLIO9TxviE=; b=EnZDwCfKZVhJYMrGbJQF3/086rpPYP6q/zMnz1Y2svQM3b90fYcJq8kHpd9ezCcW6D mZnKioc7CPVPLQFdPXqi2p4vEsBs2Bp+joRlSaej9y375XuhjUK97aXDcF0kE7KfLp2w GxrrGalxkm32zFziKXL80KZ7lCAP83x2pp/zFOiCTwiUYWSPuyPh6/ZHeGGjZz3ddIGL g/YhQ+wv4kD8+FpRlS3UHR270U4yitCubvKjYRmKeY+cKxayJOxjDnj2Cs6X8ifO0Yj4 EYexVoJCasi6TM1+5PB0jsgxft3lfuVxW/UUZF8yNYRC3sEaGqcNFCbdMGJySBAmLrqT GiLw== X-Forwarded-Encrypted: i=1; AJvYcCV7dUDNnitaAfD3Q3GFFe5rf3XS99ueSLyDdtxxcM/OXjsq3PEKIqaLfww2XrPSKTDSTDqS70XO1RVscwgKVaK3Dod84w==@vger.kernel.org, AJvYcCWmhQl0vbWEg84C3LoDgttxhjsXjn4qQeuiAQrFCmUOm8U3BQ1cn+jm/KxUK6+JTxic7MjIKkR+EzZnEQk=@vger.kernel.org X-Gm-Message-State: AOJu0YzPjdQ6Hh30DVZxVTLOoe5wDnTPdX6250YdXy4erHr2RprTYTBk Gez2iKn/SPkSv1umGUgidj9bKtht6I1lmC9Ps6BlsoQKtos2veO6 X-Gm-Gg: ASbGncuZlp7LKYd3teQeKhccpm/w+PUhSaGbfEwWjTAzWNlPoXhheTYhirA4unuKuej lfcQR5Dro8xzgEl0Qap8R6B0EhuLm9M8590nsQobujoL4pRawHSxLEAmVbvAKWlq0sUHYwcfHxJ fMvXQh1rwQDopcrQChI41Ey0EwbOqQKt2dS6dOd/1TaJF+XEP8NcWtQfTUnXikd0TB58yfvBZQn 8y9jeNWFH3VgfX0At1ffYD+WQGeqm07eGnlwu+5KRhduk48KsPg5F/63cBBSrKIGnp34q+XFGR9 j5PXK4HUoR1MDIPyNd0= X-Google-Smtp-Source: AGHT+IHGZoXQtkdzn9gcelz/RSchyTX6Ifra/ExRIUhpX7+I/4rIt6Gijq0x5nMiHxPzojX3/Q283w== X-Received: by 2002:a05:6a21:339c:b0:1e0:f05b:e727 with SMTP id adf61e73a8af0-1e1653a7977mr12494551637.2.1733359109229; Wed, 04 Dec 2024 16:38:29 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a2cc9311sm94243b3a.182.2024.12.04.16.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:38:28 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 01/21] alienware-wmi: Modify parse_rgb() signature Date: Wed, 4 Dec 2024 21:38:03 -0300 Message-ID: <20241205003802.2184367-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 77465ed9b449..b3a73fc43b3c 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 Thu Dec 5 00:38:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894622 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.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 3D1D210E9; Thu, 5 Dec 2024 00:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359143; cv=none; b=cfhvmL/K3pbLhDQNYWtB8MLj22PKwJpics1EBWsbZvBfye6FSIk36TibXaSOI9ISbgINxd0f0hWJ7YMy2WsNWmJWLq2gVvG2U0P8u50ZWHGExX0S4cFNTLEJWYT0Rzs9EaMy2+HI9AtQ/kWQiQx+0OxepS8ZtGgINDITcBnPgiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359143; c=relaxed/simple; bh=I5yT5GXn4XWD061Xb2RH/thnz8ewCQmNGoquSyoEgk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hGA3cGhZERBy0ioeUxY02YVg18iMyWCzpZkPn28A1L2saTsxtaAlDzjQJmuLYklO2Tq4+zM5qNRJ1BayhFDASxYCadP1B6cFOxB22BUVcpWIzRRVE0gRfUjpSZ1+MORqRqkXmU53O6h4FSIrFXEYpjNIC/f+EEPsfK+9ttStFis= 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=bfrKmPVY; arc=none smtp.client-ip=209.85.214.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="bfrKmPVY" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-215936688aeso2809455ad.1; Wed, 04 Dec 2024 16:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359141; x=1733963941; 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=5r0gHAwegXuzSmSEhFIyVewwYq6F+Oy8I87chR6WA6Q=; b=bfrKmPVYq/F77lDEMfTct9lswd8t8+uosWkF8etawTu4LAm9GLRZwXQiBShA1p605h NxcKZQ7s4rm1rlizDHnqhnMi0HH7dzy+6UdFWFFXzKQ++rTbMRFtNvySsvNnICJHgsnJ QGgPD6npB9WnHl5L+Qo/J4e5oPZxhQygSzhsRevmPiMwjotDuQ4vNZrn2vy+0xZdn967 G59LdJiSsqrezQE+9VkAbkSscq4DEPMtSGOmqgzpZBCyqINc+AoCh64ynvud8xj3YTcr Oqb1MvovyvPQtlQKay/YQ6PpwmbtvkZ8NffSgnupfmS5qLSRqRbqSysmGkOQ5WjTkXCL o9rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359141; x=1733963941; 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=5r0gHAwegXuzSmSEhFIyVewwYq6F+Oy8I87chR6WA6Q=; b=WtnpqYKCQCmFuhma68DiP5WPdPUCMiBIcqL/eKoKrN5rTH5EgUbObZ/OToZHX+TUb2 9vTXYloi/JFYMQkxxCsL0uGfVtTlGg1dTcE/Fs56/4f7MPad4/RT06nJuzFeBSOmezRM GlgyzHGDZMuCEZxZQITxXwcMX1MVKZFbHnfNVjYnZ0G1SJCvplIyVltUaps0CzV6NPiE SK/Hno0RvdSjXN6U0N3SCx0tfzJZ9/6/2LjfFhgymzO7qLCBaiHvOqx7gQfxkM7JAjyc pjjhhy6NRIGq1wa8hbmxgF/DadNbh2ROB1NxFZiH4YDsKqjjTbrd5UP/OtEWVwJ03KSf 6kJQ== X-Forwarded-Encrypted: i=1; AJvYcCUVuu6DU69z3l0FM/0UzpFeGlLNKoGEDSEa2f+hmxgbxt15zxX2YyF1/s6qwOGnY9TJB/d8wl6so5oTlxI=@vger.kernel.org, AJvYcCVPvXs1QyPyArvRFV7kwogmT1aV5lsTh8Edihy8sfwji1kwxSy6GMs99kAfe7LxpcMCWSV92iZDxqzEwlQUiUb1sqpmLg==@vger.kernel.org X-Gm-Message-State: AOJu0YyedEejDo/o82P/o9gnvMeUYoSY7c4HEz9lbNMgyrHtFAtT52t8 UN9ekhdAbZsT0i7CYQhddBZGXOQaCYr5nyYiye8oFShDtIV9zlFY X-Gm-Gg: ASbGncsM+OQn4BDeN8Nlt5vYl3UPkKuvPCCTbIREp+lmcU/3bLLe374/2T3fWxh79DA eXerSh0cMsN/aOhzYYKhtF8gnuiTOmgRtApyp/lrNL66j1gAdUuA6JhBNrKihdaGtHZ+93HBO36 JMHp1wAJKCUvg+SX7p753zuE7BqD9j/qz+BhoQg11ZuvkiFsw+jnFtUvQQGJmSBZkSUxeVo+aal Ejt0NrmLC6Si/WYpT9Iy3ERAlEH1QOJlWywivJBDNBrXgCEranGiEe9REGgQ7LTPqlyVv9v8Miv tMLriLzjmD2sBstSVsE= X-Google-Smtp-Source: AGHT+IE2Z+B1Krso6luH/4yPviboZj8IyJo+B/qcwzXb5cbk6ZRxRibM3UAtpOStFwEEtdmotg2skw== X-Received: by 2002:a17:903:188:b0:215:b9a7:5274 with SMTP id d9443c01a7336-215d0050befmr100072295ad.26.1733359141346; Wed, 04 Dec 2024 16:39:01 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f68c2asm1265395ad.283.2024.12.04.16.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:39:01 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 02/21] alienware-wmi: Move Lighting Control State Date: Wed, 4 Dec 2024 21:38:36 -0300 Message-ID: <20241205003835.2184510-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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() And use DEVICE_ATTR_RW() instead of DEVICE_ATTR(). Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 73 ++++++++++++----------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index b3a73fc43b3c..b1ac0e393180 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -545,6 +545,44 @@ 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 +627,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 Thu Dec 5 00:39: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: 13894623 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 BAB1C10E9; Thu, 5 Dec 2024 00:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359174; cv=none; b=XyplJubREUD4UdSu0wrTc94daarXHaxP/T/KwEADygOEyakcxDrcVzGyaK0fgsmGJU6aWZYFy4HkiyveuJm90gYqZIvwHdZRh7STgXplcB/rbsBVIa5rTM2UrcMwKWnhhkmUPmQOgC1WmqNnGZbM4don+C9RGTuuzFihqQVIryQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359174; c=relaxed/simple; bh=oiDLwOSIfBhfscSAX3ujLATZAD80iLz59OcKQdAipdA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFmJr2UbIHISVE8MRv9rmEmJZpGeSik01QFEyv2jCLUyqgFFp+DjAKYJPFHv8IjCFrFrCgjKjB4vAIf3YGrTfWfcwFfI/8VVYFIWob00PcA13hMnL9vopPqoKMVR6+mq8Xq3h8gODAVw1osFlhUYHW55Vw64PnjFqXzjEWAh+8w= 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=I86WDNOh; arc=none smtp.client-ip=209.85.214.171 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="I86WDNOh" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-215a0390925so3637015ad.0; Wed, 04 Dec 2024 16:39:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359172; x=1733963972; 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=Chv20732mrKM1AkOSSld1MdFCLH0yzZTS/nsjg0l/bI=; b=I86WDNOh5zMSuUqgqoykMGSz6aAcyPfxpEWmlGueCyUs+WS4eyZlEYQdyAcgp8hPjW kQHKCQkscoucd4eGcyhDVy1vab5TrG6TB0CwbEALKljzjI67VVGQzxzltXjDKTAyYPfx no5d+wp3tIZJAfgxi/bCOGka4h8gNBPwSoR3qBBRpb+lYmIFuvi7uTWFCX/GAvIzMWZ0 5NPLhciBHxoQs6/weaxnmDw0yGxBaWpBoxaTbNXtXdGBW884f92AaC2Bia69z8cuU2P1 /+H0W3ucY4aF8EgGs1g4SPYRHQLUBYhJQy7cz9nZUT0yrWYFRUPTQ3qoYlTPYNfXGp07 v87A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359172; x=1733963972; 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=Chv20732mrKM1AkOSSld1MdFCLH0yzZTS/nsjg0l/bI=; b=Pi69oFQD65NvLCCh+67jIKBw4TSdRx2od8B27t/zoEk/yeomqMMXO5MIA2Rv+AghMi zBflQ5goxt3mCI2Jx5bSjvuJkwSG+3sgKd1X/6mS08jnCK9U54WtWudX4eaaGdJbwwc0 vXx9TtD+OeSHDD9I+ZrEaJufBklPPsvZ+hYa54ea59hC67Im2Vc+6wjH6y5B/n1R+Rjx ycYas8nq/43MsOSfILaVhxPG4NLYigEkKsDS7qMlJji21Gh0n2oWBY5d2HqjRKOcVwX/ S4FwSH+q79eq2mMeGuX58hckAlMR0QJv4B4GDZcZJUCqCxHRo9jUIYOPUZakz7xZ1V4q DvVw== X-Forwarded-Encrypted: i=1; AJvYcCUNfSdJsBivy7qnW3XtFfsGH5HKrZoRlyAv8aKhM9P8whU/Xs5YdpkejSUyfFG8TJ8pe6U6pTJ0eBh9Q3OE/WZvlWIfsA==@vger.kernel.org, AJvYcCXSZz9Bi8S1s4hcba01bQXQ/XbaESSPQS7xadOo6qFwoPry5e9MtquLUmuT+KuhjyxX3M5XjAPKltMpm6E=@vger.kernel.org X-Gm-Message-State: AOJu0YyLDNmZjmqGtMAM9AFcsC4I3ifx6zgBehbsz1VvfYqASTpc8eNO sbJL1RwHhd3/w3vE93W3Fp14vVA9XKVvAtolrHia9Rrxf/UexD/i X-Gm-Gg: ASbGncv216FUH62WnV3hRDO3kseGnJLcB7hm2hrjRy+9pRajl//2KjLs1jf9HoWYWcX cOO2fSEYsfyO2aWwqJPzrr0r8VeqRvTGZm3FD6cxhP0fn/d1vIfAIeumxA6dY7ds/CRV10Nzqhh VoHVMmg9XBqx2Gw+KaTGq3ieZgTjxbgp2RmWCNjAHXCDK+AwF50N50zX/ruwk/KUKGVoQzZ+u64 WfuXaHKBMWNnkS45WgZn3Uv1UeDMqr16dlCmD46ZxkEi9tx/HfugoGFaPI+zVh/RaZvIySh7diQ 3XyiHQpoCAusjdwKRtc= X-Google-Smtp-Source: AGHT+IE/YU3Qk1wNo1krwWt1NDU/wozjOIm2pvdy4P0U/qbQkmBfa0fvehY2lP0ZeEqOduOpX2Ve5Q== X-Received: by 2002:a17:903:41ce:b0:215:5ea2:654b with SMTP id d9443c01a7336-215bd1b4981mr123623045ad.1.1733359172069; Wed, 04 Dec 2024 16:39:32 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f09167sm1285225ad.200.2024.12.04.16.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:39:31 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 03/21] alienware-wmi: Remove unnecessary check at module exit Date: Wed, 4 Dec 2024 21:39:07 -0300 Message-ID: <20241205003906.2184657-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 b1ac0e393180..115b3aa5637b 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1258,13 +1258,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 Thu Dec 5 00:39:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894624 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 81A1423918B; Thu, 5 Dec 2024 00:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359202; cv=none; b=olJ9zk22Umw+jmkn2Yq38qWXilnJ1DsNOCXq3dZtG6JvvGwM2YfXTo5x/4jEG+OScZtFTVZCxGN2fRwlS7WK4npOnBA/z5bS09P4up6sPVe/RRu1pTNmdl8OlSNl+oYanHcd+5LwFMNJUD1UOfPAd1lnCo6yb6dX0I9WHsqBS4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359202; c=relaxed/simple; bh=eB6rqDQZJqYeQ6+a6L0lQmoGUOd81Y85RyheWlqsR/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TM07PSV37qmVlGr8cbW8Vn2yEI9u+NGunFtG6q4lrvUto4j0D5pvOu8BYXzKRKK9TE+c2TIaC9Kqh93pYg1P8I4uPYaVsq19VWKilpJVt6XbHeo30oK+s6NmUNRO5AkfjFpcPtvpBxuEOIBe5d33vvCgZFJLmcs+sm44q8c0HCM= 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=WMJJ/gzM; arc=none smtp.client-ip=209.85.215.171 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="WMJJ/gzM" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7fbc65f6c72so381300a12.1; Wed, 04 Dec 2024 16:40:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359200; x=1733964000; 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=P+Jtuvl+mnPWEufHbehoFpaa+naDAoewS2n342oQAfI=; b=WMJJ/gzMzeQPx8dd/Cq7adGfp/ZjaRDUH67QvRvl+N2nW6ueZYz88sFG0zXRpyNmk/ VzjWbaY3w0i3fsYfHtqj93G+u91GOgKYlh8zYCgs8/09h1iMyvc3/FLvo5O9g2pG2HXi QXLm/79xfFlrlZQdfrEq4MHsDl/AIAePdZuGV0KuF4tEXSzU1MGyoJAhPEWpKwORV/2D rc6ZofIdtet/R5dQHZDkfOcuXYZRAre1u23ZrbzKcCmxx0f3LqFK8gqSIZ00lPHGk2uE KyahMu2KmgVXGVdEFw8wvs+EqUDl4qsO7Vp7ZbzPRHvGhvvSVcpI1+OXIhUgglMJ6MR9 l/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359200; x=1733964000; 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=P+Jtuvl+mnPWEufHbehoFpaa+naDAoewS2n342oQAfI=; b=H42quZCBAReO144QRvB6uHR3AnZkgYQWLVetPWWulM1ycGio/4Ygf8vBOfO6Im8lzE OOx84Jd5/yYea5+hv6zvoprCVck5N4NcV8ZN87AS1W5bOLU/IDt05f567fOK0uDmb2cu SufPXnrU8VgI6gpAB0xj4LX6ixphznwUDQuDH9gDmOxv4BSVNzNpJFDPv1gYaEDknYGF v4hiBkx/6fDnvIUk4vrKpFXxiiMnG3ccgFCMwxpuiLpMF55Z6pnyjdcMg9ng0oN/lrzD FVJ89d227OkmGsZtrpq+uguJ2F79hfhfbAdHE2m6FExkmWkrlQp18rpEdyKXuvGZMWFD 8Vxw== X-Forwarded-Encrypted: i=1; AJvYcCW1YFzW6r/h+i+RKkWEeBU3PETRjW1GBb+KMkfTNIi6HwAbw1gdwKL9xfuphDa/MHxTqdJZYrrDNXb7g8E=@vger.kernel.org, AJvYcCW2kiy5M86XbdYGmOd3l5oygVraCrzaq8HIR80kq0vicdjETV8+aklph0U3J694emJNXkh9lNAi9of/qx82OtzEi4Dbgg==@vger.kernel.org X-Gm-Message-State: AOJu0Yy+ADYSP6/vPirK2u751nV4DOkl1wkkR0o5z81MRZL/DmNag6/2 mUPg9NuGOcwxboZHqa/2Z50WaPugRLQiuezG2bH00PkHK0ivLLCy X-Gm-Gg: ASbGncsAnS4QZWpv5mw06DIUDGVR79zyrF++nmmZbZQ4XmQAe+8t5pIFSvpT9Qhrokz wJvdtFG3GE+r9M5qYWfiYalKPdagtmU9SoeDVrw9QSGfkeSzFl2H7DNVf9lB1m6R7Hnq64eIADi VLSLyIkONipfxYufytuYGfoSJxhL0T30gQbk6FxetKdEBdhrFxu/dBxOIZosHFnjcQmERrm+VAa h8OCvzNM05cIfu2dh2Sj8oFw//JeqCATxwKYAtHpdM1P/xijQ6pmZEH9f9L59ik4gWid8xc8ODZ xb7l1RBTfORDvJmkMjY= X-Google-Smtp-Source: AGHT+IH4xnCC5Pm95+cvkoaE97WlquH6efSLoe+E2GhvRluDbGxXzaCqsRAf3et/tLxQHY4s4Rcz+w== X-Received: by 2002:a05:6a20:430b:b0:1d9:c78f:4207 with SMTP id adf61e73a8af0-1e1653b7c9amr11564552637.11.1733359199719; Wed, 04 Dec 2024 16:39:59 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29c5abdsm100574b3a.35.2024.12.04.16.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:39:59 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 04/21] alienware-wmi: Improve sysfs groups creation Date: Wed, 4 Dec 2024 21:39:40 -0300 Message-ID: <20241205003939.2184799-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 115b3aa5637b..78bbb4ef4526 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", }; @@ -803,6 +797,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, @@ -811,25 +811,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 @@ -858,6 +843,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, @@ -865,25 +856,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 @@ -936,6 +912,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, @@ -943,25 +925,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 @@ -1169,6 +1136,23 @@ static void remove_thermal_profile(void) platform_profile_remove(); } +/* + * 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; @@ -1208,24 +1192,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(); if (ret) @@ -1242,9 +1208,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); @@ -1259,7 +1222,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 Thu Dec 5 00:40: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: 13894625 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82B3A17BB6; Thu, 5 Dec 2024 00:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359228; cv=none; b=sWEfe2bRPFTXzWqEhjnWUjEsceikLPaZKGQDhBhYpVU2kMvniAh57hApUOaexYgbWeQxaYZ6P77uowQnA6VL7NFn72A/+uCtToYXIP2enqPaHl2GjlWrujg8yuqOqvcPPKRwm0IVbomzTqLLb+9ltx9VEl5OmXMXmTgMcueC8I0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359228; c=relaxed/simple; bh=P5/kIGbX/bFrFqpM9iYhUcYT2ADJ5IEqutf5VESuf+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aQ03NN24spNHAgbhw1hyLdwbi7VESSUwtYv22n2+pHNphysP/krJ11osR0QJKkGc/gOIIHb5mNjnnUFhVmPvtUSgF6LV5AJzkeY8jNck/9UJDnlOUbU/F6iDwzRrPEmqxr6kombyhvR7tNroHysSMtgWjTrrjQlx28GOmVfel6A= 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=FgCWQsFg; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FgCWQsFg" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7fd10cd5b1aso291161a12.2; Wed, 04 Dec 2024 16:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359226; x=1733964026; 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=tK+ClSQ6UY0i3I0k7CEH05rGNOTkJditxK5OuDd1s0I=; b=FgCWQsFg+VFgbvayK90gvKdxmuOZu6yGC53RQcuKtiXh+vfrnoJ51brxQRXM1+Wij4 YsQvJBTPZRrQPND+/c/Zu5CXjPUsVzQbDJtN9279u60rz2LU8x8D7D4/TvLbBWTHQk8A dRYAG6/wDSL63Y+QHaBfsL8dooNGjA90fhGdorxZ85fJRlyqYdR3PrhqrZpi/Sy0WNa9 39cnfy596JG/M8zEorcH6/F68d9zKRlEQqbwhujz4ooKnojWbOX8ViNmqgGoNfxDUUUe i3ybvYXLIqvLOgbQ6/oz+ZUQpZLbqHnuYXFQfuDlslpLZIcxHm5o9oEkkxOKlYynWpef VEtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359226; x=1733964026; 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=tK+ClSQ6UY0i3I0k7CEH05rGNOTkJditxK5OuDd1s0I=; b=Q9yuweVDI9yytdCHvCqbU2kaAeYGX3F8sxTdl3D+QV9QIf9brWmCGVxZ7peaaJGqDU Pc0ieJk7OuHzxQaV/GZbnQYOAhGi1bAwK59WrujO+H10VATZZo8px5BkaG7oztBlLqNa WZJx/DRVmROeH4rk6jWSg3jmnRV3g/5XvBd8aUGli9XhOyo/u3C+u6VFJYXxKchWQDe1 xyfqkyiiqoiwKKskmrU0FssCrmaZAuIh03zju30KwVrBldMhKSayYAgpCBxQf2uLsZf2 yYUve97VWjfc1sppZx4EDXcINYdK5IC6NkoIcn73uWlktgEN/7V/mUWpqfOhYIwwBHjk oVBg== X-Forwarded-Encrypted: i=1; AJvYcCW6nZ9QkDNmSLekaFBWXSOdwhM+WUoIDk6M7l/wwzy3VxSO5h9vmY5Z0BFEn6A2z2kb3vj8xY6SvTEO1qA=@vger.kernel.org, AJvYcCXgrPPy9VNIM1hEYfoUimVTBUc80fMx9JdvuI40c8piILFvQ2WmZDw56n+wjU3gGGCLD4TYf/LrLJmk4eCaNpt0jRe3Dg==@vger.kernel.org X-Gm-Message-State: AOJu0YzHNHInbpgZsjd62hNd+m0vHG1wThirvNk761/hJ538rwdY1m5F 4mTFL6ZFCKm8y6Z/wYRH/HY5epvKtfkqf2hDPmOUT6bik8wpr2/B X-Gm-Gg: ASbGncsM1/7uCIfXpU7AIXkndiYUpb/A8pp/Trvnca6shUXUIftiP0ofjUsPUwUTQY8 3s1LPzu0fu3eZniH5mat9BXDWeY3R3NAdSU+RPFAShq6YDd2XMTGYWsSnliiDpZENFesLAmPpC8 JLqFWB2ht+Gzpr2Txk8+JYO31bV75iVCOf3xfjDIaY/kvjnS80NEvialBymWn9BsgF1DhoIBC5a y/am88jTC7UFDuz3uS9ln0DsWqb2Lu/qewrlkBvKR+IItwyWS0HhX/+VSgeZFP4rVlkzOIdwKKr tchruc6UCg6au6zemFA= X-Google-Smtp-Source: AGHT+IFNPbUuAutZgb6Iuc9X6KMHApQCqeBS/cbE9Pubfhlc8t8WZp25zilDnMqjm1Fz0yAqeOPxtg== X-Received: by 2002:a05:6a20:734f:b0:1e0:d3c6:b453 with SMTP id adf61e73a8af0-1e16bdf9bafmr10838383637.10.1733359225807; Wed, 04 Dec 2024 16:40:25 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd1568f286sm120319a12.11.2024.12.04.16.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:40:25 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 05/21] alienware-wmi: Refactor rgb-zones sysfs group creation Date: Wed, 4 Dec 2024 21:40:06 -0300 Message-ID: <20241205004005.2184945-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Define zone_attrs statically with the use of helper macros and initialize the zone_attribute_group with driver's .dev_groups. This makes match_zone() no longer needed, so drop it. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 137 ++++++++++------------ 1 file changed, 60 insertions(+), 77 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 78bbb4ef4526..fa7bbbb07b86 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -378,7 +378,6 @@ struct color_platform { struct platform_zone { u8 location; - struct device_attribute *attr; struct color_platform colors; }; @@ -411,16 +410,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 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,20 +445,6 @@ 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 */ @@ -510,12 +489,10 @@ 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"); + target_zone = &zone_data[location]; return sprintf(buf, "red: %d, green: %d, blue: %d\n", target_zone->colors.red, target_zone->colors.green, target_zone->colors.blue); @@ -523,15 +500,11 @@ static ssize_t zone_show(struct device *dev, struct device_attribute *attr, } static ssize_t zone_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) + 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; - } + target_zone = &zone_data[location]; ret = parse_rgb(buf, &target_zone->colors); if (ret) return ret; @@ -539,6 +512,32 @@ static ssize_t zone_set(struct device *dev, struct device_attribute *attr, 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_set(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) */ @@ -577,6 +576,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) */ @@ -624,7 +650,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; @@ -634,65 +659,22 @@ 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; + for (zone = 0; zone < 4; zone++) 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, @@ -1140,6 +1122,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 Thu Dec 5 00:40:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894626 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 72B7D23918B; Thu, 5 Dec 2024 00:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359249; cv=none; b=ctVeIO8yK+e4Bg+L/yYnN3eTmPevSO+Q7URENXDMceo5821Qc6ANIXhjzP96Ep0jBrqDYSVJLd1ZfkycxFlfU6hXhD0YP4Omqw/QXQfp51O6BpiPuCIgJjxWqvsc3Rkx5W8dEVUqspU0xRoeP1apXLlyRvMIe8OWakO3tS4MwpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359249; c=relaxed/simple; bh=kPSO1E/lLVtN6yh+rrWnGkXwFSNkrrG+jVBuQloc4cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AVZpPqiNS22xzWpJKIuva7KmELq0OuxxnkdSupINqaZfNsEesKUnpcectBm9pkKfekZqeb9Bey0cTCpQ+Qe08Y2ZP3fn2NoCLwj0tGnFkaUdE0OA6vpefu5vUeDEgzfONAcTo+ASBk7A6oIJpE4F4rRXOyg2RDA0c3RrUw+23HU= 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=S2VeiSE+; arc=none smtp.client-ip=209.85.210.171 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="S2VeiSE+" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-724f0f6300aso456437b3a.2; Wed, 04 Dec 2024 16:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359248; x=1733964048; 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=W0t/W1hlV7cvper6FsrFCx1e0KVtudw1c2F0t95m3C0=; b=S2VeiSE+SDZUebVR8lDYbg4s4C+g66P6kLtNKdbzHVcpkWSiVnQ9F6+rW2AG7P0aam Ltxd7Iz+6Z+U3IHQXtv/gIQrLgy8RbVjH3rnqFXrphAWGZXHDjQ6D/F71Kj6nXy0+3Sl P+hwGN9eh/4uBkp5LmkrtAX+cuJGfcG46iwwZRcuFRWB8EXElMeFD6uP3V5J6IsVojcq PKLnb3tPOHhoTxatKvA1Maqt7fTcT7Yq6EWVhyqWNfbFsnQK38KV0Jm//aC9MUWpnYOi e0q/wel0JKgpFbEdx7viOEwJYbbP9n0UljrUQR5XBJ0c3Dc1D8TI0S3ka/iM64gDDWDT w5UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359248; x=1733964048; 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=W0t/W1hlV7cvper6FsrFCx1e0KVtudw1c2F0t95m3C0=; b=KeHCeccwHSOlNUNfVvjeXn+5TUubAghZQt7PqA8hy12XiTn/QEhVpka5cNS4dhoJ8Y l9ifCkzOOX+8ZEKl8XZgxIBMOdiXErfwNZVoOLjLTs5ZxNwYiWNvNBINzqCKVpE7S1LB qh27sQcbN5ypIJMCM9XZqRoXeeTCkNGVLXfISA52aHkGhEex/gpc2e1tY5f2M82I6pKC vxMm06sBfe6lQpuxPdzOVxT0vuCXEh3dV0qtMcdtZeIQWScjy4xeJqmLBF+hqDshJbnW nTn9cyU8FQlmozJV8uJguf69t2e9rsDB3I5WB7bdUzYjWLFt/8uTEru/d2sOIXfeF2zz cJSA== X-Forwarded-Encrypted: i=1; AJvYcCV23/ZSxLq2TaX1leHhBhFB15inKuakgV71e6WwIA2i1bbiJCh9goqc9qWpaErwcUYxMGjp+F+gVlPPzD4=@vger.kernel.org, AJvYcCXYFza+AOxsrT6kLltUMi8w+l86NM6hv3P2DPcDCfIGvern4DAycij+tde6jJQ1szywansCQNo0kM/HprQnLm2f2IW1DA==@vger.kernel.org X-Gm-Message-State: AOJu0YzpAw32Pt+kATkCOACPBsIlwiUizJeczZ4V2IRgC7rehaVBuJ6y ifCyfwW0ZdVJVB+jA0pXmF/8ub8KY/YpVE3TLu9pXVdw/PTQclP8 X-Gm-Gg: ASbGncsc9Nf5rUOpEEVKSHFeUIJmHLAU3S7vJ4rjmsV5cSCnHI7te6KaRUAGVocW73B T1UFevaX3u5c2y8igapL6nFjTVo4A5M8A0DnAyW2+s5LfnHnGHt4A68Ot262mTrCaU8c/fdbruf vTs89NBlYTq6AZ/g8f1WX+vZ0QHuuZQCeb4AsYaoQfTkBrPZ6jsVwWKshfWlhOekNAk6cY7zAMo OtvYWBQjGCfmfis1Rs6h+gvu4xORL3yxPW4zrYvUAmUPiMyTjVh5z1Kd/0V935wTnV/uVTNA4Z9 WU0OpFM6fFdSw+HsYYg= X-Google-Smtp-Source: AGHT+IEDFvqC395HWoYIlU7UqoUVGWpXGJ1nTH0OWh/4JFA6a2gVPJex9Pl8pZYd31foDETfkKCiBw== X-Received: by 2002:a05:6a00:3c88:b0:725:973f:9d53 with SMTP id d2e1a72fcca58-725973fa0b5mr3891300b3a.15.1733359247613; Wed, 04 Dec 2024 16:40:47 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29c5719sm104068b3a.27.2024.12.04.16.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:40:47 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 06/21] alienware-wmi: Add state container and alienfx_probe() Date: Wed, 4 Dec 2024 21:40:38 -0300 Message-ID: <20241205004037.2185104-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a state container and initialize it on the new alienfx_probe(). Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index fa7bbbb07b86..ea848937b579 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -409,6 +409,14 @@ 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 platform_zone *zone_data; static struct platform_profile_handler pp_handler; @@ -1121,6 +1129,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 0; +} + static const struct attribute_group *alienfx_groups[] = { &zone_attribute_group, &hdmi_attribute_group, @@ -1134,6 +1168,7 @@ static struct platform_driver platform_driver = { .name = "alienware-wmi", .dev_groups = alienfx_groups, }, + .probe = alienfx_probe, }; static int __init alienware_wmi_init(void) From patchwork Thu Dec 5 00:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894627 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.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 E073611185; Thu, 5 Dec 2024 00:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359269; cv=none; b=CwHYCquFCHgKv/yTjG9yzqVx/8UYJ9CisIztiLtbuPHjCfAHomsxRj3AfGWZ19GOJ2/PZCY//eakUyq8nFNRTDzF87c8HSvcC9/Fd2XNpfC0HVEZ4IVNg+DrhHZW6AYlICDoERi1oU/dF2Iwldg3tYXNwKf4yVnruLOuuXb/tOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359269; c=relaxed/simple; bh=UccVoGu94NgUgMYRUgrC/+FtNNEsujhaYb2fbha/f5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RWeVZ0R6ZnQqOnn2P704grmeb0CHPjk/9tR+2UPESfldvkW/49iO3hL5pinrMCLLeOoraEmNgWj/b1Y2SxtyXm2huyT0MrZmOCElqUp4t4Y8kiax+7DE+UbiHTpQ3V2j2Xpgn1UvcftIYT2tJgsFEJQUrNcKB8toQGKrmFFfbxU= 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=hyHbQy4F; arc=none smtp.client-ip=209.85.215.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="hyHbQy4F" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7fc41dab8e3so323859a12.3; Wed, 04 Dec 2024 16:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359267; x=1733964067; 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=65OcLr4FPhGXkdHEMtCl+2bLn6t3Nrnc5J+Fw6WgdjQ=; b=hyHbQy4FeMQ3npNJe+jtCct3+3xoHZCNS8rUysF87oa4hsSNcdLbDRb1ohIGHP5VL/ cKcmPO6fff6b8kpQV/kqpobRJfpnTE/AzdBM3mzmyb5J6dLfERF+6GnQBs/qAl/CEISC 6I4bPEnkBIf5MoAf87VNRe9uzxdG/goCaAxZcAG7eshzpaS+oo+HMv8d43rHJVzGCYz2 Y0hSmdeoyBGj1g+NIwSiRwHeebBA2GyJI4ImvtaaS5arUqQgIEYee8EkLjYU4/JlxOFK gGleACzJcYy9sYgxYMOMVLFJ8ykn7QsaRAFdgWWnBN10aog82s8aVzfvulu2y1ocDmni c7sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359267; x=1733964067; 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=65OcLr4FPhGXkdHEMtCl+2bLn6t3Nrnc5J+Fw6WgdjQ=; b=trQF1fk5G129XzQsT4j38F5vYyb57eYJm1V9/wAHKfMaUgkgz7xEcL2BMmF5JL3Zyt jyiH99YEtysHQyMG7NdIn9bIjbNgS0woN8x4PQ3G+8wgEPf0JHiBDJ1qYI2E4DnouYn8 vFlkoQdhMqRG7v+EpmmSms4aDMnvkusYTx/kZi6PUr/fwfSxUYDGTIJddVVEZntaxu9g FzL72vUuYyagJbiB7uAsxfYd+HKSzwYwChTwNyxivr8jEHugigCsBJipKi7OUSrZFTWf 4JS4bpeP8VmaNajo2EtJcEKub85Ly3wyjj0Em0Podo9tn3PTfC1kktP4txowzRLJ6teB jMHg== X-Forwarded-Encrypted: i=1; AJvYcCVgFnFSsbUp+6L/OECSaw0j0RWiyVgUSFvXuKRkoPrxffLJgh58eTh8sKRQZjw+CW/k0F1i9Q4I/d+8Wi1Fzh6/xs0B1g==@vger.kernel.org, AJvYcCWAmTq4UT6OxwE8jvXtNT0hNgHeEp4IrVjTTft4+PYlKx3l3UrFqqCXFjoVXjhwYe0GcpAI6P753Jf5j40=@vger.kernel.org X-Gm-Message-State: AOJu0YwD8/FiI2ahnR9LkDVrfgF18dn4JJbjQ0YRjMFNbg1eLtciWmjN 2diziRTJImRTKI70ARamm4YypkZotlnOkTJ+8T6jVGGTSsJFQCxblQPXeDBi X-Gm-Gg: ASbGncs6gcUPInC+img/okWTFEaXH6jVM2lV705379A7n+K8hxOdWsF96CBOg6Vqv2v yxCpjVv6oKgq7ONiztfdcU+shurvXXBPTcRMgJVrIyMehXe+mUYLFSixqJiwftUInqhZrTjk/26 iPycpLoHdQlmhjR3dAysTaGeDz0FsSvAbtH8cZSWQUuTiVK/X51Hyr0k/CMad82okIFB6aqKE6f NNeOmPHEgxYPpo/CAxDWP75zUhJJZwu+QzEnQdRXO+y1YVos/18OJ7e51qLacjAG7qGFytG5nU9 5J2Mw4F4dLZDzzKSKTw= X-Google-Smtp-Source: AGHT+IHzx1P9kzseo/UwCY38/Rcz2V5O2hA1TN0uUl8YRb5ST4Us535wNDltWa/UcX/gg1SJ6lbtOg== X-Received: by 2002:a05:6a20:6a04:b0:1e0:dc7b:4ee9 with SMTP id adf61e73a8af0-1e1653a2a4cmr10496896637.8.1733359267078; Wed, 04 Dec 2024 16:41:07 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a2cc5482sm94414b3a.171.2024.12.04.16.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:41:06 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 07/21] alienware-wmi: Migrate to state container pattern Date: Wed, 4 Dec 2024 21:40:53 -0300 Message-ID: <20241205004052.2185242-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Migrate all led control functions to use the platform_device 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 it's no longer needed. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 123 +++++++++------------- 1 file changed, 47 insertions(+), 76 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index ea848937b579..e5e4a7b4e9ca 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -376,11 +376,6 @@ struct color_platform { u8 red; } __packed; -struct platform_zone { - u8 location; - struct color_platform colors; -}; - struct wmax_brightness_args { u32 led_mask; u32 percentage; @@ -418,13 +413,10 @@ struct alienfx_priv { }; static struct platform_device *platform_device; -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 u8 interface; -static u8 lighting_control_state; -static u8 global_brightness; /* * Helpers used for zone control @@ -456,7 +448,7 @@ static int parse_rgb(const char *buf, struct color_platform *colors) /* * Individual RGB zone control */ -static int alienware_update_led(struct platform_zone *zone) +static int alienware_update_led(struct alienfx_priv *priv, u8 location) { int method_id; acpi_status status; @@ -465,25 +457,25 @@ 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.state = lighting_control_state; + 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 = zone->colors; - 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 = zone->location + 1; + method_id = location + 1; input.length = sizeof(legacy_args); input.pointer = &legacy_args; @@ -499,24 +491,33 @@ static int alienware_update_led(struct platform_zone *zone) static ssize_t zone_show(struct device *dev, struct device_attribute *attr, char *buf, u8 location) { - struct platform_zone *target_zone; - target_zone = &zone_data[location]; + struct alienfx_priv *priv; + struct color_platform *colors; + + priv = dev_get_drvdata(dev); + colors = &priv->colors[location]; + return sprintf(buf, "red: %d, green: %d, blue: %d\n", - target_zone->colors.red, - target_zone->colors.green, target_zone->colors.blue); + colors->red, colors->green, colors->blue); } static ssize_t zone_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, u8 location) { - struct platform_zone *target_zone; + struct alienfx_priv *priv; + struct color_platform *colors; int ret; - target_zone = &zone_data[location]; - ret = parse_rgb(buf, &target_zone->colors); + + priv = dev_get_drvdata(dev); + + colors = &priv->colors[location]; + ret = parse_rgb(buf, colors); if (ret) return ret; - ret = alienware_update_led(target_zone); + + ret = alienware_update_led(priv, location); + return ret ? ret : count; } @@ -553,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"); } @@ -564,8 +569,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) @@ -575,9 +583,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; } @@ -634,55 +642,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(&zone_data[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) -{ - u8 zone; - - 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; - - zone_data = - kcalloc(quirks->num_zones, sizeof(struct platform_zone), - GFP_KERNEL); - if (!zone_data) - return -ENOMEM; - - for (zone = 0; zone < 4; zone++) - zone_data[zone].location = zone; + 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); - kfree(zone_data); + return priv->global_brightness; } static acpi_status alienware_wmax_command(void *in_args, size_t in_size, @@ -1152,7 +1131,7 @@ static int alienfx_probe(struct platform_device *pdev) priv->global_brightness = priv->global_led.max_brightness; - return 0; + return devm_led_classdev_register(&pdev->dev, &priv->global_led); } static const struct attribute_group *alienfx_groups[] = { @@ -1216,15 +1195,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: @@ -1239,7 +1211,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 Thu Dec 5 00:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894628 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.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 4827223918B; Thu, 5 Dec 2024 00:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359307; cv=none; b=o+GPWkN7g7iEPzHRoTj6DVOpgsTa56X2AeMeo+fI7yDll62jChMzy7KjggIcpMm2dREJJhTAw/BAp3hssO45Hoydl3RDXapm1r9GELSIZ4Lvm2HmIkUPPB+VDnRTzEQosslhEn0mGBd9Nf1WxVUgDoG+vtElnxY4kkENd+2fWlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359307; c=relaxed/simple; bh=idEFuKUfX0GdLxKRG884CM/bWcChZzON4b29M8UiufI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSweUstl+lQMygSj3iM7P9Ao4zSCBKeQckWSYPTnewMa4OJgI2bDA5h83hr7lQYzGs9e4/kny57oRaj/RQTSKm/VVMYmAH7oy9hF9Ja0WulTmXJJyoLmkwZojPURxnFXoh8s6r3JNHtMxt64pNOb3ph3Eklo5lZwd9c4j42nq30= 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=i2PnjjUh; arc=none smtp.client-ip=209.85.210.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="i2PnjjUh" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7252f48acf2so326542b3a.2; Wed, 04 Dec 2024 16:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359305; x=1733964105; 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=NgR2RY/7h0XKplR8sv56yktKeGsrAmbG5SmI2iAFKxU=; b=i2PnjjUhzvFOcsU7JT8Firp4rXRscvrJORjq9kVrxqH4U6FXMwpkSqj26kj+eh5YvL 8LVqiAx0c+q//OKXio6bzT41tO830SCYP97JYQf8hGdtR0/cWplu/ab1LYCp1hUIBvEy ktAQEs9mpqtXzRhWEA+TekNu43wFG5ZWW9/7d/9/eA6aNDh4uEXhnXhs0KnQMT4uLxTH MNZjnM7MxNmsDM65YBHoeYu7VkMF4TqbV0/1/ZMimamSWHrGUlTgdYf17nF5cvxyqtfr bnehtIoUfT8pV01XfYL4Pnsn0c/t30KZBUoYMRmGi0n/6LIbv1Y6Facg/tWHc/jUJWTe Xl2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359305; x=1733964105; 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=NgR2RY/7h0XKplR8sv56yktKeGsrAmbG5SmI2iAFKxU=; b=EHE4JA4f0ITTV/vtKMP5KNVbUIa02vkO1SGSaxSMi+VHO6iIdWARAtqov4i29sPUX4 Lao8pYGzPWWDIgTJR2bgpDkhZ2tvBKhNX7QgNSR9vofj0EtSLvHToXYvj8AHcWGNmtQu BlgRB+INEws5il3BfnTBbH2HZKupSRH3hgd9JU6xzqtkfDO+GjoDEKxm6xgX1Rzw5NFn 7sgJ2QVsti79UFblKAriacptEYaiHAPOVj5YFS8vgS17nN1b+Igcr9FbBcYskHlYFgs3 CcWhLLYtvnHGOsyo1cF34BA+TzwUddX1ZHOMq1eEjAK3DvgGhbVBhoJQ0vEupMzSJ3pw 7ihA== X-Forwarded-Encrypted: i=1; AJvYcCVWDSt3qZVEyWpOOgIh9I4BeucRQt8T2s4uTEAuXu0Zq2Tu7y7ocHEDnskbqZg0/e8ZPof9ZvmH6mdrvkM=@vger.kernel.org, AJvYcCXbEL8o2ZrF4lgEFYgb0PRFV/EYodjzJ1aa8u68agCbEXV/PxE2W17Gl+WjbR6cxD3wkvydWu6wSsYTItDOreAZRiMyTQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxmeEsIhsvLQ+f8t7q9qG9KVq6DeoWjiZR9FUIcj5/kr/coAkbT EpaEUv7laAw9kjFqHZzk6adcIwkjtza6a1ePwzh9few1L4FGUq0X X-Gm-Gg: ASbGnctkZo1dHEkp6vfsqypWkU5AAIssvyVH8wqfOt0cc3MVnnlLPtVxDS+DsCzUpOw Jk5qsFpETNMZTRDvvB1yC4kLfRZUTBYeGvFieakG6LMzIjkT/B9rbCS3OEbUYRKhWj4D4ATnhst IH2YvKt8Kt3bCGixLezYLG5BElkNt30K0IZFC7Tkhrm23Kv6xtsEledidUcg3t1o1B2wW7j2mGV CvgxCsIiL0EOPhXYXlVdw0P21VXzE5qRW93+/2wVJ4BQQ0AdzmXyvR2+RX5KEoeV8vz/Ivqo/ir 5fionilOrTZnY9Oh9U8= X-Google-Smtp-Source: AGHT+IGQwUfpbct958vNmk6A46ODIykELevFx7EGJjQHU8D103XHHLsrvVSOUdgZmIoY/XZ/im2RIw== X-Received: by 2002:a05:6a00:ad2:b0:724:e582:19fd with SMTP id d2e1a72fcca58-72587ee6238mr10177556b3a.3.1733359305488; Wed, 04 Dec 2024 16:41:45 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a2ca61aesm98823b3a.140.2024.12.04.16.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:41:45 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 08/21] alienware-wmi: Add WMI Drivers Date: Wed, 4 Dec 2024 21:41:26 -0300 Message-ID: <20241205004125.2185385-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add WMI drivers for LEGACY and WMAX devices. On hosts that support the AlienFX interface, the corresponding platform device will be registered as a bundle on the WMI driver's probe and will "pass" a WMI device pointer to the platform device as platform specific data. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 115 +++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index e5e4a7b4e9ca..38e9cb80ae69 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,6 +411,10 @@ struct alienfx_priv { u8 lighting_control_state; }; +struct alienfx_platdata { + struct wmi_device *wdev; +}; + static struct platform_device *platform_device; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; @@ -1150,6 +1153,114 @@ static struct platform_driver platform_driver = { .probe = alienfx_probe, }; +static int alienfx_wmi_init(struct alienfx_platdata *pdata) +{ + struct platform_device *pdev; + + pdev = platform_create_bundle(&platform_driver, alienfx_probe, NULL, 0, + pdata, sizeof(*pdata)); + + dev_set_drvdata(&pdata->wdev->dev, pdev); + + return PTR_ERR_OR_ZERO(pdev); +} + +static void alienfx_wmi_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 device + */ +static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) +{ + int ret = 0; + struct alienfx_platdata pdata = { + .wdev = wdev, + }; + + if (quirks->num_zones > 0) + ret = alienfx_wmi_init(&pdata); + + if (ret < 0) + return ret; + + return 0; +} + +static void legacy_wmi_remove(struct wmi_device *wdev) +{ + if (quirks->num_zones > 0) + alienfx_wmi_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, +}; + +/* + * WMAX WMI device + */ +static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) +{ + int ret = 0; + struct alienfx_platdata pdata = { + .wdev = wdev, + }; + + if (quirks->thermal) + ret = create_thermal_profile(); + else if (quirks->num_zones > 0) + ret = alienfx_wmi_init(&pdata); + + if (ret < 0) + return ret; + + return 0; +} + +static void wmax_wmi_remove(struct wmi_device *wdev) +{ + if (quirks->thermal) + remove_thermal_profile(); + else if (quirks->num_zones > 0) + alienfx_wmi_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_wmi_init(void) { int ret; From patchwork Thu Dec 5 00:41:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894629 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.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 DA8C0DF78; Thu, 5 Dec 2024 00:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359336; cv=none; b=oLrz7rTpKJjs3hRAfQyEQxmCnmgUsCuSvge7j1IyszjR0NIo8FuVgohr4PY6RtpXRF3NpeSD0ch7VUo2HYFbg05VtJ1raCc8jMrN2EZZ7z2/ggQuBM5kAdOEnAW6hKnXlPEuRpl7/AL2RJDaeFjYMz5khJ/baxTdd0ADYf8Y8tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359336; c=relaxed/simple; bh=TYS/+QG/QZOmVmbxFBEJ2sprBGACQgJvbcP+KIaKsyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U2ofo+fCpc8ft4dSR+xUMTrP9FVQ/beg//K89wpahOAri1iCdr+pCLvmPxFGaUY8Tt5SIl5DSRsvprBN8CBnrNgL+WsRWFqxcnOwGopYpDTeNMpJ+c8c6pfjv6d7QWcNrN2n+x17P8Qr8rXE4LSGDZYTTf5Wc01bU5MLY7VVHmg= 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=BUOfSg7A; arc=none smtp.client-ip=209.85.214.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="BUOfSg7A" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21583cf5748so3483395ad.1; Wed, 04 Dec 2024 16:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359334; x=1733964134; 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=AW2NdhokyNp5GT2wMPEkU5inhjkJ9tIPNy2oyF/lZlw=; b=BUOfSg7AWcEoUq/4Y1tcOOnZR7mFeNbud38AKorgShbXU5tiQYW4NYdAo36DFbvSyP kU0oVLQ9BUVI3iF2pAR3OhejmC60c8IMHCsJXb/DaTG/IaxIkLLTttRgeKut7N43fDXT pmrXC+z+Gjx20O2soSh2FrPslI2ygPYwTaHzMp8231Xxj3DaTnpdca3dkDCW2YKlzomF 4Ljr4x8GdavHKD/evp80xUDGOgjPsLGapjZ8G8aKLkeGVeZgPiqaVA5n2aCDaAkUhpXb I1619hBkxIniFwm60KjGNi5KK1hLzeu2rtnUew8mgio2+LPR+nKpopxITPeApu5gdOGT /KQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359334; x=1733964134; 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=AW2NdhokyNp5GT2wMPEkU5inhjkJ9tIPNy2oyF/lZlw=; b=nm7UFC7gLTtmtljpFnuuXtaAJcHUT6V8AZ89bnbQVDr7/y8HAu7Z1e3BqkS9O48z64 vHffmWHoVpvdE6PjXD1KpZi+usoepi+U5Zz6J9Pe4ycwjJsgJamxvNAgYQA0Egy1dM9G DOqckUXxlp28YHfsiunrLRDyT8RD5Bowwx3HwcQ62OuLtX4UT+CrrKzNIvGPyKp4vaxL XD30aY1UwlDCgJfWcZ0Y1gt9ZaXvIde5fwIDg8/vNjPEvdaULdjqNhi4qAq8pcjCRP9a W/uzSoJkxGZRNTsLJXTWs6Tq0bo7CFW/FJenKiEfN05ixVUHUHvOH+me19H4gjLK9J9O Dk/A== X-Forwarded-Encrypted: i=1; AJvYcCUAeujn3DigH8zf+Cp9S+6jtfOMbQwXGwJ5jtbO/s+haukiVU+4K0PtjxJxlhPWo7o3YNElrAHmRO5iWuGsGBRrGeftAQ==@vger.kernel.org, AJvYcCVl+bBdxAeS7WDAr2ENiRCY+vCV5GO3jXWTQgpJsnmsZq6CmImtzptsRoMVZt3vITtZ2x6A+Jt0HeHpO1o=@vger.kernel.org X-Gm-Message-State: AOJu0YxtxEHIhukOPqeaYiEJbwKsUny0g4ieyttOjaEdPD8U0L4mfP83 /0Szg0Vw5YXrvexw8tCRLwy/eAZnPTGSBrUB0MTg1h9TUPXDbW4N X-Gm-Gg: ASbGncsY8SSR+vGOsVDmmydoFrpAdjaIk2AGQ5BMH26+afoXrUCKtDZdcbkiafXjmR6 llpx/+htbCL9AyJKHhH7GDtL941gjQ3OOTedp6AgO2RJtgt9+zDblIISZEcSTm1t1wMR3rg8lOt JNyaA+AMWTyRFmOKly1g323uCeE+CYgHvBGlZJanIYqigBHl0GQSgKAoBZOwjcRolu+HXN+a4Rd 4LifSXAxBhqcl82XkKwwREqr8Qx4aBrqwqmfBsImhrp5lIYERe+GQnxj6y4q7B90WtNS1oSsGKj p4mO4ajjiHC1Z7Kjejk= X-Google-Smtp-Source: AGHT+IENrmQj5DGYVSm3Q09qGmnTTrno1aaNZTTYBKZd9OTNDs9cK+tqcXUkhkUUySX2J4NvRb6zbg== X-Received: by 2002:a17:902:ea0a:b0:215:7ce8:1360 with SMTP id d9443c01a7336-215bd1287b4mr113659325ad.33.1733359334057; Wed, 04 Dec 2024 16:42:14 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8e3ea7fsm1412625ad.49.2024.12.04.16.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:42:13 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 09/21] alienware-wmi: Initialize WMI drivers Date: Wed, 4 Dec 2024 21:41:51 -0300 Message-ID: <20241205004150.2185529-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Usually, laptop models only support one of the two WMI devices, however, to avoid the risk of registering two platform devices with the same name, the WMAX device driver is always preferred. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 48 ++++------------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 38e9cb80ae69..34fb59a14bc0 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -415,11 +415,11 @@ struct alienfx_platdata { struct wmi_device *wdev; }; -static struct platform_device *platform_device; static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; static u8 interface; +static struct wmi_driver *preferred_wmi_driver; /* * Helpers used for zone control @@ -1263,15 +1263,12 @@ static struct wmi_driver alienware_wmax_wmi_driver = { static int __init alienware_wmi_init(void) { - int ret; - - if (wmi_has_guid(LEGACY_CONTROL_GUID)) - interface = LEGACY; - else if (wmi_has_guid(WMAX_CONTROL_GUID)) + if (wmi_has_guid(WMAX_CONTROL_GUID)) { interface = WMAX; - else { - pr_warn("alienware-wmi: No known WMI GUID found\n"); - return -ENODEV; + preferred_wmi_driver = &alienware_wmax_wmi_driver; + } else { + interface = LEGACY; + preferred_wmi_driver = &alienware_legacy_wmi_driver; } dmi_check_system(alienware_quirks); @@ -1288,43 +1285,14 @@ 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; - } - ret = platform_device_add(platform_device); - if (ret) - goto fail_platform_device2; - - if (quirks->thermal) { - ret = create_thermal_profile(); - if (ret) - goto fail_prep_thermal_profile; - } - - 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; + return wmi_driver_register(preferred_wmi_driver); } 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); + wmi_driver_unregister(preferred_wmi_driver); } module_exit(alienware_wmi_exit); From patchwork Thu Dec 5 00:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894630 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 B8B4A23918B; Thu, 5 Dec 2024 00:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359383; cv=none; b=FFRNFloJM5btb+WxkYhulf/pzO5wH+Tjzm4DZHAeNZ83/PGvYpAy4I/RES9IKRmYIhewwebQVZp5CCdEE99EA12adVIzRvNYqj5dVlhlphelgud5zu4HfUImtSRlDs3SBOSeBYcYGzhRk+eCaHFj9cL9gj+FchtFzJL/PSH5ye8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359383; c=relaxed/simple; bh=T7YFnhgQjwgrCGMuOIZRf0mzmBxx8Fd6DoqhSTbzmiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qYpZcgVjYh3seXceYjCScX0yfflz/RC8ap7dLFjJ/ecPMdBACRqiBDiz/RxM/K4LSZYe0AD3YJ4BcyHDkrgeWaC0myxHtQoAgnloIdJTV+OtdcYaTfURlUE8J3uuefOETzQiZT3ySJaMRCFTufFyeTR2p27k4MtJ6Zd8tl7XN94= 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=CBapqeZm; arc=none smtp.client-ip=209.85.167.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="CBapqeZm" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3ea3bf79a03so239415b6e.2; Wed, 04 Dec 2024 16:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359381; x=1733964181; 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=KBCwu6aCAop1tfbiNIVVgMDCpe9BHwFkdJAFHw9D46c=; b=CBapqeZmWheIWvg9nB9E+QWY1pO8kvGobmAzMiKdddRKR3m0J8+465ZevzAdlxpRRl oXlwSQPPHdAKtwciwIXGI8Y9XEBNbsWSsg+VxOvwxANTQD+lfvaaMlKmNsyq0GKvZIOu MqgZ5FJJQZZLz2THYbnH63HwRQzK9Ny4sA/ai8M+SaecY0Up43PO6Bz9CxrAkT04BYy2 5tyel3qyxwNrDxAwJ1z3D0YBRmjM9EpOMjuTHabWRDtW5N83jWPQkHhxBuvJVf/hTmd0 R+MmI64LXvEJIb5AePBNpPMdBScm8cqG+XvOxWd2Y1C7qmnY+SV7DoHMwvSZVVHNbiqr 39Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359381; x=1733964181; 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=KBCwu6aCAop1tfbiNIVVgMDCpe9BHwFkdJAFHw9D46c=; b=fGGzSGZEGeGYzA8cX3rjmhSs7tMY4zGJ+lhbL+jHrYRw9RIyazck1juUl8ACnReF/i QaONvRcZLyZCCJstwvgmjIgXEiHIz6V6tWMw14xKf8gWVeAoByK7MKafoHe2PHMkdpEl 9loupdUl0XzgBgrZLF/YWY0Rq1yDAM+uSSp1JexUMperlNmHnjU3DVbOnSVqudnpyuap XoQrDgUERDV077zKdDs3DGeTmvlyopo8TWM46LwDIXyEUJ3J13oe3+JfdejSkvGBp4Ao M8RUhtIOijR+18jBizwk9Ue380B954v0xzaqve/6aZC0VbyMrGhl5NsOOV5DMpA1qgaT S8tw== X-Forwarded-Encrypted: i=1; AJvYcCWnY0GoorGjCILD0pMicq/GuD3qyh4pJfL/Ov/+xaDrReSiM7h1gvRnxD/FiyWt2319CTBTZoVvfa78TymAzBAxvpiizA==@vger.kernel.org, AJvYcCXi6Cmejiaj0XJM7y9PhQgl7buZS+w4eIxbmUGSSxwdAudG/J7gZY6neqQ6tzY1g0P0As5gQT6dfBJvUcc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7lpYQLYdQe3xDG0pfRYx6YwMHXddKGWUORHWSZjSVH5HJD4Jh MOkz0r5zW+mzccNCXoAJfpH0ZvnMBgQaSG3u19eZ8AI8tzUujqFQ X-Gm-Gg: ASbGncsDQ0Yh238xPsZ8vc2fcVWTzdfq//WCNTERn7Q5ax0A4z5fQQCm80HlhGuEjxm dI7DGMbAuEoxu1n98YyTwkERz0fDJUSzJgc3WUfGGaMcV7dRyQKFpHuBz0D0gm4Arwgs/I2EtGd LLfqYuKCGJCjwMHnTyRKfgSfVR4J+4HnZAAEjWIlR02NFnEU6K7W7CYbBbLGLzG2+8EtOf4wiUs mnq0xRWfw7F02lAKAtlzmPE5VYZSHFmBUGzy+8t43EVvEgUA3atVy1P43Thj8lGMR7MPn2OMBYk tC1PeE3Ur/T37Lc4vcA= X-Google-Smtp-Source: AGHT+IHz10DeYPTkfCm6InqB1Hena4Ho2vbA6A1SxSiVN+rhvIVOhRx7IZbEwof5fL+mDM3iSFtvNw== X-Received: by 2002:a05:6808:f8c:b0:3ea:61e5:90a9 with SMTP id 5614622812f47-3eae4c7d03cmr9515253b6e.0.1733359380902; Wed, 04 Dec 2024 16:43:00 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd1569aa56sm122530a12.13.2024.12.04.16.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:43:00 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 10/21] alienware-wmi: Add alienfx OPs to platdata Date: Wed, 4 Dec 2024 21:42:26 -0300 Message-ID: <20241205004225.2185672-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 wmidev_* methods, let the WMI drivers present a single interface through this "alienfx operations". 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 and makes use of non-deprecated WMI methods. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 110 ++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 34fb59a14bc0..043cde40de9a 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -411,8 +411,16 @@ 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 struct platform_profile_handler pp_handler; @@ -421,6 +429,32 @@ static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; static u8 interface; static struct wmi_driver *preferred_wmi_driver; +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 ret; + union acpi_object *obj; + struct acpi_buffer in = { in_size, in_args }; + struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; + + 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 */ @@ -1178,11 +1212,48 @@ static void alienfx_wmi_exit(struct wmi_device *wdev) /* * Legacy WMI device */ +static int legacy_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + acpi_status status; + struct acpi_buffer input; + struct legacy_led_args legacy_args; + + 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) { int ret = 0; struct alienfx_platdata pdata = { .wdev = wdev, + .ops = { + .upd_led = legacy_wmi_update_led, + .upd_brightness = legacy_wmi_update_brightness, + }, }; if (quirks->num_zones > 0) @@ -1219,11 +1290,50 @@ static struct wmi_driver alienware_legacy_wmi_driver = { /* * WMAX WMI device */ +static int wmax_wmi_update_led(struct alienfx_priv *priv, + struct wmi_device *wdev, u8 location) +{ + acpi_status status; + struct wmax_led_args in_args = { + .led_mask = 1 << location, + .colors = priv->colors[location], + .state = priv->lighting_control_state, + }; + + 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) +{ + acpi_status status; + struct wmax_brightness_args in_args = { + .led_mask = 0xFF, + .percentage = brightness, + }; + + 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) { int ret = 0; struct alienfx_platdata pdata = { .wdev = wdev, + .ops = { + .upd_led = wmax_wmi_update_led, + .upd_brightness = wmax_wmi_update_brightness, + }, }; if (quirks->thermal) From patchwork Thu Dec 5 00:43: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: 13894631 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 DFBA014A90; Thu, 5 Dec 2024 00:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359410; cv=none; b=q2CbuUmeiivgGzTYzoXwxP05dOUIrd0DxocLAJfaIoXfz9jHJh4oBFuMsj0bsfwv3sTn/9QCfoVP5JSbA4QFFWbKExeck/IgcFv4UMxOX+xWCJz3zO3dQtc6DVY0/i/CiEaOta0doeUeo7S5lN+kIYa2yqQz5lsK15Oib3WSu+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359410; c=relaxed/simple; bh=6YBujX9+M6hNotwgwETW9OjkSDYXU3KIuHj2rCyTLho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ChtkXiu9dZLYDWpYbu/wxPBtTYXup32khubM+qaSJxHVNZcIzL7NxX/3FmT8AsgLCJJH7CEgX0MIMx7b6pYP+dGv0wII1/TjmQ4XVlrQ+28Z+a4H6FHVbaPdZKze9kZOGDro7fxtznRWJUAIJzuigK+eqXiGbFdkymuH3Janzr8= 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=AQ5UwNT4; arc=none smtp.client-ip=209.85.214.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="AQ5UwNT4" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21561af95c3so2436785ad.3; Wed, 04 Dec 2024 16:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359408; x=1733964208; 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=gF2Ur1bG2IuQdjBFiLHaOmGOnYHL7AWwqbHCwE+8phs=; b=AQ5UwNT4ancYPZyLkUtLWPfJfEkgPfECv8EbQOHKt/oDP+tFcKlwo7YH+PaXXECSI7 ysJcHGCsZk8ZnMkY8JjsoGxB0klL9xLbmtUi8pLNzofaGGe2Dja0nCm6mzQ4si//3KHC jTS2rlcvLwrPaLkl3csOvm1LG3pydPOL3iygxQIO2YFBzRJ5kcExm1hLS3q/SsLPYkoW RpHqP4uoBE6fnqgdAKKEb8VeNJbcfWrtJAtxS6/P0F0smjMKxk9MFWWrJRtAnNhZOf7S oL4eP3FMrqRngWcmh/eHyNcU4ej/Jpv73uHxtqZSl2L7nGokbBfraK6t70Yn4NDqVDLq WF7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359408; x=1733964208; 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=gF2Ur1bG2IuQdjBFiLHaOmGOnYHL7AWwqbHCwE+8phs=; b=Jr0SSICskMRcpprjrZwvhJeY91pRlY0/eM+h8wDBaXKjxfHjCImpqZJ8g6dFylRuXI w/0euYtaddzjxVRidYYvGWuxuE4NGXNpfSIkhCz9UoWgJgj08m9m+s9X3gMZ0+7xnjJv tMf8F2xR2U7zdZJdWoN3uISu0dUka9JvecTYujEn/o9b6dr7T1/EMn2GbRWzfBDUcNgZ TDBTdlTJLSHYPKWa0SD+TVt7L4klT7JIeHvTQfhnT1pQc//ppAw5gmsGBvKuhpmUJSW8 YrliosRgyQRg0xELobhwnMAgwDf8BJLy2TWu6J7pAtBJhVVnxU+On5dBpogKiUCtnaDs Sa5w== X-Forwarded-Encrypted: i=1; AJvYcCUxnUKon3mEbd9J9W8oTx0u3lYrD/sSXqXaS0AqCra7Jri4Q2zIqAoN6ueQqKD3h5ecYzOlj1q+BAaH32loUC2vYXqWsg==@vger.kernel.org, AJvYcCUyudkb7wEKPh9yliiVbYKosHAOOZ12MgqFz8kvMAUERXsyj6lsa/FfiN48Lm2gjotDg4YpZm2cxH+T96A=@vger.kernel.org X-Gm-Message-State: AOJu0YzklhztmzZ2bRA6wq3uIj/x/9/DNSUmTWDetPqFaA48ObJ24T2q e+6+DJFPmTRP0mF+t6VCUayK/AD/0x5q6b98ovVx1vLx6N66BmhH X-Gm-Gg: ASbGncusXaQ4EkZyZXLPcSS7HodG6SZje1U14XOY6bVymeFpPldYJHcgQJf8VZlkU3S hchh5P3C4D3xGYmFhVInYM2hAfg35K8smXaSy+sUR57ePeT69b8Aj2vYSgCfGjCnLU6inu9oXPg rUWc1toTAQZk9uJ4CPpUipmfXTmB8cmzwVHcp1H0395XW3q8979vLUa51YeeUDw7xWo00y2NE8N gldRwtV1Zv60CXR4iSOpVop9KnH+nnnr2zE9E1N+uP6475zp01hWc5pZDrmRDzXmgWnncbPAys4 Sil2mlPIavSn+d7XuUg= X-Google-Smtp-Source: AGHT+IEDxgearYVEXy+oMDWIm/dT2iHtb9B4Z2v6xrk6Uwq4EV0ptg1BJa/JLqgGlP0xjepNvvVnSg== X-Received: by 2002:a17:902:d489:b0:215:77f8:6c12 with SMTP id d9443c01a7336-215bd143a09mr114535715ad.51.1733359408180; Wed, 04 Dec 2024 16:43:28 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f3188fsm1331965ad.265.2024.12.04.16.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:43:27 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 11/21] alienware-wmi: Refactor LED control methods Date: Wed, 4 Dec 2024 21:43:06 -0300 Message-ID: <20241205004305.2185820-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop alienware_update_led() and wmax_brightness() in favor of upd_led() and upd_brightness() provided by device's platdata. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 70 +++-------------------- 1 file changed, 8 insertions(+), 62 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 043cde40de9a..93287bbffb97 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -485,46 +485,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) { @@ -543,17 +503,19 @@ static ssize_t zone_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, u8 location) { struct alienfx_priv *priv; + struct alienfx_platdata *pdata; struct color_platform *colors; 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; } @@ -659,35 +621,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_priv *priv; + struct alienfx_platdata *pdata; 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"); } From patchwork Thu Dec 5 00:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894632 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.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 1B3C823918B; Thu, 5 Dec 2024 00:44:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359447; cv=none; b=lazldG44iMBtawkMnQQ63K8HjARw7D2yD6piJkpX1xVKx5UZWXvmlcvVFiaxS4TdYmkb5NhRN5uXkKoayHVZATFklcn9ko7XFis2o2d3jz5UWGSsktq+AT3+hiX6AyJ5KvrEHOvjUu8qEBGHI7B4BA4D4ywyX6583uKG9LIloDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359447; c=relaxed/simple; bh=I3EHQlrn6VnjP4YB+DGPP28+tB4YWDH2cmCpHYOeruc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sGgHltykS4/+6HgCJYqT/h1nb42tfxhln/UhOnks1ZiV/qFC0K/hOMf0w+QGxtxTK5UvhnSflRwB5qB4jnQlXa15NLE2TblWhNq4SpBdym4FaZi5xSY8qiDxn1ic4guVrXkYhhRwSgY12k71GkGWtQv5I2h0dtzFRrJjH3kvx78= 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=Aa85VQUH; arc=none smtp.client-ip=209.85.210.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="Aa85VQUH" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7250844b0ecso343350b3a.1; Wed, 04 Dec 2024 16:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359445; x=1733964245; 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=c3dt0NVYk+ddQcowLnPrT3tl439EMbhxaHZi6VDp8fY=; b=Aa85VQUHXoBH+0Bm2Q3wxETEMOoIAXDTsC2WRivnjBIxGge7gRQLehkB7/LW6OHFW4 oWlL2+gcZx4xQrCEfXNe/d4075O+kVuZR8hksEDnKiUpgHl68gqAT2gOhuGCbz+7LePV Anx3NUxEQ5Rw4nkGCDJdvD5szL/cicxIZqdFj/YDIx72BQKBP7lVf8Tr538Wis0Xvcg+ gUoOOqCht5NNyrxAz8guZw38fHtprJz7HbbMMbmiBw6+OS/XkdJ7FXkiu8wH0pXNtBou /8/hKsKL3/hEv5jphFNtdQ2UPPeRf1Xh5SzUMqOWO+da6Ro5jSrscaGDFpw8RM6rD1Y4 k/uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359445; x=1733964245; 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=c3dt0NVYk+ddQcowLnPrT3tl439EMbhxaHZi6VDp8fY=; b=wAt4gj7k/KeIu23RWSBqg9i+l9USgTZajEUqI0TJnDjKRZUFhUpCYp/i2l2Fw7nmEk 88bW+pkc8if2nmFw9CIshwwVBY/8iCEFsctZ2Xt6VgSeEM1y/ANDWnDB34dWHvEI9n5n KetF61Z50Pja/OIup3sNcpy+jGyBCZc1tMQl53wPCIx3Pnfx6MBq2dymPwIZZjvXmYMU L424s+bEsrLotCofbE0UM17F8P6q3+0wSXhXLyTLqlp+g6SkaN1ecMbjC6FZXoMnU3V4 Ts+0HfchXM1aTiBDZWAM1x9bgHGtGoh43EGoyEWNlwxM/ove0j9GMZpoaSTqj2dfC235 x0iQ== X-Forwarded-Encrypted: i=1; AJvYcCWQr7c3ce3sTLIX3d86YYDiWZG2wqlhRSThBvoyDPaJ/rBmL76gVi2UtEEPN1Hehkhpb4PnlPkK246vBPR+wWxGPvb1LA==@vger.kernel.org, AJvYcCWlsSjhkRt4dKyyrrqrwgY79AEfRyoL0YEDKkhAzGVTJiyepd3DAfHN7M/2Ep9MV5KQ30GtBbMBrlCbvmI=@vger.kernel.org X-Gm-Message-State: AOJu0YyFCjeDmkRsLB78257yEfJbWqY90R2/Gmkf5KLKUHTpgruS6W6V L4nggoxSX4XCyrT0Rw+JWbfVNeI65DuuWxxN+Yuxhf+PX+kvXe50 X-Gm-Gg: ASbGncvuqOrv7t7BxRUR78dZc+1wwe1P0wNUTxqWqyMIvHmI3q31F4SrjJzGY0bWVkA LUThE6aiGv9c3ms9CYYs03RnBzIKJ5Dhb1LF1oLwZ5QDG68xgtw6XY6rVCgNCAcmn1XVt++Rddk iYcyaiLG7EXX6lmDcy6Z9QCGjkmsf3YnIkhKSb0Lbt9liiWNSx0IgDAyeo+c9cBE+mwa+RV4tBh BgLpAZxwV4IKKErS4wno6Iak2ka0jKng1mopRPZmHbiqZyfoWClEj8QCi4HAePg3Zcv6BKgfIPa n3/a4TN7YxgobVd48T4= X-Google-Smtp-Source: AGHT+IE5vrE2SPwpj5Q4TjYyuTDlYgtwAkYFTpl5/sDiGjadf7LI+QBElHwkNa1hh2a6Ne0TvwZCXg== X-Received: by 2002:a05:6a00:b4e:b0:725:9e02:aa4e with SMTP id d2e1a72fcca58-7259e02ac6fmr1262679b3a.18.1733359445363; Wed, 04 Dec 2024 16:44:05 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29c5727sm106732b3a.26.2024.12.04.16.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:44:05 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 12/21] alienware-wmi: Refactor hdmi, amplifier, deepslp Date: Wed, 4 Dec 2024 21:43:35 -0300 Message-ID: <20241205004334.2185959-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 93287bbffb97..8a21342cabd6 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -682,14 +682,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"); @@ -703,14 +707,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) @@ -726,8 +733,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) @@ -736,8 +747,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", @@ -775,14 +786,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"); @@ -819,13 +833,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"); @@ -842,9 +860,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) @@ -853,8 +874,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 Thu Dec 5 00:44: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: 13894633 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 9E99711185; Thu, 5 Dec 2024 00:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359466; cv=none; b=ZlGEnaQnant5sihcd5tItHXMI9S8dsdxznfRjaVmVAeklTOnttfRYQNCbqM/OG51xNRV0DD0wKJEfblW0RSLXVTHfF8ocWV9ezurD0q5h6rBIT9cg4b85JUufjcvF7GjDtJ17icgYhYiyoS/lUu8AOWoLCI+FOkffhytIyz4GqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359466; c=relaxed/simple; bh=TMdDfvotuWy8ztjZRhCc9vjkb3GaxxY3SXmu94y4A0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aqcxd5TCasrcW/Ab27rH2j41dRGkkPqC5eRU3Fk8KRm5vZQGSLDmZCRezBdeMx9y6L+OvFVeAS/lJEmfzRAusWQNu4jehkDj8Dx9k2kPQ8NQviKtMoutMicxTIMyhWWaijl+m83dTrXyN88JoeTJXEv62NtEyUm/qLvrcjfBZik= 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=lVt/MF9u; arc=none smtp.client-ip=209.85.214.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="lVt/MF9u" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-215d92702feso2600095ad.1; Wed, 04 Dec 2024 16:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359464; x=1733964264; 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=QceCrdCI5hwUmHx2YQ+2LUKETfIfBTL6QEYbC41NrFE=; b=lVt/MF9u02S3Hmws0a8KFv0l+avM9EG3g09JZEVHrWaWcG0xnAs9+uNfl5Y3D4+VGq QZmXt9tM/9gHBi/bGAp7auvkRvcX7RcvoRXmoyW+85ap14lJZw74Xa/Cm1kcxTq+Xx99 0fGJfqGcniAd+91KNn91Z4t4oeEE2esEMxoRMwA94rtSoHuqX4yKkVWeQcA+xju1pKRJ jAEFIe6dYGLQDicv6wobMJFaXHGl4mv94/EEpVc+059OUl9IhL8Azpc0JZA2djViDyuV YUphpFOKtaqf7KO6kDv4mYnAjS2aa4onM1asitxUTWq0U2cp1Ojz0H0ASDBUtZoYKyFd 6rJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359464; x=1733964264; 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=QceCrdCI5hwUmHx2YQ+2LUKETfIfBTL6QEYbC41NrFE=; b=QRbxIGUMD0UxDc1YDfQEBeN7HLQ6xrkeZDHwRnO4iktuqfPPKRSrkiYG0ifw+Iavhv qVyhrZP9aUwDfc2aDO1+mNKb7Qbp7UTtsvu1IlYWeX0OXNT5qvJl4u1uOmghfDGcHZb0 lyGstHj5M+2HceoACyIDdQ7rzjwD1Jzj42C9rLuj8WycyacjixnlAEMiyHvAA5+ahl9H hW/1DucxCv5GLzRD3ZC41RX2xJzztzYdYj2byXAYmb5tr6rMk36BmnPSfxu78mwqPdAU oKbZLUNEOr4zES/3XwFJ8G4QcC18wSULsaSUxaIubIGFgOVIyNh9MqZ4coNCIvinRalG 3pPA== X-Forwarded-Encrypted: i=1; AJvYcCVr02dy3JKg/0gsvb9V+rcD1YVxC5wSA+qywRGBWeG44S88gMvp/TONS8H6F3UTBBd3Leur3uhAeeNgguVPQ1lWeYiDWw==@vger.kernel.org, AJvYcCW+0SHt1LZl830PM2+TC0PHKrpOYBYyjAUfhsgs87TeakRdBpZ/9sMyW23KM5jaLychG9+C2yI2ixpWQcU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywf1szkLNZ4cwe2l8Q2d5gDjUI9apYmhwksDNom4ij2F/X/kpXd dDQSlfR2s0GrG+o5dHIM737QJIa65niTSKblOphZFUGKC73cEWri3oNRmsU0 X-Gm-Gg: ASbGncvMUbF3Ijsvil6RrnUyaGFaFqDrXpZP/kX/rUPWesZgui0Sg27+WqOLpDNM6Ab MbjElN3r8FJCfrhN//bIoJXLjxX9F6J/UFI5Jon1r+ITEHRi5ViUwV1+nrYQJoShm4fWVjAJPY1 RMD+2/5vh9lvMGJ6k3X9I61DbZ7FgRmmQbrQxj7ANb4cLxW8kKg7wGk22OaSDdVeTVQFTi4D7xd mCXJ4aDtwh32d7FAR5sXCgy0/Ab7L22xCMm1J4tAOQUm+wuREwAHe2+qbVjORSwptx+XcYZ6AIb aIXnS7tSG7cGKlkxbLk= X-Google-Smtp-Source: AGHT+IE6THraoxlNHyq4DOS8D9vMe2OGZvT1wkzcWNkyAUKKq6UW3LlBjwnHqIVCXfzkNfFv2HCizg== X-Received: by 2002:a17:903:1c9:b0:215:6211:693 with SMTP id d9443c01a7336-215bd18ed72mr78970665ad.57.1733359463996; Wed, 04 Dec 2024 16:44:23 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f09344sm1348095ad.186.2024.12.04.16.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:44:23 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 13/21] alienware-wmi: Add a state container for AWCC Date: Wed, 4 Dec 2024 21:44:12 -0300 Message-ID: <20241205004411.2186107-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor all "platform_profile" 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 | 39 +++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 8a21342cabd6..01414c2d9565 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; @@ -423,9 +429,6 @@ struct alienfx_platdata { struct alienfx_ops ops; }; -static struct platform_profile_handler pp_handler; -static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; - static u8 interface; static struct wmi_driver *preferred_wmi_driver; @@ -1028,6 +1031,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; @@ -1048,11 +1055,12 @@ 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(void) +static int create_thermal_profile(struct wmi_device *wdev) { + struct awcc_priv *priv; u32 out_data; u8 sys_desc[4]; u32 first_mode; @@ -1060,6 +1068,9 @@ static int create_thermal_profile(void) enum platform_profile_option profile; int ret; + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + dev_set_drvdata(&wdev->dev, priv); + ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION, 0, (u32 *) &sys_desc); if (ret < 0) @@ -1082,25 +1093,25 @@ static int create_thermal_profile(void) 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; + priv->pp_handler.profile_get = thermal_profile_get; + priv->pp_handler.profile_set = thermal_profile_set; - return platform_profile_register(&pp_handler); + return platform_profile_register(&priv->pp_handler); } static void remove_thermal_profile(void) @@ -1304,7 +1315,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) }; if (quirks->thermal) - ret = create_thermal_profile(); + ret = create_thermal_profile(wdev); else if (quirks->num_zones > 0) ret = alienfx_wmi_init(&pdata); From patchwork Thu Dec 5 00:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894634 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 11CAB23918B; Thu, 5 Dec 2024 00:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359495; cv=none; b=nIZWoX6BWKkR93EhkywKQRbc7A8FWv7DNKzpVeoL1RF/LIGdQCe5DMgaeC1K9XM3l35IOVxgg8y2+WFqLE2sTV2nWLXV6gSZtHCcMl5q6/erHjeDjCh/EQmv3tkEtxF1EYnntRFYTVMSdHi740sBbvjsXb8NzegoLYdz0ArrE5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359495; c=relaxed/simple; bh=Vu9p3/BPrlvA/czYm0nopk3pGggPQZcyOIIwYImq2L4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XNUHfgcFJf/vYWpCIExS7Jxir+3fXjmKpK2lzvmC23ZY6PEHPC8G/hDd/uAOiJsHtiil4YNpFTfi32GlzdYL54Mt5G+RmlvynIDIJh6dX2zlpYns6w3atTj6JQ3y5mQ/oqJj7bey3pq7GENv2GStDcZKH1EcfU1nIH9q0e+PEG0= 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=RG5ocpy5; arc=none smtp.client-ip=209.85.215.171 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="RG5ocpy5" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7fd17f231a7so39271a12.0; Wed, 04 Dec 2024 16:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359493; x=1733964293; 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=fSMpWEuhlvJtsZ2OsswG9SVVUl4Sf57QbNL9YVukIAU=; b=RG5ocpy59bvONbGZmS2SHRYxcpmKqeHTL4Io3KAvgFSrBXDDY5nr9rSHgM/11fPZXy ypG8qmdx1lPpNl7p9/b4dbohjMacW+4tKWHtJ1OM0hD8vsHcg2pNiALE6S3n2l+eu0a+ ON+hidVqCM1xR+1nzJAE8K2x9GkNpn03/hcRVMbahGqjb/e6QZ0jZEBKVFhs/jNDbYn8 6F24yUZ6QtyzSjvsubKXgHZvPQ8P6pRIOSCPLhbTvL0VA4XSt7l7YU7MJ8XcKivLalS8 gUkQU7MEyjir8gSeav8+C/7Wy361kvARpMGR7tj2aLOGGprqEK8DE7i0tgfIbcvCPEm/ Eeow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359493; x=1733964293; 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=fSMpWEuhlvJtsZ2OsswG9SVVUl4Sf57QbNL9YVukIAU=; b=jhLaW3q/7frMomssCkZKzJ2NSRFni934AgJlPvxDSKtVlaSkvU1F8QdZbIrTggbr3U ADVnXk+c7BkAsa0bTtF9LkKvcRqAeiSaPTABjiDDtcc3x1FFTxJu6HZVUiCdspYyObFK 31c/ojSi9WjIiD87TCysy7R23Zx/3pV9siduqRYXQBsSbxMrbXIQGkq+upOTMBFsxzRh FcxYqgKnd0qK3abcG0AqFIhYinxMlQY5tX35PZhQp7DszaBKzDXr/+UgZYzpz3HLcJfV DHtiN19LclO+ADutVHkoz2RhiPJfwFPDbVxHx3ad9MAR1yXoTct96KjpHzB57g6gw6es slBw== X-Forwarded-Encrypted: i=1; AJvYcCUnovg/jv/WsV4lbVv6C9bxbYKTyh/iCeGKRvEv4JE1v0Ey8iDnYkHu10Z3w+1a9f5KlMbXD66Gl2G45c1khZmcsn76kQ==@vger.kernel.org, AJvYcCWn2b6OEeGCDbGuvW6ckNeYXG6j5k3xIgUMwHO63rE+gMTvNKfUxmj358wqK8wTaeMdpy8SnARNab76RHw=@vger.kernel.org X-Gm-Message-State: AOJu0YzbFKtcImoV9DTn0Ziee8oclySNoST+hgygj2ZsQD7L/1AJCoyT 0lJLMojUxgUUFlD7VvmfKezFaGoDPmPs+xHD7j96txjEfI62L1Zh X-Gm-Gg: ASbGncvpjpD/tglpf/wReatvBaTiFNoIUCiRkgPRCz66v9Y+EVTThRvKpS4vHuX8+Wh UDgpteXHcdiOLxFcYXNXTQKn7hRZv1C2J+tvxyarVFzc/eeyfDGIQ/N7PEU9O/eoSL0lQKMTp1w zbkxzlPNoaUc6cV0FOKaeKPYGqLu7pm0+puMTRchNeU0A4CLX2VSc5tMZqyT4inxv+xLuLYDkOR c9K36x5YiG4WA2tUH7YGs+HVsTy6fSLH7bg1MTf3bQIkpL6bv/wmIoDDN0yCd52zK0isx8GKcDf AZwO8DyrlLZZJr3KnEU= X-Google-Smtp-Source: AGHT+IGQTYZR9YXRPUqE23JqxoqcQQpKYmopkW/habi83Kq9SkmHrBi1SFy8oR6FrWqltSeX6ikmPg== X-Received: by 2002:a05:6a20:6a1b:b0:1e0:d9ab:27f with SMTP id adf61e73a8af0-1e16541336cmr13990803637.37.1733359493289; Wed, 04 Dec 2024 16:44:53 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd156994c3sm154251a12.16.2024.12.04.16.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:44:53 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 14/21] alienware-wmi: Migrate thermal methods to wmidev Date: Wed, 4 Dec 2024 21:44:29 -0300 Message-ID: <20241205004428.2186244-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop alienware_wmax_command() and refactor "platform_profile" methods to use alienware_wmi_command() instead. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 71 ++++++++--------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 01414c2d9565..18a15dcf90a3 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) { acpi_status status; struct wmax_u32_args in_args = { @@ -942,9 +915,8 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data) .arg3 = 0, }; - 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) { acpi_status status; struct wmax_u32_args in_args = { @@ -966,9 +938,8 @@ static int wmax_thermal_control(u8 profile) }; 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) { acpi_status status; struct wmax_u32_args in_args = { @@ -989,9 +961,8 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data) .arg3 = 0, }; - 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) @@ -1071,7 +1048,9 @@ static int create_thermal_profile(struct wmi_device *wdev) priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); dev_set_drvdata(&wdev->dev, priv); - ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION, + priv->wdev = wdev; + + ret = wmax_thermal_information(wdev, WMAX_OPERATION_SYS_DESCRIPTION, 0, (u32 *) &sys_desc); if (ret < 0) return ret; @@ -1079,7 +1058,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 Thu Dec 5 00:44: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: 13894635 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.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 BB1D1CA6F; Thu, 5 Dec 2024 00:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359532; cv=none; b=Ys25yWDK2mTUrRm+j6CdDPHV0TZU+biNOsWGEbmqz2YdA7wWbrLfh/527w7ExJoAPLwXbq21gIzb8bRXsWx+v1Hgycs36vLTeMNLz80q1eU2cN8QI/55gA75gy594+CfZLzU0IDLKW07JF7f/QaZ/gZcmdWY4aBtTKnTPQ4f28E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359532; c=relaxed/simple; bh=XaaeTh4i9x9GcUZBoJdkg6ob76CEdYTvanlP7WUGrmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KWQTH8YCUkQUcQvWPFwWo1Ij9hgdqjUp7CfMR5K1juWg3j9eUEbvJ1BnuVHLNOoT6dpx/ryivozeHoVdpgtASdoVzUePqizkorkVwISAsy+9augdQQcK2hlcPQdunw4XmsPnDZRQ1FnfEcrRKJ4tWSgd3Rj/tMYvb+IGMjsyspc= 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=i6vx2i4/; arc=none smtp.client-ip=209.85.214.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="i6vx2i4/" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2153e642114so3121145ad.0; Wed, 04 Dec 2024 16:45:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359530; x=1733964330; 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=soMelWL1/UQuv4PwOE6os4uBGru2kyLXQzhxEqo4tZA=; b=i6vx2i4/sGx8oCxEPXdce7eIqftw+tIc4RLCz/OE6rucP6crZbeXCUos7p9aKgHnAx CHEQCzrDNDOIuckAFjaEgkPoB+/RxrqbfWfvXJlZsFBn71M6FsJwv9/qykXQJt5M44BH shMEqx92e1bYczF8yXiC0fO/EyFxC0u0AixhKxLV0k59NguiSgBAQQIw100YcOsUftZ+ hVP9FO+/ndTCirg1eQQjSeNhW277E0dK21XsSae4C8yR5Em1JkQ4mbBgUHucJHX4V2+c sl9S8whYSlUPvo1+DbXU7Qn8ThRDe6ESTvw1KmvynFSyLUUFbG5YASRE5Cxsmz6m2g8f u5IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359530; x=1733964330; 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=soMelWL1/UQuv4PwOE6os4uBGru2kyLXQzhxEqo4tZA=; b=B6GaWH3T6encbsqonxRWhVoiSrHV/OjzKquNR1A1l2aTwAP7ucMB1d6emUOt7QFYQH K3wfPuvrA0OVNJl4ekCNVWs2mRjcYdyfbg3u6iU+5lK9SDAvBDViqMAsuqo8GGHt6Kuc bnAJNh1+pHM6ir+Zn5HNvUoYzK/2KZeteogjpLEu4UOUtXpJMeQvOZvraXWfCSwZs1Fk ubTFZI9xHyYPM8h8iha/yqYmxTQP2TG214n4Lg+jBC1dXgXw3dNPZSLA0pInSBr9Ag9e OaxwLqCbbgZW7biNEkq36RIcJR+IRcSroLpVA/VLoKZKBcoWeTLGUpoaeNlkRdJ/Cf43 EWSA== X-Forwarded-Encrypted: i=1; AJvYcCVCbMYCKptV0s2O+9C/Rc5EoDK+AuQozbPuDVEFBQN/hVrOiLfQhYCdBV13Cy5err8h8zNSL0qyotKyWqvKJo/Bxkv7AQ==@vger.kernel.org, AJvYcCW7hy6GUy1tqVf9wBhpJ3KvVJghlOEMmDkz/2z0l/navvzi5qXVBO/h9FN052l/9JXaLjivxikFuaNhyCU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw15pFwRPKzKl5EcDEtca+zHRcek2G6dXGufJN4ePimG2XW2C4P FecM14EO8fSj71KujSyV4NUdz2cIFJPn7FGhziDGIQFyqHdJdDtH X-Gm-Gg: ASbGnct79MaSOsK/ahafw43rorWBw5JsnqeNIKZDM6PyXcChJh7DTEnLR+i0UtLuLob 6M79vmcOPvojbkQXSsxgd9DahSFPN6d4C7v1d5zwdv2diqgETMBp0tkge8j3+TZ6L4NDLaZOKsM pwR3oOYl2Es3TNYtTFkq9+bhgvSsfc0wKv2ljdMMGYjf1Efzen5HeIpIuyyGbUbDMKTfQbwF+7t BKlLpyx7mm+35GKyF+qX2RNW5z6/qqHBoJBM2XwN6BGMD1fIKlSbC6ApzigRmEigQBYcv1GBdCo qWHIF3DXnB/BIIunzV8= X-Google-Smtp-Source: AGHT+IEV+4iLTnRE7vFLN2dsQHUYs+JAPWWL3QLDKIzFNjanYtt7/v7YLAQSqKHy7+wdek6dN9A0OQ== X-Received: by 2002:a17:903:2343:b0:215:5a53:eded with SMTP id d9443c01a7336-215bd241404mr127216975ad.39.1733359529938; Wed, 04 Dec 2024 16:45:29 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8efa535sm1338625ad.129.2024.12.04.16.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:45:29 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 15/21] alienware-wmi: Refactor sysfs visibility methods Date: Wed, 4 Dec 2024 21:44:58 -0300 Message-ID: <20241205004457.2186386-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All sysfs visibility methods relied on the `quirks` global variable. To avoid this let the WMI drivers set this information as platform specific data, and refactor visibility methods accordingly. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 52 ++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 18a15dcf90a3..25e0139ed78c 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -427,6 +427,10 @@ struct alienfx_ops { struct alienfx_platdata { struct wmi_device *wdev; struct alienfx_ops ops; + u8 num_zones; + bool hdmi_mux; + bool amplifier; + bool deepslp; }; static u8 interface; @@ -597,12 +601,24 @@ 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; + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return n < pdata->num_zones + 1 ? 0644 : 0; } static bool zone_group_visible(struct kobject *kobj) { - return quirks->num_zones > 0; + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->num_zones > 0; } DEFINE_SYSFS_GROUP_VISIBLE(zone); @@ -737,7 +753,13 @@ static DEVICE_ATTR(source, S_IRUGO | S_IWUSR, show_hdmi_source, static bool hdmi_group_visible(struct kobject *kobj) { - return quirks->hdmi_mux; + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->hdmi_mux; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); @@ -786,7 +808,13 @@ static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL); static bool amplifier_group_visible(struct kobject *kobj) { - return quirks->amplifier; + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->amplifier; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); @@ -862,7 +890,13 @@ static DEVICE_ATTR(deepsleep, S_IRUGO | S_IWUSR, show_deepsleep_status, toggle_d static bool deepsleep_group_visible(struct kobject *kobj) { - return quirks->deepslp; + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->deepslp; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); @@ -1211,6 +1245,10 @@ static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) .upd_led = legacy_wmi_update_led, .upd_brightness = legacy_wmi_update_brightness, }, + .num_zones = quirks->num_zones, + .hdmi_mux = quirks->hdmi_mux, + .amplifier = quirks->amplifier, + .deepslp = quirks->deepslp, }; if (quirks->num_zones > 0) @@ -1291,6 +1329,10 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) .upd_led = wmax_wmi_update_led, .upd_brightness = wmax_wmi_update_brightness, }, + .num_zones = quirks->num_zones, + .hdmi_mux = quirks->hdmi_mux, + .amplifier = quirks->amplifier, + .deepslp = quirks->deepslp, }; if (quirks->thermal) From patchwork Thu Dec 5 00:45:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894636 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.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 A457E10A1E; Thu, 5 Dec 2024 00:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359564; cv=none; b=ULU369maJbVUz+L1PJuWa2PbvaaRHRtlHfTXcH1pXXqsyNq0yfvLpfiZmFgDuY2Hr5sB0w5aMHVgHE8WYdPiWKB+pO7XMCaj8QtkC4wwLYu/uQABnQEVIAp3XfL8zU1WXTkPCnWGzkv+FJyGAQgwCI+gSWQ/9lwRa4Km85kJcu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359564; c=relaxed/simple; bh=DDSnkLRx/hpCsj0oZsDNoPzwOrYYZ9lCtPony0GX3+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KHr3QfWcw2/n53K55mWCs4PuX0QwuFM//COqUwp5cRHSNSeNiISjE2kqoZssrMln1GPDYO0HUaeDRvr3RajabWot93ZqGSUhP48Jkv8qbGxPKUnCaxR1UJHHHrMOaJsDi7y110ngl2auBjq9b29P54XRbGxb18FOH5hg8gSr0nc= 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=mGwSyzbq; arc=none smtp.client-ip=209.85.214.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="mGwSyzbq" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21572ca3cccso2774515ad.2; Wed, 04 Dec 2024 16:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359562; x=1733964362; 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=tfA05tZFHk4htG1XoeZapn1ays+eOzOi9+0JezvQoOE=; b=mGwSyzbqNkZs9VjTLc4K+aL4ds6as7e4NddSO+lCPdUQjc1Fb7NrPVmRkiBGI/lRBm rzEc15z8Q3+z4pIqzb9pMd6Z/dP0TfeLLxanQDaR+jA1SF+khqAFdUTLHqy0Ln6mmZQI 1CGYG6iB/syqExX7D8amLO9TdJv6Ks4U4Dn6CWvsk7vVYaw69W7McnAZHZI5z2V2MGvt BVn2dAZzdxK8c6tKQEJjWSy8uu5tlwSX2oI6qg4pbmdqPQOl9HIFoauCGNZw3fG8uoST WJ2/Fy5gajhVGMv00F0mo00Lz+gmm3F4ygLJKzWgzwY1p9Bjpb7GDhIRHOLm1hfz4S8O UHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359562; x=1733964362; 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=tfA05tZFHk4htG1XoeZapn1ays+eOzOi9+0JezvQoOE=; b=V2PIestjfzLekU9C7wP3BAJfAfzZdDXGgO/JpFF1ZaDnQ91FYL9JwDS/cIESYVQODT pslwKGxYm5/YI/BvCQxX5SbpLF3zDxdSuH6Crq53PJn6CfEoqrV2lVt3CBFn7qjtR9Xp vRUHJk5U/T0irjn7SyVY/l5TNRN3lk2G/IKmnGmlk+CFDoi+E52Dk1JDJqKbQUtjW0Nx iqyOlGjYkIaB1gG5/pnQ1o720whuVrBwY/C0Q0XtmxdszdgmAj9Upxf4dhFUM4W7Z7Nv e6XcWuq2tXANaCGwxEf42gtlD3GxOBPGxu8IWfwfD2c6Airjvqf5z7Z2d9mJFvrSczPM SwnQ== X-Forwarded-Encrypted: i=1; AJvYcCU3GVg61b96W7FdKgs8HZw0bTQomjA7tyZDxO9qveBde38+bl2TrlWTbFyi0lU8pI9GrC+VmvmKHLkB3arUmVxX9S6dDw==@vger.kernel.org, AJvYcCWlTDleyTPVaigc94zSz1wpAKHh+WZPE1P+QGVLsaM8zS5W9v6iJTeTW9n38KvDJZEIpiMOr+8/OnU58Mw=@vger.kernel.org X-Gm-Message-State: AOJu0YxsyqAMhChCE4MdzukkYf1HDzS9ngFiDUdrj9+wSXk1AQCm7xC+ sKh84VmWi6TDcnzl07fCEseCpNzadnC1WJyjlus2xp5qNZL+uTuLYXgrsP1u X-Gm-Gg: ASbGnct8ubNtsEpJrBGNSC8MkAOBejXLntKqSUZHK7ON3dS0A1J7MkEz/MDWPNV//Hk WccSTs/4RQ+X1KVyw6n27u4PZbFIrz7DSlyz+XnQYz03S4WJsSjavhOuubUBVMpywZfERmkr9DC De1yc/6aAfpnll1YzKsUcvjc528/K3oEWz9sVZIpl9flFYsvhRgMAPXRuF8soPxqN0dOA6h+sGx A/9fFFnEl34uPzv8QJ/okl5bqvZI1QCFiB2jE5g+JvxihNI4g97lyt8bqaf6yMjYLYomyVNaDaD qF31e4W2Wcf4AXV3fSo= X-Google-Smtp-Source: AGHT+IE026MuLGTKCZJ0jm1xys3jatnyTlrx3pVvJs3ZKKoA0jNN+3LgUZmcuXKx7xSr8NPb/UvMMw== X-Received: by 2002:a17:902:e841:b0:215:4e40:e4b0 with SMTP id d9443c01a7336-215bd1b46bbmr122689305ad.9.1733359561975; Wed, 04 Dec 2024 16:46:01 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a2a9050asm102329b3a.123.2024.12.04.16.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:46:01 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 16/21] alienware-wmi: Make running control state part of platdata Date: Wed, 4 Dec 2024 21:45:35 -0300 Message-ID: <20241205004534.2186539-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both WMI devices have a different "RUNNING" control state code. Make the WMI drivers decide which code to use, and refactor sysfs methods accordingly. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 25e0139ed78c..fa21a50d66bd 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -431,6 +431,7 @@ struct alienfx_platdata { bool hdmi_mux; bool amplifier; bool deepslp; + u8 running_code; }; static u8 interface; @@ -576,18 +577,18 @@ static ssize_t lighting_control_state_store(struct device *dev, const char *buf, size_t count) { struct alienfx_priv *priv; + struct alienfx_platdata *pdata; u8 val; priv = dev_get_drvdata(dev); + pdata = dev_get_platdata(dev); 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; + val = pdata->running_code; priv->lighting_control_state = val; pr_debug("alienware-wmi: updated control state to %d\n", @@ -1249,6 +1250,7 @@ static int legacy_wmi_probe(struct wmi_device *wdev, const void *context) .hdmi_mux = quirks->hdmi_mux, .amplifier = quirks->amplifier, .deepslp = quirks->deepslp, + .running_code = LEGACY_RUNNING, }; if (quirks->num_zones > 0) @@ -1333,6 +1335,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) .hdmi_mux = quirks->hdmi_mux, .amplifier = quirks->amplifier, .deepslp = quirks->deepslp, + .running_code = WMAX_RUNNING, }; if (quirks->thermal) From patchwork Thu Dec 5 00:46: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: 13894637 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 58D1610A1E; Thu, 5 Dec 2024 00:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359606; cv=none; b=uphK+CZ0yMAM3l+XywrchFaPfd5TdAvkJNh+E6O0W1pWXQKouwwNFNvPCktD4Q1fmxjA/vztZv0+nEBB5Ts9y3EvTpYo6Lt0Zb/pHR8noV+w+qewjmkBEbNy52aT+HyyP9xs4NwlPEF8iFmFd+wHGB5PougtY5AF13fhTnpIlA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359606; c=relaxed/simple; bh=NJBgxwX6kHzsleaKix8Xk7k7cQDHK5DP84r6FYtxM8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EvbAYZzcsWlbxKNcMJs8Ef110qZjTpA336YWEVrH7RmB4tZX9KH5KeukIrjIm5l/o8mG48WKRaMs8lgENHEcU6/OWAaYDlbuwbdH0nYdu9ilfPsxwDnTUamNybTMDxlR6Y6voGJUJ1NUETsv4y1i34i2RpfU7Lej0GlCOzEBCEU= 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=mSTVPd8u; arc=none smtp.client-ip=209.85.214.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="mSTVPd8u" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-215909152c5so3597865ad.3; Wed, 04 Dec 2024 16:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359602; x=1733964402; 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=PUNeDm7WDpiz0NiIzWMQfhnjPASdA8TVm4SvvGDMhRo=; b=mSTVPd8uhBY0LBa974fpibslk41Cqo8I4xaJjgq4li/YdabJlLFNuP/x89z8MSyerE iu8io8De/ELN3KKJBtEJZndhaeHbdf8XF3rB4UVTAyK4pLbzWD8P2vRJkXgIEuA6CqYB dkSnEi3GIOju5MdBdB89vjw5NBJ1LJ+YkoPmmJZHvu/YnWRS7Xz7+8KF5oixsmjHvwVz 0GwxKhV+evF4i3TxsGI19ySMq6Igt0LB5LLmLaT1lqswPfgMPlvB31q1HNPzg/vEkh0c gPTWtZWNzgBV5ImtOz2Y0y2Smv/3a19hDVjcUyxWaeBWfjRBdOg5eo2SXNB5WoCfhqXz uy+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359602; x=1733964402; 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=PUNeDm7WDpiz0NiIzWMQfhnjPASdA8TVm4SvvGDMhRo=; b=oyfWeTo3Hs51VYH2JmwFtWGaTEJpk1OhZhGKVRPoT7dt6kdaOMKYHoZIwCoTfBvDmQ 89xVT26NKBQ2NDusFg4vklzt1UjNn6nS3zflpfrq5Wk2mKVmaBXzMbrKn/t+IEm9jtoJ qvZh5KVBEy4JTejc/Z3BL/dtdys2eoDW4K9sdAmB23xdLomSwzsGdxEn2jqY93jwnIAR PlETitd3ijj9WeIk/oqDDgn6Q4TqWecxzDef9tDo8O7yPG9QOX1iutlK16DdRKxbXX1D g+z1Xcdf5aNXlghbVVikr3qbdCk7RPgPN6ax8wNUTgtZ50XcF1Qv+B0ecRj1KJ19ENZI jLTA== X-Forwarded-Encrypted: i=1; AJvYcCWFCqdaaJxwqYy33Cnz4ZAx0+qnRT2E3a+9tnrlBGtqbuad5uIy0xiG54selg/H6iwh/Rhw9PuxGszs1m01GjPMobf/yA==@vger.kernel.org, AJvYcCX2RcEdgiiwFOVXoEChaa3tdp+ugUc4UrPzY4KqXdiv1jNezopkTDkAdDhxZ8mUFpgtMD6m+WPzW5jZdWg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4debB6SZOB71u5/nihi2OI18K6fxuVrtjx35NwO9VpEZO7mQe B+vaKnhXA12hq8+U1xMYDJtyBBvdU3kjiy6Ymqo6vG0FSeouGrpU X-Gm-Gg: ASbGncurpVgPQL9WpEutbIIXjR4r6mLMz723JOB0R65mEGOZqTksMvHY/TIfwOH6tJn Nz4DUPrT1ww0QfSxudjSwHiPXUuKRIKpG0CwDLsOP9r4kqz2FHQZ9SukNZKyRQ/9KyZpsw4u/12 9maOceSiY0nZmqgLhkcLM1ARFX14H2HwK3VrAVsiAza3uUIuESRlF7/nWcATuzqoOrAbDZt+Nsv VkUbMnMsAslc4ysTrynngnUR/Xc+U0DvGHmZrgHS4F4FGuT9M2UH79uDtmsDKq6/UGNmBtf85cx lydw2WG4i0Xi7Yei/I0= X-Google-Smtp-Source: AGHT+IEtT6UDe6/SqOR1bfFKvAPs0m37cDfQxQSKzmH3C9x+u23vBfm6F8+GP4olzH2uT+UJfpSiug== X-Received: by 2002:a17:902:c943:b0:215:8d29:af2d with SMTP id d9443c01a7336-215bd24b8e9mr139025605ad.38.1733359602633; Wed, 04 Dec 2024 16:46:42 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f0a72bsm1368935ad.214.2024.12.04.16.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:46:42 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 17/21] alienware-wmi: Drop thermal methods dependency on quirks Date: Wed, 4 Dec 2024 21:46:10 -0300 Message-ID: <20241205004609.2186681-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make the `gmode` condition on AWCC WMI devices part of the device's state container, and refactor "platform_profile" methods accordingly. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index fa21a50d66bd..7137995d5983 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -407,6 +407,7 @@ struct awcc_priv { struct wmi_device *wdev; struct platform_profile_handler pp_handler; enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; + bool has_gmode; }; struct alienfx_priv { @@ -1044,7 +1045,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, priv = container_of(pprof, struct awcc_priv, pp_handler); - if (quirks->gmode) { + if (priv->has_gmode) { u32 gmode_status; int ret; @@ -1070,7 +1071,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, priv->supported_thermal_profiles[profile]); } -static int create_thermal_profile(struct wmi_device *wdev) +static int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) { struct awcc_priv *priv; u32 out_data; @@ -1115,7 +1116,8 @@ 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 (has_gmode) { + priv->has_gmode = true; priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; @@ -1130,8 +1132,7 @@ static int create_thermal_profile(struct wmi_device *wdev) static void remove_thermal_profile(void) { - if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(); } /* @@ -1339,7 +1340,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) }; if (quirks->thermal) - ret = create_thermal_profile(wdev); + ret = create_thermal_profile(wdev, quirks->gmode); else if (quirks->num_zones > 0) ret = alienfx_wmi_init(&pdata); From patchwork Thu Dec 5 00:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894638 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.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 2E4C518AFC; Thu, 5 Dec 2024 00:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359624; cv=none; b=hkmXwURE99dDENdiQd5Z5ubCcmGOFJfnCLols8Rao8Sh/Psebbti0lwvnJQfGJzWGbjcqOT49A6uBFmiUJ9w5q55U4zJ3GzufJt7hZbDjG1YNrjDpUCoW0TKLsQKGSS2DSgm0mR6VhUS6Xi395tMa5HnoCI5qPhkh3WMYkAdz+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359624; c=relaxed/simple; bh=f/JtU3JF65jK6/gj5A10+Cuk1lEzhI7uth+Fg/PmEs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ROsdfyp4gOnC15lC7+t6eCUcHW02DOOBspQmNNPFG7IRh2nALKf1jRxdBe5frQ/FWMHxP2tsmJxhfPNFktdNMjcLhNU7bw10DaN7LHFv/F34fMS7uGC4lutiSxRiIrlgN++rCB6RbgJlGHK8tbagZTUTEr9kW81lvftliUSy/ZE= 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=lqtzvl1F; arc=none smtp.client-ip=209.85.214.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="lqtzvl1F" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-215ac560292so3184655ad.2; Wed, 04 Dec 2024 16:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359622; x=1733964422; 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=JKxRbBSHgKqYHhuCZfgBL3y5hngQfwrEBg5igZSaFfw=; b=lqtzvl1Fpz8WBZTmkT9C7znbCj+YRRsYTg6Ksc1FylRmpOfw/ny5EJBuGRATJFiTie wDNxFvTAiUUiAn/IrVa7Z8+YnxTRHiCgMmzFfTZ90MyG1p2RfZI/OHaj8Qo7idBGkp10 xIku0usBiau87uze9qfzNLGB3+wySyV6Q3mGtfsvdyRX4X4LeqN2dUbu39oI+c1E/5yp Fd9JEbrJ8q8GjkIGo1MohQZ2oYy9BnnHhDVeBzvNoymaydlY9HS79rPvmKr1wHaeFXJx 30wOWRVbcONN3+geCjGsudvbwhylBq+YD1gu6eusOlX3RVNyPXhq0NP/VwJK4JfH95uU KNWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359622; x=1733964422; 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=JKxRbBSHgKqYHhuCZfgBL3y5hngQfwrEBg5igZSaFfw=; b=bIX7QRGGNRqMqB/hmif58z86P8ouX3PEtJh5iTjmA1hIBx72AID9P5ZvjjJA34K8kK gN8ktIqWyWbw/X7D2ZGo/QMVfy8EwcrmxiJxzfQvtO/9g/8YRmlWBgoCHDs7FU97Fkid Eppv48RxMpj7HZgtxhwy036i5Y88BUeMSF4PCh43479VS2ZPYuobWUd19skZgfRkCjPy fd81bXUXVSEeKfTuHzbmalAZwTT+I5QuB7I00w/MMUqmGDcVxKpcmv8VCZGgPH9ISD/G WkSeVTDzCV2EnRyB5ML/mtAn6SKh+mGnMzAnPI/jxrQcRFiphclNASarBwg80s7ZDiPI TENg== X-Forwarded-Encrypted: i=1; AJvYcCWRiYjQ9TLPsXolRgqS0j1+sfofYjpkDhRKycpzGOogdqvI/t35VopqpNDFaVsrxKJvmXsh365lTT7YSRc=@vger.kernel.org, AJvYcCWl2youZQklROwnN0dAZgvc+NJCVPi9JhxgPli7nr8KQ0HcQKe1n1wp4lIEZ3koqse46DvigfOA1V5E5Xnfp0XZEQhxTg==@vger.kernel.org X-Gm-Message-State: AOJu0YwzaaT5xC9wHNubAyUGdq1k91R56PGUGoYueQL4wyRCtGKiXSho 3QgScqb0+D82tzeTtWyqdqBN+cNszgXTxPt78PFAUExw8xf5KDl6 X-Gm-Gg: ASbGnculKehb3So/sWQLvHOs/AEtulcB/tbMR4BQ5iJVbn1w2GKuv/mP/1wOiavXMjq 1pI3zCt1pwrW68qC2Lkn5jADaAPp2Yf4WKO+kcs64N08rboJJYaKJT5f+ZNXQkKUEWrBVbXMEGU zywc/94g1LL4tg10Uefkw1asJMi79m8mXN4bgtFL2tRFwGz/69uL87mu8VzvdfCl2ZEW37+0523 8LUza4MAM5KQ0NZJuEkhLmYHu7GFVJfGJMss/badZvI8GpDujrdRMkNPIB/jhfCqeV0WfzBvpGN kFo7xKuBTyRbm9ApSeI= X-Google-Smtp-Source: AGHT+IEyUud4NjROVIiI5WXUtGZHpnkJjWH1s0UNIURra4+F/VCn1y/NdO4jLnt7KFZZ50nHEWGTkw== X-Received: by 2002:a17:902:e802:b0:215:6093:e383 with SMTP id d9443c01a7336-215bd0ce8ffmr101034055ad.27.1733359622420; Wed, 04 Dec 2024 16:47:02 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29eb38esm106048b3a.73.2024.12.04.16.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:47:02 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 18/21] platform-x86: Add header file for alienware-wmi Date: Wed, 4 Dec 2024 21:46:48 -0300 Message-ID: <20241205004647.2186826-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to split the alienware-wmi module, add a header file for all shared assets. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 106 ++----------------- drivers/platform/x86/dell/alienware-wmi.h | 119 ++++++++++++++++++++++ 2 files changed, 126 insertions(+), 99 deletions(-) create mode 100644 drivers/platform/x86/dell/alienware-wmi.h diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 7137995d5983..4165eb0d0bf5 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -16,19 +16,8 @@ #include #include #include +#include "alienware-wmi.h" -#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 @@ -54,18 +43,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, @@ -86,20 +63,6 @@ enum WMAX_THERMAL_TABLES { 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, @@ -369,33 +332,10 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { {} }; -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; @@ -403,43 +343,11 @@ 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]; - bool has_gmode; -}; - -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; - u8 num_zones; - bool hdmi_mux; - bool amplifier; - bool deepslp; - u8 running_code; -}; - static u8 interface; static struct wmi_driver *preferred_wmi_driver; -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) { acpi_status ret; union acpi_object *obj; @@ -1071,7 +979,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, priv->supported_thermal_profiles[profile]); } -static int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) +int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) { struct awcc_priv *priv; u32 out_data; @@ -1130,7 +1038,7 @@ static int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) return platform_profile_register(&priv->pp_handler); } -static void remove_thermal_profile(void) +void remove_thermal_profile(void) { platform_profile_remove(); } @@ -1180,7 +1088,7 @@ static struct platform_driver platform_driver = { .probe = alienfx_probe, }; -static int alienfx_wmi_init(struct alienfx_platdata *pdata) +int alienfx_wmi_init(struct alienfx_platdata *pdata) { struct platform_device *pdev; @@ -1192,7 +1100,7 @@ static int alienfx_wmi_init(struct alienfx_platdata *pdata) return PTR_ERR_OR_ZERO(pdev); } -static void alienfx_wmi_exit(struct wmi_device *wdev) +void alienfx_wmi_exit(struct wmi_device *wdev) { struct platform_device *pdev; diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h new file mode 100644 index 000000000000..1c12b8e330e2 --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi.h @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Alienware AlienFX control + * + * Copyright (C) 2014 Dell Inc + */ + +#ifndef _ALIENWARE_WMI_H_ +#define _ALIENWARE_WMI_H_ + +#include +#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 + +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_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 color_platform { + u8 blue; + u8 green; + u8 red; +} __packed; + +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_brightness_args { + u32 led_mask; + u32 percentage; +}; + +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; + u8 num_zones; + bool hdmi_mux; + bool amplifier; + bool deepslp; + u8 running_code; +}; + +struct awcc_priv { + struct wmi_device *wdev; + bool has_gmode; + struct platform_profile_handler pp_handler; + enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; +}; + +acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, + void *in_args, size_t in_size, u32 *out_data); + +int alienfx_wmi_init(struct alienfx_platdata *pdata); +void alienfx_wmi_exit(struct wmi_device *wdev); + +int create_thermal_profile(struct wmi_device *wdev, bool has_gmode); +void remove_thermal_profile(void); + +#endif From patchwork Thu Dec 5 00:47: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: 13894639 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.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 E548D1B59A; Thu, 5 Dec 2024 00:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359646; cv=none; b=IvJzedbQe/MzRJJ+OeZXWXEj5kGQCPPZm+B7MzY+w/MfuCfVpIvUeOlVUgHzabMc0DQR/I+TkbqE0Ndxm0xfZXRAEhuY7lPtv7CR1l7HAIMD4Xwk4AfIgMgnCa72weJQyTw45X5AJjKMKO0eTLSsMHDnPt39UtJxQWfrDAgdXPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359646; c=relaxed/simple; bh=4ZxeEJPY8xoRML7MMJMoHacS1hJ13w94RIiqCDy8sXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=brpVcTtz2sjxm3iYrjB01cQGaaEdm3tJyT4F9sgNAIJlhm7fyryS7HNTtG2wezVhYVUhQYTCdKVP0ajhl1abaYe+7pdM9ZkBzLyfWu7wDS/ildYGC2q9+eXXhM+qqJJMcP2+0A0i6NAB294YpyiWpgJPNIyFeQUmZSXRxkOKL3M= 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=VSYCLIB0; arc=none smtp.client-ip=209.85.215.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="VSYCLIB0" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7fc2dbee20fso379462a12.3; Wed, 04 Dec 2024 16:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359644; x=1733964444; 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=PhdIFnFtU8L6vmt7RyRfWOP3Xh8e0z4jvRasrWil8Yo=; b=VSYCLIB0P6jJRmdO52/HEa0Nx1L76tRGGAR3xe1osWAsq4OHcSA1UypI1vqwADTR6S zBtWZ5geA+C/ETl1JDwqrfDMc5lr8pBW6ryq/fP/C7Dsn8s4gQNRzW1YZ472pAGRXgj6 EM5KwBFqSYUX+TC71fcfNCnQI5Vhc7QUYXbeGdQ0FLqwbyDMSsvPtqxryfBbYpL5Wga6 H/d8DvWIOD7fVLWT56xD1/PuWowLT7H07zIHy5MHC7g4obrCMoL95ZtH6ZkidLAuj7Ma NRjZQe1bMI3hzvQP/m/uxUFNVxJ86cnlxLCQ9Sd4/EOmxCdLujN9ictk72IXltV2yEFP OgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359644; x=1733964444; 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=PhdIFnFtU8L6vmt7RyRfWOP3Xh8e0z4jvRasrWil8Yo=; b=KWBpzpnYxstgSRvXRqNlVsSUjjsWQ1EI/BStQbbKBhuMLV/4TPA4ez71Z1iEKPpXX4 eWRJilWbKbJgW1fOSrE39Os+sLCNPkD4mtF1otOvSD6z1bvSmRTc9dD0iZxXGohpTLPi ACW8rsyK6GqWUdgAxI1oIZUTwwXDuqDduKPtfx0GarVe078pm79aPHdMmP3h1sGybPH7 rnDA1MYnKUGZNB/5hXSO4mjuPv89M/MPta9OokoLt1aJNT5jYJpfhTVlR0ksi0yNzFgU 0ZHdVccfmHsIO+YtbGpTo+Dy9080hW55xNEXAkyXXY8XBc4yi4rBZf2OkeMutFyjFk0G IRLA== X-Forwarded-Encrypted: i=1; AJvYcCUGsS+/FF2ltv3EQd8X+xFXFutU4rSVqxRE6xH2QGsULOcSh9We7oxfXk8XQEgQtrSvBXqGX1H2RkeeFTZlgNdPu4am6A==@vger.kernel.org, AJvYcCWXkZEc3VM8xy45XH0vaaIp2RgNxCUKI7Wl0509ZNEyDd28N+mZmy/CfYi1RdUquD4c/1QoDmbt8WQ6GMQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyrgFZuM+80P6jM1pExMUpNsxKiIYwLVbNS93kPUiCyL3h5Z6hT SKeC/P9OGspbfcDmJa4HA8/TfoHM8KDU/hsNodAGBBnLjDNi6kFz X-Gm-Gg: ASbGncuOd4nTaYnYJTbpYJM7Sq4eTetMZ6UA4rrq7/PIfBmndWWOrlbIOG552cG0Xvo dBHo/FiSWx0RLVM2krsB+EchTSsl1JgCANwiIe1PQrGZLOF9CPtQ1rFvwxyvC+174EnRUbHrP/V cbVUHig95wcJXqL/VEWM9UW3m0VGa6CNOW0spGuxPNwib/jPCWZLGtKWD4e0wsX6OAEkFsrxCll +q+5WBx5kQTGtv18ujQOBkcv+Tw19/gE1Q9lpfeZsEeGAfQbr92hjs7aL5eVMV0lWDQN45GT3F9 D+Vqop82Ppk18ujp6ro= X-Google-Smtp-Source: AGHT+IFT2v8ovroLfk4FV50rHj5EP/hN5gMU/u6ifXEGMiZjTQ7Xi4QrB+uJBQuIhghdD5jTrD2Fcg== X-Received: by 2002:a05:6a20:158a:b0:1e0:f059:cd6 with SMTP id adf61e73a8af0-1e1653f23d6mr11113931637.29.1733359644219; Wed, 04 Dec 2024 16:47:24 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a29c5719sm109335b3a.27.2024.12.04.16.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:47:24 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 19/21] platform-x86: Rename alienare-wmi Date: Wed, 4 Dec 2024 21:47:10 -0300 Message-ID: <20241205004709.2186969-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to eventually split the module: Rename alienware-wmi.c -> alienware-wmi-base.c And modify MAINTAINERS accordingly. Signed-off-by: Kurt Borja --- MAINTAINERS | 3 ++- drivers/platform/x86/dell/Makefile | 1 + .../x86/dell/{alienware-wmi.c => alienware-wmi-base.c} | 0 3 files changed, 3 insertions(+), 1 deletion(-) rename drivers/platform/x86/dell/{alienware-wmi.c => alienware-wmi-base.c} (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 3809931b9240..a4d02074dd91 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -787,7 +787,8 @@ ALIENWARE WMI DRIVER L: Dell.Client.Kernel@dell.com S: Maintained F: Documentation/wmi/devices/alienware-wmi.rst -F: drivers/platform/x86/dell/alienware-wmi.c +F: drivers/platform/x86/dell/alienware-wmi-* +F: drivers/platform/x86/dell/alienware-wmi.* ALLEGRO DVT VIDEO IP CORE DRIVER M: Michael Tretter diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index 79d60f1bf4c1..5e7496aeb070 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 Thu Dec 5 00:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13894640 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 139C8CA6F; Thu, 5 Dec 2024 00:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359682; cv=none; b=Sw3QFSnSb0Py/XvCIIxMgDzHmFFe5loFg0nbRqtYvb7c7ndQVLLZMdA6KmkF50yXmv5+M4nCMXTFQO/lsAh1NrOX9ueJ+doliCHzJi40C8NCU+JYVMiVGQBn+bAu7fdXEzhR/Jn7s+Z10TgWAvg6PYjuqp+Wk9y68gOsqC31Phw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359682; c=relaxed/simple; bh=i28X71/BjYrTnrXL1OTZHZGe56vkJmM/YoI0AmPbEfw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zv/2krq6eEGDBGP96FE0NISnE6sbgQm7VOILxi7Hrl0V9m+Bg9tTlEPcRFuP6mhVRB/i+CJcMuZ3W7QvYjgm2bXzIbJoxjY/qRGBcGB1NeL8akpFnnlgsGvI66PoniQhQth0E3AOl/WSgkTLOVbkhT3bKqN5Qu04/eK6sPeaMxo= 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=YFccknqC; arc=none smtp.client-ip=209.85.210.171 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="YFccknqC" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-724f42c1c38so347686b3a.1; Wed, 04 Dec 2024 16:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359679; x=1733964479; 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=BhtsuYMPQb007qW0/oMwsYDjLAG0FyJEKs2Ui1unyzo=; b=YFccknqCscOMY+PWq7nzcy4oihft7iQXZ7h5tuOe3bv2hhOpgCiDHPk+bDzh6KZTMv pp9CSQe2poL5syi9M/IZgCeCijRZTII6yFLp+rNWCz2ANviydXBBuRJDpfz6sVQS8OZd 8VTE3E9QCJkpbgRvrQ7q2vQgFNW1q8akVmWMa1tHDfPAtjpPHn71JZtjEgYLWe/ebiup WQYKkIo3pKPvLAzWHML4XLaXC8aLH3L7yzNdPv/OHpXTRW319GxrOI/4wsAZb8vis83s 3EX1LLQCAk01GXuB6mpNAaECjqG1cW0rJtAP7OxB/elvBERSC8BYQRw4+hFzQNmwUnwP KHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359679; x=1733964479; 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=BhtsuYMPQb007qW0/oMwsYDjLAG0FyJEKs2Ui1unyzo=; b=Pqfu7S7F8SlWfYExSi2ibRHLWKxEh9eNRWoxhT7iU7EdeR9Wx0GE4+4RqE9aVRCGlB F2qH7uTIz8eaFNL7jF4S9sXzLL2tFp9TqungFhyCfkSJbQaPTm///xxQUhg7MV4rkAF8 NBzZ6qFmqpJM67xBa/3PMiwq71AKg+sAxJycKOTcdvrDW7AHsbjh5ZtDO03JgbkwtMxl uxSMNX/YcKX0O0xW1rNQedj7KLWnK7wvCbCJElbLqkq6jeUMBMUy8kCDOKONKbswQJmn rDKBJZ7xHY4Ww4/7LL/OvEHiOyWG4upodYJFHyoyYpmGSikf4FtVCZYlwn39f7s0yJ/C RAzQ== X-Forwarded-Encrypted: i=1; AJvYcCU7/Tt9PEhMwbggXdyEYeshinfwmvmKMKuF8XJpNpCeIOnXsj9kRGOkOSLu/xgEpdKzVDTs09hUH3eX+kg=@vger.kernel.org, AJvYcCUJ/BGdr0T+Vv6mTVku8cETVgjxLdnktr9wtPKiD5yGfyJDwxMTrnzNOEYjHxSHH9vQ3DeI7cYJnS6rExEThpo32TRySw==@vger.kernel.org X-Gm-Message-State: AOJu0YwHEi7t1zMtXh0BcQYhaeycMh3p6snv0mykZrpGN3aF/mkYWpS/ A/9fQZd19mJ4GmJ6IJ756wtrO1zaplx5WyIW4itj0Et+S1xOONTy X-Gm-Gg: ASbGncucsgN7rmLF27dVi0QE2B/bSCIhqzFzSVR4SBOUI1xvgaRIzH8eROIt5i2+YVK 7Dd8OaltcCM7xkApWztGifl33UPTDhovwjAw+qss1nCCZcZW1mo3mdagBLIUt5feT8o808+3LQO 0j3vVkybgl0T8TswfPxY5P14gulw2F1ysWiHcjcZ8tvJgr4A6caebIB4jiIinMKnroJhEXkOr4o +r3Z5LNKRSClHBlOmHEgLVLJPb1fC5d88Ajso6BwVnSJoaQ6tvf0gf3dGQr272aU4FO0EOYAgMp gJZjHw1iwOaQHn3riM0= X-Google-Smtp-Source: AGHT+IG4PWiSwzvJudmwPhNGdXE0nYN9nI5SGEPi+xvWUXE1pZQl7VlI2Rco53ODmANT/XjUsrEEYg== X-Received: by 2002:a17:902:e751:b0:215:4b92:2656 with SMTP id d9443c01a7336-215bd10ed5amr122509195ad.31.1733359679050; Wed, 04 Dec 2024 16:47:59 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8e42752sm1457115ad.55.2024.12.04.16.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:47:58 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 20/21] platform-x86: Split the alienware-wmi module Date: Wed, 4 Dec 2024 21:47:31 -0300 Message-ID: <20241205004730.2187107-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split the alienware-wmi module into three files, which correspond to the different interfaces this module exposed. The new structure roughly works like this: - alienware-wmi-base.c: Manages DMI quirks and will initialize the preferred WMI driver - alienware-wmi-alienfx.c: Manages the sysfs interface exposed by the "alienware-wmi" platform device - alienware-wmi-awcc.c: Manages thermal control methods present on new Alienware and Dell devices These three parts already worked completely independently, so the split is done seamlessly by copying and pasting. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Makefile | 2 + .../platform/x86/dell/alienware-wmi-alienfx.c | 531 ++++++++++++ .../platform/x86/dell/alienware-wmi-awcc.c | 282 +++++++ .../platform/x86/dell/alienware-wmi-base.c | 794 ------------------ 4 files changed, 815 insertions(+), 794 deletions(-) create mode 100644 drivers/platform/x86/dell/alienware-wmi-alienfx.c create mode 100644 drivers/platform/x86/dell/alienware-wmi-awcc.c diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index 5e7496aeb070..54a592fd6ae6 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-alienfx.o +alienware-wmi-y += alienware-wmi-awcc.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-alienfx.c b/drivers/platform/x86/dell/alienware-wmi-alienfx.c new file mode 100644 index 000000000000..d0291d1ba9bb --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi-alienfx.c @@ -0,0 +1,531 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Alienware AlienFX control + * + * Copyright (C) 2014 Dell Inc + */ + +#include +#include +#include +#include "alienware-wmi.h" + +struct wmax_basic_args { + u8 arg; +}; + +/* + * Helpers used for zone control + */ +static int parse_rgb(const char *buf, struct color_platform *colors) +{ + long unsigned int rgb; + int ret; + union color_union { + struct color_platform cp; + int package; + } repackager; + + ret = kstrtoul(buf, 16, &rgb); + if (ret) + return ret; + + /* RGB triplet notation is 24-bit hexadecimal */ + if (rgb > 0xFFFFFF) + return -EINVAL; + + repackager.package = rgb & 0x0f0f0f0f; + pr_debug("alienware-wmi: r: %d g:%d b: %d\n", + repackager.cp.red, repackager.cp.green, repackager.cp.blue); + *colors = repackager.cp; + return 0; +} + +/* + * Individual RGB zone control + */ +static ssize_t zone_show(struct device *dev, struct device_attribute *attr, + char *buf, u8 location) +{ + struct alienfx_priv *priv; + struct color_platform *colors; + + priv = dev_get_drvdata(dev); + colors = &priv->colors[location]; + + return sprintf(buf, "red: %d, green: %d, blue: %d\n", + colors->red, colors->green, colors->blue); + +} + +static ssize_t zone_set(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count, u8 location) +{ + struct alienfx_priv *priv; + struct alienfx_platdata *pdata; + struct color_platform *colors; + 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 = pdata->ops.upd_led(priv, pdata->wdev, 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_set(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) + */ +static ssize_t lighting_control_state_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + 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 (priv->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) +{ + struct alienfx_priv *priv; + struct alienfx_platdata *pdata; + u8 val; + + priv = dev_get_drvdata(dev); + pdata = dev_get_platdata(dev); + + if (strcmp(buf, "booting\n") == 0) + val = LEGACY_BOOTING; + else if (strcmp(buf, "suspend\n") == 0) + val = LEGACY_SUSPEND; + else + val = pdata->running_code; + + priv->lighting_control_state = val; + pr_debug("alienware-wmi: updated control state to %d\n", + priv->lighting_control_state); + + return count; +} + +static DEVICE_ATTR_RW(lighting_control_state); + +static umode_t zone_attr_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return n < pdata->num_zones + 1 ? 0644 : 0; +} + +static bool zone_group_visible(struct kobject *kobj) +{ + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->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) + */ +static void global_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct alienfx_priv *priv; + struct alienfx_platdata *pdata; + int ret; + + priv = container_of(led_cdev, struct alienfx_priv, global_led); + pdata = dev_get_platdata(&priv->pdev->dev); + + priv->global_brightness = brightness; + + ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness); + if (ret) + pr_err("LED brightness update failed\n"); +} + +static enum led_brightness global_led_get(struct led_classdev *led_cdev) +{ + struct alienfx_priv *priv; + + priv = container_of(led_cdev, struct alienfx_priv, global_led); + + return priv->global_brightness; +} + +/* + * The HDMI mux sysfs node indicates the status of the HDMI input mux. + * It can toggle between standard system GPU output and HDMI input. + */ +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, + }; + + 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"); + else if (out_data == 1) + return sysfs_emit(buf, "unconnected [connected] unknown\n"); + } + pr_err("alienware-wmi: unknown HDMI cable status: %d\n", status); + return sysfs_emit(buf, "unconnected connected [unknown]\n"); +} + +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, + }; + + 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) + return sysfs_emit(buf, "[input] gpu unknown\n"); + else if (out_data == 2) + return sysfs_emit(buf, "input [gpu] unknown\n"); + } + pr_err("alienware-wmi: unknown HDMI source status: %u\n", status); + return sysfs_emit(buf, "input gpu [unknown]\n"); +} + +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) + args.arg = 2; + else + args.arg = 3; + pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf); + + 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", + status); + return count; +} + +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) +{ + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->hdmi_mux; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); + +static struct attribute *hdmi_attrs[] = { + &dev_attr_cable.attr, + &dev_attr_source.attr, + NULL, +}; + +static const struct attribute_group hdmi_attribute_group = { + .name = "hdmi", + .is_visible = SYSFS_GROUP_VISIBLE(hdmi), + .attrs = hdmi_attrs, +}; + +/* + * Alienware GFX amplifier support + * - Currently supports reading cable status + * - Leaving expansion room to possibly support dock/undock events later + */ +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, + }; + + 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"); + else if (out_data == 1) + return sysfs_emit(buf, "unconnected [connected] unknown\n"); + } + pr_err("alienware-wmi: unknown amplifier cable status: %d\n", status); + return sysfs_emit(buf, "unconnected connected [unknown]\n"); +} + +static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL); + +static bool amplifier_group_visible(struct kobject *kobj) +{ + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->amplifier; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); + +static struct attribute *amplifier_attrs[] = { + &dev_attr_status.attr, + NULL, +}; + +static const struct attribute_group amplifier_attribute_group = { + .name = "amplifier", + .is_visible = SYSFS_GROUP_VISIBLE(amplifier), + .attrs = amplifier_attrs, +}; + +/* + * Deep Sleep Control support + * - Modifies BIOS setting for deep sleep control allowing extra wakeup events + */ +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, + }; + + 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"); + else if (out_data == 1) + return sysfs_emit(buf, "disabled [s5] s5_s4\n"); + else if (out_data == 2) + return sysfs_emit(buf, "disabled s5 [s5_s4]\n"); + } + pr_err("alienware-wmi: unknown deep sleep status: %d\n", status); + return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n"); +} + +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) + args.arg = 1; + else + args.arg = 2; + pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf); + + 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", + status); + return count; +} + +static DEVICE_ATTR(deepsleep, S_IRUGO | S_IWUSR, show_deepsleep_status, toggle_deepsleep); + +static bool deepsleep_group_visible(struct kobject *kobj) +{ + struct device *dev; + struct alienfx_platdata *pdata; + + dev = container_of(kobj, struct device, kobj); + pdata = dev_get_platdata(dev); + + return pdata->deepslp; +} +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); + +static struct attribute *deepsleep_attrs[] = { + &dev_attr_deepsleep.attr, + NULL, +}; + +static const struct attribute_group deepsleep_attribute_group = { + .name = "deepsleep", + .is_visible = SYSFS_GROUP_VISIBLE(deepsleep), + .attrs = deepsleep_attrs, +}; + +/* + * Platform Driver + */ +static int alienfx_probe(struct platform_device *pdev) +{ + struct alienfx_priv *priv; + struct alienfx_platdata *pdata; + struct led_classdev *leds; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + platform_set_drvdata(pdev, priv); + + priv->pdev = pdev; + + pdata = dev_get_platdata(&pdev->dev); + + priv->lighting_control_state = pdata->running_code; + + 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, + &lifier_attribute_group, + &deepsleep_attribute_group, + NULL +}; + +static struct platform_driver platform_driver = { + .driver = { + .name = "alienware-wmi", + .dev_groups = alienfx_groups, + }, + .probe = alienfx_probe, +}; + +int alienfx_wmi_init(struct alienfx_platdata *pdata) +{ + struct platform_device *pdev; + + pdev = platform_create_bundle(&platform_driver, alienfx_probe, NULL, 0, + pdata, sizeof(*pdata)); + + dev_set_drvdata(&pdata->wdev->dev, pdev); + + return PTR_ERR_OR_ZERO(pdev); +} + +void alienfx_wmi_exit(struct wmi_device *wdev) +{ + struct platform_device *pdev; + + pdev = dev_get_drvdata(&wdev->dev); + + platform_device_unregister(pdev); + platform_driver_unregister(&platform_driver); +} diff --git a/drivers/platform/x86/dell/alienware-wmi-awcc.c b/drivers/platform/x86/dell/alienware-wmi-awcc.c new file mode 100644 index 000000000000..115ef8436ae3 --- /dev/null +++ b/drivers/platform/x86/dell/alienware-wmi-awcc.c @@ -0,0 +1,282 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Alienware AlienFX control + * + * Copyright (C) 2024 Kurt Borja + */ + +#include +#include +#include +#include +#include +#include "alienware-wmi.h" + +#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 +#define WMAX_THERMAL_TABLE_MASK GENMASK(7, 4) +#define WMAX_THERMAL_MODE_MASK GENMASK(3, 0) +#define WMAX_SENSOR_ID_MASK BIT(8) + +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, +}; + +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 wmax_u32_args { + u8 operation; + u8 arg1; + u8 arg2; + u8 arg3; +}; + +/* + * 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) +{ + acpi_status status; + struct wmax_u32_args in_args = { + .operation = operation, + .arg1 = arg, + .arg2 = 0, + .arg3 = 0, + }; + + 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) +{ + acpi_status status; + struct wmax_u32_args in_args = { + .operation = WMAX_OPERATION_ACTIVATE_PROFILE, + .arg1 = profile, + .arg2 = 0, + .arg3 = 0, + }; + 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) +{ + acpi_status status; + struct wmax_u32_args in_args = { + .operation = operation, + .arg1 = 0, + .arg2 = 0, + .arg3 = 0, + }; + + 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 (priv->has_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]); +} + +int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) +{ + struct awcc_priv *priv; + u32 out_data; + u8 sys_desc[4]; + u32 first_mode; + enum wmax_thermal_mode mode; + enum platform_profile_option profile; + int ret; + + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + dev_set_drvdata(&wdev->dev, priv); + + priv->wdev = wdev; + + 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 (has_gmode) { + priv->has_gmode = true; + 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; + + return platform_profile_register(&priv->pp_handler); +} + +void remove_thermal_profile(void) +{ + platform_profile_remove(); +} diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c index 4165eb0d0bf5..7cc6bb3dc0d7 100644 --- a/drivers/platform/x86/dell/alienware-wmi-base.c +++ b/drivers/platform/x86/dell/alienware-wmi-base.c @@ -8,24 +8,12 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include -#include #include #include -#include #include -#include #include #include "alienware-wmi.h" -#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 - MODULE_AUTHOR("Mario Limonciello "); MODULE_DESCRIPTION("Alienware special feature control"); MODULE_LICENSE("GPL"); @@ -43,39 +31,6 @@ enum INTERFACE_FLAGS { 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, -}; - -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; @@ -332,17 +287,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { {} }; -struct wmax_basic_args { - u8 arg; -}; - -struct wmax_u32_args { - u8 operation; - u8 arg1; - u8 arg2; - u8 arg3; -}; - static u8 interface; static struct wmi_driver *preferred_wmi_driver; @@ -372,744 +316,6 @@ acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, return ret; } -/* - * Helpers used for zone control - */ -static int parse_rgb(const char *buf, struct color_platform *colors) -{ - long unsigned int rgb; - int ret; - union color_union { - struct color_platform cp; - int package; - } repackager; - - ret = kstrtoul(buf, 16, &rgb); - if (ret) - return ret; - - /* RGB triplet notation is 24-bit hexadecimal */ - if (rgb > 0xFFFFFF) - return -EINVAL; - - repackager.package = rgb & 0x0f0f0f0f; - pr_debug("alienware-wmi: r: %d g:%d b: %d\n", - repackager.cp.red, repackager.cp.green, repackager.cp.blue); - *colors = repackager.cp; - return 0; -} - -/* - * Individual RGB zone control - */ -static ssize_t zone_show(struct device *dev, struct device_attribute *attr, - char *buf, u8 location) -{ - struct alienfx_priv *priv; - struct color_platform *colors; - - priv = dev_get_drvdata(dev); - colors = &priv->colors[location]; - - return sprintf(buf, "red: %d, green: %d, blue: %d\n", - colors->red, colors->green, colors->blue); - -} - -static ssize_t zone_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count, u8 location) -{ - struct alienfx_priv *priv; - struct alienfx_platdata *pdata; - struct color_platform *colors; - 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 = pdata->ops.upd_led(priv, pdata->wdev, 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_set(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) - */ -static ssize_t lighting_control_state_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - 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 (priv->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) -{ - struct alienfx_priv *priv; - struct alienfx_platdata *pdata; - u8 val; - - priv = dev_get_drvdata(dev); - pdata = dev_get_platdata(dev); - - if (strcmp(buf, "booting\n") == 0) - val = LEGACY_BOOTING; - else if (strcmp(buf, "suspend\n") == 0) - val = LEGACY_SUSPEND; - else - val = pdata->running_code; - - priv->lighting_control_state = val; - pr_debug("alienware-wmi: updated control state to %d\n", - priv->lighting_control_state); - - return count; -} - -static DEVICE_ATTR_RW(lighting_control_state); - -static umode_t zone_attr_visible(struct kobject *kobj, - struct attribute *attr, int n) -{ - struct device *dev; - struct alienfx_platdata *pdata; - - dev = container_of(kobj, struct device, kobj); - pdata = dev_get_platdata(dev); - - return n < pdata->num_zones + 1 ? 0644 : 0; -} - -static bool zone_group_visible(struct kobject *kobj) -{ - struct device *dev; - struct alienfx_platdata *pdata; - - dev = container_of(kobj, struct device, kobj); - pdata = dev_get_platdata(dev); - - return pdata->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) - */ -static void global_led_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct alienfx_priv *priv; - struct alienfx_platdata *pdata; - int ret; - - priv = container_of(led_cdev, struct alienfx_priv, global_led); - pdata = dev_get_platdata(&priv->pdev->dev); - - priv->global_brightness = brightness; - - ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness); - if (ret) - pr_err("LED brightness update failed\n"); -} - -static enum led_brightness global_led_get(struct led_classdev *led_cdev) -{ - struct alienfx_priv *priv; - - priv = container_of(led_cdev, struct alienfx_priv, global_led); - - return priv->global_brightness; -} - -/* - * The HDMI mux sysfs node indicates the status of the HDMI input mux. - * It can toggle between standard system GPU output and HDMI input. - */ -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, - }; - - 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"); - else if (out_data == 1) - return sysfs_emit(buf, "unconnected [connected] unknown\n"); - } - pr_err("alienware-wmi: unknown HDMI cable status: %d\n", status); - return sysfs_emit(buf, "unconnected connected [unknown]\n"); -} - -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, - }; - - 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) - return sysfs_emit(buf, "[input] gpu unknown\n"); - else if (out_data == 2) - return sysfs_emit(buf, "input [gpu] unknown\n"); - } - pr_err("alienware-wmi: unknown HDMI source status: %u\n", status); - return sysfs_emit(buf, "input gpu [unknown]\n"); -} - -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) - args.arg = 2; - else - args.arg = 3; - pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf); - - 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", - status); - return count; -} - -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) -{ - struct device *dev; - struct alienfx_platdata *pdata; - - dev = container_of(kobj, struct device, kobj); - pdata = dev_get_platdata(dev); - - return pdata->hdmi_mux; -} -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); - -static struct attribute *hdmi_attrs[] = { - &dev_attr_cable.attr, - &dev_attr_source.attr, - NULL, -}; - -static const struct attribute_group hdmi_attribute_group = { - .name = "hdmi", - .is_visible = SYSFS_GROUP_VISIBLE(hdmi), - .attrs = hdmi_attrs, -}; - -/* - * Alienware GFX amplifier support - * - Currently supports reading cable status - * - Leaving expansion room to possibly support dock/undock events later - */ -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, - }; - - 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"); - else if (out_data == 1) - return sysfs_emit(buf, "unconnected [connected] unknown\n"); - } - pr_err("alienware-wmi: unknown amplifier cable status: %d\n", status); - return sysfs_emit(buf, "unconnected connected [unknown]\n"); -} - -static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL); - -static bool amplifier_group_visible(struct kobject *kobj) -{ - struct device *dev; - struct alienfx_platdata *pdata; - - dev = container_of(kobj, struct device, kobj); - pdata = dev_get_platdata(dev); - - return pdata->amplifier; -} -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); - -static struct attribute *amplifier_attrs[] = { - &dev_attr_status.attr, - NULL, -}; - -static const struct attribute_group amplifier_attribute_group = { - .name = "amplifier", - .is_visible = SYSFS_GROUP_VISIBLE(amplifier), - .attrs = amplifier_attrs, -}; - -/* - * Deep Sleep Control support - * - Modifies BIOS setting for deep sleep control allowing extra wakeup events - */ -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, - }; - - 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"); - else if (out_data == 1) - return sysfs_emit(buf, "disabled [s5] s5_s4\n"); - else if (out_data == 2) - return sysfs_emit(buf, "disabled s5 [s5_s4]\n"); - } - pr_err("alienware-wmi: unknown deep sleep status: %d\n", status); - return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n"); -} - -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) - args.arg = 1; - else - args.arg = 2; - pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf); - - 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", - status); - return count; -} - -static DEVICE_ATTR(deepsleep, S_IRUGO | S_IWUSR, show_deepsleep_status, toggle_deepsleep); - -static bool deepsleep_group_visible(struct kobject *kobj) -{ - struct device *dev; - struct alienfx_platdata *pdata; - - dev = container_of(kobj, struct device, kobj); - pdata = dev_get_platdata(dev); - - return pdata->deepslp; -} -DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); - -static struct attribute *deepsleep_attrs[] = { - &dev_attr_deepsleep.attr, - NULL, -}; - -static const struct attribute_group deepsleep_attribute_group = { - .name = "deepsleep", - .is_visible = SYSFS_GROUP_VISIBLE(deepsleep), - .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) -{ - acpi_status status; - struct wmax_u32_args in_args = { - .operation = operation, - .arg1 = arg, - .arg2 = 0, - .arg3 = 0, - }; - - 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) -{ - acpi_status status; - struct wmax_u32_args in_args = { - .operation = WMAX_OPERATION_ACTIVATE_PROFILE, - .arg1 = profile, - .arg2 = 0, - .arg3 = 0, - }; - 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) -{ - acpi_status status; - struct wmax_u32_args in_args = { - .operation = operation, - .arg1 = 0, - .arg2 = 0, - .arg3 = 0, - }; - - 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 (priv->has_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]); -} - -int create_thermal_profile(struct wmi_device *wdev, bool has_gmode) -{ - struct awcc_priv *priv; - u32 out_data; - u8 sys_desc[4]; - u32 first_mode; - enum wmax_thermal_mode mode; - enum platform_profile_option profile; - int ret; - - priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); - dev_set_drvdata(&wdev->dev, priv); - - priv->wdev = wdev; - - 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 (has_gmode) { - priv->has_gmode = true; - 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; - - return platform_profile_register(&priv->pp_handler); -} - -void remove_thermal_profile(void) -{ - platform_profile_remove(); -} - -/* - * 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, - &lifier_attribute_group, - &deepsleep_attribute_group, - NULL -}; - -static struct platform_driver platform_driver = { - .driver = { - .name = "alienware-wmi", - .dev_groups = alienfx_groups, - }, - .probe = alienfx_probe, -}; - -int alienfx_wmi_init(struct alienfx_platdata *pdata) -{ - struct platform_device *pdev; - - pdev = platform_create_bundle(&platform_driver, alienfx_probe, NULL, 0, - pdata, sizeof(*pdata)); - - dev_set_drvdata(&pdata->wdev->dev, pdev); - - return PTR_ERR_OR_ZERO(pdev); -} - -void alienfx_wmi_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 device */ From patchwork Thu Dec 5 00:48: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: 13894641 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.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 5359517BD6; Thu, 5 Dec 2024 00:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359706; cv=none; b=pLt+er5vU+lLTbiyzQ/SWv0zUh87usbhWHobB16sKoYHcy5u+OgJZaOTicmmooApAyaNwpZ2BsjhcrxpLVn64KqNJ3JVsmmc8rBvVhzk6mrhQ24OccbMLIQhPPbkjQDvq7IYZrj1HnbMcpLQvOFRdw9D/aG2ALE8z0wHMjGQAXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733359706; c=relaxed/simple; bh=U9buNCn3Q6EwBDv1ejzzt7584TCtyKt3bwWsdIBPaRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SosCRFfXcI7X3JrDu+s2mVlADD2dHWn0jTkXzjma+j53Kw31sFvfb40XOrRbE73jgVM7btCh1RWOLKnAdiM127uBCGu/xMSGjPTHmHMD3Yu0OtF0HHzjc4wuLFcALueovJPtbpwv6CaRhGpt/XSnbGSCVtYSyayzeHOEI57z7As= 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=aqSKL1xz; arc=none smtp.client-ip=209.85.214.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="aqSKL1xz" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-215c4000c20so3735135ad.3; Wed, 04 Dec 2024 16:48:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733359704; x=1733964504; 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=0V9Nc2MLGRoLsywNBsHM1XPUkoBaWbrhQmpIa1sSKzU=; b=aqSKL1xz5sPdGK2YrhH2uDy7eSd+xGRL1SH7xRHxOWxmcV9dxF3iNaRbKc933JVpR4 gz+rwQll1bUlAOqJM5gXhX228ZEFtPZ62MD9eCejemjqpxvBe1PI340sxKjMjp5tbrO5 HkVpo/WJTkp3v86hB4rIoOrfpovbp3pWj9X6SmRYKiPgxYB/buRYlh6Kbh76oX8QVEDe p4FkF8xKE3V4WyVBwJ4Tw3spPR+pQMsLb86jqJ6NvSf2eih8rl3lYcbhtR1MVIf+6aQY slowIEednpO3Qqjten0nJjJ4hV/GosJvwmVv9m+fGtO2srRl3yRIaM7m3MDitW6yC5Q1 cqTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733359704; x=1733964504; 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=0V9Nc2MLGRoLsywNBsHM1XPUkoBaWbrhQmpIa1sSKzU=; b=l6I72+VEKadIRIPWup5W0XpVWJNEJgLeIH3wDYTOHsbpu+ZqGBRrW+HHK6JVQwhx2F 1t/ROigpCTSrAEitrGnk0gH+aD4k6atoifXqL9WR+FpRBEQB7TeqrCV+ZSNfAmVaZ7UQ ON6bozFsusTKMT+4akBmt7b06SG6EWyOHIqUY3eFz41QUzARUQWdd+ycO4HmWV7uQz+l sprIaJkZpVj73biOWna9JefcOM6kd6dwm/AsKZIGHCw66ypYTE3+lB4TXMAdZX0VgAxe njNn66pZV7g1s6aV/yXD+9yX5kei6kTVzaapWUjnPXAzrq8eW4ZYHIY5BZPiCQKrca1O VRRA== X-Forwarded-Encrypted: i=1; AJvYcCUalRLQbZofrn2qy7B831gkX6WAlGhaMsH6W1er3Y3J861S9WgdCSYRDtyaTxhW5zs/vR/4pcORzt0Oz4bNTpssDC0Jgw==@vger.kernel.org, AJvYcCUwc3e2KQZMrQZWvEllOqLAQMC1sLN+lwJ6Mvmxpvt8HMeMwYeE4B4sBbSIBvg48sRvPGPv6dBB1Y+zqc4=@vger.kernel.org X-Gm-Message-State: AOJu0YxBa+DiKfLlXTcdlPS+pfSy1ZKYZlbmAtl0sGwR38i3xkQVjmms y+MgYhuNgzWYqzYcmwmMD+cP3i7SBocWL+4sApdoeItdn3mVAdv5JVtf+WGd X-Gm-Gg: ASbGnct5/ZP5GfJCqhwq6G3xy+vlaKU0+nzzujvsIixmV2bZDdNdT1ucyawaBsgI1pD ZYE88edZevjCo28O6Ck555lmh82e6zNrdhernHRVn+X9LkyRMCJf+JVoC2veyhkTaj/PtteRiim +oTT9QbcAg13KVHvEWIAxCiBdG/C5oJ1BtLGpf2WlJV+4TBLiDZSdE/N6KePRJ6Nl7lBKK2tYCr ALjfT3rUl6R4RlymQITNyxzfWLyuETEWC4hmTlDAHZmclmtlEIck3++7Tp/ArlOa7k3X72V/g3q 7C2eldLeg9vBDs9LbiY= X-Google-Smtp-Source: AGHT+IHdW9EoBC+guyiuoiRxfVcpdxSPxViXTfYiPBAPPbJb7JPwiQUl+M5/dg7Emlzr5VAx6iaM2Q== X-Received: by 2002:a17:902:cec2:b0:215:7fad:49ab with SMTP id d9443c01a7336-215bd1b3babmr103860265ad.10.1733359704549; Wed, 04 Dec 2024 16:48:24 -0800 (PST) Received: from localhost.localdomain (host111.181-10-101.telecom.net.ar. [181.10.101.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f0921asm1384655ad.178.2024.12.04.16.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 16:48:24 -0800 (PST) From: Kurt Borja To: kuurtb@gmail.com Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, w_armin@gmx.de Subject: [RFC PATCH 21/21] platform-x86: Add config entries to alienware-wmi Date: Wed, 4 Dec 2024 21:48:05 -0300 Message-ID: <20241205004804.2187253-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241205002733.2183537-3-kuurtb@gmail.com> References: <20241205002733.2183537-3-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add config entries to conditionally compile alienware-wmi-alienfx.c and alienware-wmi-awcc.c. Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Kconfig | 25 ++++++++++++++++++----- drivers/platform/x86/dell/Makefile | 8 ++++---- drivers/platform/x86/dell/alienware-wmi.h | 22 ++++++++++++++++++++ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig index 2dddafb3f7fa..fcc7f7d28ac1 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -18,16 +18,31 @@ config ALIENWARE_WMI tristate "Alienware Special feature control" default m depends on ACPI + depends on ACPI_WMI + help + This is a driver for controlling Alienware WMI driven + features. + +config ALIENWARE_ALIENFX + bool "Alienware AlienFX backend" + default y depends on LEDS_CLASS depends on NEW_LEDS - depends on ACPI_WMI - select ACPI_PLATFORM_PROFILE + depends on ALIENWARE_WMI 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 + 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. +config ALIENWARE_AWCC + bool "Alienware AWCC backend" + default y + depends on ALIENWARE_WMI + select ACPI_PLATFORM_PROFILE + help + Provides thermal control features on Alienware and Dell's + GSeries laptops with a WMI device with UID "AWCC". + config DCDBAS tristate "Dell Systems Management Base Driver" default m diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index 54a592fd6ae6..6153cff5538f 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -4,10 +4,10 @@ # Dell x86 Platform-Specific Drivers # -obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o -alienware-wmi-objs := alienware-wmi-base.o -alienware-wmi-y += alienware-wmi-alienfx.o -alienware-wmi-y += alienware-wmi-awcc.o +obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o +alienware-wmi-objs := alienware-wmi-base.o +alienware-wmi-$(CONFIG_ALIENWARE_ALIENFX) += alienware-wmi-alienfx.o +alienware-wmi-$(CONFIG_ALIENWARE_AWCC) += alienware-wmi-awcc.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 1c12b8e330e2..16624c824828 100644 --- a/drivers/platform/x86/dell/alienware-wmi.h +++ b/drivers/platform/x86/dell/alienware-wmi.h @@ -110,10 +110,32 @@ struct awcc_priv { acpi_status alienware_wmi_command(struct wmi_device *wdev, u32 method_id, void *in_args, size_t in_size, u32 *out_data); +#if IS_ENABLED(CONFIG_ALIENWARE_ALIENFX) int alienfx_wmi_init(struct alienfx_platdata *pdata); void alienfx_wmi_exit(struct wmi_device *wdev); +#else +int inline alienfx_wmi_init(struct alienfx_platdata *pdata) +{ + return 0; +} + +void inline alienfx_wmi_exit(struct wmi_device *wdev) +{ +} +#endif +#if IS_ENABLED(CONFIG_ALIENWARE_AWCC) int create_thermal_profile(struct wmi_device *wdev, bool has_gmode); void remove_thermal_profile(void); +#else +int inline create_thermal_profile(struct wmi_device *wdev, bool has_gmode) +{ + return 0; +} + +void inline remove_thermal_profile(void) +{ +} +#endif #endif