All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PATCH] thinkpad-acpi changes for the merge window (part 1)
@ 2007-09-20 13:50 Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 1/7] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield Henrique de Moraes Holschuh
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

Len,

Here is the first batch of changes for thinkpad-acpi, targetted at the
next merge window.   They're mostly non-critical fixes.

Please merge this batch to acpi-test.

I do have some new work to submit (NVRAM polling), but I am waiting for
some testing feedback before I consider pushing it for the next merge
window.  I will send that as a separate batch later.

As usual, it is available at:
git://repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git for-upstream/acpi-test

Shortlog of the above branch:

Henrique de Moraes Holschuh (7):
      ACPI: thinkpad-acpi: make room for more features in tp_features bitfield
      ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH
      ACPI: thinkpad-acpi: add mutex-based locking to input device event send path
      ACPI: thinkpad-acpi: keep track of module state
      ACPI: thinkpad-acpi: check version of hot key firmware
      ACPI: thinkpad-acpi: dequeue all pending hot key events at once
      ACPI: thinkpad-acpi: fix regression on HKEY LID event handling

Thanks.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* [PATCH 1/7] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield
  2007-09-20 13:50 [GIT PATCH] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
@ 2007-09-20 13:50 ` Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 2/7] ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH Henrique de Moraes Holschuh
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh

Increase tp_features to 32 bits.  It is too close to running out of room.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.h |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 082a1cb..fa64ded 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -233,22 +233,22 @@ struct ibm_init_struct {
 
 static struct {
 #ifdef CONFIG_THINKPAD_ACPI_BAY
-	u16 bay_status:1;
-	u16 bay_eject:1;
-	u16 bay_status2:1;
-	u16 bay_eject2:1;
+	u32 bay_status:1;
+	u32 bay_eject:1;
+	u32 bay_status2:1;
+	u32 bay_eject2:1;
 #endif
-	u16 bluetooth:1;
-	u16 hotkey:1;
-	u16 hotkey_mask:1;
-	u16 hotkey_wlsw:1;
-	u16 light:1;
-	u16 light_status:1;
-	u16 wan:1;
-	u16 fan_ctrl_status_undef:1;
-	u16 input_device_registered:1;
-	u16 platform_drv_registered:1;
-	u16 platform_drv_attrs_registered:1;
+	u32 bluetooth:1;
+	u32 hotkey:1;
+	u32 hotkey_mask:1;
+	u32 hotkey_wlsw:1;
+	u32 light:1;
+	u32 light_status:1;
+	u32 wan:1;
+	u32 fan_ctrl_status_undef:1;
+	u32 input_device_registered:1;
+	u32 platform_drv_registered:1;
+	u32 platform_drv_attrs_registered:1;
 } tp_features;
 
 struct thinkpad_id_data {
-- 
1.5.3.1


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

* [PATCH 2/7] ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH
  2007-09-20 13:50 [GIT PATCH] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 1/7] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield Henrique de Moraes Holschuh
@ 2007-09-20 13:50 ` Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 3/7] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path Henrique de Moraes Holschuh
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh

We were missing a input_sync on the radio switch event report path. Add it.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 0222bba..8aa0f96 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1149,9 +1149,11 @@ static void tpacpi_input_send_radiosw(void)
 {
 	int wlsw;
 
-	if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw))
+	if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
 		input_report_switch(tpacpi_inputdev,
 				    SW_RADIO, !!wlsw);
+		input_sync(tpacpi_inputdev);
+	}
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
-- 
1.5.3.1


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

