Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Mar 2022 16:26:13 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4e4e477d89fd - stable/12 - vt_vga: fix colour in pixel blocks with more than 4 colours
Message-ID:  <202203071626.227GQDDM004299@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=4e4e477d89fd0333425ed4623858082bdb58ffe7

commit 4e4e477d89fd0333425ed4623858082bdb58ffe7
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-03-02 16:40:00 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-03-07 16:25:58 +0000

    vt_vga: fix colour in pixel blocks with more than 4 colours
    
    VGA hardware provides many different graphics and data access modes,
    each with different capabilities and limitations.
    
    VGA vt(4) graphics mode operates on blocks of pixels at a time.  When a
    given pixel block contains only two colours the vt_vga driver uses write
    mode 3.  When the block contains more than two colours it uses write
    mode 0.  This is done because two-colour write mode 3 is much more
    efficient.
    
    In practice write mode 3 is used most of the time, as there is often a
    single foreground colour and single background colour across the entire
    console.  One common exception requiring the use of mode 0 is when the
    mouse cursor is drawn over a background other than black, as we need
    black and white for the cursor in addition to the background colour.
    
    VGA's default 16-colour palette provides the same set of colours as the
    system console, but in a different order.  Previously we configured a
    non-default VGA palette that had the same colours at the same indexes.
    However, this caused anything drawn before the kernel started (drawn by
    the loader, for instance) to change colours once the kernel configured
    the new, non-default palette.
    
    In 5e251aec8636 we switched to leaving the default VGA palette in place,
    translating console colour indexes to VGA colour indexes as necessary.
    This translation was missed for the write mode 0 case for pixel blocks
    with more than two colours.
    
    PR:             261751
    Reviewed by:    adrian
    MFC after:      1 week
    Fixes:          5e251aec8636 ("vt(4): Use default VGA palette")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34412
    
    (cherry picked from commit f266082f113a6a110c28034c64693c2cc216fd9d)
---
 sys/dev/vt/hw/vga/vt_vga.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index c0d001d09659..bac8f3eb7b97 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -582,7 +582,8 @@ vga_bitblt_pixels_block_ncolors(struct vt_device *vd, const uint8_t *masks,
 				/* The pixel "j" uses color "color". */
 				for (plane = 0; plane < 4; ++plane)
 					planes[i * 4 + plane] |=
-					    ((color >> plane) & 0x1) << (7 - j);
+					    ((cons_to_vga_colors[color] >>
+					    plane) & 0x1) << (7 - j);
 			}
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203071626.227GQDDM004299>