* [PATCH] via-pmu: report powerbutton as proper input event
@ 2006-04-28 19:15 Johannes Berg
2006-05-01 6:58 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2006-04-28 19:15 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, debian-powerpc
This patch adds an input device for the power button so that userspace gets
notified about the user pressing it via the standard input layer.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
--- linux-2.6.orig/drivers/macintosh/Makefile 2006-04-28 19:07:27.057288704 +0200
+++ linux-2.6/drivers/macintosh/Makefile 2006-04-28 19:07:49.987288704 +0200
@@ -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_PMU_LED) += via-pmu-led.o
obj-$(CONFIG_ADB_CUDA) += via-cuda.o
obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/drivers/macintosh/via-pmu-event.c 2006-04-28 20:35:12.277288704 +0200
@@ -0,0 +1,35 @@
+#include <linux/input.h>
+#include "via-pmu-event.h"
+
+static struct input_dev *pmu_input_dev;
+
+int pmu_event_init(void)
+{
+ pmu_input_dev = input_allocate_device();
+ if (unlikely(!pmu_input_dev))
+ return -ENODEV;
+
+ pmu_input_dev->name = "PMU powerbutton";
+ pmu_input_dev->id.bustype = BUS_PMU;
+ pmu_input_dev->id.vendor = 0x0001;
+ pmu_input_dev->id.product = 0x0001;
+ pmu_input_dev->id.version = 0x0100;
+
+ pmu_input_dev->evbit[0] = BIT(EV_KEY);
+ pmu_input_dev->keybit[LONG(KEY_POWER)] = BIT(KEY_POWER);
+
+ return input_register_device(pmu_input_dev);
+}
+
+void pmu_event_powerbutton(int down)
+{
+ static int powerbutton_pressed;
+
+ if (unlikely(!pmu_input_dev))
+ return;
+ if (powerbutton_pressed == down)
+ return;
+ powerbutton_pressed = down;
+ input_report_key(pmu_input_dev, KEY_POWER, down);
+ input_sync(pmu_input_dev);
+}
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/drivers/macintosh/via-pmu-event.h 2006-04-28 20:09:34.967288704 +0200
@@ -0,0 +1,8 @@
+#ifndef __VIA_PMU_EVENT_H
+#define __VIA_PMU_EVENT_H
+
+extern int pmu_event_init(void);
+
+extern void pmu_event_powerbutton(int down);
+
+#endif /* __VIA_PMU_EVENT_H */
--- linux-2.6.orig/include/linux/input.h 2006-04-28 20:00:37.417288704 +0200
+++ linux-2.6/include/linux/input.h 2006-04-28 20:00:48.157288704 +0200
@@ -658,6 +658,7 @@ struct input_absinfo {
#define BUS_I2C 0x18
#define BUS_HOST 0x19
#define BUS_GSC 0x1A
+#define BUS_PMU 0x20
/*
* Values describing the status of an effect
--- linux-2.6.orig/drivers/macintosh/via-pmu.c 2006-04-28 19:07:19.207288704 +0200
+++ linux-2.6/drivers/macintosh/via-pmu.c 2006-04-28 20:35:23.417288704 +0200
@@ -70,6 +70,7 @@
#endif
#include "via-pmu-led.h"
+#include "via-pmu-event.h"
/* Some compile options */
#undef SUSPEND_USES_PMU
@@ -1443,6 +1444,11 @@ next:
if (pmu_battery_count)
query_battery_state();
pmu_pass_intr(data, len);
+ /* if the thing has the powerbutton bit set then
+ * update the powerbutton key status */
+ if (len == 6) {
+ pmu_event_powerbutton(!!(data[1]&8));
+ }
} else {
pmu_pass_intr(data, len);
}
@@ -2915,6 +2921,10 @@ static int __init init_pmu_led(void)
if (pmu_led_init()) {
printk(KERN_WARNING "via-pmu: LED failed to init\n");
}
+
+ /* only on keylargo can the power button be on the pmu ... */
+ if (pmu_event_init())
+ printk(KERN_WARNING "via-pmu: couldn't add event device");
}
return 0;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] via-pmu: report powerbutton as proper input event
2006-04-28 19:15 [PATCH] via-pmu: report powerbutton as proper input event Johannes Berg
@ 2006-05-01 6:58 ` Benjamin Herrenschmidt
2006-05-01 8:56 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2006-05-01 6:58 UTC (permalink / raw)
To: Johannes Berg; +Cc: linuxppc-dev list, debian-powerpc
On Fri, 2006-04-28 at 21:15 +0200, Johannes Berg wrote:
> This patch adds an input device for the power button so that userspace gets
> notified about the user pressing it via the standard input layer.
Looks interesting. Waht about other buttons/events the PMU can report ?
> +#endif /* __VIA_PMU_EVENT_H */
> --- linux-2.6.orig/include/linux/input.h 2006-04-28 20:00:37.417288704 +0200
> +++ linux-2.6/include/linux/input.h 2006-04-28 20:00:48.157288704 +0200
> @@ -658,6 +658,7 @@ struct input_absinfo {
> #define BUS_I2C 0x18
> #define BUS_HOST 0x19
> #define BUS_GSC 0x1A
> +#define BUS_PMU 0x20
Magic numbers... BAD BAD BAD ... Somebody needs to LART the input layer
people.
> @@ -2915,6 +2921,10 @@ static int __init init_pmu_led(void)
> if (pmu_led_init()) {
> printk(KERN_WARNING "via-pmu: LED failed to init\n");
> }
> +
> + /* only on keylargo can the power button be on the pmu ... */
> + if (pmu_event_init())
> + printk(KERN_WARNING "via-pmu: couldn't add event device");
> }
>
> return 0;
Do we need these here ? Why not an initcall self-contained in each
file ?
Ben.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] via-pmu: report powerbutton as proper input event
2006-05-01 6:58 ` Benjamin Herrenschmidt
@ 2006-05-01 8:56 ` Johannes Berg
2006-05-01 9:09 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2006-05-01 8:56 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 943 bytes --]
On Mon, 2006-05-01 at 16:58 +1000, Benjamin Herrenschmidt wrote:
> On Fri, 2006-04-28 at 21:15 +0200, Johannes Berg wrote:
> > This patch adds an input device for the power button so that userspace gets
> > notified about the user pressing it via the standard input layer.
>
> Looks interesting. Waht about other buttons/events the PMU can report ?
What else does it report? As far as I know it doesn't have anything
else, at least on my system.
> > +#define BUS_PMU 0x20
>
> Magic numbers... BAD BAD BAD ... Somebody needs to LART the input layer
> people.
It's not really a "magic" number since it doesn't really carry any
information, or would you like string identifiers in each device
descriptor? An enum would be just the same, in fact, the definition
could be rewritten as an enum :)
> Do we need these here ? Why not an initcall self-contained in each
> file ?
No heh, good point.
Thanks,
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 793 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] via-pmu: report powerbutton as proper input event
2006-05-01 8:56 ` Johannes Berg
@ 2006-05-01 9:09 ` Benjamin Herrenschmidt
2006-05-01 9:21 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2006-05-01 9:09 UTC (permalink / raw)
To: Johannes Berg; +Cc: linuxppc-dev list
On Mon, 2006-05-01 at 10:56 +0200, Johannes Berg wrote:
> On Mon, 2006-05-01 at 16:58 +1000, Benjamin Herrenschmidt wrote:
> > On Fri, 2006-04-28 at 21:15 +0200, Johannes Berg wrote:
> > > This patch adds an input device for the power button so that userspace gets
> > > notified about the user pressing it via the standard input layer.
> >
> > Looks interesting. Waht about other buttons/events the PMU can report ?
>
> What else does it report? As far as I know it doesn't have anything
> else, at least on my system.
Depends on the machine... earlier ones have the backlight there or
volume control.. then LID close could be an event too...
> > > +#define BUS_PMU 0x20
> >
> > Magic numbers... BAD BAD BAD ... Somebody needs to LART the input layer
> > people.
>
> It's not really a "magic" number since it doesn't really carry any
> information, or would you like string identifiers in each device
> descriptor? An enum would be just the same, in fact, the definition
> could be rewritten as an enum :)
>
> > Do we need these here ? Why not an initcall self-contained in each
> > file ?
>
> No heh, good point.
>
> Thanks,
> johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] via-pmu: report powerbutton as proper input event
2006-05-01 9:09 ` Benjamin Herrenschmidt
@ 2006-05-01 9:21 ` Johannes Berg
2006-05-01 9:35 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2006-05-01 9:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 536 bytes --]
On Mon, 2006-05-01 at 19:09 +1000, Benjamin Herrenschmidt wrote:
> > What else does it report? As far as I know it doesn't have anything
> > else, at least on my system.
>
> Depends on the machine... earlier ones have the backlight there or
> volume control.. then LID close could be an event too...
Ok, yea. Well, we need to rework all of that. Currently, to get at the
lid status, you have to open /dev/adb and do something through that.
I honestly don't understand the reason for this. Is it just historic?
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 793 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] via-pmu: report powerbutton as proper input event
2006-05-01 9:21 ` Johannes Berg
@ 2006-05-01 9:35 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2006-05-01 9:35 UTC (permalink / raw)
To: Johannes Berg; +Cc: linuxppc-dev list
On Mon, 2006-05-01 at 11:21 +0200, Johannes Berg wrote:
> On Mon, 2006-05-01 at 19:09 +1000, Benjamin Herrenschmidt wrote:
> > > What else does it report? As far as I know it doesn't have anything
> > > else, at least on my system.
> >
> > Depends on the machine... earlier ones have the backlight there or
> > volume control.. then LID close could be an event too...
>
> Ok, yea. Well, we need to rework all of that. Currently, to get at the
> lid status, you have to open /dev/adb and do something through that.
>
> I honestly don't understand the reason for this. Is it just historic?
Yes.
Ben.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-05-01 9:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-28 19:15 [PATCH] via-pmu: report powerbutton as proper input event Johannes Berg
2006-05-01 6:58 ` Benjamin Herrenschmidt
2006-05-01 8:56 ` Johannes Berg
2006-05-01 9:09 ` Benjamin Herrenschmidt
2006-05-01 9:21 ` Johannes Berg
2006-05-01 9:35 ` Benjamin Herrenschmidt
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).