summaryrefslogtreecommitdiff
path: root/sys/dev/wscons
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2007-12-09 20:27:42 +0000
committerjmcneill <jmcneill@NetBSD.org>2007-12-09 20:27:42 +0000
commit4c1d81b2b5fa658e9fd5e7151eb40ba71ba676da (patch)
tree3f8b0d6c63745bde8809b8c6f9e4f6b1514f335e /sys/dev/wscons
parent3947df41d16da8b387239b9b87789bfbe950a3b2 (diff)
Merge jmcneill-pm branch.
Diffstat (limited to 'sys/dev/wscons')
-rw-r--r--sys/dev/wscons/wsdisplay.c45
-rw-r--r--sys/dev/wscons/wskbd.c25
-rw-r--r--sys/dev/wscons/wsksymdef.h5
-rw-r--r--sys/dev/wscons/wsmouse.c7
4 files changed, 67 insertions, 15 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index 3e46ba7af52..a1715d68a13 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.113 2007/12/09 20:28:25 jmcneill Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.113 2007/12/09 20:28:25 jmcneill Exp $");
#include "opt_wsdisplay_compat.h"
#include "opt_wsmsgattrs.h"
@@ -108,6 +108,7 @@ static void wsdisplay_shutdownhook(void *);
static void wsdisplay_addscreen_print(struct wsdisplay_softc *, int, int);
static void wsdisplay_closescreen(struct wsdisplay_softc *, struct wsscreen *);
int wsdisplay_delscreen(struct wsdisplay_softc *, int, int);
+static void wsdisplay_switchto(int);
#define WSDISPLAY_MAXSCREEN 8
@@ -158,10 +159,12 @@ static int wsdisplay_emul_match(device_t , struct cfdata *, void *);
static void wsdisplay_emul_attach(device_t, device_t, void *);
static int wsdisplay_noemul_match(device_t, struct cfdata *, void *);
static void wsdisplay_noemul_attach(device_t, device_t, void *);
+static bool wsdisplay_resume(device_t dv);
+static bool wsdisplay_suspend(device_t dv);
CFATTACH_DECL_NEW(wsdisplay_emul, sizeof (struct wsdisplay_softc),
wsdisplay_emul_match, wsdisplay_emul_attach, NULL, NULL);
-
+
CFATTACH_DECL_NEW(wsdisplay_noemul, sizeof (struct wsdisplay_softc),
wsdisplay_noemul_match, wsdisplay_noemul_attach, NULL, NULL);
@@ -598,6 +601,21 @@ wsdisplay_noemul_attach(device_t parent, device_t self, void *aux)
ap->accessops, ap->accesscookie);
}
+static bool
+wsdisplay_suspend(device_t dv)
+{
+ wsdisplay_switchtoconsole();
+
+ return true;
+}
+
+static bool
+wsdisplay_resume(device_t dv)
+{
+
+ return true;
+}
+
/* Print function (for parent devices). */
int
wsdisplaydevprint(void *aux, const char *pnp)
@@ -696,6 +714,9 @@ wsdisplay_common_attach(struct wsdisplay_softc *sc, int console, int kbdmux,
if (i > start)
wsdisplay_addscreen_print(sc, start, i-start);
+ if (!pmf_device_register(sc->sc_dev, wsdisplay_suspend, wsdisplay_resume))
+ aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n");
+
if (hookset == 0)
shutdownhook_establish(wsdisplay_shutdownhook, NULL);
hookset = 1;
@@ -2057,18 +2078,15 @@ wsdisplay_unset_cons_kbd(void)
wsdisplay_cons_kbd_pollc = 0;
}
-/*
- * Switch the console display to it's first screen.
- */
-void
-wsdisplay_switchtoconsole(void)
+static void
+wsdisplay_switchto(int no)
{
struct wsdisplay_softc *sc;
struct wsscreen *scr;
if (wsdisplay_console_device != NULL) {
sc = wsdisplay_console_device;
- if ((scr = sc->sc_scr[0]) == NULL)
+ if ((scr = sc->sc_scr[no]) == NULL)
return;
(*sc->sc_accessops->show_screen)(sc->sc_accesscookie,
scr->scr_dconf->emulcookie,
@@ -2077,6 +2095,15 @@ wsdisplay_switchtoconsole(void)
}
/*
+ * Switch the console display to it's first screen.
+ */
+void
+wsdisplay_switchtoconsole(void)
+{
+ wsdisplay_switchto(0);
+}
+
+/*
* Switch the console at shutdown.
*/
static void
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index cc154617c6d..42abfce3b8a 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbd.c,v 1.108 2007/12/01 05:22:02 jmcneill Exp $ */
+/* $NetBSD: wskbd.c,v 1.109 2007/12/09 20:28:25 jmcneill Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.108 2007/12/01 05:22:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.109 2007/12/09 20:28:25 jmcneill Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -464,6 +464,11 @@ wskbd_attach(struct device *parent, struct device *self, void *aux)
sc->sc_base.me_dv.dv_xname, error);
}
#endif
+
+ if (!pmf_device_register(self, NULL, NULL))
+ aprint_error_dev(self, "couldn't establish power handler\n");
+ else if (!pmf_class_input_register(self))
+ aprint_error_dev(self, "couldn't register as input device\n");
}
void
@@ -620,6 +625,8 @@ wskbd_input(struct device *dev, u_int type, int value)
callout_stop(&sc->sc_repeat_ch);
}
+ device_active(dev, DVA_HARDWARE);
+
#if NWSDISPLAY > 0
/*
* If /dev/wskbdN is not connected in event mode translate and
@@ -689,7 +696,7 @@ wskbd_deliver_event(struct wskbd_softc *sc, u_int type, int value)
return;
}
#endif
-
+
event.type = type;
event.value = value;
if (wsevent_inject(evar, &event, 1) != 0)
@@ -1453,6 +1460,18 @@ internal_command(struct wskbd_softc *sc, u_int *type, keysym_t ksym,
u_int state = 0;
#endif
switch (ksym) {
+ case KS_Cmd_VolumeToggle:
+ if (*type == WSCONS_EVENT_KEY_DOWN)
+ pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_TOGGLE);
+ break;
+ case KS_Cmd_VolumeUp:
+ if (*type == WSCONS_EVENT_KEY_DOWN)
+ pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_UP);
+ break;
+ case KS_Cmd_VolumeDown:
+ if (*type == WSCONS_EVENT_KEY_DOWN)
+ pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_DOWN);
+ break;
#ifdef WSDISPLAY_SCROLLSUPPORT
case KS_Cmd_ScrollFastUp:
case KS_Cmd_ScrollFastDown:
diff --git a/sys/dev/wscons/wsksymdef.h b/sys/dev/wscons/wsksymdef.h
index 8bc48f04924..1d082521a87 100644
--- a/sys/dev/wscons/wsksymdef.h
+++ b/sys/dev/wscons/wsksymdef.h
@@ -1,4 +1,4 @@
-/* $NetBSD: wsksymdef.h,v 1.58 2007/04/04 14:50:21 mishka Exp $ */
+/* $NetBSD: wsksymdef.h,v 1.59 2007/12/09 20:28:25 jmcneill Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -524,6 +524,9 @@
#define KS_Cmd_ScrollFastDown 0xf42d
#define KS_Cmd_ScrollSlowUp 0xf42e
#define KS_Cmd_ScrollSlowDown 0xf42f
+#define KS_Cmd_VolumeUp 0xf430
+#define KS_Cmd_VolumeDown 0xf431
+#define KS_Cmd_VolumeToggle 0xf432
/*
* Group 5 (internal)
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index 05bab1a2ebe..4b8cd0616fa 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmouse.c,v 1.54 2007/12/01 05:40:44 jmcneill Exp $ */
+/* $NetBSD: wsmouse.c,v 1.55 2007/12/09 20:28:25 jmcneill Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.54 2007/12/01 05:40:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.55 2007/12/09 20:28:25 jmcneill Exp $");
#include "wsmouse.h"
#include "wsdisplay.h"
@@ -275,6 +275,9 @@ wsmouse_attach(struct device *parent, struct device *self, void *aux)
aprint_naive("\n");
aprint_normal("\n");
+
+ if (!pmf_device_register(self, NULL, NULL))
+ aprint_error_dev(self, "couldn't establish power handler\n");
}
int