att20c49x.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "pci.h"
  5. #include "vga.h"
  6. /*
  7. * ATT20C490 and ATT20C49[12] True-Color CMOS RAMDACs.
  8. */
  9. enum {
  10. Cr0 = 0x00, /* Control register 0 */
  11. };
  12. static void
  13. init(Vga* vga, Ctlr* ctlr)
  14. {
  15. ulong pclk;
  16. char *p;
  17. /*
  18. * Part comes in -100, -80, -65 and -55MHz speed-grades.
  19. * Work out the part speed-grade from name. Name can have,
  20. * e.g. '-100' on the end for 100MHz part.
  21. */
  22. pclk = 55000000;
  23. if(p = strrchr(ctlr->name, '-'))
  24. pclk = strtoul(p+1, 0, 0) * 1000000;
  25. /*
  26. * If we don't already have a desired pclk,
  27. * take it from the mode.
  28. * Check it's within range.
  29. */
  30. if(vga->f == 0)
  31. vga->f[0] = vga->mode->frequency;
  32. if(vga->f[0] > pclk)
  33. error("%s: invalid pclk - %ld\n", ctlr->name, vga->f[0]);
  34. }
  35. static void
  36. load(Vga* vga, Ctlr* ctlr)
  37. {
  38. uchar mode, x;
  39. /*
  40. * Put the chip to sleep if possible.
  41. */
  42. if(ctlr->name[8] == '1'){
  43. x = attdaci(Cr0);
  44. attdaco(Cr0, x|0x04);
  45. }
  46. /*
  47. * Set the mode in the RAMDAC, setting 6/8-bit colour
  48. * as appropriate and waking the chip back up.
  49. */
  50. mode = 0x00;
  51. if(vga->mode->z == 8 && ctlr->name[8] == '1' && 0)
  52. mode |= 0x02;
  53. attdaco(Cr0, mode);
  54. }
  55. static void
  56. dump(Vga*, Ctlr* ctlr)
  57. {
  58. printitem(ctlr->name, "Cr0");
  59. printreg(attdaci(Cr0));
  60. }
  61. Ctlr att20c490 = {
  62. "att20c490", /* name */
  63. 0, /* snarf */
  64. 0, /* options */
  65. init, /* init */
  66. load, /* load */
  67. dump, /* dump */
  68. };
  69. Ctlr att20c491 = {
  70. "att20c491", /* name */
  71. 0, /* snarf */
  72. 0, /* options */
  73. init, /* init */
  74. load, /* load */
  75. dump, /* dump */
  76. };
  77. Ctlr att20c492 = {
  78. "att20c492", /* name */
  79. 0, /* snarf */
  80. 0, /* options */
  81. init, /* init */
  82. load, /* load */
  83. dump, /* dump */
  84. };