summaryrefslogtreecommitdiff
path: root/src/apm.h
blob: ceefffff3dbd473ea2ec98eeb4acf23c034c922d (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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h,v 1.19tsi Exp $ */


/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"

/* All drivers need this */
#include "xf86_ansic.h"

/* Everything using inb/outb, etc needs "compiler.h" */
#include "compiler.h"

/* This is used for module versioning */
#include "xf86Version.h"

/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"

/* Drivers that need to access the PCI config space directly need this */
#include "xf86Pci.h"

/* All drivers using the vgahw module need this */
#include "vgaHW.h"

/* Drivers using the mi banking wrapper need this */
#include "mibank.h"

/* All drivers using the mi colormap manipulation need this */
#include "micmap.h"

/* Needed for the 1 and 4 bpp framebuffers */
#include "xf1bpp.h"
#include "xf4bpp.h"

#include "fb.h"

/* Drivers using the XAA interface ... */
#include "xaa.h"
#include "xaalocal.h"
#include "xf86Cursor.h"
#include "xf86fbman.h"

/* All drivers initialising the SW cursor need this */
#include "mipointer.h"

/* All drivers implementing backing store need this */
#include "mibstore.h"

/* I2C support */
#include "xf86i2c.h"

/* DDC support */
#include "xf86DDC.h"

#include "xf86xv.h"
#include "Xv.h"

#ifdef TRUE
#undef TRUE
#endif
#define TRUE	(1)

#define rdinx(port, ind)	(outb((port), (ind)), inb((port) + 1))
#define wrinx(port, ind, val)	outb((port), (ind)),  outb((port) + 1, (val))
#define modinx(port, ind, mask, bits)					\
    do {								\
	unsigned char tmp;						\
	tmp = (rdinx((port), (ind)) & ~(mask)) | ((bits) & (mask));	\
	wrinx((port), (ind), tmp);					\
    } while(0)

typedef unsigned char	u8;
typedef unsigned short	u16;
typedef unsigned long	u32;

#define NoSEQRegs	0x20
#define NoCRTRegs	0x1F
#define NoGRCRegs	0x09
#define	NoATCRegs	0x15

enum {
    XR80, XRC0, XRD0, XRE0, XRE8, XREC, XR140, XR144, XR148, XR14C, NoEXRegs
};

typedef struct {
	unsigned char	SEQ[NoSEQRegs];
	unsigned char	CRT[NoCRTRegs];
	unsigned char	GRC[NoGRCRegs];
	unsigned char	ATC[NoATCRegs];
	unsigned int	EX[NoEXRegs];
} ApmRegStr, *ApmRegPtr;

typedef struct {
    int			displayWidth, displayHeight;
    int			bitsPerPixel, bytesPerScanline;
    int			depth, Scanlines;
    CARD32		mask32;		/* Mask to have 32bit aligned data */
    unsigned int	Setup_DEC;
    DisplayModePtr	pMode;
} ApmFBLayout;

#define APM_CACHE_NUMBER	32

typedef struct {
    pciVideoPtr		PciInfo;
    PCITAG		PciTag;
    int			scrnIndex;
    int			Chipset;
    int			ChipRev;
    CARD32		LinAddress;
    unsigned long	LinMapSize;
    CARD32		FbMapSize;
    pointer		LinMap;
    pointer		FbBase;
    char		*VGAMap;
    char		*MemMap;
    pointer		BltMap;
    Bool		UnlockCalled;
    IOADDRESS		iobase, xport, xbase;
    unsigned char	savedSR10;
    CARD8		MiscOut;
    CARD8		c9, d9, db, Rush;
    unsigned long	saveCmd;
    pointer		FontInfo;
    Bool		hwCursor;
    Bool		noLinear;
    ApmRegStr		ModeReg, SavedReg;
    CloseScreenProcPtr	CloseScreen;
    Bool		UsePCIRetry;  /* Do we use PCI-retry or busy-waiting */
    Bool		NoAccel;  /* Do we use XAA acceleration architecture */
    int			MinClock;                        /* Min ramdac clock */
    int			MaxClock;                        /* Max ramdac clock */
    ApmFBLayout		CurrentLayout, SavedLayout;
    EntityInfoPtr	pEnt;
    XAAInfoRecPtr	AccelInfoRec, DGAXAAInfo;
    xf86CursorInfoPtr	CursorInfoRec;
    int			DGAactive, numDGAModes;
    DGAModePtr		DGAModes;
    int			BaseCursorAddress,CursorAddress,DisplayedCursorAddress;
    int			OffscreenReserved;
    int			blitxdir, blitydir;
    Bool		apmTransparency, apmClip, ShadowFB, I2C;
    int			rop, Bg8x8, Fg8x8;
    I2CBusPtr		I2CPtr;
    struct ApmStippleCacheRec {
	XAACacheInfoRec		apmStippleCache;
	FBAreaPtr		area;
	unsigned int		apmStippleCached:1;
    }			apmCache[APM_CACHE_NUMBER];
    int			apmCachePtr;
    unsigned char	regcurr[0x54];
    ScreenPtr		pScreen;
    int			Generation;
    int			apmLock, pixelStride, RushY[7], CopyMode;
    int			PutImageStride;
    Bool		(*DestroyPixmap)(PixmapPtr);
    PixmapPtr		(*CreatePixmap)(ScreenPtr, int, int, int);
    void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, int rop,
					unsigned int planemask);
    void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn, int x, int y,
				       int w, int h);
    void (*SetupForSolidFill24)(ScrnInfoPtr pScrn, int color, int rop,
					unsigned int planemask);
    void (*SubsequentSolidFillRect24)(ScrnInfoPtr pScrn, int x, int y,
				       int w, int h);
    void (*SetupForScreenToScreenCopy)(ScrnInfoPtr pScrn, int xdir, int ydir,
					  int rop, unsigned int planemask,
                                          int transparency_color);
    void (*SubsequentScreenToScreenCopy)(ScrnInfoPtr pScrn, int x1, int y1,
					    int x2, int y2, int w, int h);
    void (*SetupForScreenToScreenCopy24)(ScrnInfoPtr pScrn, int xdir, int ydir,
					  int rop, unsigned int planemask,
                                          int transparency_color);
    void (*SubsequentScreenToScreenCopy24)(ScrnInfoPtr pScrn, int x1, int y1,
					    int x2, int y2, int w, int h);
    int			MemClk;
    unsigned char	*ShadowPtr;
    int			ShadowPitch;
    memType		ScratchMem, ScratchMemSize, ScratchMemOffset;
    memType		ScratchMemPtr, ScratchMemEnd;
    int			ScratchMemWidth;
    CARD32		color;
    XF86VideoAdaptorPtr	adaptor;
    int			timerIsOn;
    Time		offTime;
    OptionInfoPtr	Options;
    char		DPMSMask[4];
} ApmRec, *ApmPtr;

