All of lore.kernel.org
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
	Johannes Berg <johannes@sipsolutions.net>,
	Dmitry Torokhov <dtor@mail.ru>
Subject: [PATCH 10/10] thinkpad-acpi: sync input device EV_SW state directly
Date: Tue,  8 Dec 2009 23:36:30 -0200	[thread overview]
Message-ID: <1260322590-5571-11-git-send-email-hmh@hmh.eng.br> (raw)
In-Reply-To: <1260322590-5571-1-git-send-email-hmh@hmh.eng.br>

Before we register the input device, sync the input layer EV_SW state
directly by setting the bitmaps, to avoid issuing a gratuitous event
for the initial state of these switches.

I will propose a clean input layer API for this and change the driver
to use it later, but I'd rather get the driver fix in mainline ASAP.

This fixes some annoyances caused by the interaction with rfkill and
EV_SW SW_RFKILL_ALL events.

Reported-by: Kevin Locke <kevin@kevinlocke.name>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
 drivers/platform/x86/thinkpad_acpi.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 53d6c33..e7ff6c7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3186,6 +3186,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	int res, i;
 	int status;
 	int hkeyv;
+	bool radiosw_state  = false;
+	bool tabletsw_state = false;
 
 	unsigned long quirks;
 
@@ -3291,6 +3293,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
 	if (dbg_wlswemul) {
 		tp_features.hotkey_wlsw = 1;
+		radiosw_state = !!tpacpi_wlsw_emulstate;
 		printk(TPACPI_INFO
 			"radio switch emulation enabled\n");
 	} else
@@ -3298,6 +3301,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	/* Not all thinkpads have a hardware radio switch */
 	if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
 		tp_features.hotkey_wlsw = 1;
+		radiosw_state = !!status;
 		printk(TPACPI_INFO
 			"radio switch found; radios are %s\n",
 			enabled(status, 0));
@@ -3309,11 +3313,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	/* For X41t, X60t, X61t Tablets... */
 	if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) {
 		tp_features.hotkey_tablet = 1;
+		tabletsw_state = !!(status & TP_HOTKEY_TABLET_MASK);
 		printk(TPACPI_INFO
 			"possible tablet mode switch found; "
 			"ThinkPad in %s mode\n",
-			(status & TP_HOTKEY_TABLET_MASK)?
-				"tablet" : "laptop");
+			(tabletsw_state) ? "tablet" : "laptop");
 		res = add_to_attr_set(hotkey_dev_attributes,
 				&dev_attr_hotkey_tablet_mode.attr);
 	}
@@ -3364,9 +3368,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 
 	if (tp_features.hotkey_wlsw) {
 		input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
+		if (radiosw_state)
+			__set_bit(SW_RFKILL_ALL, tpacpi_inputdev->sw);
 	}
 	if (tp_features.hotkey_tablet) {
 		input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
+		if (tabletsw_state)
+			__set_bit(SW_TABLET_MODE, tpacpi_inputdev->sw);
 	}
 
 	/* Do not issue duplicate brightness change events to
@@ -3433,8 +3441,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	tpacpi_inputdev->close = &hotkey_inputdev_close;
 
 	hotkey_poll_setup_safe(true);
-	tpacpi_send_radiosw_update();
-	tpacpi_input_send_tabletsw();
 
 	return 0;
 
-- 
1.6.5.4


  parent reply	other threads:[~2009-12-09  1:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-09  1:36 [GIT PATCH v2] thinkpad-acpi first set of changes for 2.6.33 (v2) Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 01/10] thinkpad-acpi: fix default brightness_mode for R50e/R51 Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 02/10] thinkpad-acpi: preserve rfkill state across suspend/resume Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 03/10] thinkpad-acpi: fix some version quirks Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 04/10] thinkpad-acpi: issue backlight class events Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 05/10] thinkpad-acpi: silence bogus complain during rmmod Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 06/10] thinkpad-acpi: adopt input device Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 07/10] thinkpad-acpi: expose module parameters Henrique de Moraes Holschuh
2009-12-09  1:36 ` [PATCH 08/10] thinkpad-acpi: log temperatures on termal alarm (v2) Henrique de Moraes Holschuh
2009-12-09 10:46   ` Pavel Machek
2009-12-09  1:36 ` [PATCH 09/10] thinkpad-acpi: use input_set_capability Henrique de Moraes Holschuh
2009-12-09  1:36 ` Henrique de Moraes Holschuh [this message]
     [not found]   ` <1260322590-5571-11-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2009-12-09  1:45     ` [PATCH 10/10] thinkpad-acpi: sync input device EV_SW state directly Dmitry Torokhov
2009-12-09 16:30       ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
     [not found]         ` <20091209163041.GA29575-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2009-12-09 17:21           ` Dmitry Torokhov
2009-12-09 20:32             ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2009-12-09 20:59               ` Dmitry Torokhov
2009-12-10 13:19                 ` Henrique de Moraes Holschuh
2009-12-10 18:59                   ` Dmitry Torokhov
     [not found]                     ` <20091210185922.GD23717-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2009-12-11  0:46                       ` Henrique de Moraes Holschuh
     [not found]                         ` <20091211004602.GB24245-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2009-12-11  7:54                           ` Dmitry Torokhov
2009-12-11 15:02                             ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2009-12-09 20:47 ` [GIT PATCH v2] thinkpad-acpi first set of changes for 2.6.33 (v2) Len Brown
2009-12-09 22:32   ` Henrique de Moraes Holschuh

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=1260322590-5571-11-git-send-email-hmh@hmh.eng.br \
    --to=hmh@hmh.eng.br \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=dtor@mail.ru \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=johannes@sipsolutions.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.