home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / SVGALIB1.TAR / svgalib / src / vgahico.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-23  |  2.5 KB  |  122 lines

  1. /* vgahico.c - used by ET4000 driver. */
  2. /* Set Hicolor RAMDAC mode.
  3.  *
  4.  * HH: Added support for 24-bit Sierra RAMDAC (15025/6) (untested).
  5.  */
  6.  
  7.  
  8. #include "vga.h"
  9. #include "libvga.h"
  10. #include "driver.h"
  11.  
  12. int __vga_hicolor(int dac_type, int mode)
  13. /* Enters hicolor mode - 0 for no hi, 1 for 15 bit, 2 for 16, 3 for 24 */
  14. /* For any modes it doesn't know about, etc, it attempts to turn hicolor off. */
  15. {
  16.     int x;
  17.  
  18.     port_in(0x3C8);        /* Clears register funny mode */
  19.     port_in(0x3C6);
  20.     port_in(0x3C6);
  21.     port_in(0x3C6);
  22.     port_in(0x3C6);
  23.     x = port_in(0x3c6);
  24.     port_in(0x3C8);        /* Clears register funny mode */
  25.     port_in(0x3C6);
  26.     port_in(0x3C6);
  27.     port_in(0x3C6);
  28.     port_in(0x3C6);
  29.     switch (dac_type & ~1)
  30.     {
  31.         case 0:    /* Sierra SC11486 */
  32.         if (mode == HI15_DAC)
  33.             port_out( x | 0x80, 0x3c6);
  34.         else
  35.             port_out( x & ~0x80, 0x3c6);
  36.         break;
  37.         case 2:    /* Sierra Mark2/Mark3 */
  38.         switch (mode)
  39.         {
  40.         case HI15_DAC:
  41.             /* port_out( (x | 0x80) & ~0x40, 0x3c6); */
  42.             port_out( (x & 0x1f) | 0xa0, 0x3c6);
  43.             break;
  44.         case HI16_DAC:
  45.             /* port_out( x | 0xC0, 0x3c6); */
  46.             port_out( (x & 0x1f) | 0xe0, 0x3c6);
  47.             break;
  48.         default:
  49.             port_out( x & ~0xC0, 0x3c6);
  50.             break;
  51.         }
  52.         break;
  53.         case 4:    /* Diamond SS2410 */
  54.         if (mode == HI15_DAC)
  55.             port_out( x | 0x80, 0x3c6);
  56.         else
  57.             port_out( x & ~0x80, 0x3c6);
  58.         break;
  59.         case 8:    /* AT&T 20c491/2 */
  60.         switch (mode)
  61.         {
  62.         case HI15_DAC:
  63.             port_out((x & 0x1f) | 0xA0, 0x3C6);
  64.             break;
  65.         case HI16_DAC:
  66.             port_out((x & 0x1f) | 0xC0, 0x3C6);
  67.             break;
  68.         case TC24_DAC:
  69.             port_out((x & 0x1f) | 0xE0, 0x3C6);
  70.             break;
  71.         default:
  72.             port_out(x & 0x1F, 0x3C6);
  73.             break;
  74.         }
  75.         break;
  76.         case 16:    /* AcuMos ADAC1 */
  77.         switch (mode)
  78.         {
  79.         case HI15_DAC:
  80.             port_out(0xF0, 0x3C6);
  81.             break;
  82.         case HI16_DAC:
  83.             port_out(0xE1, 0x3C6);
  84.             break;
  85.         case TC24_DAC:
  86.             port_out(0xE5, 0x3C6);
  87.             break;
  88.         default:
  89.             port_out(0, 0x3C6);
  90.             break;
  91.         }
  92.         break;
  93.         case 32:    /* Sierra 15025/6 24-bit DAC */
  94.         switch (mode)
  95.         {
  96.         case HI15_DAC:
  97.             port_out((x & 0x1f) | 0xa0 , 0x3C6);
  98.             /* 0xa0 is also a 15-bit mode. */
  99.             break;
  100.         case HI16_DAC:
  101.             port_out((x & 0x1f) | 0xe0, 0x3C6);
  102.             /* 0xc0 is also a 16-bit mode. */
  103.             /* 0xc0 doesn't seem to work, so use 0xe0. */
  104.             break;
  105.         case TC24_DAC:
  106.             port_out((x & 0x1f) | 0x60, 0x3C6);
  107.             break;
  108.         default:
  109.             port_out(x & 0x1f, 0x3C6);
  110.             break;
  111.         }
  112.         break;
  113.     default:
  114.         /* Normal VGA mode. */
  115.         port_out(x & 0x1F, 0x3c6);
  116.         break;
  117.     }
  118.     port_in(0x3C8);
  119.  
  120.     return 0;
  121. }
  122.