Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sun report power button events to sysmon
details: https://anonhg.NetBSD.org/src/rev/af009eac0a5c
branches: trunk
changeset: 779019:af009eac0a5c
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Apr 26 00:50:10 2012 +0000
description:
report power button events to sysmon
also send pwm events for volume control keys directly with
options KBD_HIJACK_VOLUME_BUTTONS
so they work in X as well
diffstat:
sys/dev/sun/files.sun | 4 +-
sys/dev/sun/kbd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++----
sys/dev/sun/kbdvar.h | 6 ++++-
3 files changed, 54 insertions(+), 8 deletions(-)
diffs (160 lines):
diff -r ad87e8709c5a -r af009eac0a5c sys/dev/sun/files.sun
--- a/sys/dev/sun/files.sun Thu Apr 26 00:21:44 2012 +0000
+++ b/sys/dev/sun/files.sun Thu Apr 26 00:50:10 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sun,v 1.16 2008/12/05 11:52:42 jdc Exp $
+# $NetBSD: files.sun,v 1.17 2012/04/26 00:50:10 macallan Exp $
#
# Configuration file for devices found on Sun machines.
#
@@ -19,7 +19,7 @@
file dev/sun/kbd.c kbd needs-flag
file dev/sun/kbd_tables.c kbd
-defflag opt_sunkbd.h SPARCBOOK_CMD
+defflag opt_sunkbd.h SPARCBOOK_CMD KBD_HIJACK_VOLUME_BUTTONS
file dev/sun/wskbdmap_sun.c kbd & wskbd
# e.g. - lower layer: sun keyboard at zs
diff -r ad87e8709c5a -r af009eac0a5c sys/dev/sun/kbd.c
--- a/sys/dev/sun/kbd.c Thu Apr 26 00:21:44 2012 +0000
+++ b/sys/dev/sun/kbd.c Thu Apr 26 00:50:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kbd.c,v 1.63 2009/05/12 14:46:39 cegger Exp $ */
+/* $NetBSD: kbd.c,v 1.64 2012/04/26 00:50:10 macallan Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.63 2009/05/12 14:46:39 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.64 2012/04/26 00:50:10 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -65,6 +65,8 @@
#include <sys/poll.h>
#include <sys/file.h>
+#include <dev/sysmon/sysmon_taskq.h>
+
#include <dev/wscons/wsksymdef.h>
#include <dev/sun/kbd_reg.h>
@@ -76,6 +78,7 @@
#include "ioconf.h"
#include "locators.h"
+#include "opt_sunkbd.h"
dev_type_open(kbdopen);
dev_type_close(kbdclose);
@@ -150,7 +153,7 @@
/* firm events input */
static void kbd_input_event(struct kbd_softc *, int);
-
+static void kbd_powerbutton(void *);
/****************************************************************
* Entry points for /dev/kbd
@@ -899,7 +902,7 @@
kbd_input_wskbd(struct kbd_softc *k, int code)
{
int type, key;
-
+
#ifdef WSDISPLAY_COMPAT_RAWKBD
if (k->k_wsraw) {
u_char buf;
@@ -912,6 +915,27 @@
type = KEY_UP(code) ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
key = KEY_CODE(code);
+
+ if (type == WSCONS_EVENT_KEY_DOWN) {
+ switch (key) {
+#ifdef KBD_HIJACK_VOLUME_BUTTONS
+ case 0x02:
+ pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_DOWN);
+ return;
+ case 0x04:
+ pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_UP);
+ return;
+#endif
+ case 0x30:
+ if (k->k_isconsole)
+ k->k_ev = KEY_UP(code) ?
+ PSWITCH_EVENT_RELEASED :
+ PSWITCH_EVENT_PRESSED;
+ sysmon_task_queue_sched(0, kbd_powerbutton, k);
+ return;
+ }
+ }
+
wskbd_input(k->k_wskbd, type, key);
}
@@ -919,6 +943,7 @@
wssunkbd_enable(void *v, int on)
{
struct kbd_softc *k = v;
+
if (k->k_wsenabled != on) {
k->k_wsenabled = on;
if (on) {
@@ -1048,7 +1073,24 @@
kbd_wskbd_attach(struct kbd_softc *k, int isconsole)
{
k->k_isconsole = isconsole;
-
+ if (isconsole) {
+ sysmon_task_queue_init();
+ memset(&k->k_sm_pbutton, 0, sizeof(struct sysmon_pswitch));
+ k->k_sm_pbutton.smpsw_name = device_xname(k->k_dev);
+ k->k_sm_pbutton.smpsw_type = PSWITCH_TYPE_POWER;
+ if (sysmon_pswitch_register(&k->k_sm_pbutton) != 0)
+ aprint_error_dev(k->k_dev,
+ "unable to register power button with sysmon\n");
+ }
config_interrupts(k->k_dev, kbd_enable);
}
+
+static void
+kbd_powerbutton(void *cookie)
+{
+ struct kbd_softc *k = cookie;
+
+ sysmon_pswitch_event(&k->k_sm_pbutton, k->k_ev);
+}
+
#endif
diff -r ad87e8709c5a -r af009eac0a5c sys/dev/sun/kbdvar.h
--- a/sys/dev/sun/kbdvar.h Thu Apr 26 00:21:44 2012 +0000
+++ b/sys/dev/sun/kbdvar.h Thu Apr 26 00:50:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kbdvar.h,v 1.20 2009/05/12 14:46:39 cegger Exp $ */
+/* $NetBSD: kbdvar.h,v 1.21 2012/04/26 00:50:10 macallan Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -43,6 +43,7 @@
#include "wskbd.h" /* for NWSKBD */
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wskbdvar.h>
+#include <dev/sysmon/sysmonvar.h>
#if NWSKBD > 0
#include "opt_wsdisplay_compat.h"
@@ -51,6 +52,9 @@
struct kbd_softc {
device_t k_dev; /* required first: base device */
+ struct sysmon_pswitch k_sm_pbutton;
+ int k_ev;
+
/* middle layer methods */
const struct kbd_ops *k_ops;
Home |
Main Index |
Thread Index |
Old Index