Subversion Repositories shark

Rev

Rev 54 | Details | Compare with Previous | Last modification | View Log | RSS feed

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