summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavide <davide@FreeBSD.org>2013-03-04 14:00:58 +0000
committerdavide <davide@FreeBSD.org>2013-03-04 14:00:58 +0000
commitc3613bbf4032390e36e11642abe61f25bb32be80 (patch)
treea8e0e13c9ab4b9ed92d7efae11430745be03366e
parentf7c18136b1eb2ab224d0b91246ee0b051f465520 (diff)
downloadFreeBSD-src-c3613bbf4032390e36e11642abe61f25bb32be80.zip
FreeBSD-src-c3613bbf4032390e36e11642abe61f25bb32be80.tar.gz
MFcalloutng (r244249, r244306 by mav):
- Switch syscons from timeout() to callout_reset_flags() and specify that precision is not important there -- anything from 20 to 30Hz will be fine. - Reduce syscons "refresh" rate to 1-2Hz when console is in graphics mode and there is nothing to do except some polling for keyboard. Text mode refresh would also be nice to have adaptive, but this change at least should help laptop users who running X. Sponsored by: Google Summer of Code 2012, iXsystems inc. Tested by: flo, marius, ian, markj, Fabian Keil
-rw-r--r--sys/dev/syscons/syscons.c58
-rw-r--r--sys/dev/syscons/syscons.h2
2 files changed, 32 insertions, 28 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 8094ea3..b863f90 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -506,6 +506,8 @@ sc_attach_unit(int unit, int flags)
sc = sc_get_softc(unit, flags & SC_KERNEL_CONSOLE);
sc->config = flags;
+ callout_init(&sc->ctimeout, 0);
+ callout_init(&sc->cblink, 0);
scp = sc_get_stat(sc->dev[0]);
if (sc_console == NULL) /* sc_console_unit < 0 */
sc_console = scp;
@@ -1831,13 +1833,11 @@ static void
scrn_timer(void *arg)
{
#ifndef PC98
- static int kbd_interval = 0;
+ static time_t kbd_time_stamp = 0;
#endif
- struct timeval tv;
sc_softc_t *sc;
scr_stat *scp;
- int again;
- int s;
+ int again, rate;
again = (arg != NULL);
if (arg != NULL)
@@ -1847,18 +1847,18 @@ scrn_timer(void *arg)
else
return;
+ /* find the vty to update */
+ scp = sc->cur_scp;
+
/* don't do anything when we are performing some I/O operations */
- if (suspend_in_progress || sc->font_loading_in_progress) {
- if (again)
- timeout(scrn_timer, sc, hz / 10);
- return;
- }
- s = spltty();
+ if (suspend_in_progress || sc->font_loading_in_progress)
+ goto done;
#ifndef PC98
if ((sc->kbd == NULL) && (sc->config & SC_AUTODETECT_KBD)) {
/* try to allocate a keyboard automatically */
- if (++kbd_interval >= 25) {
+ if (kbd_time_stamp != time_uptime) {
+ kbd_time_stamp = time_uptime;
sc->keyboard = sc_allocate_keyboard(sc, -1);
if (sc->keyboard >= 0) {
sc->kbd = kbd_get_keyboard(sc->keyboard);
@@ -1867,25 +1867,20 @@ scrn_timer(void *arg)
update_kbd_state(sc->cur_scp, sc->cur_scp->status,
LOCK_MASK);
}
- kbd_interval = 0;
}
}
#endif /* PC98 */
- /* find the vty to update */
- scp = sc->cur_scp;
-
/* should we stop the screen saver? */
- getmicrouptime(&tv);
if (debugger > 0 || panicstr || shutdown_in_progress)
sc_touch_scrn_saver();
if (run_scrn_saver) {
- if (tv.tv_sec > sc->scrn_time_stamp + scrn_blank_time)
+ if (time_uptime > sc->scrn_time_stamp + scrn_blank_time)
sc->flags |= SC_SCRN_IDLE;
else
sc->flags &= ~SC_SCRN_IDLE;
} else {
- sc->scrn_time_stamp = tv.tv_sec;
+ sc->scrn_time_stamp = time_uptime;
sc->flags &= ~SC_SCRN_IDLE;
if (scrn_blank_time > 0)
run_scrn_saver = TRUE;
@@ -1898,12 +1893,8 @@ scrn_timer(void *arg)
/* should we just return ? */
if (sc->blink_in_progress || sc->switch_in_progress
- || sc->write_in_progress) {
- if (again)
- timeout(scrn_timer, sc, hz / 10);
- splx(s);
- return;
- }
+ || sc->write_in_progress)
+ goto done;
/* Update the screen */
scp = sc->cur_scp; /* cur_scp may have changed... */
@@ -1917,9 +1908,19 @@ scrn_timer(void *arg)
(*current_saver)(sc, TRUE);
#endif
- if (again)
- timeout(scrn_timer, sc, hz / 25);
- splx(s);
+done:
+ if (again) {
+ /*
+ * Use reduced "refresh" rate if we are in graphics and that is not a
+ * graphical screen saver. In such case we just have nothing to do.
+ */
+ if (ISGRAPHSC(scp) && !(sc->flags & SC_SCRN_BLANKED))
+ rate = 2;
+ else
+ rate = 30;
+ callout_reset_sbt(&sc->ctimeout, SBT_1S / rate, 0,
+ scrn_timer, sc, C_PREL(1));
+ }
}
static int
@@ -3863,7 +3864,8 @@ blink_screen(void *arg)
(*scp->rndr->draw)(scp, 0, scp->xsize*scp->ysize,
scp->sc->blink_in_progress & 1);
scp->sc->blink_in_progress--;
- timeout(blink_screen, scp, hz / 10);
+ callout_reset_sbt(&scp->sc->cblink, SBT_1S / 15, 0,
+ blink_screen, scp, C_PREL(0));
}
}
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 23a7bba..353b67f 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -269,6 +269,8 @@ typedef struct sc_softc {
#ifdef KDB
int sc_altbrk;
#endif
+ struct callout ctimeout;
+ struct callout cblink;
} sc_softc_t;
/* virtual screen */
OpenPOWER on IntegriCloud