Subject: port-i386/35030: vesafb ioctl WSDISPLAIO_GETCMAP returns wrong values
To: None <port-i386-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <tho@jtpn.net>
List: netbsd-bugs
Date: 11/10/2006 16:10:00
>Number:         35030
>Category:       port-i386
>Synopsis:       vesafb ioctl WSDISPLAIO_GETCMAP returns wrong values
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 10 16:10:00 +0000 2006
>Originator:     Jan Thorsson
>Release:        netbsd-current
>Organization:
>Environment:
NetBSD labpc 4.99.3 NetBSD 4.99.3 (VESAFB) #3: Thu Nov  9 22:21:35 CET 2006  tho
@labpc:/sys/arch/i386/compile/VESAFB i386
>Description:
The color values returned from vesafb ioctl WSDIPLAYIO_GETCMAP are wrong, if you want to retreive them before changing tho color map. They do not reflect the colors on the sceen. After changing the colormap once the ioctl works OK. vesafb_init initialize the colors on the screen but stores wrong values in the softc struct:

                       /* Fill in the softc colourmap arrays */
                        sc->sc_cmap_red[i / 3] = rasops_cmap[i + 0];
                        sc->sc_cmap_green[i / 3] = rasops_cmap[i + 1];
                        sc->sc_cmap_blue[i / 3] = rasops_cmap[i + 2];

I think this should be:

                       /* Fill in the softc colourmap arrays */
                        sc->sc_cmap_red[i] = rasops_cmap[i*3 + 0];
                        sc->sc_cmap_green[i] = rasops_cmap[i*3 + 1];
                        sc->sc_cmap_blue[i] = rasops_cmap[i*3 + 2];

The source file is /usr/src/sys/arch/i386/bios/vesafb.c

- Janne

>How-To-Repeat:
Retreive the colormap after boot.
>Fix:
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/bios/vesafb.c,v
retrieving revision 1.18
diff -c -r1.18 vesafb.c
*** sys/arch/i386/bios/vesafb.c 12 Oct 2006 01:30:42 -0000      1.18
--- sys/arch/i386/bios/vesafb.c 10 Nov 2006 16:02:19 -0000
***************
*** 540,548 ****
  #endif

                        /* Fill in the softc colourmap arrays */
!                       sc->sc_cmap_red[i / 3] = rasops_cmap[i + 0];
!                       sc->sc_cmap_green[i / 3] = rasops_cmap[i + 1];
!                       sc->sc_cmap_blue[i / 3] = rasops_cmap[i + 2];
                }
        }

--- 540,548 ----
  #endif

                        /* Fill in the softc colourmap arrays */
!                       sc->sc_cmap_red[i] = rasops_cmap[i*3 + 0];
!                       sc->sc_cmap_green[i] = rasops_cmap[i*3 + 1];
!                       sc->sc_cmap_blue[i] = rasops_cmap[i*3 + 2];
                }
        }