From owner-svn-src-head@FreeBSD.ORG Tue Mar 10 17:04:12 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3C97C641; Tue, 10 Mar 2015 17:04:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0D1D4D75; Tue, 10 Mar 2015 17:04:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2AH4BR4027591; Tue, 10 Mar 2015 17:04:11 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2AH4BmR027590; Tue, 10 Mar 2015 17:04:11 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201503101704.t2AH4BmR027590@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 10 Mar 2015 17:04:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279855 - head/sys/dev/vt/hw/ofwfb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2015 17:04:12 -0000 Author: nwhitehorn Date: Tue Mar 10 17:04:11 2015 New Revision: 279855 URL: https://svnweb.freebsd.org/changeset/base/279855 Log: Let unchangeable 8-bit frame buffers have vaguely correct colors. MFC after: 2 weeks Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c ============================================================================== --- head/sys/dev/vt/hw/ofwfb/ofwfb.c Tue Mar 10 16:06:07 2015 (r279854) +++ head/sys/dev/vt/hw/ofwfb/ofwfb.c Tue Mar 10 17:04:11 2015 (r279855) @@ -54,6 +54,7 @@ struct ofwfb_softc { phandle_t sc_node; ihandle_t sc_handle; bus_space_tag_t sc_memt; + int iso_palette; }; static vd_probe_t ofwfb_probe; @@ -73,6 +74,12 @@ static const struct vt_driver vt_ofwfb_d .vd_priority = VD_PRIORITY_GENERIC+1, }; +static unsigned char ofw_colors[16] = { + /* See "16-color Text Extension" Open Firmware document, page 4 */ + 0, 4, 2, 6, 1, 5, 3, 7, + 8, 12, 10, 14, 9, 13, 11, 15 +}; + static struct ofwfb_softc ofwfb_conssoftc; VT_DRIVER_DECLARE(vt_ofwfb, vt_ofwfb_driver); @@ -121,6 +128,11 @@ ofwfb_bitblt_bitmap(struct vt_device *vd bgc = sc->fb_cmap[bg]; b = m = 0; + if (((struct ofwfb_softc *)vd->vd_softc)->iso_palette) { + fg = ofw_colors[fg]; + bg = ofw_colors[bg]; + } + line = (sc->fb_stride * y) + x * sc->fb_bpp/8; if (mask == NULL && sc->fb_bpp == 8 && (width % 8 == 0)) { /* Don't try to put off screen pixels */ @@ -255,7 +267,7 @@ static void ofwfb_initialize(struct vt_device *vd) { struct ofwfb_softc *sc = vd->vd_softc; - int i; + int i, err; cell_t retval; uint32_t oldpix; @@ -263,18 +275,24 @@ ofwfb_initialize(struct vt_device *vd) * Set up the color map */ + sc->iso_palette = 0; switch (sc->fb.fb_bpp) { case 8: vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); for (i = 0; i < 16; i++) { - OF_call_method("color!", sc->sc_handle, 4, 1, + err = OF_call_method("color!", sc->sc_handle, 4, 1, (cell_t)((sc->fb.fb_cmap[i] >> 16) & 0xff), (cell_t)((sc->fb.fb_cmap[i] >> 8) & 0xff), (cell_t)((sc->fb.fb_cmap[i] >> 0) & 0xff), (cell_t)i, &retval); + if (err) + break; } + if (i != 16) + sc->iso_palette = 1; + break; case 32: