summaryrefslogtreecommitdiff
path: root/src/tga.h
blob: 7903b80b7b806648b44b79d6a490a8f281fdc18b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
 * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk>
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Alan Hourihane not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Alan Hourihane makes no representations
 * about the suitability of this software for any purpose.  It is provided
 * "as is" without express or implied warranty.
 *
 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
 */

#ifndef _TGA_H_
#define _TGA_H_

#include "tga_pcirename.h"
#ifdef HAVE_XAA_H
#include "xaa.h"
#endif
#include "xf86RamDac.h"

#include "compat-api.h"

typedef struct {
	unsigned long tgaRegs[0x100];
} TGARegRec, *TGARegPtr;

#define TGA_OLDPRIV (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 4)

#define TGAPTR(p)	((TGAPtr)((p)->driverPrivate))

typedef struct {
    pciVideoPtr		PciInfo;
#ifndef XSERVER_LIBPCIACCESS
    PCITAG		PciTag;
#endif
    int			Chipset;
    RamDacHelperRecPtr	RamDac;
    int                 ChipRev;
    int			HwBpp;
    int			BppShift;
    int			pprod;
    CARD32		CardAddress;
    CARD32		IOAddress;
    CARD32		FbAddress;
    unsigned char *     FbBase;
    unsigned char *     IOBase;
    unsigned char *     ClkBase; /* TGA2 */
    unsigned char *     DACBase; /* TGA2 */
    unsigned char *     HACKBase; /* TGA2 */
    long		FbMapSize;
    unsigned long	regOffset;
    Bool		NoAccel;
    Bool		NoXaaPolySegment;
    Bool		Dac6Bit;
    Bool		SyncOnGreen;
    Bool		HWCursor;
    Bool		UsePCIRetry;
    int			MinClock;
    int			MaxClock;
    TGARegRec		SavedReg;
    TGARegRec		ModeReg;
    CARD32		AccelFlags;
    RamDacRecPtr	RamDacRec;
#ifdef HAVE_XAA_H
    XAAInfoRecPtr	AccelInfoRec;
#endif
    xf86CursorInfoPtr   CursorInfoRec;
    CloseScreenProcPtr	CloseScreen;
    int                 CardType;
    unsigned char       Bt463modeReg[59];
    unsigned char       Bt463saveReg[59];
    unsigned char       Ibm561modeReg[59];
    unsigned char       Ibm561saveReg[59];
    EntityInfoPtr       pEnt;
    CARD32     *buffers[1];
    unsigned int        current_rop;
    unsigned int        current_planemask;
    int                 transparent_pattern_p;
    int                 blitdir;
    int                 block_or_opaque_p;
    int                 ce_height;
    int                 ce_width;
    int                 ce_x;
    int                 ce_y;
    int                 ce_skipleft;
    int                 line_pattern_length;
    CARD16              line_pattern; /* for dashed lines */
    int                 Bpp; /* bytes per pixel */
    int                 depthflag; /* either BPP8PACKED or BPP24 */
    OptionInfoPtr	Options;
} TGARec, *TGAPtr;

/* ?? this is a hack for initial TGA2 support */
struct monitor_data {
  unsigned int max_rows;   /* Monitor setup */
  unsigned int max_cols;
  unsigned int pixel_freq;
  unsigned int refresh_rate;
  unsigned int vert_slines;
  unsigned int vert_fp;
  unsigned int vert_sync;
  unsigned int vert_bp;
  unsigned int horz_pix;
  unsigned int horz_fp;
  unsigned int horz_sync;
  unsigned int horz_bp;
  unsigned int vco_div;      /* ICS setup */
  unsigned int ref_div;
  unsigned int vco_pre;
  unsigned int clk_div;
  unsigned int vco_out_div;
  unsigned int clk_out_en;
  unsigned int clk_out_enX;
  unsigned int res0;
  unsigned int clk_sel;
  unsigned int res1;
  unsigned int ibm561_vco_div; /* IBM561 PLL setup */
  unsigned int ibm561_ref;
};

extern struct monitor_data tga_crystal_table[];
extern int tga_crystal_table_entries;
extern struct monitor_data *tga_c_table;

/* Prototypes */

/* tga_dac.c */
void DEC21030Restore(ScrnInfoPtr pScrn,/* vgaRegPtr vgaReg,*/
		      TGARegPtr tgaReg/*, Bool restoreFonts*/);
void DEC21030Save(ScrnInfoPtr pScrn, /*vgaRegPtr vgaReg,*/ TGARegPtr tgaReg/*,
		   Bool saveFonts*/);
Bool DEC21030Init(ScrnInfoPtr pScrn, DisplayModePtr mode);
void write_av9110(ScrnInfoPtr pScrn, unsigned int *);
void TGA2SetupMode(ScrnInfoPtr pScrn);
void Ibm561Init(TGAPtr pTga);
void Bt463Init(TGAPtr pTga);

/* tga_accel.c */
Bool DEC21030AccelInit(ScreenPtr pScreen);

/* BTramdac.c */
void tgaBTOutIndReg(ScrnInfoPtr pScrn,
		     CARD32 reg, unsigned char mask, unsigned char data);
unsigned char tgaBTInIndReg(ScrnInfoPtr pScrn, CARD32 reg);
void tgaBTWriteAddress(ScrnInfoPtr pScrn, CARD32 index);
void tgaBTReadAddress(ScrnInfoPtr pScrn, CARD32 index);
void tgaBTWriteData(ScrnInfoPtr pScrn, unsigned char data);
unsigned char tgaBTReadData(ScrnInfoPtr pScrn);

void tga2BTOutIndReg(ScrnInfoPtr pScrn,
		     CARD32 reg, unsigned char mask, unsigned char data);
unsigned char tga2BTInIndReg(ScrnInfoPtr pScrn, CARD32 reg);
void tga2BTWriteAddress(ScrnInfoPtr pScrn, CARD32 index);
void tga2BTReadAddress(ScrnInfoPtr pScrn, CARD32 index);
void tga2BTWriteData(ScrnInfoPtr pScrn, unsigned char data);
unsigned char tga2BTReadData(ScrnInfoPtr pScrn);

/* BT463ramdac.c */
void BT463ramdacSave(ScrnInfoPtr pScrn, unsigned char *data);
void BT463ramdacRestore(ScrnInfoPtr pScrn, unsigned char *data);

/* IBM561ramdac.c */
void IBM561ramdacSave(ScrnInfoPtr pScrn, unsigned char *data);
void IBM561ramdacHWInit(ScrnInfoPtr pScrn);
void IBM561ramdacRestore(ScrnInfoPtr pScrn, unsigned char *data);
unsigned char IBM561ReadReg(ScrnInfoPtr pScrn, CARD32 reg);
void IBM561WriteReg(ScrnInfoPtr pScrn, CARD32 reg, unsigned char data);

/* tga_cursor.c */
Bool TGAHWCursorInit(ScreenPtr pScreen);

/* tga_line.c */

void TGAPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
		    xSegment *pSeg);
void TGAPolyLines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
		  DDXPointPtr pptInit);
void TGAPolySegmentDashed(DrawablePtr pDrawable, GCPtr pGC, int	nseg,
			  xSegment *pSeg);
void TGAPolyLinesDashed(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
			DDXPointPtr pptInit);

/* line functions */
void
TGASetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
		      unsigned int planemask);
void
TGASubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len,
			      int dir);
void
TGASubsequentSolidLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2,
		       int octant, int flags);
void
TGASetupForClippedLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2,
		       int octant);
void
TGASubsequentClippedSolidLine(ScrnInfoPtr pScrn, int x1, int y1, int len,
			      int err);

void
TGASetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
		      unsigned int planemask, int length,
		      unsigned char *pattern);
void
TGASubsequentDashedLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2,
			int octant, int flags, int phase);
void
TGASubsequentClippedDashedLine(ScrnInfoPtr pScrn, int x1, int y1, int len,
			       int err, int phase);




#endif /* _TGA_H_ */