linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] platform/x86: Add driver for Yoga Tablet mode switch
@ 2023-03-23  2:51 Andrew Kallmeyer
  2023-03-23  2:51 ` [PATCH v2 1/2] platform/x86: Move ideapad ACPI helpers to a new header Andrew Kallmeyer
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andrew Kallmeyer @ 2023-03-23  2:51 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: Andrew Kallmeyer, Gergo Koteles, Ike Panhc, linux-input,
	Hans de Goede, Armin Wolf, Barnabás Pőcze

This driver maps the Lenovo Yoga tablet mode switch to a SW_TABLET_MODE input
device. This will make the tablet status available to desktop environments.

This patch series is the result of the discussion at
https://lore.kernel.org/r/CAG4kvq9US=-NjyXFMzJYu2zCJryJWtOc7FGZbrewpgCDjdAkbg@mail.gmail.com/

I decided to follow-up on the patch Gergo wrote and respond to the review
comments to get it merged and available for everyone.

Gergo and I have tested this on the Yoga 7 14ARB7, and the Yoga 7 14AIL7
respectively. Additionally, according to reports at
https://github.com/lukas-w/yoga-usage-mode, which uses the same WMI devices,
this driver should work with:
Yoga C940, Ideapad flex 14API, Yoga 9 14IAP7, Yoga 7 14ARB7, etc.

The diff since v1 is as follows:
v1: https://lore.kernel.org/platform-driver-x86/20230310041726.217447-1-kallmeyeras@gmail.com/

--- a/drivers/platform/x86/lenovo-ymc.c
+++ b/drivers/platform/x86/lenovo-ymc.c
@@ -18,7 +18,7 @@
 #define LENOVO_YMC_QUERY_GUID	"09B0EE6E-C3FD-4243-8DA1-7911FF80BB8C"
 
 #define LENOVO_YMC_QUERY_INSTANCE 0
-#define LENOVO_YMC_QUERY_METHOD 0xAB
+#define LENOVO_YMC_QUERY_METHOD 0x01
 
 static bool ec_trigger __read_mostly;
 module_param(ec_trigger, bool, 0644);
@@ -103,6 +103,12 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
 	lenovo_ymc_trigger_ec(wdev, priv);
 }
 
+static void lenovo_ymc_remove(struct wmi_device *wdev)
+{
+	struct lenovo_ymc_private *priv = dev_get_drvdata(&wdev->dev);
+	acpi_dev_put(priv->ec_acpi_dev);
+}
+
 static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
 {
 	struct input_dev *input_dev;
@@ -117,7 +123,7 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
 
 	if (ec_trigger) {
 		pr_debug("Lenovo YMC enable EC triggering.\n");
-		priv->ec_acpi_dev = acpi_dev_get_first_match_dev("VCP2004", NULL, -1);
+		priv->ec_acpi_dev = acpi_dev_get_first_match_dev("VPC2004", NULL, -1);
 		if (!priv->ec_acpi_dev) {
 			dev_err(&wdev->dev, "Could not find EC ACPI device.\n");
 			return -ENODEV;
@@ -151,7 +157,10 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
 
 	priv->input_dev = input_dev;
 	dev_set_drvdata(&wdev->dev, priv);
+
+	// Report the state for the first time on probe
 	lenovo_ymc_trigger_ec(wdev, priv);
+	lenovo_ymc_notify(wdev, NULL);
 	return 0;
 }
 
@@ -168,6 +177,7 @@ static struct wmi_driver lenovo_ymc_driver = {
 	.id_table = lenovo_ymc_wmi_id_table,
 	.probe = lenovo_ymc_probe,
 	.notify = lenovo_ymc_notify,
+	.remove = lenovo_ymc_remove,
 };
 
 module_wmi_driver(lenovo_ymc_driver);

Andrew Kallmeyer (1):
  platform/x86: Move ideapad ACPI helpers to a new header

Gergo Koteles (1):
  platform/x86: Add driver for Yoga Tablet Mode switch

 drivers/platform/x86/Kconfig          |  10 ++
 drivers/platform/x86/Makefile         |   1 +
 drivers/platform/x86/ideapad-laptop.c | 135 +------------------
 drivers/platform/x86/ideapad-laptop.h | 152 +++++++++++++++++++++
 drivers/platform/x86/lenovo-ymc.c     | 187 ++++++++++++++++++++++++++
 5 files changed, 351 insertions(+), 134 deletions(-)
 create mode 100644 drivers/platform/x86/ideapad-laptop.h
 create mode 100644 drivers/platform/x86/lenovo-ymc.c

-- 
2.40.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-26 11:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23  2:51 [PATCH v2 0/2] platform/x86: Add driver for Yoga Tablet mode switch Andrew Kallmeyer
2023-03-23  2:51 ` [PATCH v2 1/2] platform/x86: Move ideapad ACPI helpers to a new header Andrew Kallmeyer
2023-03-23  2:52 ` [PATCH v2 2/2] platform/x86: Add driver for Yoga Tablet Mode switch Andrew Kallmeyer
2023-03-23 12:05   ` Barnabás Pőcze
2023-03-25  7:10   ` Armin Wolf
2023-03-25 15:16     ` Andrew Kallmeyer
2023-03-25 21:49       ` Armin Wolf
2023-03-26 11:16         ` Hans de Goede
2023-03-24 19:37 ` [PATCH v2 0/2] platform/x86: Add driver for Yoga Tablet mode switch André Apitzsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).