* [PATCH 3/7] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path
  2007-09-20 13:50 [GIT PATCH] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 1/7] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield Henrique de Moraes Holschuh
  2007-09-20 13:50 ` [PATCH 2/7] ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH Henrique de Moraes Holschuh
@ 2007-09-20 13:50 ` Henrique de Moraes Holschuh
       [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
  2007-09-20 13:51 ` [PATCH 7/7] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling Henrique de Moraes Holschuh
  4 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh

Protect the input device event sending path with a mutex, since hot key
input events are not atomic and require an cohesive event block to be sent
together.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 8aa0f96..0ced9d6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -519,6 +519,7 @@ static char *next_cmd(char **cmds)
 static struct platform_device *tpacpi_pdev;
 static struct class_device *tpacpi_hwmon;
 static struct input_dev *tpacpi_inputdev;
+static struct mutex tpacpi_inputdev_send_mutex;
 
 
 static int tpacpi_resume_handler(struct platform_device *pdev)
@@ -1131,6 +1132,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
 				  unsigned int keycode)
 {
 	if (keycode != KEY_RESERVED) {
+		mutex_lock(&tpacpi_inputdev_send_mutex);
+
 		input_report_key(tpacpi_inputdev, keycode, 1);
 		if (keycode == KEY_UNKNOWN)
 			input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
@@ -1142,6 +1145,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
 			input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
 				    scancode);
 		input_sync(tpacpi_inputdev);
+
+		mutex_unlock(&tpacpi_inputdev_send_mutex);
 	}
 }
 
@@ -1149,11 +1154,15 @@ static void tpacpi_input_send_radiosw(void)
 {
 	int wlsw;
 
+	mutex_lock(&tpacpi_inputdev_send_mutex);
+
 	if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
 		input_report_switch(tpacpi_inputdev,
 				    SW_RADIO, !!wlsw);
 		input_sync(tpacpi_inputdev);
 	}
+
+	mutex_unlock(&tpacpi_inputdev_send_mutex);
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -4737,6 +4746,7 @@ static int __init thinkpad_acpi_module_init(void)
 		thinkpad_acpi_module_exit();
 		return ret;
 	}
+	mutex_init(&tpacpi_inputdev_send_mutex);
 	tpacpi_inputdev = input_allocate_device();
 	if (!tpacpi_inputdev) {
 		printk(IBM_ERR "unable to allocate input device\n");
-- 
1.5.3.1


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

* [PATCH 4/7] ACPI: thinkpad-acpi: keep track of module state
       [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-09-20 13:50   ` Henrique de Moraes Holschuh
  2007-09-20 13:50   ` [PATCH 5/7] ACPI: thinkpad-acpi: check version of hot key firmware Henrique de Moraes Holschuh
  2007-09-20 13:50   ` [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once Henrique de Moraes Holschuh
  2 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA

Keep track of module state (init, running, exit).  This makes it trivially
easy to avoid running any interrupt handlers, threads, or any other async
activity before we are ready, or when we want to go away.

Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
 drivers/misc/thinkpad_acpi.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 0ced9d6..2155139 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
 
 #define __unused __attribute__ ((unused))
 
+static enum {
+	TPACPI_LIFE_INIT = 0,
+	TPACPI_LIFE_RUNNING,
+	TPACPI_LIFE_EXITING,
+} tpacpi_lifecycle;
+
 /****************************************************************************
  ****************************************************************************
  *
@@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	struct ibm_struct *ibm = data;
 
+	if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
+		return;
+
 	if (!ibm || !ibm->acpi || !ibm->acpi->notify)
 		return;
 
@@ -3899,6 +3908,9 @@ static void fan_watchdog_fire(struct work_struct *ignored)
 {
 	int rc;
 
+	if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
+		return;
+
 	printk(IBM_NOTICE "fan watchdog: enabling fan\n");
 	rc = fan_set_enable();
 	if (rc < 0) {
@@ -3919,7 +3931,8 @@ static void fan_watchdog_reset(void)
 	if (fan_watchdog_active)
 		cancel_delayed_work(&fan_watchdog_task);
 
-	if (fan_watchdog_maxinterval > 0) {
+	if (fan_watchdog_maxinterval > 0 &&
+	    tpacpi_lifecycle != TPACPI_LIFE_EXITING) {
 		fan_watchdog_active = 1;
 		if (!schedule_delayed_work(&fan_watchdog_task,
 				msecs_to_jiffies(fan_watchdog_maxinterval
@@ -4685,6 +4698,8 @@ static int __init thinkpad_acpi_module_init(void)
 {
 	int ret, i;
 
+	tpacpi_lifecycle = TPACPI_LIFE_INIT;
+
 	/* Parameter checking */
 	if (hotkey_report_mode > 2)
 		return -EINVAL;
@@ -4781,6 +4796,7 @@ static int __init thinkpad_acpi_module_init(void)
 		tp_features.input_device_registered = 1;
 	}
 
+	tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
 	return 0;
 }
 
