home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / SVGALIB1.TAR / svgalib / src / timing.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-21  |  4.9 KB  |  153 lines

  1.  
  2. #ifndef TIMING_H
  3. #define TIMING_H
  4.  
  5. /*
  6.  * Generic mode timing module.
  7.  */
  8.  
  9. /* This is the type of a basic (monitor-oriented) mode timing. */
  10. typedef struct {
  11.     int pixelClock;        /* Pixel clock in kHz. */
  12.     int HDisplay;        /* Horizontal Timing. */
  13.     int HSyncStart;
  14.     int HSyncEnd;
  15.     int HTotal;
  16.     int VDisplay;        /* Vertical Timing. */
  17.     int VSyncStart;
  18.     int VSyncEnd;
  19.     int VTotal;
  20.     int flags;
  21. } MonitorModeTiming;
  22.  
  23. /* This is for the hardware (card)-adjusted mode timing. */
  24. typedef struct {
  25.     int pixelClock;        /* Pixel clock in kHz. */
  26.     int HDisplay;        /* Horizontal Timing. */
  27.     int HSyncStart;
  28.     int HSyncEnd;
  29.     int HTotal;
  30.     int VDisplay;        /* Vertical Timing. */
  31.     int VSyncStart;
  32.     int VSyncEnd;
  33.     int VTotal;
  34.     int flags; 
  35. /* The following field are optionally filled in according to card */
  36. /* specific parameters. */
  37.     int programmedClock;    /* Actual clock to be programmed. */
  38.     int selectedClockNo;    /* Index number of fixed clock used. */
  39.     int CrtcHDisplay;    /* Actual programmed horizontal CRTC timing. */
  40.     int CrtcHSyncStart;
  41.     int CrtcHSyncEnd;
  42.     int CrtcHTotal;
  43.     int CrtcVDisplay;    /* Actual programmed vertical CRTC timing. */
  44.     int CrtcVSyncStart;
  45.     int CrtcVSyncEnd;
  46.     int CrtcVTotal;
  47. } ModeTiming;
  48.  
  49. /* Flags in ModeTiming. */
  50. #define PHSYNC        0x1    /* Positive hsync polarity. */
  51. #define NHSYNC        0x2    /* Negative hsync polarity. */
  52. #define PVSYNC        0x4    /* Positive vsync polarity. */
  53. #define NVSYNC        0x8    /* Negative vsync polarity. */
  54. #define INTERLACED    0x10    /* Mode has interlaced timing. */
  55. #define DOUBLESCAN    0x20    /* Mode uses VGA doublescan (see note). */
  56. #define HADJUSTED    0x40    /* Horizontal CRTC timing adjusted. */
  57. #define VADJUSTED    0x80    /* Vertical CRTC timing adjusted. */
  58. #define USEPROGRCLOCK    0x100    /* A programmable clock is used. */
  59.  
  60. /*
  61.  * Note: Double scan implies that each scanline is displayed twice. The
  62.  * vertical CRTC timings are programmed to double the effective vertical
  63.  * resolution (the CRT still displays 400 scanlines for a 200 line
  64.  * resolution).
  65.  */
  66.  
  67. /* Cards specifications. */
  68. typedef struct {
  69.     int videoMemory;    /* Video memory in kilobytes. */
  70.     int maxPixelClock4bpp;    /* Maximum pixel clocks in kHz for each depth. */
  71.     int maxPixelClock8bpp;
  72.     int maxPixelClock16bpp;
  73.     int maxPixelClock24bpp;
  74.     int maxPixelClock32bpp;
  75.     int flags;        /* Flags (e.g. programmable clocks). */
  76.     int nClocks;        /* Number of fixed clocks. */
  77.     int *clocks;        /* Pointer to array of fixed clock values. */
  78.     int maxHorizontalCrtc;
  79.     /*
  80.      * The following function maps from a pixel clock and depth to
  81.      * the raw clock frequency required.
  82.      */
  83.     int (*mapClock)(int bpp, int pixelclock);
  84.     /*
  85.      * The following function maps from a requested clock value
  86.      * to the closest clock that the programmable clock device
  87.      * can produce.
  88.      */
  89.     int (*matchProgrammableClock)(int desiredclock);
  90.     /*
  91.      * The following function maps from a pixel clock, depth and
  92.      * horizontal CRTC timing parameter to the horizontal timing
  93.      * that has to be programmed.
  94.      */
  95.     int (*mapHorizontalCrtc)(int bpp, int pixelclock, int htiming);
  96. } CardSpecs;
  97.  
  98. /* Card flags. */
  99. /* The card has programmable clocks (matchProgrammableClock is valid). */
  100. #define CLOCK_PROGRAMMABLE        0x1
  101. /* For interlaced modes, the vertical timing must be divided by two. */
  102. #define INTERLACE_DIVIDE_VERT        0x2
  103. /* For modes with vertical timing greater or equal to 1024, vertical */
  104. /* timing must be divided by two. */
  105. #define GREATER_1024_DIVIDE_VERT    0x4
  106. /* The DAC doesn't support 64K colors (5-6-5) at 16bpp, just 5-5-5. */
  107. #define NO_RGB16_565            0x8
  108.  
  109. /* Mode info. */
  110. typedef struct {
  111. /* Basic properties. */
  112.     short width;        /* Width of the screen in pixels. */
  113.     short height;        /* Height of the screen in pixels. */
  114.     char bytesPerPixel;    /* Number of bytes per pixel. */
  115.     char bitsPerPixel;    /* Number of bits per pixel. */
  116.     char colorBits;        /* Number of significant bits in pixel. */
  117.     char __padding1;
  118. /* Truecolor pixel specification. */
  119.     char redWeight;        /* Number of significant red bits. */
  120.     char greenWeight;    /* Number of significant green bits. */
  121.     char blueWeight;    /* Number of significant blue bits. */
  122.     char __padding2;
  123.     char redOffset;        /* Offset in bits of red value into pixel. */
  124.     char blueOffset;    /* Offset of green value. */
  125.     char greenOffset;    /* Offset of blue value. */
  126.     char __padding3;
  127.     unsigned redMask;    /* Pixel mask of read value. */
  128.     unsigned blueMask;    /* Pixel mask of green value. */
  129.     unsigned greenMask;    /* Pixel mask of blue value. */
  130. /* Structural properties of the mode. */
  131.     int lineWidth;        /* Offset in bytes between scanlines. */
  132.     short realWidth;    /* Real on-screen resolution. */
  133.     short realHeight;    /* Real on-screen resolution. */
  134.     int flags;
  135. } ModeInfo;
  136.  
  137.  
  138. /* Prototypes of functions defined in timing.c. */
  139.  
  140. /*
  141.  * This function will look up mode timings for a mode matching ModeInfo
  142.  * that is within monitor spec and matches the capabilities (clocks etc.)
  143.  * of the card.
  144.  */
  145.  
  146. int getmodetiming(
  147.     ModeTiming *,    /* Resulting mode timing. */
  148.     ModeInfo *,    /* Structural mode info. */
  149.     CardSpecs *    /* Card specs (dot clocks etc.). */
  150.     );
  151.  
  152. #endif
  153.