mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: "Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Gergo Koteles" <soyer@irl.hu>, "Ike Panhc" <ikepanhc@gmail.com>,
	"Andrew Kallmeyer" <kallmeyeras@gmail.com>
Cc: Eduard Aliman <edialiman20@gmail.com>,
	 platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Mahir Faisal <mahirfaisalantiq33@gmail.com>,
	Rong Zhang <i@rong.moe>,
	 stable@vger.kernel.org
Subject: [PATCH v3 1/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture
Date: Thu, 26 Nov 2026 02:08:19 +0800	[thread overview]
Message-ID: <20261126-ymc-82yl-v3-1-e30842671ec3@rong.moe> (raw)
In-Reply-To: <20261126-ymc-82yl-v3-0-e30842671ec3@rong.moe>

There are five known Yoga modes: unknown, laptop, tablet, drawing board,
and tent, but lacks symbolic representations for reuse.

Introduce an enumeration called ymc_posture to collect and represent
them. The lenovo_ymc_keymap is also refactored to use the enumeration.

Cc: stable@vger.kernel.org
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Eduard Aliman <edialiman20@gmail.com>
Signed-off-by: Rong Zhang <i@rong.moe>
---
Cc stable as the later fixes depend on this.
---
 drivers/platform/x86/lenovo/ideapad-laptop.h |  9 +++++++++
 drivers/platform/x86/lenovo/ymc.c            | 14 +++++---------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.h b/drivers/platform/x86/lenovo/ideapad-laptop.h
index 1e52f2aa0aac..e29f741ffbf3 100644
--- a/drivers/platform/x86/lenovo/ideapad-laptop.h
+++ b/drivers/platform/x86/lenovo/ideapad-laptop.h
@@ -15,6 +15,15 @@ enum ideapad_laptop_notifier_actions {
 	IDEAPAD_LAPTOP_YMC_EVENT,
 };
 
+enum ymc_posture {
+	/* Some devices cannot recognize their postures on boot. */
+	YMC_POSTURE_UNKNOWN		= 0,
+	YMC_POSTURE_LAPTOP		= 1,
+	YMC_POSTURE_TABLET		= 2,
+	YMC_POSTURE_DRAWING_BOARD	= 3,
+	YMC_POSTURE_TENT		= 4,
+};
+
 int ideapad_laptop_register_notifier(struct notifier_block *nb);
 int ideapad_laptop_unregister_notifier(struct notifier_block *nb);
 void ideapad_laptop_call_notifier(unsigned long action, void *data);
diff --git a/drivers/platform/x86/lenovo/ymc.c b/drivers/platform/x86/lenovo/ymc.c
index 91de02d989a0..70f3ae20d3e3 100644
--- a/drivers/platform/x86/lenovo/ymc.c
+++ b/drivers/platform/x86/lenovo/ymc.c
@@ -64,15 +64,11 @@ struct lenovo_ymc_private {
 
 static const struct key_entry lenovo_ymc_keymap[] = {
 	/* Ignore the uninitialized state */
-	{ KE_IGNORE, 0x00 },
-	/* Laptop */
-	{ KE_SW, 0x01, { .sw = { SW_TABLET_MODE, 0 } } },
-	/* Tablet */
-	{ KE_SW, 0x02, { .sw = { SW_TABLET_MODE, 1 } } },
-	/* Drawing Board */
-	{ KE_SW, 0x03, { .sw = { SW_TABLET_MODE, 1 } } },
-	/* Tent */
-	{ KE_SW, 0x04, { .sw = { SW_TABLET_MODE, 1 } } },
+	{ KE_IGNORE,	YMC_POSTURE_UNKNOWN },
+	{ KE_SW,	YMC_POSTURE_LAPTOP,		{ .sw = { SW_TABLET_MODE, 0 } } },
+	{ KE_SW,	YMC_POSTURE_TABLET,		{ .sw = { SW_TABLET_MODE, 1 } } },
+	{ KE_SW,	YMC_POSTURE_DRAWING_BOARD,	{ .sw = { SW_TABLET_MODE, 1 } } },
+	{ KE_SW,	YMC_POSTURE_TENT,		{ .sw = { SW_TABLET_MODE, 1 } } },
 	{ KE_END },
 };
 

-- 
2.55.0


  reply	other threads:[~2026-11-25 18:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 18:08 [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
2026-11-25 18:08 ` Rong Zhang [this message]
2026-11-25 18:08 ` [PATCH v3 2/8] platform/x86: lenovo-ymc: Serialize WMI event handling Rong Zhang
2026-11-25 18:08 ` [PATCH v3 3/8] platform/x86: lenovo-wmi-events: Modernize " Rong Zhang
2026-11-25 18:08 ` [PATCH v3 4/8] platform/x86: lenovo-ymc: Modernize WMI driver and factor out events Rong Zhang
2026-11-25 18:08 ` [PATCH v3 5/8] platform/x86: lenovo-ymc: Refresh posture on resume Rong Zhang
2026-11-25 18:08 ` [PATCH v3 6/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
2026-11-25 18:08 ` [PATCH v3 7/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14IRL8 Rong Zhang
2026-11-25 18:08 ` [PATCH v3 8/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14ARP8 Rong Zhang
2026-11-25 19:14 ` [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Eduard Aliman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126-ymc-82yl-v3-1-e30842671ec3@rong.moe \
    --to=i@rong.moe \
    --cc=derekjohn.clark@gmail.com \
    --cc=edialiman20@gmail.com \
    --cc=hansg@kernel.org \
    --cc=ikepanhc@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kallmeyeras@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahirfaisalantiq33@gmail.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=soyer@irl.hu \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®