From patchwork Sun Jan 19 22:05:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13944604 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C33181E0DE6; Sun, 19 Jan 2025 22:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737324374; cv=none; b=aGYl8/awfOAHNRFyK547PHJyuu/+Xv/wIlMdJjdT+htlYW+jzawZ85InyBcrGUvY9+rRhSxhCanbEjk46eGUptcs4NJKQk8806O14rdEQGh9ka74iTTjOrhFTU3h8BUK9BpsV2G4FZr32LdrQNh4aGFI5tCnHolDojeAF4sdSb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737324374; c=relaxed/simple; bh=4IuArjh+AK8PJkZe1DtLRtmSa8xdmHRBNzbo/WXG014=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gdl/lRxoENu1wUC0mXDbRwUjKjYvwflU3DyR0HfNknMAwkdFaq2fgv9bCUB55lTBnfyEhQEfnrT4IXz/rMAkCGaatRoOAx6IyPS0F8ed7A69rFtmUaGUARA2yzsd0bmgmgfunhV+413Pal9e1W3R/VkqmYxXGS3HQy41YzK3vYM= 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=QDBpcSQ3; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QDBpcSQ3" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7b702c3c021so391066385a.3; Sun, 19 Jan 2025 14:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737324371; x=1737929171; 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=WXAQGSLMtinCxvaNfiFVXbDRwjvoN1IPCs2lLpdMaWg=; b=QDBpcSQ3qZHeH2x9//iv9MP5cGSrWslZbT5PDEwBtI6TuW0+mM97eaR/XMz2VJSZTO EtOTDBp4F/oc9yq9hcXiIJPOxgsPjsy7xtmQYxPDs7SfrnGChtEaWbIZSINDf7VnuYvp X+m2SB5lOpp/Bbhfbv7HgTlG+H/NOenP6Vbo307FZHfZtv+557eSnng8Sh5qRNnL+NwF gWqNFvhBmvHzcffQTy8hQHwk9lVQdCm+yybPGqtwS6oF3qFvlEj9AJxceuLLjfFyci4n mpLjMESr2Es6RcVTT/HYTfgrsHhtD+huspwn3qVKO4so3GRVEnzPDjU1XP2desWnxAHe t/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737324371; x=1737929171; 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=WXAQGSLMtinCxvaNfiFVXbDRwjvoN1IPCs2lLpdMaWg=; b=vEHhlvjbFufUyDPeHFmfdy9AEPt5/6shRThJMtf/AjK3xn9rVvmyPncKRBv1/B5bXC Oi8UrDMb9Q2lGJtXsR9UVMzxTTehkq4NrOCbWRHoa4D83MpRRL/nptCnNmnPbnKHJS77 5VD9wK8rOcE1/owTj8DNwzF/syq1d3+f1Ja4DzOCV3FaeVDYWna5cphO++X3yTd2jhLs s1kJLqgmBf8N4PIHQ/hooBVR+RnW5sXH/oaISI+8SbtXbeA1iePE3WPB+hTYKWwEtacG O7571Z2yVVb7h8NW6OAp/D30Lqx+OvyVyUssRrc49018hUOCTWRG1dexTJBy0NSF1uQy nDKQ== X-Forwarded-Encrypted: i=1; AJvYcCVt+S5AuCPQqnTYbWRB6I7shYJKdq7kvHXEYO5H4IOO++C/cfpp23gesSqjx4OLzq0pDxLalFAgV6dI/aA=@vger.kernel.org X-Gm-Message-State: AOJu0YwoARKtql8nKEUU41jEOWHWAI7LPBs5ueNCnqke/+z/s9IISqwj dymZwXM/HY5y2yCyzscLB1aBdx3rvlFxwEteo/U/AHhxOPGyG6/qNnouKw== X-Gm-Gg: ASbGncuiFxC4pv/Og+kRGgWnpa2dW8Az94Wc1qzCIrCpG44BR5cR6G0EttWiNJQPX5M 1OUDFGp0Kjlk0EGsdaghfvtZxC7hw8rztuLhHkkRS8OgUuue8toJnDb/f6kF7/nExms/8wN7M9x QLjyzxITM2+YD0gn1NfFyUAhkSNUolqYr5JYxmjpH2F5vQpGSQ4GIQNHs92vVGdnEDSBpiTNwTH imuaNaIx+aC4ms0A0vmfCzSmtpaII+sBAjI9F2K8WyFowXU86iufDztbs9AvfgGG7LYUNZ4byAB CQ== X-Google-Smtp-Source: AGHT+IEg9NL9o/gAYVr78SzxNcBd1DIzShx1D/TIR6fMdZYRsT4L44E2/4iartfEIGBfsGlWabjH1g== X-Received: by 2002:a05:620a:2888:b0:7b6:c695:fb7c with SMTP id af79cd13be357-7be6320c398mr1651811285a.33.1737324371284; Sun, 19 Jan 2025 14:06:11 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:c837:3446:190b:188d]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7be614f0096sm369243085a.112.2025.01.19.14.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2025 14:06:10 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Armin Wolf" , "Mario Limonciello" , "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, "Kurt Borja" Subject: [PATCH v5 07/14] platform/x86: alienware-wmi: Split DMI table Date: Sun, 19 Jan 2025 17:05:35 -0500 Message-ID: <20250119220542.3136-8-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250119220542.3136-1-kuurtb@gmail.com> References: <20250119220542.3136-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split thermal features into a new DMI table to support upcoming file split. While at it: Rename quirk_entry -> alienfx_features, Rename quirks -> alienfx and change hdmi_mux, amplifier and deepslp types to bool, because they are already being implicitly used as bools. Reviewed-by: Armin Wolf Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/alienware-wmi.c | 337 ++++++++++------------ 1 file changed, 158 insertions(+), 179 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index d2a3d58a65dc..6b19b35dc5b9 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -114,102 +114,68 @@ static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_ [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE, }; -struct quirk_entry { +struct alienfx_quirks { u8 num_zones; - u8 hdmi_mux; - u8 amplifier; - u8 deepslp; - bool thermal; - bool gmode; + bool hdmi_mux; + bool amplifier; + bool deepslp; }; -static struct quirk_entry *quirks; +static struct alienfx_quirks *alienfx; -static struct quirk_entry quirk_inspiron5675 = { +static struct alienfx_quirks quirk_inspiron5675 = { .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = false, - .gmode = false, + .hdmi_mux = false, + .amplifier = false, + .deepslp = false, }; -static struct quirk_entry quirk_unknown = { +static struct alienfx_quirks quirk_unknown = { .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = false, - .gmode = false, + .hdmi_mux = false, + .amplifier = false, + .deepslp = false, }; -static struct quirk_entry quirk_x51_r1_r2 = { +static struct alienfx_quirks quirk_x51_r1_r2 = { .num_zones = 3, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = false, - .gmode = false, + .hdmi_mux = false, + .amplifier = false, + .deepslp = false, }; -static struct quirk_entry quirk_x51_r3 = { +static struct alienfx_quirks quirk_x51_r3 = { .num_zones = 4, - .hdmi_mux = 0, - .amplifier = 1, - .deepslp = 0, - .thermal = false, - .gmode = false, + .hdmi_mux = false, + .amplifier = true, + .deepslp = false, }; -static struct quirk_entry quirk_asm100 = { +static struct alienfx_quirks quirk_asm100 = { .num_zones = 2, - .hdmi_mux = 1, - .amplifier = 0, - .deepslp = 0, - .thermal = false, - .gmode = false, + .hdmi_mux = true, + .amplifier = false, + .deepslp = false, }; -static struct quirk_entry quirk_asm200 = { +static struct alienfx_quirks quirk_asm200 = { .num_zones = 2, - .hdmi_mux = 1, - .amplifier = 0, - .deepslp = 1, - .thermal = false, - .gmode = false, + .hdmi_mux = true, + .amplifier = false, + .deepslp = true, }; -static struct quirk_entry quirk_asm201 = { +static struct alienfx_quirks quirk_asm201 = { .num_zones = 2, - .hdmi_mux = 1, - .amplifier = 1, - .deepslp = 1, - .thermal = false, - .gmode = false, -}; - -static struct quirk_entry quirk_g_series = { - .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = true, - .gmode = true, -}; - -static struct quirk_entry quirk_x_series = { - .num_zones = 2, - .hdmi_mux = 0, - .amplifier = 0, - .deepslp = 0, - .thermal = true, - .gmode = false, + .hdmi_mux = true, + .amplifier = true, + .deepslp = true, }; static int __init dmi_matched(const struct dmi_system_id *dmi) { - quirks = dmi->driver_data; + alienfx = dmi->driver_data; return 1; } @@ -241,42 +207,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { }, .driver_data = &quirk_asm201, }, - { - .callback = dmi_matched, - .ident = "Alienware m17 R5", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), - }, - .driver_data = &quirk_x_series, - }, - { - .callback = dmi_matched, - .ident = "Alienware m18 R2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), - }, - .driver_data = &quirk_x_series, - }, - { - .callback = dmi_matched, - .ident = "Alienware x15 R1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), - }, - .driver_data = &quirk_x_series, - }, - { - .callback = dmi_matched, - .ident = "Alienware x17 R2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), - }, - .driver_data = &quirk_x_series, - }, { .callback = dmi_matched, .ident = "Alienware X51 R1", @@ -304,60 +234,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = { }, .driver_data = &quirk_x51_r3, }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G15 5510", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"), - }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G15 5511", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"), - }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G15 5515", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), - }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G3 3500", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"), - }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G3 3590", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"), - }, - .driver_data = &quirk_g_series, - }, - { - .callback = dmi_matched, - .ident = "Dell Inc. G5 5500", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"), - }, - .driver_data = &quirk_g_series, - }, { .callback = dmi_matched, .ident = "Dell Inc. Inspiron 5675", @@ -432,6 +308,103 @@ struct alienfx_platdata { static u8 interface; +struct awcc_quirks { + bool gmode; +}; + +static struct awcc_quirks g_series_quirks = { + .gmode = true, +}; + +static struct awcc_quirks generic_quirks = { + .gmode = false, +}; + +static const struct dmi_system_id awcc_dmi_table[] __initconst = { + { + .ident = "Alienware m17 R5", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), + }, + .driver_data = &generic_quirks, + }, + { + .ident = "Alienware m18 R2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"), + }, + .driver_data = &generic_quirks, + }, + { + .ident = "Alienware x15 R1", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"), + }, + .driver_data = &generic_quirks, + }, + { + .ident = "Alienware x17 R2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"), + }, + .driver_data = &generic_quirks, + }, + { + .ident = "Dell Inc. G15 5510", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"), + }, + .driver_data = &g_series_quirks, + }, + { + .ident = "Dell Inc. G15 5511", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"), + }, + .driver_data = &g_series_quirks, + }, + { + .ident = "Dell Inc. G15 5515", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"), + }, + .driver_data = &g_series_quirks, + }, + { + .ident = "Dell Inc. G3 3500", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"), + }, + .driver_data = &g_series_quirks, + }, + { + .ident = "Dell Inc. G3 3590", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"), + }, + .driver_data = &g_series_quirks, + }, + { + .ident = "Dell Inc. G5 5500", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"), + }, + .driver_data = &g_series_quirks, + }, +}; + +static struct awcc_quirks *awcc; + static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id, void *in_args, size_t in_size, u32 *out_data) { @@ -614,7 +587,7 @@ static DEVICE_ATTR_RW(lighting_control_state); static umode_t zone_attr_visible(struct kobject *kobj, struct attribute *attr, int n) { - if (n < quirks->num_zones + 1) + if (n < alienfx->num_zones + 1) return attr->mode; return 0; @@ -622,7 +595,7 @@ static umode_t zone_attr_visible(struct kobject *kobj, static bool zone_group_visible(struct kobject *kobj) { - return quirks->num_zones > 0; + return alienfx->num_zones > 0; } DEFINE_SYSFS_GROUP_VISIBLE(zone); @@ -748,7 +721,7 @@ static DEVICE_ATTR_RW(source); static bool hdmi_group_visible(struct kobject *kobj) { - return quirks->hdmi_mux; + return alienfx->hdmi_mux; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi); @@ -797,7 +770,7 @@ static DEVICE_ATTR_RO(status); static bool amplifier_group_visible(struct kobject *kobj) { - return quirks->amplifier; + return alienfx->amplifier; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier); @@ -870,7 +843,7 @@ static DEVICE_ATTR_RW(deepsleep); static bool deepsleep_group_visible(struct kobject *kobj) { - return quirks->deepslp; + return alienfx->deepslp; } DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep); @@ -1011,7 +984,7 @@ static int thermal_profile_set(struct device *dev, { struct awcc_priv *priv = dev_get_drvdata(dev); - if (quirks->gmode) { + if (awcc->gmode) { u32 gmode_status; int ret; @@ -1077,7 +1050,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices) if (bitmap_empty(choices, PLATFORM_PROFILE_LAST)) return -ENODEV; - if (quirks->gmode) { + if (awcc->gmode) { priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; @@ -1300,7 +1273,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context) struct platform_device *pdev; int ret; - if (quirks->thermal) { + if (awcc) { return alienware_awcc_setup(wdev); } else { ret = alienware_alienfx_setup(&pdata); @@ -1321,7 +1294,7 @@ static void wmax_wmi_remove(struct wmi_device *wdev) { struct platform_device *pdev; - if (!quirks->thermal) { + if (!awcc) { pdev = dev_get_drvdata(&wdev->dev); device_remove_groups(&pdev->dev, wmax_alienfx_groups); @@ -1348,6 +1321,22 @@ static struct wmi_driver alienware_wmax_wmi_driver = { static int __init alienware_wmax_wmi_init(void) { + const struct dmi_system_id *id; + + id = dmi_first_match(awcc_dmi_table); + if (id) + awcc = id->driver_data; + + if (force_platform_profile) + awcc = &generic_quirks; + + if (force_gmode) { + if (awcc) + awcc->gmode = true; + else + pr_warn("force_gmode requires platform profile support\n"); + } + return wmi_driver_register(&alienware_wmax_wmi_driver); } @@ -1361,18 +1350,8 @@ static int __init alienware_wmi_init(void) int ret; dmi_check_system(alienware_quirks); - if (quirks == NULL) - quirks = &quirk_unknown; - - if (force_platform_profile) - quirks->thermal = true; - - if (force_gmode) { - if (quirks->thermal) - quirks->gmode = true; - else - pr_warn("force_gmode requires platform profile support\n"); - } + if (!alienfx) + alienfx = &quirk_unknown; ret = platform_driver_register(&platform_driver); if (ret < 0)