#define curr		((unsigned char *)pApm->regcurr)

typedef struct {
    u16		ca;
    u8		font;
    u8		pad;
} ApmFontBuf;

typedef struct {
    u16		ca;
    u8		font;
    u8		pad;
    u16		ca2;
    u8		font2;
    u8		pad2;
} ApmTextBuf;

enum ApmChipId {
    AP6422	= 0x6422,
    AT24	= 0x6424,
    AT3D	= 0x643D
};

typedef struct {
    BoxRec			box;
    int				num;
    MoveAreaCallbackProcPtr	MoveAreaCallback;
    RemoveAreaCallbackProcPtr	RemoveAreaCallback;
    void			*devPriv;
} ApmPixmapRec, *ApmPixmapPtr;

#define APMDECL(p)	ApmPtr pApm = ((ApmPtr)(((ScrnInfoPtr)(p))->driverPrivate))
#define APMPTR(p)	((ApmPtr)(((ScrnInfoPtr)(p))->driverPrivate))

extern int	ApmHWCursorInit(ScreenPtr pScreen);
extern int	ApmDGAInit(ScreenPtr pScreen);
extern int	ApmAccelInit(ScreenPtr pScreen);
extern Bool	ApmI2CInit(ScrnInfoPtr pScrn);
extern void	XFree86RushExtensionInit(ScreenPtr pScreen);
extern void	ApmInitVideo(ScreenPtr pScreen);
extern void	ApmInitVideo_IOP(ScreenPtr pScreen);
extern void	ApmSetupXAAInfo(ApmPtr pApm, XAAInfoRecPtr pXAAinfo);
extern Bool     ApmSwitchMode(int scrnIndex, DisplayModePtr mode,
                                  int flags);
extern void     ApmAdjustFrame(int scrnIndex, int x, int y, int flags);
extern void	ApmHWCursorReserveSpace(ApmPtr pApm);
extern void	ApmAccelReserveSpace(ApmPtr pApm);

extern int	ApmPixmapIndex;
#define APM_GET_PIXMAP_PRIVATE(pix)\
	((ApmPixmapPtr)(((PixmapPtr)(pix))->devPrivates[ApmPixmapIndex].ptr))

#include "apm_regs.h"