From owner-svn-src-all@FreeBSD.ORG Sat Dec 17 15:57:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E429106564A; Sat, 17 Dec 2011 15:57:40 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D1D08FC08; Sat, 17 Dec 2011 15:57:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBHFvdS4066313; Sat, 17 Dec 2011 15:57:39 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBHFvdel066310; Sat, 17 Dec 2011 15:57:39 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201112171557.pBHFvdel066310@svn.freebsd.org> From: Andriy Gapon Date: Sat, 17 Dec 2011 15:57:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228644 - head/sys/dev/syscons X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2011 15:57:41 -0000 Author: avg Date: Sat Dec 17 15:57:39 2011 New Revision: 228644 URL: http://svn.freebsd.org/changeset/base/228644 Log: syscons: provide a first iteration of cngrab/cnungrab implementation - put underlying keyboard(s) into the polling mode for the whole duration of the grab, instead of the previous behavior of going into and out of the polling mode around each polling attempt - ditto for setting K_XLATE mode and enabling a disabled keyboard Inspired by: bde MFC after: 2 months Modified: head/sys/dev/syscons/syscons.c head/sys/dev/syscons/syscons.h Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Sat Dec 17 15:50:45 2011 (r228643) +++ head/sys/dev/syscons/syscons.c Sat Dec 17 15:57:39 2011 (r228644) @@ -1613,11 +1613,46 @@ sc_cnterm(struct consdev *cp) static void sc_cngrab(struct consdev *cp) { + scr_stat *scp; + + scp = sc_console->sc->cur_scp; + if (scp->sc->kbd == NULL) + return; + + if (scp->grabbed++ > 0) + return; + + /* + * Make sure the keyboard is accessible even when the kbd device + * driver is disabled. + */ + kbdd_enable(scp->sc->kbd); + + /* we shall always use the keyboard in the XLATE mode here */ + scp->kbd_prev_mode = scp->kbd_mode; + scp->kbd_mode = K_XLATE; + (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); + + kbdd_poll(scp->sc->kbd, TRUE); } static void sc_cnungrab(struct consdev *cp) { + scr_stat *scp; + + scp = sc_console->sc->cur_scp; /* XXX */ + if (scp->sc->kbd == NULL) + return; + + if (--scp->grabbed > 0) + return; + + kbdd_poll(scp->sc->kbd, FALSE); + + scp->kbd_mode = scp->kbd_prev_mode; + (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); + kbdd_disable(scp->sc->kbd); } static void @@ -1675,7 +1710,6 @@ sc_cngetc(struct consdev *cd) static int fkeycp; scr_stat *scp; const u_char *p; - int cur_mode; int s = spltty(); /* block sckbdevent and scrn_timer while we poll */ int c; @@ -1699,25 +1733,7 @@ sc_cngetc(struct consdev *cd) return -1; } - /* - * Make sure the keyboard is accessible even when the kbd device - * driver is disabled. - */ - kbdd_enable(scp->sc->kbd); - - /* we shall always use the keyboard in the XLATE mode here */ - cur_mode = scp->kbd_mode; - scp->kbd_mode = K_XLATE; - (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); - - kbdd_poll(scp->sc->kbd, TRUE); c = scgetc(scp->sc, SCGETC_CN | SCGETC_NONBLOCK); - kbdd_poll(scp->sc->kbd, FALSE); - - scp->kbd_mode = cur_mode; - (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); - kbdd_disable(scp->sc->kbd); - splx(s); switch (KEYFLAGS(c)) { case 0: /* normal char */ Modified: head/sys/dev/syscons/syscons.h ============================================================================== --- head/sys/dev/syscons/syscons.h Sat Dec 17 15:50:45 2011 (r228643) +++ head/sys/dev/syscons/syscons.h Sat Dec 17 15:57:39 2011 (r228644) @@ -301,7 +301,9 @@ typedef struct scr_stat { void *ts; int status; /* status (bitfield) */ + int grabbed; int kbd_mode; /* keyboard I/O mode */ + int kbd_prev_mode; /* keyboard I/O mode */ int cursor_pos; /* cursor buffer position */ int cursor_oldpos; /* cursor old buffer position */