# Colors are messed up when returning to the graphics console from a non-graphics console



## Jay F. Shachter (Oct 29, 2019)

Esteemed Colleagues:

When I leave the graphics console with CTRL-ALT-F?,
and then return to it with the appropriate CTRL-ALT-F?
combination, the colors are all messed up.  It seems
that switching to a non-graphics console changes the
hardware colormap, and that when the X server regains
control of the display it does not perform the
internal equivalent of XInstallColormap to restore the
original colormap, or it performs the internal
equivalent of XInstallColormap with the wrong
colormap.  I am guessing; I do not know why the colors
are messed up, only that they are messed up.  When I
log out from the graphics console, and the X server
exits, and the display manager restarts it, the colors
are good again.

The operating system is FreeBSD 12.0.  Here is the
relevant section from the output of "pciconf -lv":


```
vgapci0@pci0:0:1:0:    class=0x030000 card=0x82f6103c chip=0x98511002 rev=0x40 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Mullins [Radeon R4/R5 Graphics]'
    class      = display
    subclass   = VGA
```

and here are the first few lines from the output of
"xdpyinfo":


```
name of display:    :0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11804000
X.Org version: 1.18.4
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    7
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 15, bits_per_pixel 16, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0x1400022, revert to Parent
number of extensions:    28
    BIG-REQUESTS
    Composite
    DAMAGE
    DOUBLE-BUFFER
    DPMS
    DRI2
    GLX
    Generic Event Extension
    MIT-SCREEN-SAVER
    MIT-SHM
    Present
    RANDR
    RECORD
    RENDER
    SECURITY
    SGI-GLX
    SHAPE
    SYNC
    X-Resource
    XC-MISC
    XFIXES
    XFree86-DGA
    XFree86-VidModeExtension
    XINERAMA
    XInputExtension
    XKEYBOARD
    XTEST
    XVideo
default screen number:    0
number of screens:    1

screen #0:
  dimensions:    1368x768 pixels (341x191 millimeters)
  resolution:    102x102 dots per inch
  depths (7):    24, 1, 4, 8, 15, 16, 32
  root window id:    0x34d
  depth of root window:    24 planes
  number of colormaps:    minimum 1, maximum 1
  default colormap:    0x20
  default number of colormap cells:    256
  preallocated pixels:    black 0, white 16777215
  options:    backing-store WHEN MAPPED, save-unders NO
```

I do not think the output of kldstat is relevant but
here it is if you want it:


```
Id Refs Address                Size Name
 1   51 0xffffffff80200000  2136000 kernel
 2    1 0xffffffff82821000     1a20 fdescfs.ko
 3    1 0xffffffff82823000     490c linprocfs.ko
 4    3 0xffffffff82828000     2e28 linux_common.ko
 5    1 0xffffffff8282b000     3d44 geom_linux_lvm.ko
 6    1 0xffffffff8282f000     6708 if_rtwn_pci.ko
 7    1 0xffffffff82836000    162a0 rtwn.ko
 8    1 0xffffffff8284d000    39970 linux.ko
 9    1 0xffffffff82887000    33c60 linux64.ko
10    1 0xffffffff828bb000     2678 intpm.ko
11    1 0xffffffff828be000      b10 smbus.ko
12    1 0xffffffff828bf000     1800 uhid.ko
13    1 0xffffffff828c1000     23a8 ums.ko
14    1 0xffffffff828c4000   247e20 zfs.ko
15    1 0xffffffff82b0c000     7628 opensolaris.ko
16    1 0xffffffff82b14000    16a78 ext2fs.ko
```

This problem does not occur on the Linux and Solaris
systems that share the same hardware, only when I boot
into FreeBSD (there is also a Haiku system that shares
the hardware but I cannot test the problem there
because Haiku does not have virtual screens).  How do
I fix this misbehavior?  Thank you in advance for any
and all replies -- jay at m5 dot chicago dot il dot us


----------



## tingo (Nov 1, 2019)

Try this from within an xterm after returning to graphics: `xset dpms force off ; sleep 0.1; xset dpms force on`.
Does that restore proper colors?


----------



## Jay F. Shachter (Nov 5, 2019)

Alas, it does not.  It made no difference, except that
the screen went black, and then came back, just as
messed up as before.


----------

