First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / ramdac / xf86RamDacCmap.c
blob600fe3f07f49fee8b7f629f6aa61b8cd67b49e47
1 /*
2 * Copyright 1998 by Alan Hourihane, Wigan, England.
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Alan Hourihane not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Alan Hourihane makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
14 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
22 * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
24 * Generic RAMDAC access to colormaps.
27 #ifdef HAVE_XORG_CONFIG_H
28 #include <xorg-config.h>
29 #endif
31 #include <X11/X.h>
32 #include <X11/Xproto.h>
33 #include "windowstr.h"
34 #include "mipointer.h"
35 #include "micmap.h"
37 #include "xf86.h"
38 #include "compiler.h"
39 #include "colormapst.h"
40 #include "xf86RamDacPriv.h"
42 #include "xf86PciInfo.h"
43 #include "xf86Pci.h"
45 void
46 RamDacLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
47 VisualPtr pVisual)
49 RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
50 int i, index;
52 for (i = 0; i < numColors; i++) {
53 index = indices[i];
54 (*hwp->WriteAddress)(pScrn, index);
55 (*hwp->WriteData)(pScrn, colors[index].red);
56 (*hwp->WriteData)(pScrn, colors[index].green);
57 (*hwp->WriteData)(pScrn, colors[index].blue);
61 Bool
62 RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
63 unsigned int flags)
65 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
66 RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
68 if (hwp->LoadPalette == NULL)
69 return xf86HandleColormaps(pScreen, maxColors, sigRGBbits,
70 RamDacLoadPalette, NULL, flags);
71 else
72 return xf86HandleColormaps(pScreen, maxColors, sigRGBbits,
73 hwp->LoadPalette, NULL, flags);