Date: Thu, 21 Aug 2014 10:18:43 +0000 (UTC) From: Jean-Sebastien Pedron <dumbbell@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r270262 - in stable/10/sys: arm/freescale/imx dev/vt/colors dev/vt/hw/efifb dev/vt/hw/fb dev/vt/hw/ofwfb Message-ID: <201408211018.s7LAIhXL082778@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dumbbell Date: Thu Aug 21 10:18:42 2014 New Revision: 270262 URL: http://svnweb.freebsd.org/changeset/base/270262 Log: vt(4): Colors are indexed against a console palette, not a VGA palette Rename vt_generate_vga_palette() to vt_generate_cons_palette() and change it to build a palette where the color index is the same than in terminal escape codes, not the VGA index. That's what TCHAR_CREATE() uses and passes to vt(4). The main differences between both orders are: o Blue and red are swapped (1 <-> 4) o Yellow and cyan are swapped (3 <-> 6) The problem remained unnoticed, because the RGB bit indexes passed to vt_generate_vga_palette() were reversed. This inversion was cancelled by the colors inversions in the generated palette. For instance, red (0xff0000) and blue (0x0000ff) have bytes in opposite order, but were swapped in the palette. But after changing the value of blue (see last paragraph), the modified color was in fact the red one. While here, tune the palette to better match console colors and improve the readability (especially the dark blue). This is an MFC of r269783 and r269791. Modified: stable/10/sys/arm/freescale/imx/imx51_ipuv3_fbd.c stable/10/sys/dev/vt/colors/vt_termcolors.c stable/10/sys/dev/vt/colors/vt_termcolors.h stable/10/sys/dev/vt/hw/efifb/efifb.c stable/10/sys/dev/vt/hw/fb/vt_early_fb.c stable/10/sys/dev/vt/hw/fb/vt_fb.c stable/10/sys/dev/vt/hw/ofwfb/ofwfb.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/freescale/imx/imx51_ipuv3_fbd.c ============================================================================== --- stable/10/sys/arm/freescale/imx/imx51_ipuv3_fbd.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/arm/freescale/imx/imx51_ipuv3_fbd.c Thu Aug 21 10:18:42 2014 (r270262) @@ -163,18 +163,18 @@ ipu3_fb_init_cmap(uint32_t *cmap, int by switch (bytespp) { case 8: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x7, 5, 0x7, 2, 0x3, 0)); case 15: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x1f, 10, 0x1f, 5, 0x1f, 0)); case 16: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x1f, 11, 0x3f, 5, 0x1f, 0)); case 24: case 32: /* Ignore alpha. */ - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, - 0xff, 16, 0xff, 8, 0xff, 0)); + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, + 0xff, 0, 0xff, 8, 0xff, 16)); default: return (1); } Modified: stable/10/sys/dev/vt/colors/vt_termcolors.c ============================================================================== --- stable/10/sys/dev/vt/colors/vt_termcolors.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/colors/vt_termcolors.c Thu Aug 21 10:18:42 2014 (r270262) @@ -39,25 +39,36 @@ static struct { unsigned char b; /* Blue percentage value. */ } color_def[16] = { {0, 0, 0}, /* black */ - {0, 0, 50}, /* dark blue */ - {0, 50, 0}, /* dark green */ - {0, 50, 50}, /* dark cyan */ {50, 0, 0}, /* dark red */ + {0, 50, 0}, /* dark green */ + {77, 63, 0}, /* dark yellow */ + {20, 40, 64}, /* dark blue */ {50, 0, 50}, /* dark magenta */ - {50, 50, 0}, /* brown */ + {0, 50, 50}, /* dark cyan */ {75, 75, 75}, /* light gray */ - {50, 50, 50}, /* dark gray */ - {0, 0, 100}, /* light blue */ - {0, 100, 0}, /* light green */ - {0, 100, 100}, /* light cyan */ + + {18, 20, 21}, /* dark gray */ {100, 0, 0}, /* light red */ + {0, 100, 0}, /* light green */ + {100, 100, 0}, /* light yellow */ + {45, 62, 81}, /* light blue */ {100, 0, 100}, /* light magenta */ - {100, 100, 0}, /* yellow */ + {0, 100, 100}, /* light cyan */ {100, 100, 100}, /* white */ }; +/* + * Between console's palette and VGA's one: + * - blue and red are swapped (1 <-> 4) + * - yellow ad cyan are swapped (3 <-> 6) + */ +static const int cons_to_vga_colors[16] = { + 0, 4, 2, 6, 1, 5, 3, 7, + 0, 4, 2, 6, 1, 5, 3, 7 +}; + int -vt_generate_vga_palette(uint32_t *palette, int format, uint32_t rmax, int roffset, +vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax, int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) { int i; @@ -66,7 +77,7 @@ vt_generate_vga_palette(uint32_t *palett for (i = 0; i < 16; i++) { switch (format) { case COLOR_FORMAT_VGA: - palette[i] = i; + palette[i] = cons_to_vga_colors[i]; break; case COLOR_FORMAT_RGB: palette[i] = CF(r, i) | CF(g, i) | CF(b, i); Modified: stable/10/sys/dev/vt/colors/vt_termcolors.h ============================================================================== --- stable/10/sys/dev/vt/colors/vt_termcolors.h Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/colors/vt_termcolors.h Thu Aug 21 10:18:42 2014 (r270262) @@ -45,6 +45,6 @@ enum vt_color_format { }; /* Helper to fill color map used by driver */ -int vt_generate_vga_palette(uint32_t *palette, int format, uint32_t rmax, +int vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax, int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset); Modified: stable/10/sys/dev/vt/hw/efifb/efifb.c ============================================================================== --- stable/10/sys/dev/vt/hw/efifb/efifb.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/hw/efifb/efifb.c Thu Aug 21 10:18:42 2014 (r270262) @@ -126,7 +126,7 @@ vt_efifb_init(struct vt_device *vd) info->fb_stride = efifb->fb_stride * (depth / 8); - vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, + vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, efifb->fb_mask_green, ffs(efifb->fb_mask_green) - 1, efifb->fb_mask_blue, ffs(efifb->fb_mask_blue) - 1); Modified: stable/10/sys/dev/vt/hw/fb/vt_early_fb.c ============================================================================== --- stable/10/sys/dev/vt/hw/fb/vt_early_fb.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/hw/fb/vt_early_fb.c Thu Aug 21 10:18:42 2014 (r270262) @@ -90,25 +90,25 @@ vt_efb_initialize(struct fb_info *info) */ switch (info->fb_depth) { case 8: - vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, + vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 0x7, 5, 0x7, 2, 0x3, 0); break; case 15: - vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, + vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 0x1f, 10, 0x1f, 5, 0x1f, 0); break; case 16: - vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, + vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 0x1f, 11, 0x3f, 5, 0x1f, 0); break; case 24: case 32: #if BYTE_ORDER == BIG_ENDIAN - vt_generate_vga_palette(info->fb_cmap, - COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); -#else - vt_generate_vga_palette(info->fb_cmap, + vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 255, 0, 255, 8, 255, 16); +#else + vt_generate_cons_palette(info->fb_cmap, + COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); #endif #ifdef FDT for (i = 0; i < 16; i++) { Modified: stable/10/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- stable/10/sys/dev/vt/hw/fb/vt_fb.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/hw/fb/vt_fb.c Thu Aug 21 10:18:42 2014 (r270262) @@ -334,18 +334,18 @@ vt_fb_init_cmap(uint32_t *cmap, int dept switch (depth) { case 8: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x7, 5, 0x7, 2, 0x3, 0)); case 15: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x1f, 10, 0x1f, 5, 0x1f, 0)); case 16: - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, 0x1f, 11, 0x3f, 5, 0x1f, 0)); case 24: case 32: /* Ignore alpha. */ - return (vt_generate_vga_palette(cmap, COLOR_FORMAT_RGB, - 0xff, 0, 0xff, 8, 0xff, 16)); + return (vt_generate_cons_palette(cmap, COLOR_FORMAT_RGB, + 0xff, 16, 0xff, 8, 0xff, 0)); default: return (1); } Modified: stable/10/sys/dev/vt/hw/ofwfb/ofwfb.c ============================================================================== --- stable/10/sys/dev/vt/hw/ofwfb/ofwfb.c Thu Aug 21 09:01:42 2014 (r270261) +++ stable/10/sys/dev/vt/hw/ofwfb/ofwfb.c Thu Aug 21 10:18:42 2014 (r270262) @@ -245,8 +245,8 @@ ofwfb_initialize(struct vt_device *vd) switch (sc->sc_depth) { case 8: - vt_generate_vga_palette(sc->sc_colormap, COLOR_FORMAT_RGB, 255, - 0, 255, 8, 255, 16); + vt_generate_cons_palette(sc->sc_colormap, COLOR_FORMAT_RGB, 255, + 16, 255, 8, 255, 0); for (i = 0; i < 16; i++) { OF_call_method("color!", ih, 4, 1, @@ -268,11 +268,11 @@ ofwfb_initialize(struct vt_device *vd) oldpix = bus_space_read_4(sc->sc_memt, sc->sc_addr, 0); bus_space_write_4(sc->sc_memt, sc->sc_addr, 0, 0xff000000); if (*(uint8_t *)(sc->sc_addr) == 0xff) - vt_generate_vga_palette(sc->sc_colormap, - COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); - else - vt_generate_vga_palette(sc->sc_colormap, + vt_generate_cons_palette(sc->sc_colormap, COLOR_FORMAT_RGB, 255, 0, 255, 8, 255, 16); + else + vt_generate_cons_palette(sc->sc_colormap, + COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); bus_space_write_4(sc->sc_memt, sc->sc_addr, 0, oldpix); break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408211018.s7LAIhXL082778>