* [PATCH 1/2] platform/x86: intel-vbtn: Move detect_tablet_mode() to higher in the file
@ 2020-05-10 12:20 Hans de Goede
2020-05-10 12:20 ` [PATCH 2/2] platform/x86: intel-vbtn: Detect switch position before registering the input-device Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2020-05-10 12:20 UTC (permalink / raw)
To: Darren Hart, Andy Shevchenko
Cc: Hans de Goede, platform-driver-x86, linux-kernel
This is a preparation patch for calling detect_tablet_mode() from
intel_vbtn_input_setup() without needing a forward declaration.
Note this commit makes no functional changes, the moved block of code
is completely unchanged.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/intel-vbtn.c | 36 +++++++++++++++----------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 4efc70b693a7..29984154f8e4 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -60,6 +60,24 @@ struct intel_vbtn_priv {
bool wakeup_mode;
};
+static void detect_tablet_mode(struct platform_device *device)
+{
+ struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
+ acpi_handle handle = ACPI_HANDLE(&device->dev);
+ unsigned long long vgbs;
+ acpi_status status;
+ int m;
+
+ status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
+ if (ACPI_FAILURE(status))
+ return;
+
+ m = !(vgbs & TABLET_MODE_FLAG);
+ input_report_switch(priv->input_dev, SW_TABLET_MODE, m);
+ m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0;
+ input_report_switch(priv->input_dev, SW_DOCK, m);
+}
+
static int intel_vbtn_input_setup(struct platform_device *device)
{
struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
@@ -138,24 +156,6 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
}
-static void detect_tablet_mode(struct platform_device *device)
-{
- struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
- acpi_handle handle = ACPI_HANDLE(&device->dev);
- unsigned long long vgbs;
- acpi_status status;
- int m;
-
- status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
- if (ACPI_FAILURE(status))
- return;
-
- m = !(vgbs & TABLET_MODE_FLAG);
- input_report_switch(priv->input_dev, SW_TABLET_MODE, m);
- m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0;
- input_report_switch(priv->input_dev, SW_DOCK, m);
-}
-
static bool intel_vbtn_has_buttons(acpi_handle handle)
{
acpi_status status;
--
2.26.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] platform/x86: intel-vbtn: Detect switch position before registering the input-device
2020-05-10 12:20 [PATCH 1/2] platform/x86: intel-vbtn: Move detect_tablet_mode() to higher in the file Hans de Goede
@ 2020-05-10 12:20 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2020-05-10 12:20 UTC (permalink / raw)
To: Darren Hart, Andy Shevchenko
Cc: Hans de Goede, platform-driver-x86, linux-kernel
Setting the initial state of input-device switches must be done before
registering the input-device.
Otherwise the initial state will get send out as an event as soon
as input_sync() gets called.
E.g. when undocking a tablet using intel-vbtn to report SW_TABLET_MODE
and SW_DOCK before this commit we would get (evemu-record output):
E: 0.000001 0005 0005 0001 # EV_SW / SW_DOCK 1
E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.000109 0005 0005 0000 # EV_SW / SW_DOCK 0
E: 0.000109 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.000133 0005 0001 0001 # EV_SW / SW_TABLET_MODE 1
E: 0.000133 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
The first SW_DOCK=1 report is spurious, setting the initial switch
state before registering the input-device fixes this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/intel-vbtn.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 29984154f8e4..ef92c1c3adbd 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -111,6 +111,9 @@ static int intel_vbtn_input_setup(struct platform_device *device)
priv->input_dev->name = "Intel Virtual Button driver";
priv->input_dev->id.bustype = BUS_HOST;
+ if (priv->has_switches)
+ detect_tablet_mode(device);
+
return input_register_device(priv->input_dev);
}
@@ -217,9 +220,6 @@ static int intel_vbtn_probe(struct platform_device *device)
return err;
}
- if (priv->has_switches)
- detect_tablet_mode(device);
-
status = acpi_install_notify_handler(handle,
ACPI_DEVICE_NOTIFY,
notify_handler,
--
2.26.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-10 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10 12:20 [PATCH 1/2] platform/x86: intel-vbtn: Move detect_tablet_mode() to higher in the file Hans de Goede
2020-05-10 12:20 ` [PATCH 2/2] platform/x86: intel-vbtn: Detect switch position before registering the input-device Hans de Goede
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).