home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / SVGALIB1.TAR / svgalib / utils / setmclk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-25  |  2.7 KB  |  85 lines

  1. /*
  2.   Note: Previously this program did not unlock the extended registers,
  3.         so it only worked if the registers happened to be unlocked.
  4.  
  5.   This program sets the 'memory clock' of Cirrus 5424/26/28 cards.
  6.   The first three values could be set by utility programs that
  7.   came with my card (AVGA3), but somewhat higher values seem to work (on my
  8.   card at least). It may be that better and more recent Cirrus cards use a
  9.   higher value as boot-up default. It should depend on DRAM speed, but it
  10.   seems to be more dependant on the card logic.
  11.   
  12.   I have the impression that many Cirrus 542x cards suffer from horrible
  13.   BIOS version/DRAM timing misconfigurations. Perhaps even some versions of
  14.   MS-Windows drivers change the MCLK register. In any case, the boot-up BIOS
  15.   default (0x1c) may be inappropriately low for the type of DRAM timing most
  16.   cards use.
  17.  
  18.   Using a higher memory clock gives a very significant performance improvement;
  19.   with high dot clock modes (like 640x480x16M or 1150x900x256) performance can
  20.   be more than twice that of the standard 50 MHz clock. This goes for both
  21.   (VLB) framebuffer access and accelerated features (bitblt). This also helps
  22.   XFree86 server performance, but only if the XFree86 Cirrus driver doesn't
  23.   set the memory clock register (it should work for XFree86 1.3 and 2.0).
  24.   Use at your own risk!
  25.  
  26.   Note that the 'dot clock' is something entirely different. There does not
  27.   seem to be much correlation between the two (i.e. if a high dot clock gives
  28.   screen problems, using a high memory clock is not likely to fix it, other
  29.   than improving speed).
  30.  
  31. */
  32.  
  33.  
  34. #define NEW_MCLK 0x1C        /* Default value */
  35. /* #define NEW_MCLK 0x26 */    /* High value to test XFree86 */
  36.  
  37.  
  38. #include <stdlib.h>
  39. #include <unistd.h>
  40. #include <vga.h>
  41. #include "../src/libvga.h"    /* For port I/O macros. */
  42.  
  43. void main() {
  44.     vga_init();
  45.     if (vga_getcurrentchipset() != CIRRUS) {
  46.         printf("Not a Cirrus.\n");
  47.         printf("Continue anyway (y/n)?\n");
  48.         if (getchar() != 'y')
  49.             exit(-1);
  50.     }
  51.  
  52.     /* Unlock extended registers. */
  53.            outb(0x3c4, 0x06);
  54.            outb(0x3c5, 0x12);
  55.  
  56.  
  57.     /*
  58.         Tested on VLB AVGA3 CL-GD5426 on 40MHz VLB
  59.         0x1c        50 MHz (boot-up default)
  60.         0x21        59
  61.         0x22        62
  62.         0x23 OK
  63.         0x24 OK
  64.         0x25 OK
  65.         0x26 OK        [This corresponds to the highest value
  66.                 mentioned in the databook (which does
  67.                 not mean that it is supposed to work
  68.                 on all cards); the book also says the
  69.                 parts are not specified for more than
  70.                 50 MHz].
  71.         0x27 occasional loose pixels
  72.         0x28 occasional problems
  73.         0x29 some problems
  74.         0x2A 16M/textmode problems
  75.         0x2c 256/32k color problems
  76.     */
  77.     outb(0x3c4, 0x1f);
  78.     printf("Old MCLK value: %02x\n", inb(0x3c5));
  79.     outb(0x3c4, 0x1f);
  80.     outb(0x3c5, NEW_MCLK);
  81.     printf("New MCLK value: %02x\n", NEW_MCLK);
  82.  
  83.     exit(0);
  84. }
  85.