vision864.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "pci.h"
  5. #include "vga.h"
  6. /*
  7. * S3 Vision864 GUI Accelerator.
  8. * Pretty much the same as the 86C80[15].
  9. * First pass, needs tuning.
  10. */
  11. static void
  12. snarf(Vga* vga, Ctlr* ctlr)
  13. {
  14. s3generic.snarf(vga, ctlr);
  15. }
  16. static void
  17. options(Vga*, Ctlr* ctlr)
  18. {
  19. ctlr->flag |= Hlinear|Hpclk2x8|Henhanced|Foptions;
  20. }
  21. static void
  22. init(Vga* vga, Ctlr* ctlr)
  23. {
  24. ulong x;
  25. char *val;
  26. s3generic.init(vga, ctlr);
  27. vga->crt[0x3B] = vga->crt[0]-5;
  28. if(vga->mode->z > 8)
  29. error("depth %d not supported\n", vga->mode->z);
  30. /*
  31. * VL-bus crap.
  32. */
  33. if((vga->crt[0x36] & 0x03) == 0x01){
  34. vga->crt[0x40] |= 0x08;
  35. vga->crt[0x58] &= ~0x88;
  36. }
  37. /*
  38. * Display memory access control.
  39. * Calculation of the M-parameter (Crt54) is
  40. * memory-system and dot-clock dependent, the
  41. * values below are guesses from dumping
  42. * registers.
  43. */
  44. vga->crt[0x60] = 0xFF;
  45. x = vga->mode->x/8;
  46. vga->crt[0x61] = 0x80|((x>>8) & 0x07);
  47. vga->crt[0x62] = (x & 0xFF);
  48. if(vga->mode->x <= 800)
  49. vga->crt[0x54] = 0x88;
  50. else if(vga->mode->x <= 1024)
  51. vga->crt[0x54] = 0xF8;
  52. else
  53. vga->crt[0x54] = 0x40;
  54. vga->crt[0x67] &= ~0xF0;
  55. if(ctlr->flag & Upclk2x8)
  56. vga->crt[0x67] |= 0x10;
  57. vga->crt[0x69] = 0x00;
  58. vga->crt[0x6A] = 0x00;
  59. /*
  60. * Blank adjust.
  61. * This may not be correct for all monitors.
  62. */
  63. vga->crt[0x6D] = 0x00;
  64. if(val = dbattr(vga->attr, "delaybl"))
  65. vga->crt[0x6D] |= strtoul(val, 0, 0) & 0x07;
  66. else
  67. vga->crt[0x6D] |= 2;
  68. if(val = dbattr(vga->attr, "delaysc"))
  69. vga->crt[0x6D] |= (strtoul(val, 0, 0) & 0x07)<<4;
  70. }
  71. static void
  72. load(Vga* vga, Ctlr* ctlr)
  73. {
  74. ushort advfunc;
  75. s3generic.load(vga, ctlr);
  76. vgaxo(Crtx, 0x60, vga->crt[0x60]);
  77. vgaxo(Crtx, 0x61, vga->crt[0x61]);
  78. vgaxo(Crtx, 0x62, vga->crt[0x62]);
  79. vgaxo(Crtx, 0x67, vga->crt[0x67]);
  80. vgaxo(Crtx, 0x69, vga->crt[0x69]);
  81. vgaxo(Crtx, 0x6A, vga->crt[0x6A]);
  82. vgaxo(Crtx, 0x6D, vga->crt[0x6D]);
  83. advfunc = 0x0000;
  84. if(ctlr->flag & Uenhanced){
  85. if(vga->mode->x == 1024 || vga->mode->x == 800)
  86. advfunc = 0x0057;
  87. else
  88. advfunc = 0x0053;
  89. }
  90. outportw(0x4AE8, advfunc);
  91. }
  92. static void
  93. dump(Vga* vga, Ctlr* ctlr)
  94. {
  95. s3generic.dump(vga, ctlr);
  96. }
  97. Ctlr vision864 = {
  98. "vision864", /* name */
  99. snarf, /* snarf */
  100. options, /* options */
  101. init, /* init */
  102. load, /* load */
  103. dump, /* dump */
  104. };