s3928.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "pci.h"
  5. #include "vga.h"
  6. /*
  7. * S3 86C928 GUI Accelerator.
  8. */
  9. static void
  10. snarf(Vga* vga, Ctlr* ctlr)
  11. {
  12. s3generic.snarf(vga, ctlr);
  13. }
  14. static void
  15. options(Vga*, Ctlr* ctlr)
  16. {
  17. ctlr->flag |= Hlinear|Henhanced|Foptions;
  18. }
  19. static void
  20. init(Vga* vga, Ctlr* ctlr)
  21. {
  22. Mode *mode;
  23. ulong x;
  24. /*
  25. * s3generic.init() will perform the same test.
  26. * We need to do it here too so that the Crt registers
  27. * will be correct when s3generic.init() calculates
  28. * the overflow bits.
  29. */
  30. if(vga->mode->z > 8)
  31. error("depth %d not supported\n", vga->mode->z);
  32. mode = vga->mode;
  33. if((ctlr->flag & Henhanced) && mode->x >= 1024 && mode->z == 8){
  34. resyncinit(vga, ctlr, Uenhanced, 0);
  35. vga->crt[0x00] = ((mode->ht/4)>>3)-5;
  36. vga->crt[0x01] = ((mode->x/4)>>3)-1;
  37. vga->crt[0x02] = ((mode->shb/4)>>3)-1;
  38. x = (mode->ehb/4)>>3;
  39. vga->crt[0x03] = 0x80|(x & 0x1F);
  40. vga->crt[0x04] = (mode->shs/4)>>3;
  41. vga->crt[0x05] = ((mode->ehs/4)>>3) & 0x1F;
  42. if(x & 0x20)
  43. vga->crt[0x05] |= 0x80;
  44. vga->crt[0x13] = mode->x/8;
  45. if(mode->z == 1)
  46. vga->crt[0x13] /= 8;
  47. }
  48. s3generic.init(vga, ctlr);
  49. vga->crt[0x3B] = (vga->crt[0]+vga->crt[4]+1)/2;
  50. /*
  51. * Set up write-posting and read-ahead-cache.
  52. */
  53. vga->crt[0x54] = 0xA7;
  54. if(ctlr->flag & Uenhanced){
  55. vga->crt[0x58] |= 0x04;
  56. vga->crt[0x40] |= 0x08;
  57. }
  58. else{
  59. vga->crt[0x58] &= ~0x04;
  60. vga->crt[0x40] &= ~0x08;
  61. }
  62. /*
  63. * Set up parallel VRAM and the external
  64. * SID enable on the 86C928
  65. */
  66. vga->crt[0x53] &= ~0x20; /* parallel VRAM */
  67. vga->crt[0x55] &= ~0x48; /* external SID */
  68. vga->crt[0x65] &= ~0x60; /* 2 86C928 E-step chip bugs */
  69. if(ctlr->flag & Uenhanced){
  70. if(vga->ramdac->flag & Hpvram)
  71. vga->crt[0x53] |= 0x20;
  72. if(vga->ramdac->flag & Hextsid)
  73. vga->crt[0x55] |= 0x48;
  74. vga->crt[0x65] |= 0x60;
  75. }
  76. }
  77. static void
  78. load(Vga* vga, Ctlr* ctlr)
  79. {
  80. ushort advfunc;
  81. (*s3generic.load)(vga, ctlr);
  82. vgaxo(Crtx, 0x65, vga->crt[0x65]);
  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 s3928 = {
  98. "s3928", /* name */
  99. snarf, /* snarf */
  100. options, /* options */
  101. init, /* init */
  102. load, /* load */
  103. dump, /* dump */
  104. };