+ via-pmu-add-input-device.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     via-pmu: add input device

has been added to the -mm tree.  Its filename is

     via-pmu-add-input-device.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>

Add an input device for the button and lid switch so that userspace gets
notified about the user pressing them via the standard input layer.

I know this is going to be quite controversial due to the changes in the
input layer.  But I was reading http://lkml.org/lkml/2006/4/24/172 and
there seemed to be some consensus about this...

Cc: Pavel Machek <pavel@xxxxxxx>
Cc: Richard Purdie <rpurdie@xxxxxxxxx>
Cc: Matthew Garrett <mjg59@xxxxxxxxxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: <linux-input@xxxxxxxxxxxxxxxxxxxxxxxx>
Cc: Dmitry Torokhov <dtor_core@xxxxxxxxxxxxx>
Signed-off-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/macintosh/Makefile        |    2 
 drivers/macintosh/via-pmu-event.c |   75 ++++++++++++++++++++++++++++
 drivers/macintosh/via-pmu-event.h |    8 ++
 drivers/macintosh/via-pmu.c       |    8 ++
 include/linux/input.h             |    4 +
 5 files changed, 95 insertions(+), 2 deletions(-)

diff -puN drivers/macintosh/Makefile~via-pmu-add-input-device drivers/macintosh/Makefile
--- 25/drivers/macintosh/Makefile~via-pmu-add-input-device	Mon May  8 13:41:51 2006
+++ 25-akpm/drivers/macintosh/Makefile	Mon May  8 13:41:51 2006
@@ -11,7 +11,7 @@ obj-$(CONFIG_MAC_EMUMOUSEBTN)	+= mac_hid
 obj-$(CONFIG_INPUT_ADBHID)	+= adbhid.o
 obj-$(CONFIG_ANSLCD)		+= ans-lcd.o
 
-obj-$(CONFIG_ADB_PMU)		+= via-pmu.o
+obj-$(CONFIG_ADB_PMU)		+= via-pmu.o via-pmu-event.o
 obj-$(CONFIG_ADB_CUDA)		+= via-cuda.o
 obj-$(CONFIG_PMAC_APM_EMU)	+= apm_emu.o
 obj-$(CONFIG_PMAC_SMU)		+= smu.o
diff -puN drivers/macintosh/via-pmu.c~via-pmu-add-input-device drivers/macintosh/via-pmu.c
--- 25/drivers/macintosh/via-pmu.c~via-pmu-add-input-device	Mon May  8 13:41:51 2006
+++ 25-akpm/drivers/macintosh/via-pmu.c	Mon May  8 13:43:25 2006
@@ -69,6 +69,8 @@
 #include <asm/open_pic.h>
 #endif
 
+#include "via-pmu-event.h"
+
 /* Some compile options */
 #undef SUSPEND_USES_PMU
 #define DEBUG_SLEEP
@@ -1441,6 +1443,12 @@ next:
 		if (pmu_battery_count)
 			query_battery_state();
 		pmu_pass_intr(data, len);
+		/* len == 6 is probably a bad check. But how do I
+		 * know what PMU versions send what events here? */
+		if (len == 6) {
+			pmu_event(PMU_EVT_POWER, !!(data[1]&8));
+			pmu_event(PMU_EVT_LID, data[1]&1);
+		}
 	} else {
 	       pmu_pass_intr(data, len);
 	}
diff -puN /dev/null drivers/macintosh/via-pmu-event.c
--- /dev/null	Thu Apr 11 07:25:15 2002
+++ 25-akpm/drivers/macintosh/via-pmu-event.c	Mon May  8 13:43:25 2006
@@ -0,0 +1,75 @@
+/*
+ * via-pmu event device for reporting some events that come through the PMU
+ *
+ * Copyright 2006 Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ */
+
+#include <linux/input.h>
+#include <linux/adb.h>
+#include <linux/pmu.h>
+#include "via-pmu-event.h"
+
+static struct input_dev *pmu_input_dev;
+
+static int pmu_event_init(void)
+{
+	/* do other models report button/lid status? */
+	if (pmu_get_model() != PMU_KEYLARGO_BASED)
+		return -ENODEV;
+
+	pmu_input_dev = input_allocate_device();
+	if (!pmu_input_dev)
+		return -ENODEV;
+
+	pmu_input_dev->name = "PMU";
+	pmu_input_dev->id.bustype = BUS_HOST;
+	pmu_input_dev->id.vendor = 0x0001;
+	pmu_input_dev->id.product = 0x0001;
+	pmu_input_dev->id.version = 0x0100;
+
+	set_bit(EV_KEY, pmu_input_dev->evbit);
+	set_bit(EV_SW, pmu_input_dev->evbit);
+	set_bit(KEY_POWER, pmu_input_dev->keybit);
+	set_bit(SW_LID, pmu_input_dev->swbit);
+
+	return input_register_device(pmu_input_dev);
+}
+
+void pmu_event(int key, int down)
+{
+
+	if (unlikely(!pmu_input_dev))
+		return;
+
+	switch (key) {
+	case PMU_EVT_POWER:
+		input_report_key(pmu_input_dev, KEY_POWER, down);
+		break;
+	case PMU_EVT_LID:
+		input_report_switch(pmu_input_dev, SW_LID, down);
+		break;
+	default:
+		/* no such key handled */
+		return;
+	}
+
+	input_sync(pmu_input_dev);
+}
+
+late_initcall(pmu_event_init);
diff -puN /dev/null drivers/macintosh/via-pmu-event.h
--- /dev/null	Thu Apr 11 07:25:15 2002
+++ 25-akpm/drivers/macintosh/via-pmu-event.h	Mon May  8 13:43:25 2006
@@ -0,0 +1,8 @@
+#ifndef __VIA_PMU_EVENT_H
+#define __VIA_PMU_EVENT_H
+
+#define PMU_EVT_POWER	0
+#define PMU_EVT_LID	1
+extern void pmu_event(int key, int down);
+
+#endif /* __VIA_PMU_EVENT_H */
diff -puN include/linux/input.h~via-pmu-add-input-device include/linux/input.h
--- 25/include/linux/input.h~via-pmu-add-input-device	Mon May  8 13:41:51 2006
+++ 25-akpm/include/linux/input.h	Mon May  8 13:41:51 2006
@@ -577,7 +577,9 @@ struct input_absinfo {
  * Switch events
  */
 
-#define SW_0			0x00
+#define SW_LID		0x00
+/* numeric ones should go away */
+#define SW_0		SW_LID
 #define SW_1			0x01
 #define SW_2			0x02
 #define SW_3			0x03
_

Patches currently in -mm which might be from johannes@xxxxxxxxxxxxxxxx are

via-pmu-add-input-device.patch
via-pmu-add-input-device-tidy.patch
git-netdev-all.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux