From owner-svn-src-all@FreeBSD.ORG Fri Oct 23 18:53:22 2009 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 7E9861065679; Fri, 23 Oct 2009 18:53:22 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 541848FC12; Fri, 23 Oct 2009 18:53:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9NIrMIA069372; Fri, 23 Oct 2009 18:53:22 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9NIrLsm069370; Fri, 23 Oct 2009 18:53:21 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200910231853.n9NIrLsm069370@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 23 Oct 2009 18:53:21 +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: r198421 - 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: Fri, 23 Oct 2009 18:53:22 -0000 Author: jkim Date: Fri Oct 23 18:53:21 2009 New Revision: 198421 URL: http://svn.freebsd.org/changeset/base/198421 Log: Search for default 800x600 graphics mode from supported VESA mode list. Many video controllers do not support 800x600x24 mode any more. Modified: head/sys/dev/syscons/syscons.c Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Fri Oct 23 18:44:53 2009 (r198420) +++ head/sys/dev/syscons/syscons.c Fri Oct 23 18:53:21 2009 (r198421) @@ -343,17 +343,46 @@ sc_alloc_tty(int index, int devnum) return (tp); } +#ifdef SC_PIXEL_MODE +static int +sc_initial_mode(video_adapter_t *adp, int unit) +{ + video_info_t info; + int depth, vmode; + int i; + + vmode = 0; + (void)resource_int_value("sc", unit, "vesa_mode", &vmode); + if (vmode < M_VESA_BASE || vmode > M_VESA_MODE_MAX) + vmode = 0; + + /* + * If the default mode is not supported, search for an available + * 800x600 graphics mode with the highest color depth. + */ + if (vmode == 0 || vidd_get_info(adp, vmode, &info) != 0) { + depth = vmode = 0; + for (i = M_VESA_BASE; i <= M_VESA_MODE_MAX; i++) + if (vidd_get_info(adp, i, &info) == 0 && + (info.vi_flags & V_INFO_GRAPHICS) != 0 && + info.vi_width == 800 && info.vi_height == 600 && + info.vi_depth > depth) { + vmode = i; + depth = info.vi_depth; + } + } + + return (vmode); +} +#endif + int sc_attach_unit(int unit, int flags) { sc_softc_t *sc; scr_stat *scp; -#ifdef SC_PIXEL_MODE - video_info_t info; -#endif int vc; struct cdev *dev; - unsigned int vmode = 0; flags &= ~SC_KERNEL_CONSOLE; @@ -374,25 +403,24 @@ sc_attach_unit(int unit, int flags) if (sc_console == NULL) /* sc_console_unit < 0 */ sc_console = scp; - (void)resource_int_value("sc", unit, "vesa_mode", &vmode); - if (vmode < M_VESA_BASE || vmode > M_VESA_MODE_MAX) - vmode = M_VESA_FULL_800; - #ifdef SC_PIXEL_MODE - if ((sc->config & SC_VESAMODE) - && (vidd_get_info(sc->adp, vmode, &info) == 0)) { + if ((sc->config & SC_VESAMODE) != 0) { + int vmode; + vmode = sc_initial_mode(sc->adp, unit); + if (vmode >= M_VESA_BASE) { #ifdef DEV_SPLASH - if (sc->flags & SC_SPLASH_SCRN) - splash_term(sc->adp); + if (sc->flags & SC_SPLASH_SCRN) + splash_term(sc->adp); #endif - sc_set_graphics_mode(scp, NULL, vmode); - sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8); - sc->initial_mode = vmode; + sc_set_graphics_mode(scp, NULL, vmode); + sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8); + sc->initial_mode = vmode; #ifdef DEV_SPLASH - /* put up the splash again! */ - if (sc->flags & SC_SPLASH_SCRN) - splash_init(sc->adp, scsplash_callback, sc); + /* put up the splash again! */ + if (sc->flags & SC_SPLASH_SCRN) + splash_init(sc->adp, scsplash_callback, sc); #endif + } } #endif /* SC_PIXEL_MODE */