@@ -4788,6 +4804,8 @@ static void thinkpad_acpi_module_exit(void)
 {
 	struct ibm_struct *ibm, *itmp;
 
+	tpacpi_lifecycle = TPACPI_LIFE_EXITING;
+
 	list_for_each_entry_safe_reverse(ibm, itmp,
 					 &tpacpi_all_drivers,
 					 all_drivers) {
-- 
1.5.3.1


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* [PATCH 5/7] ACPI: thinkpad-acpi: check version of hot key firmware
       [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
  2007-09-20 13:50   ` [PATCH 4/7] ACPI: thinkpad-acpi: keep track of module state Henrique de Moraes Holschuh
@ 2007-09-20 13:50   ` Henrique de Moraes Holschuh
  2007-09-20 13:50   ` [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once Henrique de Moraes Holschuh
  2 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA

Check the HKEY firmware version (HKEY.MHKV handler), and refuse to load if
it is unknown.  Use this instead of the presence of HKEY.DHKV to detect hot
key mask capability.

Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
 drivers/misc/thinkpad_acpi.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 2155139..9a61140 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -999,6 +999,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 
 	int res, i;
 	int status;
+	int hkeyv;
 
 	vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
 
@@ -1024,18 +1025,35 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 			return res;
 
 		/* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
-		   A30, R30, R31, T20-22, X20-21, X22-24 */
-		tp_features.hotkey_mask =
-			acpi_evalf(hkey_handle, NULL, "DHKN", "qv");
+		   A30, R30, R31, T20-22, X20-21, X22-24.  Detected by checking
+		   for HKEY interface version 0x100 */
+		if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
+			if ((hkeyv >> 8) != 1) {
+				printk(IBM_ERR "unknown version of the "
+				       "HKEY interface: 0x%x\n", hkeyv);
+				printk(IBM_ERR "please report this to %s\n",
+				       IBM_MAIL);
+			} else {
+				/*
+				 * MHKV 0x100 in A31, R40, R40e,
+				 * T4x, X31, and later
+				 * */
+				tp_features.hotkey_mask = 1;
+			}
+		}
 
 		vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
 			str_supported(tp_features.hotkey_mask));
 
 		if (tp_features.hotkey_mask) {
-			/* MHKA available in A31, R40, R40e, T4x, X31, and later */
 			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
-					"MHKA", "qd"))
+					"MHKA", "qd")) {
+				printk(IBM_ERR
+				       "missing MHKA handler, "
+				       "please report this to %s\n",
+				       IBM_MAIL);
 				hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */
+			}
 		}
 
 		res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask);
-- 
1.5.3.1


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once
       [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
  2007-09-20 13:50   ` [PATCH 4/7] ACPI: thinkpad-acpi: keep track of module state Henrique de Moraes Holschuh
  2007-09-20 13:50   ` [PATCH 5/7] ACPI: thinkpad-acpi: check version of hot key firmware Henrique de Moraes Holschuh
@ 2007-09-20 13:50   ` Henrique de Moraes Holschuh
       [not found]     ` <11902962613565-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
  2 siblings, 1 reply; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:50 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA

Receive all pending hot key events at once from a single notification, and
don't complain if the queue is empty.

Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
 drivers/misc/thinkpad_acpi.c |   52 ++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 9a61140..de415fe 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1196,9 +1196,31 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 {
 	u32 hkey;
 	unsigned int keycode, scancode;
-	int send_acpi_ev = 0;
+	int send_acpi_ev;
+
+	if (event != 0x80) {
+		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
+		/* forward it to userspace, maybe it knows how to handle it */
+		acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
+		acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+						ibm->acpi->device->dev.bus_id,
+						event, 0);
+		return;
+	}
+
+	while (1) {
+		if (!acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
+			printk(IBM_ERR "failed to retrieve hot key event\n");
+			return;
+		}
+
+		if (hkey == 0) {
+			/* queue empty */
+			return;
+		}
+
+		send_acpi_ev = 0;
 
-	if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
 		switch (hkey >> 12) {
 		case 1:
 			/* 0x1000-0x1FFF: key presses */
@@ -1220,8 +1242,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 			 * eat up known LID events */
 			if (hkey != 0x5001 && hkey != 0x5002) {
 				printk(IBM_ERR
-					"unknown LID-related hotkey event: 0x%04x\n",
-					hkey);
+				       "unknown LID-related hotkey event: 0x%04x\n",
+				       hkey);
 				send_acpi_ev = 1;
 			}
 			break;
@@ -1240,21 +1262,17 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 			printk(IBM_NOTICE "unhandled HKEY event 0x%04x\n", hkey);
 			send_acpi_ev = 1;
 		}
-	} else {
-		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
-		hkey = 0;
-		send_acpi_ev = 1;
-	}
 
-	/* Legacy events */
-	if (send_acpi_ev || hotkey_report_mode < 2)
-		acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
+		/* Legacy events */
+		if (send_acpi_ev || hotkey_report_mode < 2)
+			acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
 
-	/* netlink events */
-	if (send_acpi_ev) {
-		acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
-						ibm->acpi->device->dev.bus_id,
-						event, hkey);
+		/* netlink events */
+		if (send_acpi_ev) {
+			acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+							ibm->acpi->device->dev.bus_id,
+							event, hkey);
+		}
 	}
 }
 
-- 
1.5.3.1


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* [PATCH 7/7] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling
  2007-09-20 13:50 [GIT PATCH] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
                   ` (3 preceding siblings ...)
       [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-09-20 13:51 ` Henrique de Moraes Holschuh
  4 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-20 13:51 UTC (permalink / raw)
  To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi, Henrique de Moraes Holschuh

We were letting ThinkPad-specific LID events through to userspace again,
instead of dropping them.  Fix it.  We don't want to give userspace the
option of not using generic LID handling.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index de415fe..24503cc 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1197,6 +1197,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 	u32 hkey;
 	unsigned int keycode, scancode;
 	int send_acpi_ev;
+	int ignore_acpi_ev;
 
 	if (event != 0x80) {
 		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
@@ -1220,6 +1221,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		}
 
 		send_acpi_ev = 0;
+		ignore_acpi_ev = 0;
 
 		switch (hkey >> 12) {
 		case 1:
@@ -1245,6 +1247,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 				       "unknown LID-related hotkey event: 0x%04x\n",
 				       hkey);
 				send_acpi_ev = 1;
+			} else {
+				ignore_acpi_ev = 1;
 			}
 			break;
 		case 7:
@@ -1264,11 +1268,12 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		}
 
 		/* Legacy events */
-		if (send_acpi_ev || hotkey_report_mode < 2)
+		if (!ignore_acpi_ev && (send_acpi_ev || hotkey_report_mode < 2)) {
 			acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
+		}
 
 		/* netlink events */
-		if (send_acpi_ev) {
+		if (!ignore_acpi_ev && send_acpi_ev) {
 			acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
 							ibm->acpi->device->dev.bus_id,
 							event, hkey);
-- 
1.5.3.1


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

* Re: [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once
       [not found]     ` <11902962613565-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-09-21  0:42       ` Len Brown
       [not found]         ` <200709202042.22724.lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Len Brown @ 2007-09-21  0:42 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Thursday 20 September 2007 09:50, Henrique de Moraes Holschuh wrote:
> Receive all pending hot key events at once from a single notification, and
> don't complain if the queue is empty.
> 
> Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
> ---
>  drivers/misc/thinkpad_acpi.c |   52 ++++++++++++++++++++++++++++-------------
>  1 files changed, 35 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
> index 9a61140..de415fe 100644
> --- a/drivers/misc/thinkpad_acpi.c
> +++ b/drivers/misc/thinkpad_acpi.c
> @@ -1196,9 +1196,31 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
>  {
>  	u32 hkey;
>  	unsigned int keycode, scancode;
> -	int send_acpi_ev = 0;
> +	int send_acpi_ev;
> +
> +	if (event != 0x80) {
> +		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
> +		/* forward it to userspace, maybe it knows how to handle it */
> +		acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
> +		acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
> +						ibm->acpi->device->dev.bus_id,
> +						event, 0);

If this is really an event due to an hotkey (emphasis on the word KEY:-),
why is it being sent via netlink instead of via input?

thanks,
-Len

> +		return;
> +	}
> +
> +	while (1) {
> +		if (!acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
> +			printk(IBM_ERR "failed to retrieve hot key event\n");
> +			return;
> +		}
> +
> +		if (hkey == 0) {
> +			/* queue empty */
> +			return;
> +		}
> +
> +		send_acpi_ev = 0;
>  
> -	if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
>  		switch (hkey >> 12) {
>  		case 1:
>  			/* 0x1000-0x1FFF: key presses */
> @@ -1220,8 +1242,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
>  			 * eat up known LID events */
>  			if (hkey != 0x5001 && hkey != 0x5002) {
>  				printk(IBM_ERR
> -					"unknown LID-related hotkey event: 0x%04x\n",
> -					hkey);
> +				       "unknown LID-related hotkey event: 0x%04x\n",
> +				       hkey);
>  				send_acpi_ev = 1;
>  			}
>  			break;
> @@ -1240,21 +1262,17 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
>  			printk(IBM_NOTICE "unhandled HKEY event 0x%04x\n", hkey);
>  			send_acpi_ev = 1;
>  		}
> -	} else {
> -		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
> -		hkey = 0;
> -		send_acpi_ev = 1;
> -	}
>  
> -	/* Legacy events */
> -	if (send_acpi_ev || hotkey_report_mode < 2)
> -		acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
> +		/* Legacy events */
> +		if (send_acpi_ev || hotkey_report_mode < 2)
> +			acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
>  
> -	/* netlink events */
> -	if (send_acpi_ev) {
> -		acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
> -						ibm->acpi->device->dev.bus_id,
> -						event, hkey);
> +		/* netlink events */
> +		if (send_acpi_ev) {
> +			acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
> +							ibm->acpi->device->dev.bus_id,
> +							event, hkey);
> +		}
>  	}
>  }
>  

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* Re: [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once
       [not found]         ` <200709202042.22724.lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
@ 2007-09-21 13:53           ` Henrique de Moraes Holschuh
  2007-09-24  2:33             ` Len Brown
  0 siblings, 1 reply; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-21 13:53 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Thu, 20 Sep 2007, Len Brown wrote:
> On Thursday 20 September 2007 09:50, Henrique de Moraes Holschuh wrote:
> > Receive all pending hot key events at once from a single notification, and
> > don't complain if the queue is empty.

Maybe I should have s/hot.?key/HKEY/ throughout this patch.

The HKEY handler is the thinkpad-specific handler to message-pass
interesting events to the O.S. This include hot key pressing, but also
inclures: LID open/close, radio switch toggling, what looks like thermal
alarms, reason for wakeup (bay eject, whatever), notification of impending
undock (to show a helper to the user explaining how to undock a x40/x60,
etc)... and only IBM and Lenovo knows what else.  Hot key presses are just
one of the many things reported through thinkpad HKEY events.

> If this is really an event due to an hotkey (emphasis on the word KEY:-),
> why is it being sent via netlink instead of via input?

Like I said, if it hit that branch, it is some other notification than a hot
key press :-)  Yeah, it is non-obvious.

I will rework the patch to use the word HKEY event instead of hotkey event
where applicable.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

* Re: [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once
  2007-09-21 13:53           ` Henrique de Moraes Holschuh
@ 2007-09-24  2:33             ` Len Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Len Brown @ 2007-09-24  2:33 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh; +Cc: ibm-acpi-devel, linux-acpi

On Friday 21 September 2007 09:53, Henrique de Moraes Holschuh wrote:
> On Thu, 20 Sep 2007, Len Brown wrote:
> > On Thursday 20 September 2007 09:50, Henrique de Moraes Holschuh wrote:
> > > Receive all pending hot key events at once from a single notification, and
> > > don't complain if the queue is empty.
> 
> Maybe I should have s/hot.?key/HKEY/ throughout this patch.
> 
> The HKEY handler is the thinkpad-specific handler to message-pass
> interesting events to the O.S. This include hot key pressing, but also
> inclures: LID open/close, radio switch toggling, what looks like thermal
> alarms, reason for wakeup (bay eject, whatever), notification of impending
> undock (to show a helper to the user explaining how to undock a x40/x60,
> etc)... and only IBM and Lenovo knows what else.  Hot key presses are just
> one of the many things reported through thinkpad HKEY events.
> 
> > If this is really an event due to an hotkey (emphasis on the word KEY:-),
> > why is it being sent via netlink instead of via input?
> 
> Like I said, if it hit that branch, it is some other notification than a hot
> key press :-)  Yeah, it is non-obvious.
> 
> I will rework the patch to use the word HKEY event instead of hotkey event
> where applicable.

Thanks for the clarification, Henrique.

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

* [PATCH 7/7] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling
       [not found] ` <11905098422303-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-09-23  1:10   ` Henrique de Moraes Holschuh
  0 siblings, 0 replies; 12+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-09-23  1:10 UTC (permalink / raw)
  To: Len Brown
  Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA

We were letting ThinkPad-specific LID events through to userspace again,
instead of dropping them.  Fix it.  We don't want to give userspace the
option of not using generic LID handling.

Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
 drivers/misc/thinkpad_acpi.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index b1db51e..1a77fe4 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1197,6 +1197,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 	u32 hkey;
 	unsigned int keycode, scancode;
 	int send_acpi_ev;
+	int ignore_acpi_ev;
 
 	if (event != 0x80) {
 		printk(IBM_ERR "unknown HKEY notification event %d\n", event);
@@ -1218,6 +1219,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		}
 
 		send_acpi_ev = 0;
+		ignore_acpi_ev = 0;
 
 		switch (hkey >> 12) {
 		case 1:
@@ -1243,6 +1245,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 				       "unknown LID-related HKEY event: 0x%04x\n",
 				       hkey);
 				send_acpi_ev = 1;
+			} else {
+				ignore_acpi_ev = 1;
 			}
 			break;
 		case 7:
@@ -1262,11 +1266,12 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		}
 
 		/* Legacy events */
-		if (send_acpi_ev || hotkey_report_mode < 2)
+		if (!ignore_acpi_ev && (send_acpi_ev || hotkey_report_mode < 2)) {
 			acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
+		}
 
 		/* netlink events */
-		if (send_acpi_ev) {
+		if (!ignore_acpi_ev && send_acpi_ev) {
 			acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
 							ibm->acpi->device->dev.bus_id,
 							event, hkey);
-- 
1.5.3.1


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

end of thread, other threads:[~2007-09-24  2:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-20 13:50 [GIT PATCH] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
2007-09-20 13:50 ` [PATCH 1/7] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield Henrique de Moraes Holschuh
2007-09-20 13:50 ` [PATCH 2/7] ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH Henrique de Moraes Holschuh
2007-09-20 13:50 ` [PATCH 3/7] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path Henrique de Moraes Holschuh
     [not found] ` <11902962603691-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-09-20 13:50   ` [PATCH 4/7] ACPI: thinkpad-acpi: keep track of module state Henrique de Moraes Holschuh
2007-09-20 13:50   ` [PATCH 5/7] ACPI: thinkpad-acpi: check version of hot key firmware Henrique de Moraes Holschuh
2007-09-20 13:50   ` [PATCH 6/7] ACPI: thinkpad-acpi: dequeue all pending hot key events at once Henrique de Moraes Holschuh
     [not found]     ` <11902962613565-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-09-21  0:42       ` Len Brown
     [not found]         ` <200709202042.22724.lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2007-09-21 13:53           ` Henrique de Moraes Holschuh
2007-09-24  2:33             ` Len Brown
2007-09-20 13:51 ` [PATCH 7/7] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling Henrique de Moraes Holschuh
2007-09-23  1:10 [GIT PATCH v2] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
     [not found] ` <11905098422303-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-09-23  1:10   ` [PATCH 7/7] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling Henrique de Moraes Holschuh

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.