From nobody Mon Sep 28 22:28:41 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 7BDB237BE7F for ; Sun, 16 Aug 2026 00:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839140; cv=none; b=UyxtdHW3+zYTY2kXGlFsBhYugZ28kB8qHEaxWRXcmduc/rZr4K6U/7VXuOWGl+04ORq0BS8CM/GfuPGE1hQKjqID/boxVK3ZPfH9iwicGSoKjpYkG8NUjCIj66cWKfAcsZE00JLCD6SzyUhHTs4P+lyysrbvnKUw/mH35dJreI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839140; c=relaxed/simple; bh=QY5aebFr1evE8tRE7OmTPb6tag7jx6XNKxf+rMRmOXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BytoLoi/1ZVi2ZcASfJAEbioQs2YDR9wOmw4yroCZr3+Jj4W2Yz0fe0o/xsoNPIKx35FxUJpAlnEcJc1a0hFC9KE0RG/1pw9zQWcc4prOcWcsKssIi2ukhIkuDgFpS6SORxy1ylZehk2pmXeIAy0nSsAmJ5n1rhIpwjwAsTx7Mo= 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=I4/PKcnr; arc=none smtp.client-ip=209.85.216.45 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="I4/PKcnr" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-38e58034d05so1861465a91.2 for ; Sat, 15 Aug 2026 17:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839135; x=1787443935; 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:content-type; bh=A3guaqxr7NyyvixOm12MKeegXbSzy/kPgiJ95xUExEc=; b=I4/PKcnr6YgWig2Cl38H0q6AtM/MGxBGQgq699cH8jB0zcLzUCWw93lYEVkjeREEV8 xNanjNq1gPl96bI8PHiFFYzRBqfaEnWN115lho6KqWj1xxpJvjhmcoaa+t48PWOt8gpg DrjoWZdBCGztxPdjMi6FDAh5EgC5i5PdYc+ihdKNcbDKcLl24k2sKsfGZ5Ndv78vlLo7 Cga+ouUhU8cHpDolRzXIzhSbnTRoSFh0a0LmMzOooGu0TDEBL+Ci2Nk0mRRbMHaenaQP 2yrpzWys7euZKiumg079gxpjLoi7pJCTCM2Id3llgu1LeNde3ce3ORpcLFH9l/85yzks M+KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839135; x=1787443935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=A3guaqxr7NyyvixOm12MKeegXbSzy/kPgiJ95xUExEc=; b=mkdDHXtUvHFXRlBiNQD0HI+1lZSnS+wuxwBj0ig0Fn9P4aUit+/kFj6XG7Si0EpCLy tJjHc00IwAG+daR8prfNU8A7e6+QPFSr2ErP4S6HNAkGb7VYc6OuegupFswYScjVl4Io Ww90XXQiio3wXT2J19ou7NEVPTsfwDtHxnGUXEf+nJ2a6DW3JbC6qfC1SKSgrTww277k YD3E3LIh9pWHBOuDLgBZVKdiZ6aTQhcyIirDvipCZFeJpJ9rKNbV7xLgQSxLQ9QlMmBm bHO0kKY+nZUQqrsW97v8io7CGGRA2gM/XSTFzd8O4qBdCOmQ1vV87nVXQ4Jzcw+/0hYL WBuA== X-Forwarded-Encrypted: i=1; AHgh+RrPHPwv4kHqbYD2uz7hrkA5hx3B0AJ8R4Pgpnr5h2hhV7ObEGOhMxbmtfcejha1guP5vEYKq23mq1F6E6Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzJXGYLraTINqiQbb1VdlrTh+ZUXIk6egWiizkN6fZENaD8fHby pEjM50j2GJNTStA9vZo8dN7Ng3RpKVeKyW/ERooE0uZP7Sr6F8LalosQ X-Gm-Gg: AR+sD11/KTD8npp84au2ujJVMEysroy2E6xW4cXLibpj1bxif7g654o5Lh6Egyg4s7D Wm1GBHGvjTk/flpK2CSpRvXxa5H//xRU4+bVes8BjHivr2imDqPxL7UHDGrq6qfzkqBBAFzWQyN N/Itc73RXaX2oFiNk/QDr845vPWFvVABXNoH+rCG6fy/OKM51WhnjVjIoFjf81QNSJ+BhRFOTaS X2uwXdY/qpb5gKeRKu1C5THJQbAdiinYU7Zaw4d2KpUhlRJM2FSdnSHdNH7EfpzckGzQBDGZQmc ft2qY2PH0xwcwPnrx6AdW5E4apI4IE+7ltJr8zrQ895dxzaeL7TRRF5gFPcPEeSEJz6/oKZnSRN H2UBLWnoUkpDpnH6SPTYyBydnTwrYRxezfXWhuk5fkI1d+GrWPl0/CKJ3NibFa1aNR1VFulYz8f kG3/BeHYktnhJfJ4ZRP5W2j1agm6n87g3VIv8= X-Received: by 2002:a17:90b:1d44:b0:366:3517:1aa2 with SMTP id 98e67ed59e1d1-3933b4fa051mr16661547a91.0.1786839134719; Sat, 15 Aug 2026 17:12:14 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:13 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 1/6] MAINTAINERS: Add maintainer entry of bitland-mifs-wmi driver Date: Sun, 16 Aug 2026 08:11:24 +0800 Message-ID: <20260816001129.16998-2-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new maintainer entry for the bitland-mifs-wmi platform driver. Signed-off-by: Mingyou Chen --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f37a81950e25..af86b1df1a94 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22774,6 +22774,13 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/x86/redmi-wmi.c =20 +BITLAND LAPTOP DRIVER +M: Mingyou Chen +M: Gladyshev Ilya +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/x86/bitland-mifs-wmi.c + REDPINE WIRELESS DRIVER L: linux-wireless@vger.kernel.org S: Orphan --=20 2.55.0 From nobody Mon Sep 28 22:28:41 2026 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 BE73E37BE71 for ; Sun, 16 Aug 2026 00:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839144; cv=none; b=nqQblkhlzG81R4gHSS+Cm5OMCXVgPfwMZV7ENQbfbrh9e3qD0pArRFD9zzaC3kJODjPulA3aZdDJz8dO6AwzWf+5CYlVWQ8XXphvzBlbb2sSUra8Ace444rgZmL0GgfnPb1buu0Z09NazWXvRWlXNz3OSYW/8YS3kYk+7jxwTu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839144; c=relaxed/simple; bh=qycZ0BRozYzT9bbWxMfxPy3rhm2G36ZCHEaEgjWL4BA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IkeoHPh326WgLC4eNznkhke+JmxEFrzMbwhwGJVeBQrLrDbtcKWAYsO6cjc+rEWdDWYRsxg1noziTln/6S38JtUUTIeFG+VorCKV3oXhF9Fa4kbHXtopZUrEcHeq3QtxD2A3KfZaMbpdEQi09ol+LCkknUUo6tOpUSdzIGDfjUM= 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=GOgFOQGz; arc=none smtp.client-ip=209.85.216.52 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="GOgFOQGz" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-38dd55ad76cso2186156a91.1 for ; Sat, 15 Aug 2026 17:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839139; x=1787443939; 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:content-type; bh=AyjTvRH2L6UPE0KXVLuz5HIPgBQCFlPffiuhEy0FlTw=; b=GOgFOQGzbLE65/fcBq43MMdWQnKJB38dcQkceLg0jdfvKLzGloguyjPS8G+fK8FFUU Anw7nxxb6XteONVmec0BjAYA4Kl6CMqTiEwsCAZ3WIygCjjTiFbrw/hjcRtZni8ka/NS XjGgP3zkR5TycRl7JpcF6KSuTeqnCZq2T9vATpYvlE1EJPO2SNDmRq6hup6s4FNxNOje dgodbfWtkFhqV3utrS9a31GEBidXts8dhbKlkQsvqEHuZFjm/KhSp3EG+V/huGsTWK+O FDBruuyjM+H2fUkWDqbOmJfFrFrr6BoMtxvMOikefragHs5potXO0ZWBSbL4z5yJbEwq Jxqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839139; x=1787443939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AyjTvRH2L6UPE0KXVLuz5HIPgBQCFlPffiuhEy0FlTw=; b=elGTUzaSzm+QprZX/IAINwOMioErv8PsOTbg2IH6QQO+Ev5RJKgt22fy1dHhE7CBXH NCukBGoCZ8dsGORNyZ2g0qtUFLLbR5YfPdC6vW1AYQeuNCL0NAtKvahQRxxdJKbctHNQ oroggV9iRMDkL+GKPtVVwBAZJLno/0mS//LYeBJVU1/eyUcNzZH38G5zJCYKjJGESIWk YZd3BcT//Ml/xVnIMs/L7e3I4x496QMDww4W9FcfDZ7WhZhWkSNRYB+P8bDlkuO/i88U VqljJrBfUPfDXtfz87lZwaMwaag9PR17uMk2iLJFgU27TTDYe5+xfJaJdrc8XUqh1eCw oc2Q== X-Forwarded-Encrypted: i=1; AHgh+Rr6P8LvpCavi4qdKkqAji5QQ52Z33E+GWoRTKlWFTJ0mDcSKitkXqySCZVEr+v11BoOSw+DYIsC/BUF3l8=@vger.kernel.org X-Gm-Message-State: AOJu0YwuqKwMZUsRb0Gtyt6dmOHtpLlzNIhlWox8ANPRaM6utpGRb6xU WNL2V/1w+mQmRkYUzGc4kLcyA+1zrhCMAMdgVIYsDj+ByT7/QU5HdTWE X-Gm-Gg: AR+sD10366W/IneZPOf3QDxz0jrFD0WB7GtYYpip9swFV9d7JVIa76IXrtsIfOaonBb 2it08tZoqLFKIrVPc405omlVRhVqfpSU7h8SGpBFxkhf7MAoLlH9XYn+sq1pSYiQjLbngNXGbjo ehIWRJPYTZPVTsfQenUttm0fDRukHVoMaXynJACHIrkVup3EBw6yuxZzeVincE3En89FpLkg9d9 wXmR/j2d8GC9dzQaINwo2cmixZdo0DAspYwiLrZpu9+yW1Bnx9Fv3J+/1iOc1NN8VcYBgeAc4VY yWUvPygQFC5JOgawrL6FKtamvNbrsq4yClZ3t5NZ9gn/fua0BmKchNoCWT9aGERtlPQujLcuaHO uMt+fJebYHQCKeQmYuBfaWqKkrcM27hvrzrmnUqAirG1QhDRcDwyDrspXNim3r8suODZ6zGB8JB W86Hq42kCeGmETLOOUA6ItbaPaYb5v3AMIVm8= X-Received: by 2002:a17:90b:1dcb:b0:38e:5ce1:ae30 with SMTP id 98e67ed59e1d1-3933b0d37ebmr11959267a91.14.1786839138915; Sat, 15 Aug 2026 17:12:18 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:17 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 2/6] platform/x86: bitland-mifs-wmi: Merge the function of redmi-wmi into the bitland driver Date: Sun, 16 Aug 2026 08:11:25 +0800 Message-ID: <20260816001129.16998-3-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The bitland-mifs-wmi and legacy redmi-wmi drivers both attempt to bind to the same WMI GUID (46C93E13-EE9B-4262-8488-563BCA757FEF). This overlap causes a device registration conflict, preventing one of the drivers from loading properly depending on the module initialization order. Merge the event handling logic from redmi-wmi into bitland-mifs-wmi. By handling both device layouts within a single driver, we eliminate the GUID ownership conflict. Tested-by: Nika Krasnova Signed-off-by: Mingyou Chen --- drivers/platform/x86/bitland-mifs-wmi.c | 139 ++++++++++++++++-------- 1 file changed, 96 insertions(+), 43 deletions(-) diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86= /bitland-mifs-wmi.c index b0d06a80e89e..8b6476881de6 100644 --- a/drivers/platform/x86/bitland-mifs-wmi.c +++ b/drivers/platform/x86/bitland-mifs-wmi.c @@ -34,6 +34,11 @@ #include #include =20 +#define BI_HOTKEY_CODE(id, low, high) \ + (((u32)(high) << 24) | ((u32)(low) << 16) | ((u32)(id) << 8) | WMI_EVENT_= TYPE_HOTKEY) + +#define AI_KEY_VALUE_MASK BIT(8) + #define DRV_NAME "bitland-mifs-wmi" #define BITLAND_MIFS_GUID "B60BFB48-3E5B-49E4-A0E9-8CFFE1B3434B" #define BITLAND_EVENT_GUID "46C93E13-EE9B-4262-8488-563BCA757FEF" @@ -601,18 +606,59 @@ static const struct attribute *const laptop_attrs[] = =3D { ATTRIBUTE_GROUPS(laptop); =20 static const struct key_entry bitland_mifs_wmi_keymap[] =3D { - { KE_KEY, WMI_EVENT_OPEN_APP, { KEY_PROG1 } }, - { KE_KEY, WMI_EVENT_CALCULATOR_START, { KEY_CALC } }, - { KE_KEY, WMI_EVENT_BROWSER_START, { KEY_WWW } }, - { KE_IGNORE, WMI_EVENT_FN_J, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_F, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_0, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_1, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_2, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_3, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_4, { KEY_RESERVED } }, - { KE_IGNORE, WMI_EVENT_FN_5, { KEY_RESERVED } }, - { KE_END, 0 } + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_OPEN_APP, 1, 0), { KEY_PROG1 } }, + + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_CALCULATOR_START, 1, 0), { KEY_CALC } = }, + + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_BROWSER_START, 1, 0), { KEY_WWW } }, + + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_J, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_F, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_0, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_1, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_2, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_3, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_4, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FN_5, 0, 0), {} }, + + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_2, 0, 0), { KEY_SELECTIVE_SCR= EENSHOT } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_3, 0, 0), { KEY_ALL_APPLICATI= ONS } }, + { KE_KEY, BI_HOTKEY_CODE(0x1b, 0, 0), { KEY_CONFIG } }, + { KE_KEY, BI_HOTKEY_CODE(0x1b, 1, 0), { KEY_CONFIG } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_1, 1, 0), { KEY_SWITCHVIDEOMO= DE } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_REFRESH_RATE, 0, 0), { KEY_REFRESH_RAT= E_TOGGLE } }, + + /* AI button has code for each position */ + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_5, 1, 0), { KEY_ASSISTANT } }, + + { KE_KEY, BI_HOTKEY_CODE(0x19, 1, 0), { KEY_ASSISTANT } }, + + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_BRIGHTNESS, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_BRIGHTNESS, 0, 0x80), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_BRIGHTNESS, 5, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_BRIGHTNESS, 0x0a, 0), {} }, + + /* Xiaomi G Command Center */ + { KE_KEY, BI_HOTKEY_CODE(0x0a, 1, 0), { KEY_VENDOR } }, + + /* OEM preset power mode */ + { KE_IGNORE, BI_HOTKEY_CODE(0x16, 1, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(0x16, 2, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(0x16, 3, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(0x16, 4, 0), {} }, + + /* Fn Lock state */ + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FNLOCK_STATE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FNLOCK_STATE, 1, 0), {} }, + + /* Fn+`/1/2/3/4 */ + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_F, 1, 0), { KEY_F13 } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_0, 1, 0), { KEY_F14 } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_1, 1, 0), { KEY_F15 } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_2, 1, 0), { KEY_F16 } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_3, 1, 0), { KEY_F17 } }, + + { KE_END } }; =20 static void bitland_notifier_unregister(void *data) @@ -730,12 +776,35 @@ static int bitland_mifs_wmi_probe(struct wmi_device *= wdev, const void *context) &drv_data->notifier); } =20 +static void bitland_mifs_wmi_report_key(struct wmi_device *wdev, u32 paylo= ad) +{ + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(&wdev->dev); + struct key_entry *entry; + bool autorelease =3D true; + int value =3D 1; + + entry =3D sparse_keymap_entry_from_scancode(data->input_dev, payload); + if (!entry) { + dev_dbg(&wdev->dev, "Unknown WMI hotkey with payload 0x%08x\n", payload); + return; + } + + /* AI key quirk */ + if (entry->keycode =3D=3D KEY_ASSISTANT) { + value =3D !(payload & AI_KEY_VALUE_MASK); + autorelease =3D false; + } + + guard(mutex)(&data->lock); + sparse_keymap_report_entry(data->input_dev, entry, value, autorelease); +} + static void bitland_mifs_wmi_notify(struct wmi_device *wdev, const struct wmi_buffer *buffer) { - struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(&wdev->dev); const struct bitland_mifs_event *event =3D buffer->data; struct bitland_fan_notify_data fan_data; + u32 payload; u8 brightness; =20 /* Validate event type */ @@ -752,24 +821,13 @@ static void bitland_mifs_wmi_notify(struct wmi_device= *wdev, blocking_notifier_call_chain(&bitland_notifier_list, BITLAND_NOTIFY_KBD_BRIGHTNESS, &brightness); - break; + return; =20 case WMI_EVENT_PERFORMANCE_PLAN: blocking_notifier_call_chain(&bitland_notifier_list, BITLAND_NOTIFY_PLATFORM_PROFILE, NULL); - break; - - case WMI_EVENT_OPEN_APP: - case WMI_EVENT_CALCULATOR_START: - case WMI_EVENT_BROWSER_START: { - guard(mutex)(&data->lock); - if (!sparse_keymap_report_event(data->input_dev, - event->event_id, 1, true)) - dev_warn(&wdev->dev, "Unknown key pressed: 0x%02x\n", - event->event_id); - break; - } + return; =20 /* * The device has 3 fans (CPU, GPU, SYS), @@ -777,6 +835,14 @@ static void bitland_mifs_wmi_notify(struct wmi_device = *wdev, */ case WMI_EVENT_CPU_FAN_SPEED: case WMI_EVENT_GPU_FAN_SPEED: + /* Redmi refresh rate toggle quirk */ + if (event->event_id =3D=3D WMI_EVENT_CPU_FAN_SPEED && + event->value_low =3D=3D 0 && event->value_high =3D=3D 0) { + payload =3D BI_HOTKEY_CODE(WMI_EVENT_REFRESH_RATE, 0, 0); + bitland_mifs_wmi_report_key(wdev, payload); + return; + } + if (event->event_id =3D=3D WMI_EVENT_CPU_FAN_SPEED) fan_data.channel =3D 0; else @@ -787,27 +853,14 @@ static void bitland_mifs_wmi_notify(struct wmi_device= *wdev, blocking_notifier_call_chain(&bitland_notifier_list, BITLAND_NOTIFY_HWMON, &fan_data); - break; - - case WMI_EVENT_AIRPLANE_MODE: - case WMI_EVENT_TOUCHPAD_STATE: - case WMI_EVENT_FNLOCK_STATE: - case WMI_EVENT_KBD_MODE: - case WMI_EVENT_CAPSLOCK_STATE: - case WMI_EVENT_NUMLOCK_STATE: - case WMI_EVENT_SCROLLLOCK_STATE: - case WMI_EVENT_REFRESH_RATE: - case WMI_EVENT_WIN_KEY_LOCK: - /* These events are informational or handled by firmware */ - dev_dbg(&wdev->dev, "State change event: id=3D%d value=3D%d\n", - event->event_id, event->value_low); - break; + return; =20 default: - dev_dbg(&wdev->dev, "Unknown event: id=3D0x%02x value=3D0x%02x\n", - event->event_id, event->value_low); break; } + + payload =3D get_unaligned_le32(buffer->data); + bitland_mifs_wmi_report_key(wdev, payload); } =20 static const struct wmi_device_id bitland_mifs_wmi_id_table[] =3D { --=20 2.55.0 From nobody Mon Sep 28 22:28:41 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 4F0F137BE95 for ; Sun, 16 Aug 2026 00:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839147; cv=none; b=cxJVHYXe1BhhDiM4M46+8ELWM3Is8tEXJMCKp32emKpRnCRWwr+GoyExkQCR+dCmFQeAThIjPCUZPBBffYMCEd3MBv/IKXq9P11wC4UR3d+xKIS0rK7/8L2ZpqfOgGBRX347p0Fn9mW34ZRNUEPqS3yu7uGqUqIOksdALjlHe3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839147; c=relaxed/simple; bh=fCV+2yJC4cZrnJl1H1PmJvR+PHD59988Urbd1y2vbjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AjzKlSBd9MSMaeLmujY9w4ZVy7nNvJyRKZ/UKDIkpTBZ0GvgAbkPqWptlPgfFNOfbvYWAZwsXPNb6GPdnjVawo9pVdwTESwA/kTkWa7CAe+1MmLqB3TgbOMvkJHFwtsXoGRi73pXcZUAIZqQHb+KGOgu4+rQ7dvTF6LEqipegqw= 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=Hv/Guei+; arc=none smtp.client-ip=209.85.216.47 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="Hv/Guei+" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-38e347638adso2693764a91.0 for ; Sat, 15 Aug 2026 17:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839143; x=1787443943; 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:content-type; bh=TFReB0FpblksjxyfEVt8Xa+UaQs+LIPFGRM0Eqvgr6U=; b=Hv/Guei+fXxGRZsHvVnwGlcyiFpRJQXSyCcN/Dr6G1Tla4qL5qKuUUU9r302S7LB5A xzmQ4tHDTBWucKOIP6mo4QUNgxaPeNEcLrfAqmUZd5Gynekl6oDGKuyMhvtw2lPKwCdQ 0BaiiYGh15d7M3MonOwN7iOe2I9WrPIx/eFvxQ1TDDqrE2sfuR6mLexlOLmmk4xZioJh l/vZ/ugGlcZu0MBBpeWwX4GzQ5HJmmKMkyWAKP/tr2cQL1vfCBRkFkVRwLqcdTpBksr6 h5k/DOoGQXHV+pS88lsmmmWfd6yX6xq7DLXWJAny5aRQa4ABx2gXtmVVuSOyz7gmKDCN DcLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839143; x=1787443943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TFReB0FpblksjxyfEVt8Xa+UaQs+LIPFGRM0Eqvgr6U=; b=mE1Xi8f1JwmQJeKNREpvqxVvQPoNP7g14qK/nuejLqKd2DrTEPUEiDikYWPJB8I32v XQInNfD+k39iaXRuxhsq+GS9XUuGxhm9RmiAsx0zDg4lrSU/RmBPu4tWRmvHSwAO5TQ1 ptwcIUC5tdAEd++S2W8wqE1bqIAHtgwu0qc49apeeQZAQRfDEMj9/M/AQn11fPe5mNNl C9B+J7ro94CBOFTxO+V+NLZpgGpQh7IerNiD9waCZbt/WAsUKYgFLllts42AFvGctLU7 4p0JR+gC63nv4YpM6SZ40SjqBC5KjYMridXIM3WhZWPvpit9S20eB8UHa1HrRz7Y+o1w dJDw== X-Forwarded-Encrypted: i=1; AHgh+Rr/5DjdnZrmai9SVoF72KDZJbwrutM20YLKFsKQc4WhnxZMjuLP9vGWeYDnzqlsM7iHPm+P0R7wMGbDo5U=@vger.kernel.org X-Gm-Message-State: AOJu0YyXRJka1HFzWNVjk3eE2NCjxkTcsmV0nut7427HG9d6dMuTT7jc kuS8RSP9hbFMIBjyhUWn/2GeYLyYRK6TNNx2aWks1+klK+gu2YH+2o9q X-Gm-Gg: AR+sD10wIooqb3VvxNdTpzSc7JhjFTTvEt8eN2vjiv0kcDxUqV1Ft19vMp0uvK06nJl 2iDEGinimGEZSxivmfwH1/OQfHfZSehY0hfo1VD4d8/GwyJVSqI5dKngTltwyIqAk7xH+6axXTv iBSkbcLQIsASOwjW+MtZVzg1kdjy0jW09BH2wnOpCNdVwe6UMRnpmknFSMRN2ESMLq3WHwwRaZN cyst6laHKMaLUZLMLozb5I9xyhN87Wmy82kIdM+fbiBgSavHskWBejEv/FSSJrOCoGYWlmyUsYc 79Y94zFLFkT5AisaJJKoeK6Yvejw16fSwe34/jZoF9R+El3Jl75Shol77JO9Lfl0X8MlOCdmU5w We4ElX1MIZGhI6N/Luqbp3twtd1h+V7fyNdtrEPrIgjWhTGeEY7BXtsNZ+5gf+Jt+Ohjwpmbxo9 K+grbyik8eyezvYqZc6GBZVTSjIdrgNiOrEVY= X-Received: by 2002:a17:90b:4d08:b0:37f:c22a:c188 with SMTP id 98e67ed59e1d1-3933b6f0622mr16027893a91.4.1786839142688; Sat, 15 Aug 2026 17:12:22 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:22 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 3/6] platform/x86: bitland-mifs-wmi: Add Redmi mic-mute key entries Date: Sun, 16 Aug 2026 08:11:26 +0800 Message-ID: <20260816001129.16998-4-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the missing Redmibook mic-mute hotkey definitions to the shared sparse keymap table: - 0x00002101 (Fn-lock disabled state) - 0x00012101 (Fn-lock enabled state) Reported-by: Nika Krasnova Link: https://lore.kernel.org/platform-driver-x86/20260531123345.237521-1-nika@ni= kableh.moe/ Signed-off-by: Mingyou Chen --- drivers/platform/x86/bitland-mifs-wmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86= /bitland-mifs-wmi.c index 8b6476881de6..81dad2b65f4f 100644 --- a/drivers/platform/x86/bitland-mifs-wmi.c +++ b/drivers/platform/x86/bitland-mifs-wmi.c @@ -628,6 +628,10 @@ static const struct key_entry bitland_mifs_wmi_keymap[= ] =3D { { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_1, 1, 0), { KEY_SWITCHVIDEOMO= DE } }, { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_REFRESH_RATE, 0, 0), { KEY_REFRESH_RAT= E_TOGGLE } }, =20 + /* Mic-mute key */ + { KE_KEY, BI_HOTKEY_CODE(0x21, 0, 0), { KEY_MICMUTE } }, + { KE_KEY, BI_HOTKEY_CODE(0x21, 1, 0), { KEY_MICMUTE } }, + /* AI button has code for each position */ { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_5, 1, 0), { KEY_ASSISTANT } }, =20 --=20 2.55.0 From nobody Mon Sep 28 22:28:41 2026 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 C487637E5DA for ; Sun, 16 Aug 2026 00:12:29 +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=1786839153; cv=none; b=F6Qfq/cYPy5hVLYuDBHAe7+BiYLznA67MlAxqSQw9j8qeGnRseUYIJbg/hFOSNCjYoWpJvM3Ygl7lQ+4CyoVRXlbMS7O8pVB4/Fq5lGmj9FEv2PBKI05S415LNbY2C8ENHJf92jo+urvU5d7PFaF5p7lVX527JGFAcsQjFXduc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839153; c=relaxed/simple; bh=qaNQ/iKdm+tr9gI6Dq66O60lBZHzk6jx64BBqORlpLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B7qRzusUHVRW8oCeqJZgUvAYTyPzAYSnS2DbdghW6zdvLimqPCrNC1DBxe7xbxPtnZCMbu6T0EprE/PpJOygrEsQTC8Z0aIRKEXsc5zo8HXNb2IarWo/zuef+8+IZl1n4WlaWZXbUaZNnYBgHh6KimHmi4AOrv4Xaydi72IYXpQ= 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=loyEtwBL; 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="loyEtwBL" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2d02b4c3601so25256125ad.3 for ; Sat, 15 Aug 2026 17:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839146; x=1787443946; 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:content-type; bh=7u0RLtYXUYQ7iwz3Gl2qvOsAZ+m2eRqkafH2q6kwGqA=; b=loyEtwBLb3OLXES1ELEO/wslIu4qgm7r3Yus4QMIw9IMxiOxzDfEEjM9Ry3zm1lqEM PNMa1xD9acUioJ8igyjlBeOiMJ/fJg+Nf8tbLXvC6scPzeWrSFLcUTsqpG6wYFdmfuIq 6noF18XnxAA6xwo/6S9nGS39/Z2QS2359D9NaaOhtEiRQs11TBQdahaJC008svQrY4Wu bfvKsdGCCeq8SfJn/aNS4IQx5MZjzrQUq/78HVLfqvAXh9Nw50aH+zU9jQ0prtpIKsCp LIClgc6FvEsKha+XAiIlo37PEWWLsy95Vw1w4Gjhp4NNiuS+Ucv7okqwjxhftV7i1YzM 3mkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839146; x=1787443946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7u0RLtYXUYQ7iwz3Gl2qvOsAZ+m2eRqkafH2q6kwGqA=; b=EIPPAy1IIbGKSxbUOQxXIxweNLQ/4RqAfjW+n9EJhO210ArAQhp1zYBpA0kUT1oB8o WawIy9klBk4ULUf/47icF+Dchog9ZxQGvZ3q9hDFtotHMNeLAGl2serUhcQ9lcglz8F2 vwdVKOGkMQ/f9/qvjWb5SgqWCrEmgchXBRU2sn/iIzy1uk7urIphP+HISo6hPH8ZFBrv 7zBfNAyyP9jVFXcj64512Tdqe3OIDUDtq/XLx9xexxm8CkZf+c4UBYQYoq+vRXXvR7F1 1fYUKGRCoRX9B5K+Ql6cK3tzztMFUebAo+HjaIoRxOSu4PMU3pMpAGgJQ3+mHSUji0c9 RSPQ== X-Forwarded-Encrypted: i=1; AHgh+RplPGnjAHklqqMEIMEG5AiolQPjqQ5IZRNMQTmX4b26mrlHRMSUhPGvjBi7VDGvTfuqeZhvZmCoF0YypeY=@vger.kernel.org X-Gm-Message-State: AOJu0YzOt/DwoP3D9Ka8B1gFouchsvdT+YnWZ5d9SKpS1EWcC4OxbUCL WD7jx6VqKbFbWnPc8abrwIi88p6r2kkA5T8sKONLGyTPJIzIw0/Eicfb X-Gm-Gg: AR+sD10UtovEz34GppCiZMNEOtlqmJEL4NtEbPpsfWvWDGVScRZNkyY9evthvqT6LOL JNcYQi3jWwJsolZ30q/HqrhUemwP4rohBuH+/ptiUnXJPeke1aw1BezjtTYS965px3v3QlT1urR O243933LMWA3AHT+2wMXUYVLoYGsC4MReGrB3Z1kiygoKBUZRfHPA7AV0dgslAGufFa/T7zw9E6 du9ALAB22eSpWn2pRqJfJ0vHqrImXO8OMnK2cplnhZxOh+fS2vGwEXvmsEaZFQW7FFz6WYSscH+ 4QPeFFlZhx1x5AcS0tPfiVwLbFXXrIgohyilMmAhlIWagxUNZvgv9htIBSxbaakItFBrXJVg/3B Q0mmrKKJaUltwsoqKVRjBI1/A8uHydPMMS1jPnJntU/PN2zB8QwkxzDNmcsSgTKGynrJ5cISZrT UZXWcyrg6WGT0UHy9FjMDlxS/435T4NjwhUBw= X-Received: by 2002:a17:90a:e707:b0:37c:18e0:90dc with SMTP id 98e67ed59e1d1-3933b8cb37dmr16672571a91.16.1786839146461; Sat, 15 Aug 2026 17:12:26 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:25 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 4/6] platform/x86: redmi-wmi: Drop redmi-wmi driver Date: Sun, 16 Aug 2026 08:11:27 +0800 Message-ID: <20260816001129.16998-5-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The redmi-wmi driver is no longer needed because its functionality has been superseded by the new generic bitland platform driver. All supported Redmi laptop models are now handled properly via the updated WMI interfaces in bitland-mifs-wmi. Remove the obsolete code, Kconfig entries, and Makefile references to clean up the platform directory. Signed-off-by: Mingyou Chen --- MAINTAINERS | 6 -- drivers/platform/x86/Kconfig | 12 --- drivers/platform/x86/Makefile | 1 - drivers/platform/x86/redmi-wmi.c | 154 ------------------------------- 4 files changed, 173 deletions(-) delete mode 100644 drivers/platform/x86/redmi-wmi.c diff --git a/MAINTAINERS b/MAINTAINERS index af86b1df1a94..b92bc4816fa6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22768,12 +22768,6 @@ S: Maintained T: git https://github.com/pkshih/rtw.git F: drivers/net/wireless/realtek/rtw89/ =20 -REDMIBOOK WMI DRIVERS -M: Gladyshev Ilya -L: platform-driver-x86@vger.kernel.org -S: Maintained -F: drivers/platform/x86/redmi-wmi.c - BITLAND LAPTOP DRIVER M: Mingyou Chen M: Gladyshev Ilya diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index b54b5212b204..036fc76f62df 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -90,18 +90,6 @@ config XIAOMI_WMI To compile this driver as a module, choose M here: the module will be called xiaomi-wmi. =20 -config REDMI_WMI - tristate "Redmibook WMI key driver" - depends on ACPI_WMI - depends on INPUT - select INPUT_SPARSEKMAP - help - Say Y here if you want support for WMI-based hotkey events on - Xiaomi Redmibook devices. - - To compile this driver as a module, choose M here: the module will - be called redmi-wmi. - config GIGABYTE_WMI tristate "Gigabyte WMI temperature driver" depends on ACPI_WMI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 872ac3842391..0da4876f766e 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -12,7 +12,6 @@ obj-$(CONFIG_HUAWEI_WMI) +=3D huawei-wmi.o obj-$(CONFIG_MXM_WMI) +=3D mxm-wmi.o obj-$(CONFIG_NVIDIA_WMI_EC_BACKLIGHT) +=3D nvidia-wmi-ec-backlight.o obj-$(CONFIG_XIAOMI_WMI) +=3D xiaomi-wmi.o -obj-$(CONFIG_REDMI_WMI) +=3D redmi-wmi.o obj-$(CONFIG_GIGABYTE_WMI) +=3D gigabyte-wmi.o obj-$(CONFIG_BITLAND_MIFS_WMI) +=3D bitland-mifs-wmi.o =20 diff --git a/drivers/platform/x86/redmi-wmi.c b/drivers/platform/x86/redmi-= wmi.c deleted file mode 100644 index 58898630eda6..000000000000 --- a/drivers/platform/x86/redmi-wmi.c +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* WMI driver for Xiaomi Redmibooks */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define WMI_REDMIBOOK_KEYBOARD_EVENT_GUID "46C93E13-EE9B-4262-8488-563BCA7= 57FEF" - -#define AI_KEY_VALUE_MASK BIT(8) - -static const struct key_entry redmi_wmi_keymap[] =3D { - {KE_KEY, 0x00000201, {KEY_SELECTIVE_SCREENSHOT}}, - {KE_KEY, 0x00000301, {KEY_ALL_APPLICATIONS}}, - {KE_KEY, 0x00001b01, {KEY_CONFIG}}, - {KE_KEY, 0x00011b01, {KEY_CONFIG}}, - {KE_KEY, 0x00010101, {KEY_SWITCHVIDEOMODE}}, - {KE_KEY, 0x00001a01, {KEY_REFRESH_RATE_TOGGLE}}, - - /* AI button has code for each position */ - {KE_KEY, 0x00011801, {KEY_ASSISTANT}}, - {KE_KEY, 0x00011901, {KEY_ASSISTANT}}, - - /* Keyboard backlight */ - {KE_IGNORE, 0x00000501, {}}, - {KE_IGNORE, 0x00800501, {}}, - {KE_IGNORE, 0x00050501, {}}, - {KE_IGNORE, 0x000a0501, {}}, - - /* Xiaomi G Command Center */ - {KE_KEY, 0x00010a01, {KEY_VENDOR}}, - - /* OEM preset power mode */ - {KE_IGNORE, 0x00011601, {}}, - {KE_IGNORE, 0x00021601, {}}, - {KE_IGNORE, 0x00031601, {}}, - {KE_IGNORE, 0x00041601, {}}, - - /* Fn Lock state */ - {KE_IGNORE, 0x00000701, {}}, - {KE_IGNORE, 0x00010701, {}}, - - /* Fn+`/1/2/3/4 */ - {KE_KEY, 0x00011101, {KEY_F13}}, - {KE_KEY, 0x00011201, {KEY_F14}}, - {KE_KEY, 0x00011301, {KEY_F15}}, - {KE_KEY, 0x00011401, {KEY_F16}}, - {KE_KEY, 0x00011501, {KEY_F17}}, - - {KE_END} -}; - -struct redmi_wmi { - struct input_dev *input_dev; - /* Protects the key event sequence */ - struct mutex key_lock; -}; - -static int redmi_wmi_probe(struct wmi_device *wdev, const void *context) -{ - struct redmi_wmi *data; - int err; - - /* Init dev */ - data =3D devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - dev_set_drvdata(&wdev->dev, data); - - err =3D devm_mutex_init(&wdev->dev, &data->key_lock); - if (err) - return err; - - data->input_dev =3D devm_input_allocate_device(&wdev->dev); - if (!data->input_dev) - return -ENOMEM; - - data->input_dev->name =3D "Redmibook WMI keys"; - data->input_dev->phys =3D "wmi/input0"; - - err =3D sparse_keymap_setup(data->input_dev, redmi_wmi_keymap, NULL); - if (err) - return err; - - return input_register_device(data->input_dev); -} - -static void redmi_wmi_notify(struct wmi_device *wdev, union acpi_object *o= bj) -{ - struct key_entry *entry; - struct redmi_wmi *data =3D dev_get_drvdata(&wdev->dev); - bool autorelease =3D true; - u32 payload; - int value =3D 1; - - if (obj->type !=3D ACPI_TYPE_BUFFER) { - dev_err(&wdev->dev, "Bad response type %u\n", obj->type); - return; - } - - if (obj->buffer.length < 32) { - dev_err(&wdev->dev, "Invalid buffer length %u\n", obj->buffer.length); - return; - } - - payload =3D get_unaligned_le32(obj->buffer.pointer); - entry =3D sparse_keymap_entry_from_scancode(data->input_dev, payload); - - if (!entry) { - dev_dbg(&wdev->dev, "Unknown WMI event with payload %u", payload); - return; - } - - /* AI key quirk */ - if (entry->keycode =3D=3D KEY_ASSISTANT) { - value =3D !(payload & AI_KEY_VALUE_MASK); - autorelease =3D false; - } - - guard(mutex)(&data->key_lock); - sparse_keymap_report_entry(data->input_dev, entry, value, autorelease); -} - -static const struct wmi_device_id redmi_wmi_id_table[] =3D { - { WMI_REDMIBOOK_KEYBOARD_EVENT_GUID, NULL }, - { } -}; - -static struct wmi_driver redmi_wmi_driver =3D { - .driver =3D { - .name =3D "redmi-wmi", - .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, - }, - .id_table =3D redmi_wmi_id_table, - .min_event_size =3D 32, - .probe =3D redmi_wmi_probe, - .notify =3D redmi_wmi_notify, - .no_singleton =3D true, -}; -module_wmi_driver(redmi_wmi_driver); - -MODULE_DEVICE_TABLE(wmi, redmi_wmi_id_table); -MODULE_AUTHOR("Gladyshev Ilya "); -MODULE_DESCRIPTION("Redmibook WMI driver"); -MODULE_LICENSE("GPL"); --=20 2.55.0 From nobody Mon Sep 28 22:28:41 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 A722137BE86 for ; Sun, 16 Aug 2026 00:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839157; cv=none; b=HUaYxKSEZo7j63KItSQOwx5Kf+BIOkMixK/gbCUbL/63Kkq4r17uJOzSbkyUJ/efDbDqUVQnBbPsG7ishib0gqnf+Kwdi7+IICRhD2xN3ojSEIyW/BpVmmaXZ3TGsbRZCS4oeVUiyg0JvtgQqDATtBJU2PUGDbFqa+MIMqr274w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839157; c=relaxed/simple; bh=rz/N6YjVafxuJ7l7ui4YPxX1PJNihBUbWeyPN273N3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QILZgAG0mP9YmKbbW1Z/ENbBztQBpXzwPSR7WynPn+V8+c9FWZ3xXF8B0bq4OWBQhghzwv4z/nRjiMh/gUF2HwDYJ/VheJuTOyuqP4PZtkQ2JUPL6/Vm3m8HcWmFzoFs2FlnZg0vSgiYa7gJfHwqo+qv4TARKLIArPVSs5922zY= 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=kcN9nv6N; arc=none smtp.client-ip=209.85.216.49 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="kcN9nv6N" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-39266382df6so1828770a91.3 for ; Sat, 15 Aug 2026 17:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839151; x=1787443951; 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:content-type; bh=ZSkR9tIKiTyiThY12Ko2HUffdRvYZARmMC0w+0N9FPw=; b=kcN9nv6Nn0QIR8cCWmAdp7ovFgAsBNsWJhs7SAxmxsKlj82RjoI5Hvk1kSWaNiwjXX ixg5uQSbfMsgqL59GG1r8Bj51qwtQW03Xlj/lfaHIxdANIhXOkTC0Oi/A5Enq8/mynbG 3Pj6pFVqYG9f4l+H+lJW0NoiMfUxIHWbcrqWXD0EXLdAC4PUe0seD/ReuEw29hkzGDkj J80+XLPjJrWNsHepV3ja1w95+5NZTrNRNeWdjmHpqCPXxAg70OpCefGZkbRTesSvX/jY s0QCs9aOXKdVviTx6C9t63w08tfVd+t+Pk1Cf0+LCSQaW9XmNeSHRdLceq6coCqEODFl 1QZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839151; x=1787443951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZSkR9tIKiTyiThY12Ko2HUffdRvYZARmMC0w+0N9FPw=; b=d3D8eJovPIhBs4SMdthtgJsjqqrCtPumUUFjSc20K9l/Q1MsqSO3hzxVKwuHfD2Hfi Q2F6FU1AnpSyDJiqLcsQjiijESZNUPycYqB4/morzBkhjKULO9ksFZTE/PBmMRWDOKbI XSz6qS7Ykmpbk41RNgks07AG8yLikvR2DGCdZjmLourtqZL/k3HGlHLQujEw+51SVWSw gNZ3O43X0+7nQ66c9CcZQQ5igxKsuasiKi5wkXl5z7BlMUKyAjwGSMaaN0oak3Gw2cxe /9Sli83+G9K8uDLtvOvv24eBvy7bB2W9RJYRfnVs6karc8gX2QgmVKXyj8ilFh7C2HoX cQ9w== X-Forwarded-Encrypted: i=1; AHgh+Rq9TbXF9GIn1yPP1H8MLYvFcyEKgzW8SDnt/0QfAqw7ytILIPKucaX4Rbp5Lf0OE0FxduNbYC/D7d+hCFw=@vger.kernel.org X-Gm-Message-State: AOJu0Ywu2KYvi83ao5V+CoE4q4Jb3WFOo11Xl2umGwLlVL5+zNnt69y0 G45icfqVIzQbJnTMjiz4CmKxVjXH95SJ0mDyjclKAm0fN4nKQpJCZzBSTJ3MZvh9 X-Gm-Gg: AR+sD10YjOLud5HBu0iS8owVh6JSLu9aXU2uVr2ZSGh3UAHdrQtApCKmOeGWrneZUiu V9sCPmVwjZc3Jr+gRCdDox6v7kFyqaIOgieK0hLRVv/cbFYcx+h3jkdnb9Liws/kULWfHPdaxlz ZgoStmtQdnWr/Gp3URCVrt/faiH+7oDyBgCbcuWIRm/wC7aRsqgGpippxGqLmEiaXBh6YLUX0JM WrDtH+a/RbpVFxB6xiRWqcmqYhRkQERzPMwEgERw6S4WowaDY6r3C9gJ5gTNDQPiIP+93LNGXGQ WGKVMVs31XS52i1TOhjH4QUYw4oC6TFQD9V3I8bQg0toi6BdUpcHWeLEY7rBoFGoBoun5zQIlk+ YzKasuIfZvrHXFCIybYqwM5JbcBv2sALBV+nGckyYBnpmpvq3n9mA57a4A7dxuxfXsry3i8oYQS KAN3J6TwW3oRYIUotpuHPmTOiZlVkId8d/dTo= X-Received: by 2002:a17:90b:2248:b0:392:c80b:8eff with SMTP id 98e67ed59e1d1-3933b87a743mr15027563a91.11.1786839150806; Sat, 15 Aug 2026 17:12:30 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:30 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 5/6] platform/x86: bitland-mifs-wmi: Add per-machine ops table Date: Sun, 16 Aug 2026 08:11:28 +0800 Message-ID: <20260816001129.16998-6-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The MIFS WMI interface is shared by several Bitland ODM laptops which differ in the layout of the performance mode values of WMI_FN_SYSTEM_PER_MODE and in the capability checks. Introduce a machine ops table to support multiple machine families without sprinkling model checks over the driver: struct bitland_mifs_ops { const char *name; const struct bitland_profile_mode_map *mode_map; int (*check_performance_capability)( struct bitland_mifs_wmi_data *data); bool has_full_speed; }; The default ops instance keeps the current Bitland behavior, so this change is a pure refactor without any functional changes. Signed-off-by: Mingyou Chen --- drivers/platform/x86/bitland-mifs-wmi.c | 89 +++++++++++++++++++------ 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86= /bitland-mifs-wmi.c index 81dad2b65f4f..17792d8b7c29 100644 --- a/drivers/platform/x86/bitland-mifs-wmi.c +++ b/drivers/platform/x86/bitland-mifs-wmi.c @@ -78,6 +78,46 @@ enum bitland_mifs_power_profile { WMI_PP_FULL_SPEED =3D 3, }; =20 +struct bitland_mifs_wmi_data; + +/* + * Value layout of WMI_FN_SYSTEM_PER_MODE. + */ +struct bitland_profile_mode_map { + u8 balanced; + u8 performance; + u8 quiet; + u8 full_speed; +}; + +static const struct bitland_profile_mode_map bitland_mode_map =3D { + .balanced =3D WMI_PP_BALANCED, + .performance =3D WMI_PP_PERFORMANCE, + .quiet =3D WMI_PP_QUIET, + .full_speed =3D WMI_PP_FULL_SPEED, +}; + +static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data); + +/* + * Machine-specific operations. The MIFS WMI interface is shared by + * several Bitland ODM laptops which differ in the layout of the + * performance mode values and in the capability checks. + */ +struct bitland_mifs_ops { + const char *name; + const struct bitland_profile_mode_map *mode_map; + int (*check_performance_capability)(struct bitland_mifs_wmi_data *data); + bool has_full_speed; +}; + +static const struct bitland_mifs_ops bitland_ops =3D { + .name =3D "Bitland", + .mode_map =3D &bitland_mode_map, + .check_performance_capability =3D bitland_pp_check_capability, + .has_full_speed =3D true, +}; + enum bitland_mifs_event_id { WMI_EVENT_RESERVED_1 =3D 1, WMI_EVENT_RESERVED_2 =3D 2, @@ -163,6 +203,7 @@ struct bitland_mifs_wmi_data { struct input_dev *input_dev; struct device *hwmon_dev; struct device *pp_dev; + const struct bitland_mifs_ops *ops; enum platform_profile_option saved_profile; }; =20 @@ -193,6 +234,7 @@ static int laptop_profile_get(struct device *dev, enum platform_profile_option *profile) { struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + const struct bitland_profile_mode_map *map =3D data->ops->mode_map; struct bitland_mifs_input input =3D { .reserved1 =3D 0, .operation =3D WMI_METHOD_GET, @@ -200,32 +242,29 @@ static int laptop_profile_get(struct device *dev, .function =3D WMI_FN_SYSTEM_PER_MODE, }; struct bitland_mifs_output result; + u8 mode; int ret; =20 ret =3D bitland_mifs_wmi_call(data, &input, &result); if (ret) return ret; =20 - switch (result.data[0]) { - case WMI_PP_BALANCED: + mode =3D result.data[0]; + if (mode =3D=3D map->quiet) + *profile =3D PLATFORM_PROFILE_LOW_POWER; + else if (mode =3D=3D map->balanced) *profile =3D PLATFORM_PROFILE_BALANCED; - break; - case WMI_PP_PERFORMANCE: + else if (mode =3D=3D map->performance) *profile =3D PLATFORM_PROFILE_BALANCED_PERFORMANCE; - break; - case WMI_PP_QUIET: - *profile =3D PLATFORM_PROFILE_LOW_POWER; - break; - case WMI_PP_FULL_SPEED: + else if (mode =3D=3D map->full_speed) *profile =3D PLATFORM_PROFILE_PERFORMANCE; - break; - default: + else return -EINVAL; - } + return 0; } =20 -static int bitland_check_performance_capability(struct bitland_mifs_wmi_da= ta *data) +static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data) { struct bitland_mifs_input input =3D { .operation =3D WMI_METHOD_GET, @@ -252,6 +291,7 @@ static int laptop_profile_set(struct device *dev, enum platform_profile_option profile) { struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + const struct bitland_profile_mode_map *map =3D data->ops->mode_map; struct bitland_mifs_input input =3D { .reserved1 =3D 0, .operation =3D WMI_METHOD_SET, @@ -259,42 +299,46 @@ static int laptop_profile_set(struct device *dev, .function =3D WMI_FN_SYSTEM_PER_MODE, }; int ret; - u8 val; + u8 mode; =20 switch (profile) { case PLATFORM_PROFILE_LOW_POWER: - val =3D WMI_PP_QUIET; + mode =3D map->quiet; break; case PLATFORM_PROFILE_BALANCED: - val =3D WMI_PP_BALANCED; + mode =3D map->balanced; break; case PLATFORM_PROFILE_BALANCED_PERFORMANCE: - ret =3D bitland_check_performance_capability(data); + ret =3D data->ops->check_performance_capability(data); if (ret) return ret; - val =3D WMI_PP_PERFORMANCE; + mode =3D map->performance; break; case PLATFORM_PROFILE_PERFORMANCE: - ret =3D bitland_check_performance_capability(data); + ret =3D data->ops->check_performance_capability(data); if (ret) return ret; - val =3D WMI_PP_FULL_SPEED; + mode =3D map->full_speed; break; default: return -EOPNOTSUPP; } =20 - input.payload[0] =3D val; + input.payload[0] =3D mode; =20 return bitland_mifs_wmi_call(data, &input, NULL); } =20 static int platform_profile_probe(void *drvdata, unsigned long *choices) { + struct bitland_mifs_wmi_data *data =3D drvdata; + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); set_bit(PLATFORM_PROFILE_BALANCED, choices); set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + if (data->ops->has_full_speed) + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); =20 return 0; } @@ -717,6 +761,7 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wd= ev, const void *context) return -ENOMEM; =20 drv_data->wdev =3D wdev; + drv_data->ops =3D &bitland_ops; =20 ret =3D devm_mutex_init(&wdev->dev, &drv_data->lock); if (ret) --=20 2.55.0 From nobody Mon Sep 28 22:28:41 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 23A9C3803E1 for ; Sun, 16 Aug 2026 00:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839162; cv=none; b=eu53mX7UPs+DJ3oo09mRhyVtBAKY7/Q9FUu+TUQzXvkTI1PLcsXzqyvldb0DbGrX1KhZEdLobfj+h5NC+wTWnOKpdxvcTvT8tV6W8M7VJdG6v8VhG3TQVTyLNn5ATBr1V3M9A+0Zg6J6vFvYDis51I1qOF16THhZywbjI7Z19lY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786839162; c=relaxed/simple; bh=JBuzA5hg1qvZNRp9olV8K91CvQBVG9cw6YKXqhZGkCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0qoF5n4aFfYWhfGa8+MW2mbKKqacDLzbIXUGJyyQQ4maks3LF8ykFQ6i/B7M2TOlJpfL/OJrWgZa+DonCR1G1TJu4+Hnbf7m5rSvux4J7VKtTek5KmWDD0qpnEpWaQK04VUuA+97RbCD66EnyWh7tss78JszRCqB5gV7rq3H0U= 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=hHlGRUKE; arc=none smtp.client-ip=209.85.216.44 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="hHlGRUKE" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-38101f85591so3020285a91.1 for ; Sat, 15 Aug 2026 17:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786839155; x=1787443955; 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:content-type; bh=sqvxbAS28iThazOG2QpKbu+4eGvj4FNxYpL/+Nzg/d8=; b=hHlGRUKED1WJZeJ74tRUYb0gyDlq5cJcA80he3NWMyp90XaaAInILrDY7dMkZxcD4Y 0R40y/1GV4JED0HmZNzXKtBhCKGnlrdKsyeiwvi2ncOrzIvew/8mH+zVEh2e1dA8ibEx sn3YpvZ6JY4RkGrUnMmTs2HpdTDrIGl+4HqUGyJntdtsjDMcV3wpum2RZGj8r+l0kGkN cpdHKHn4wX9LgzbQaZf2AuxCADGotCeo/jNktbc9Hb+eKM8Q8Gq9R9/ZrObzAApx26gD 5pxxO9svV1b8rmztda9fX4bsKvFe8Bj53G/4Y1iJoIUzCtNuxio+Z4EI5HcqnY7BCJF5 LJow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786839155; x=1787443955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sqvxbAS28iThazOG2QpKbu+4eGvj4FNxYpL/+Nzg/d8=; b=AbjjiVoe5xWU2hdkZ8bs2aAsoTFW0URZ4agjYVCnJZNC6xKkIwU7n9qQV7hKsIN8Ip 1zRNX7DWpCTg3S0vHuUCJeFBKcABlnfjBvPYW5ooac94BYy3pBIsQD92oK5iyamuPvBU 6RoQ/TyxlIP8eq8bQSEsp3o0ivzmPJ3weKmNngr7WgYhbqO6B1QY5vGKKhAVGxzeb6N5 MRLnb+9p+vsfgYS8vuvL56yAt7hI27ctsZFwYPG59h6doRlqfs5tdnqV8SbpEngF1LMI 5agB83nmHBgRqEwoEFkO+ZThbt3snZVbQNTfrqXmvVTRR/igtg/nZksGdNoR85UHLEmO fm/g== X-Forwarded-Encrypted: i=1; AHgh+RogpFSs1wwilK6fk1QwmvBHxe7VzwOwoIDDqjI7fyKBzCs8qToqpcOn5myFBaYjdx56o7WveS07HPmAKWY=@vger.kernel.org X-Gm-Message-State: AOJu0YxD59QWBQGkJyneAYtEhAYIkz+xlvEqr+RzJPoxBxZdyBmuO4/v yrWWJs4dUCORNR+p257FJSEIscOeIiX9uhCZxEL1TAUweYXIbAwekR5U X-Gm-Gg: AR+sD11nhk8rjjFX/Tjb3KflxxDURvJRMeSQjOaYdz72sQWtUEILlxyZJrXBIxxLzDZ ZXEagXDug/MPyei3lne0v124luAvRSlec5smZao86wwqotHDr80i7M/P+HhpYXiNCgafRcSY1VX sQpsIHomOHDZ57OBOQj4xP1FUTA/PI/ORHdnI1jtVvXe9qEKW+0YdL0WwUV1kFxWFlvNyPDGbbW ArO89y1Yof5+uJT4dYqyFxNvZWtOt9+pakYHwPAewBMD0EMN1afVH2LYGJgRYgTgy5Hdi3ByOjp MhZEojJXZbgj6VDpb1eJoyhdXB2CRo3QA7u5x/KedadodpvtWm4jt65DXeNaJQFawXq2lW5pi+5 ysAcBs1RrlbATu/4hFSx/OoR4mkjEkxKWMaMmTkmJHJyoCmaSS3lsdZopLT8VMG/pG99ZE5dZS/ TjQZuGa4IOsnqtSbf4ivMD2K7wpD1BB08eQbU= X-Received: by 2002:a17:90b:48c2:b0:385:3ab:fecb with SMTP id 98e67ed59e1d1-3933af07e4dmr12264117a91.4.1786839155262; Sat, 15 Aug 2026 17:12:35 -0700 (PDT) Received: from qby-laptop ([2a13:edc0:18:16f::a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c87bsm7409320a91.4.2026.08.15.17.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 17:12:34 -0700 (PDT) From: Mingyou Chen To: qby140326@gmail.com Cc: W_Armin@gmx.de, foxido@foxido.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, nika@nikableh.moe, platform-driver-x86@vger.kernel.org, vlku.milos.fun@gmail.com, i@rsplwe.com, wolf109909@outlook.com Subject: [PATCH v4 6/6] platform/x86: bitland-mifs-wmi: Add Redmi laptop support Date: Sun, 16 Aug 2026 08:11:29 +0800 Message-ID: <20260816001129.16998-7-qby140326@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260816001129.16998-1-qby140326@gmail.com> References: <20260816001129.16998-1-qby140326@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Redmi laptops (Redmi Book and Redmi G series) use the same MIFS WMI interface but encode the performance mode values of WMI_FN_SYSTEM_PER_MODE differently, as reverse engineered from the Windows GCommandCenter application: 0 =3D performance, 1 =3D balanced, 2 =3D quiet, 4 =3D full speed Add "Redmi Book" and "Redmi G" ops entries selected via DMI: - Redmi G (board TM2135/TM2137): the full-speed mode is available - Redmi Book/Xiaomi Book: no full-speed mode - The performance modes only require AC power (any source); the barrel-jack requirement is Bitland-specific The GCommandCenter application further showed that: - the CPU power sensor (WMI_FN_CPU_POWER) is only available on Redmi machines, gate the hwmon power channel on the ops table - the refresh-rate-toggle quirk in the CPU fan speed event is Redmi-specific, gate it on the ops table instead of applying it unconditionally Also add Redmi support for Fn lock and touchpad lock control (WMI_FN_FN_LOCK / WMI_FN_TP_LOCK sysfs attributes), keyboard type detection (hide the RGB kb_mode attribute on white-only backlit keyboards) and hotkeys (airplane mode -> KEY_RFKILL, ignore the lock-state and keyboard mode indicator events). The sysfs attribute group is now registered in probe (instead of via dev_groups) so that the is_visible callback can access the probe populated driver data. Signed-off-by: Mingyou Chen --- drivers/platform/x86/bitland-mifs-wmi.c | 336 ++++++++++++++++++++++-- 1 file changed, 318 insertions(+), 18 deletions(-) diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86= /bitland-mifs-wmi.c index 17792d8b7c29..41ffc5ca56a1 100644 --- a/drivers/platform/x86/bitland-mifs-wmi.c +++ b/drivers/platform/x86/bitland-mifs-wmi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,11 @@ enum bitland_system_ac_mode { WMI_SYSTEM_AC_CIRCULARHOLE =3D 2, }; =20 +enum bitland_kbd_type { + WMI_KBD_TYPE_WHITE =3D 0, + WMI_KBD_TYPE_RGB =3D 1, +}; + enum bitland_mifs_power_profile { WMI_PP_BALANCED =3D 0, WMI_PP_PERFORMANCE =3D 1, @@ -97,7 +103,15 @@ static const struct bitland_profile_mode_map bitland_mo= de_map =3D { .full_speed =3D WMI_PP_FULL_SPEED, }; =20 +static const struct bitland_profile_mode_map redmi_mode_map =3D { + .balanced =3D 1, + .performance =3D 0, + .quiet =3D 2, + .full_speed =3D 4, +}; + static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data); +static int redmi_pp_check_capability(struct bitland_mifs_wmi_data *data); =20 /* * Machine-specific operations. The MIFS WMI interface is shared by @@ -109,6 +123,8 @@ struct bitland_mifs_ops { const struct bitland_profile_mode_map *mode_map; int (*check_performance_capability)(struct bitland_mifs_wmi_data *data); bool has_full_speed; + bool has_cpu_power; + bool quirk_refresh_rate_toggle; }; =20 static const struct bitland_mifs_ops bitland_ops =3D { @@ -118,6 +134,54 @@ static const struct bitland_mifs_ops bitland_ops =3D { .has_full_speed =3D true, }; =20 +static const struct bitland_mifs_ops redmi_book_ops =3D { + .name =3D "Redmi Book", + .mode_map =3D &redmi_mode_map, + .check_performance_capability =3D redmi_pp_check_capability, + .has_cpu_power =3D true, + .quirk_refresh_rate_toggle =3D true, +}; + +static const struct bitland_mifs_ops redmi_g_ops =3D { + .name =3D "Redmi G", + .mode_map =3D &redmi_mode_map, + .check_performance_capability =3D redmi_pp_check_capability, + .has_full_speed =3D true, + .has_cpu_power =3D true, + .quirk_refresh_rate_toggle =3D true, +}; + +static const struct dmi_system_id bitland_mifs_dmi_table[] =3D { + { + /* Redmi G */ + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "TM2135"), + }, + .driver_data =3D (void *)&redmi_g_ops, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "TM2137"), + }, + .driver_data =3D (void *)&redmi_g_ops, + }, + { + /* Redmi Book series */ + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Redmi"), + }, + .driver_data =3D (void *)&redmi_book_ops, + }, + { + /* Xiaomi Book series */ + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi"), + }, + .driver_data =3D (void *)&redmi_book_ops, + }, + {} +}; + enum bitland_mifs_event_id { WMI_EVENT_RESERVED_1 =3D 1, WMI_EVENT_RESERVED_2 =3D 2, @@ -203,6 +267,8 @@ struct bitland_mifs_wmi_data { struct input_dev *input_dev; struct device *hwmon_dev; struct device *pp_dev; + enum bitland_wmi_device_type dev_type; + u8 kbd_type; const struct bitland_mifs_ops *ops; enum platform_profile_option saved_profile; }; @@ -255,8 +321,10 @@ static int laptop_profile_get(struct device *dev, else if (mode =3D=3D map->balanced) *profile =3D PLATFORM_PROFILE_BALANCED; else if (mode =3D=3D map->performance) - *profile =3D PLATFORM_PROFILE_BALANCED_PERFORMANCE; - else if (mode =3D=3D map->full_speed) + *profile =3D data->ops->has_full_speed ? + PLATFORM_PROFILE_BALANCED_PERFORMANCE : + PLATFORM_PROFILE_PERFORMANCE; + else if (data->ops->has_full_speed && mode =3D=3D map->full_speed) *profile =3D PLATFORM_PROFILE_PERFORMANCE; else return -EINVAL; @@ -273,10 +341,11 @@ static int bitland_pp_check_capability(struct bitland= _mifs_wmi_data *data) struct bitland_mifs_output output; int ret; =20 - /* Full-speed/performance mode requires DC power (not USB-C) */ + /* The performance modes require AC power */ if (!power_supply_is_system_supplied()) return -EOPNOTSUPP; =20 + /* Additionally require the barrel-jack power supply (not USB-C) */ ret =3D bitland_mifs_wmi_call(data, &input, &output); if (ret) return ret; @@ -287,6 +356,15 @@ static int bitland_pp_check_capability(struct bitland_= mifs_wmi_data *data) return 0; } =20 +static int redmi_pp_check_capability(struct bitland_mifs_wmi_data *data) +{ + /* The performance modes require AC power (any source) */ + if (!power_supply_is_system_supplied()) + return -EOPNOTSUPP; + + return 0; +} + static int laptop_profile_set(struct device *dev, enum platform_profile_option profile) { @@ -309,6 +387,8 @@ static int laptop_profile_set(struct device *dev, mode =3D map->balanced; break; case PLATFORM_PROFILE_BALANCED_PERFORMANCE: + if (!data->ops->has_full_speed) + return -EOPNOTSUPP; ret =3D data->ops->check_performance_capability(data); if (ret) return ret; @@ -318,7 +398,7 @@ static int laptop_profile_set(struct device *dev, ret =3D data->ops->check_performance_capability(data); if (ret) return ret; - mode =3D map->full_speed; + mode =3D data->ops->has_full_speed ? map->full_speed : map->performance; break; default: return -EOPNOTSUPP; @@ -335,10 +415,10 @@ static int platform_profile_probe(void *drvdata, unsi= gned long *choices) =20 set_bit(PLATFORM_PROFILE_LOW_POWER, choices); set_bit(PLATFORM_PROFILE_BALANCED, choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); =20 if (data->ops->has_full_speed) - set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); =20 return 0; } @@ -418,6 +498,13 @@ static int laptop_hwmon_read(struct device *dev, enum = hwmon_sensor_types type, default: return -EINVAL; } + case hwmon_power: + /* WMI_FN_CPU_POWER returns the CPU power draw in watts */ + input.function =3D WMI_FN_CPU_POWER; + ret =3D bitland_mifs_wmi_call(data, &input, &res); + if (!ret) + *val =3D res.data[0] * MICROWATT_PER_WATT; + return ret; default: return -EINVAL; } @@ -444,6 +531,15 @@ static const struct hwmon_channel_info *laptop_hwmon_i= nfo[] =3D { NULL }; =20 +static const struct hwmon_channel_info *laptop_hwmon_info_power[] =3D { + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), + HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL), + HWMON_CHANNEL_INFO(power, HWMON_P_INPUT), + NULL +}; + static const struct hwmon_ops laptop_hwmon_ops =3D { .visible =3D 0444, .read =3D laptop_hwmon_read, @@ -455,6 +551,11 @@ static const struct hwmon_chip_info laptop_chip_info = =3D { .info =3D laptop_hwmon_info, }; =20 +static const struct hwmon_chip_info laptop_chip_info_power =3D { + .ops =3D &laptop_hwmon_ops, + .info =3D laptop_hwmon_info_power, +}; + static int laptop_kbd_led_set(struct led_classdev *led_cdev, enum led_brightness value) { @@ -498,6 +599,96 @@ static const char *const gpu_mode_strings[] =3D { "uma", }; =20 +static ssize_t fn_lock_show(struct device *dev, struct device_attribute *a= ttr, + char *buf) +{ + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + struct bitland_mifs_input input =3D { + .reserved1 =3D 0, + .operation =3D WMI_METHOD_GET, + .reserved2 =3D 0, + .function =3D WMI_FN_FN_LOCK, + }; + struct bitland_mifs_output res; + int ret; + + ret =3D bitland_mifs_wmi_call(data, &input, &res); + if (ret) + return ret; + + return sysfs_emit(buf, "%u\n", res.data[0]); +} + +static ssize_t fn_lock_store(struct device *dev, struct device_attribute *= attr, + const char *buf, size_t count) +{ + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + struct bitland_mifs_input input =3D { + .reserved1 =3D 0, + .operation =3D WMI_METHOD_SET, + .reserved2 =3D 0, + .function =3D WMI_FN_FN_LOCK, + }; + bool val; + int ret; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + input.payload[0] =3D val; + + ret =3D bitland_mifs_wmi_call(data, &input, NULL); + if (ret) + return ret; + + return count; +} + +static ssize_t touchpad_lock_show(struct device *dev, struct device_attrib= ute *attr, + char *buf) +{ + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + struct bitland_mifs_input input =3D { + .reserved1 =3D 0, + .operation =3D WMI_METHOD_GET, + .reserved2 =3D 0, + .function =3D WMI_FN_TP_LOCK, + }; + struct bitland_mifs_output res; + int ret; + + ret =3D bitland_mifs_wmi_call(data, &input, &res); + if (ret) + return ret; + + return sysfs_emit(buf, "%u\n", res.data[0]); +} + +static ssize_t touchpad_lock_store(struct device *dev, struct device_attri= bute *attr, + const char *buf, size_t count) +{ + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + struct bitland_mifs_input input =3D { + .reserved1 =3D 0, + .operation =3D WMI_METHOD_SET, + .reserved2 =3D 0, + .function =3D WMI_FN_TP_LOCK, + }; + bool val; + int ret; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + input.payload[0] =3D val; + + ret =3D bitland_mifs_wmi_call(data, &input, NULL); + if (ret) + return ret; + + return count; +} + /* GPU Mode: 0:Hybrid, 1:Discrete, 2:UMA */ static ssize_t gpu_mode_show(struct device *dev, struct device_attribute *= attr, char *buf) @@ -637,17 +828,46 @@ static ssize_t fan_boost_store(struct device *dev, return count; } =20 -static const DEVICE_ATTR_RW(gpu_mode); -static const DEVICE_ATTR_RW(kb_mode); -static const DEVICE_ATTR_WO(fan_boost); +static DEVICE_ATTR_RW(gpu_mode); +static DEVICE_ATTR_RW(kb_mode); +static DEVICE_ATTR_WO(fan_boost); +static DEVICE_ATTR_RW(fn_lock); +static DEVICE_ATTR_RW(touchpad_lock); =20 -static const struct attribute *const laptop_attrs[] =3D { +static struct attribute *laptop_attrs[] =3D { &dev_attr_gpu_mode.attr, &dev_attr_kb_mode.attr, &dev_attr_fan_boost.attr, + &dev_attr_fn_lock.attr, + &dev_attr_touchpad_lock.attr, NULL, }; -ATTRIBUTE_GROUPS(laptop); + +static umode_t laptop_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int idx) +{ + struct device *dev =3D kobj_to_dev(kobj); + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(dev); + + /* The sysfs attributes are only supported on the control device */ + if (data->dev_type !=3D BITLAND_WMI_CONTROL) + return 0; + + /* + * White-only backlit keyboards (e.g. Redmi Book series) do not + * support the RGB backlight modes. + */ + if (attr =3D=3D &dev_attr_kb_mode.attr && + data->kbd_type =3D=3D WMI_KBD_TYPE_WHITE) + return 0; + + return attr->mode; +} + +static const struct attribute_group laptop_group =3D { + .attrs =3D laptop_attrs, + .is_visible =3D laptop_attr_is_visible, +}; =20 static const struct key_entry bitland_mifs_wmi_keymap[] =3D { { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_OPEN_APP, 1, 0), { KEY_PROG1 } }, @@ -699,6 +919,34 @@ static const struct key_entry bitland_mifs_wmi_keymap[= ] =3D { { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FNLOCK_STATE, 0, 0), {} }, { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_FNLOCK_STATE, 1, 0), {} }, =20 + /* Airplane mode toggle (Redmi) */ + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_AIRPLANE_MODE, 0, 0), { KEY_RFKILL } }, + { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_AIRPLANE_MODE, 1, 0), { KEY_RFKILL } }, + + /* + * Touchpad state change (Redmi Fn+F7). The EC performs the actual + * toggle itself; userspace can control the state via the + * touchpad_lock sysfs attribute. + */ + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_TOUCHPAD_STATE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_TOUCHPAD_STATE, 1, 0), {} }, + + /* Keyboard backlight mode change */ + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_MODE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_KBD_MODE, 1, 0), {} }, + + /* Lock-state indicator events */ + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_CAPSLOCK_STATE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_CAPSLOCK_STATE, 1, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_NUMLOCK_STATE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_NUMLOCK_STATE, 1, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_SCROLLLOCK_STATE, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_SCROLLLOCK_STATE, 1, 0), {} }, + + /* Win key lock (Redmi gaming mode) */ + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_WIN_KEY_LOCK, 0, 0), {} }, + { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_WIN_KEY_LOCK, 1, 0), {} }, + /* Fn+`/1/2/3/4 */ { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_F, 1, 0), { KEY_F13 } }, { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_FN_0, 1, 0), { KEY_F14 } }, @@ -744,6 +992,36 @@ static int bitland_notifier_callback(struct notifier_b= lock *nb, return NOTIFY_OK; } =20 +static int bitland_detect_kbd_type(struct bitland_mifs_wmi_data *data) +{ + struct bitland_mifs_input input =3D { + .reserved1 =3D 0, + .operation =3D WMI_METHOD_GET, + .reserved2 =3D 0, + .function =3D WMI_FN_KBD_TYPE, + }; + struct bitland_mifs_output res; + int ret; + + ret =3D bitland_mifs_wmi_call(data, &input, &res); + if (ret) + return ret; + + data->kbd_type =3D res.data[0]; + return 0; +} + +static void bitland_detect_ops(struct bitland_mifs_wmi_data *data) +{ + const struct dmi_system_id *id; + + id =3D dmi_first_match(bitland_mifs_dmi_table); + if (id) + data->ops =3D id->driver_data; + + dev_dbg(&data->wdev->dev, "Detected machine ops: %s\n", data->ops->name); +} + static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *con= text) { struct bitland_mifs_wmi_data *drv_data; @@ -761,6 +1039,9 @@ static int bitland_mifs_wmi_probe(struct wmi_device *w= dev, const void *context) return -ENOMEM; =20 drv_data->wdev =3D wdev; + drv_data->dev_type =3D dev_type; + /* Default to RGB so the RGB attributes stay visible if detection fails */ + drv_data->kbd_type =3D WMI_KBD_TYPE_RGB; drv_data->ops =3D &bitland_ops; =20 ret =3D devm_mutex_init(&wdev->dev, &drv_data->lock); @@ -769,6 +1050,8 @@ static int bitland_mifs_wmi_probe(struct wmi_device *w= dev, const void *context) =20 dev_set_drvdata(&wdev->dev, drv_data); =20 + bitland_detect_ops(drv_data); + if (dev_type =3D=3D BITLAND_WMI_EVENT) { /* Register input device for hotkeys */ drv_data->input_dev =3D devm_input_allocate_device(&wdev->dev); @@ -794,12 +1077,28 @@ static int bitland_mifs_wmi_probe(struct wmi_device = *wdev, const void *context) if (IS_ERR(drv_data->pp_dev)) return PTR_ERR(drv_data->pp_dev); =20 + /* Detect the keyboard type */ + ret =3D bitland_detect_kbd_type(drv_data); + if (ret) + dev_dbg(&wdev->dev, "Failed to detect keyboard type, assuming RGB: %d\n"= , ret); + + ret =3D devm_device_add_group(&wdev->dev, &laptop_group); + if (ret) + return ret; + /* Register hwmon */ - drv_data->hwmon_dev =3D devm_hwmon_device_register_with_info(&wdev->dev, - "bitland_mifs", - drv_data, - &laptop_chip_info, - NULL); + if (drv_data->ops->has_cpu_power) + drv_data->hwmon_dev =3D devm_hwmon_device_register_with_info(&wdev->dev, + "bitland_mifs", + drv_data, + &laptop_chip_info_power, + NULL); + else + drv_data->hwmon_dev =3D devm_hwmon_device_register_with_info(&wdev->dev, + "bitland_mifs", + drv_data, + &laptop_chip_info, + NULL); if (IS_ERR(drv_data->hwmon_dev)) return PTR_ERR(drv_data->hwmon_dev); =20 @@ -851,6 +1150,7 @@ static void bitland_mifs_wmi_report_key(struct wmi_dev= ice *wdev, u32 payload) static void bitland_mifs_wmi_notify(struct wmi_device *wdev, const struct wmi_buffer *buffer) { + struct bitland_mifs_wmi_data *data =3D dev_get_drvdata(&wdev->dev); const struct bitland_mifs_event *event =3D buffer->data; struct bitland_fan_notify_data fan_data; u32 payload; @@ -885,7 +1185,8 @@ static void bitland_mifs_wmi_notify(struct wmi_device = *wdev, case WMI_EVENT_CPU_FAN_SPEED: case WMI_EVENT_GPU_FAN_SPEED: /* Redmi refresh rate toggle quirk */ - if (event->event_id =3D=3D WMI_EVENT_CPU_FAN_SPEED && + if (data->ops->quirk_refresh_rate_toggle && + event->event_id =3D=3D WMI_EVENT_CPU_FAN_SPEED && event->value_low =3D=3D 0 && event->value_high =3D=3D 0) { payload =3D BI_HOTKEY_CODE(WMI_EVENT_REFRESH_RATE, 0, 0); bitland_mifs_wmi_report_key(wdev, payload); @@ -923,7 +1224,6 @@ static struct wmi_driver bitland_mifs_wmi_driver =3D { .no_singleton =3D true, .driver =3D { .name =3D DRV_NAME, - .dev_groups =3D laptop_groups, .pm =3D pm_sleep_ptr(&bitland_mifs_wmi_pm_ops), }, .id_table =3D bitland_mifs_wmi_id_table, --=20 2.55.0