xf86RamDacCmap.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 1998 by Alan Hourihane, Wigan, England.
  3. *
  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.
  13. *
  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.
  21. *
  22. * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
  23. *
  24. * Generic RAMDAC access to colormaps.
  25. */
  26. #ifdef HAVE_XORG_CONFIG_H
  27. #include <xorg-config.h>
  28. #endif
  29. #include <X11/X.h>
  30. #include <X11/Xproto.h>
  31. #include "windowstr.h"
  32. #include "mipointer.h"
  33. #include "micmap.h"
  34. #include "xf86.h"
  35. #include "compiler.h"
  36. #include "colormapst.h"
  37. #include "xf86RamDacPriv.h"
  38. void
  39. RamDacLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO * colors,
  40. VisualPtr pVisual)
  41. {
  42. RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
  43. int i, index;
  44. for (i = 0; i < numColors; i++) {
  45. index = indices[i];
  46. (*hwp->WriteAddress) (pScrn, index);
  47. (*hwp->WriteData) (pScrn, colors[index].red);
  48. (*hwp->WriteData) (pScrn, colors[index].green);
  49. (*hwp->WriteData) (pScrn, colors[index].blue);
  50. }
  51. }
  52. Bool
  53. RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
  54. unsigned int flags)
  55. {
  56. ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
  57. RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
  58. if (hwp->LoadPalette == NULL)
  59. return xf86HandleColormaps(pScreen, maxColors, sigRGBbits,
  60. RamDacLoadPalette, NULL, flags);
  61. else
  62. return xf86HandleColormaps(pScreen, maxColors, sigRGBbits,
  63. hwp->LoadPalette, NULL, flags);
  64. }