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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
/*
* Copyright (C) 2009 RDC Semiconductor Co.,Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For technical support :
* <jason.lin@rdc.com.tw>
*/
#if XSERVER_LIBPCIACCESS
#include <pciaccess.h>
#endif
#define PCI_DEV_MAP_FLAG_WRITABLE (1U<<0)
#define PCI_DEV_MAP_FLAG_WRITE_COMBINE (1U<<1)
#define PCI_DEV_MAP_FLAG_CACHABLE (1U<<2)
#if XSERVER_LIBPCIACCESS
#define RDC_MEMBASE(p,n) (p)->regions[(n)].base_addr
#define VENDOR_ID(p) (p)->vendor_id
#define DEVICE_ID(p) (p)->device_id
#define SUBVENDOR_ID(p) (p)->subvendor_id
#define SUBSYS_ID(p) (p)->subdevice_id
#define CHIP_REVISION(p) (p)->revision
#else
#define RDC_MEMBASE(p,n) (p)->memBase[n]
#define VENDOR_ID(p) (p)->vendor
#define DEVICE_ID(p) (p)->chipType
#define SUBVENDOR_ID(p) (p)->subsysVendor
#define SUBSYS_ID(p) (p)->subsysCard
#define CHIP_REVISION(p) (p)->chipRev
#endif
/* Compiler Options */
#define Accel_2D
#define Accel_2D_DEBUG 0
/* #define MMIO_2D */
#define HWC
#define HWC_DEBUG 0
/* Vendor & Device Info */
#ifndef PCI_VENDOR_RDC
#define PCI_VENDOR_RDC 0x17F3
#endif
#ifndef PCI_VENDOR_RDC_M2010_A0
#define PCI_VENDOR_RDC_M2010_A0 0x25F0
#endif
#ifndef PCI_CHIP_M2010
#define PCI_CHIP_M2010 0x2010
#endif
#ifndef PCI_CHIP_M2010_A0
#define PCI_CHIP_M2010_A0 0x17F3
#endif
#ifndef PCI_CHIP_M2011
#define PCI_CHIP_M2011 0x2011
#endif
typedef enum _CHIP_ID {
VGALegacy,
M2010,
M2011
} CHIP_ID;
/* RDC REC Info */
#define RDC_NAME "RDC"
#define RDC_DRIVER_NAME "rdc"
#define RDC_MAJOR_VERSION 0
#define RDC_MINOR_VERSION 0
#define RDC_PATCH_VERSION 6
#define RDC_VERSION \
((RDC_MAJOR_VERSION << 20) | (RDC_MINOR_VERSION << 10) | RDC_PATCH_VERSION)
/* Customized Info */
#define DEFAULT_VIDEOMEM_SIZE 0x00800000
#define DEFAULT_MMIO_SIZE 0x00020000
#define DEFAULT_CMDQ_SIZE 0x00100000
#define MIN_CMDQ_SIZE 0x00040000
#define CMD_QUEUE_GUARD_BAND 0x00000020
#define DEFAULT_HWC_NUM 0x00000002
/* Data Type Definition */
typedef INT32 LONG;
typedef CARD8 UCHAR;
typedef CARD16 USHORT;
typedef CARD32 ULONG;
/* Verberse level define */
#define ErrorLevel 0 /* Report Error message */
#define DefaultLevel 4 /* Driver entry function */
#define InfoLevel 5 /* Report information */
#define InternalLevel 6 /* Driver interanl function entry */
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
#define BIT3 0x00000008
#define BIT4 0x00000010
#define BIT5 0x00000020
#define BIT6 0x00000040
#define BIT7 0x00000080
#define BIT8 0x00000100
#define BIT9 0x00000200
#define BIT10 0x00000400
#define BIT11 0x00000800
#define BIT12 0x00001000
#define BIT13 0x00002000
#define BIT14 0x00004000
#define BIT15 0x00008000
#define BIT16 0x00010000
#define BIT17 0x00020000
#define BIT18 0x00040000
#define BIT19 0x00080000
#define BIT20 0x00100000
#define BIT21 0x00200000
#define BIT22 0x00400000
#define BIT23 0x00800000
#define BIT24 0x01000000
#define BIT25 0x02000000
#define BIT26 0x04000000
#define BIT27 0x08000000
#define BIT28 0x10000000
#define BIT29 0x20000000
#define BIT30 0x40000000
#define BIT31 0x80000000
#define BIOS_ROM_PATH_FILE "//root//RDCVBIOS.ROM"
#define BIOS_ROM_SIZE 32*1024
#define BIOS_ROM_PHY_BASE 0xC0000
/* Data Structure Definition */
typedef struct _RDCRegRec {
/* UCHAR ucScratch[0x1F];*/
UCHAR ucPLLValue[3];
UCHAR ucCRA3;
UCHAR ucSR58;
} RDCRegRec, *RDCRegPtr;
typedef struct _VIDEOMODE {
int ScreenWidth;
int ScreenHeight;
int bitsPerPixel;
int Bpp;
int ScreenPitch;
} VIDEOMODE, *PVIDEOMODE;
typedef struct {
ULONG ulCMDQSize;
ULONG ulCMDQType;
ULONG ulCMDQOffsetAddr;
UCHAR *pjCMDQVirtualAddr;
UCHAR *pjCmdQBasePort;
UCHAR *pjWritePort;
UCHAR *pjReadPort;
UCHAR *pjEngStatePort;
ULONG ulCMDQMask;
ULONG ulCurCMDQueueLen;
ULONG ulWritePointer;
ULONG ulReadPointer;
ULONG ulReadPointer_OK; /* for Eng_DBGChk */
} CMDQINFO, *PCMDQINFO;
typedef struct {
ULONG fg;
ULONG bg;
UCHAR *pjPatternVirtualAddr;
UCHAR ucXorBitmap[64*64/8];
UCHAR ucAndBitmap[64*64/8];
} MONOHWC, *PMONOHWC;
typedef struct {
int HWC_NUM;
int HWC_NUM_Next;
ULONG ulHWCOffsetAddr;
UCHAR *pjHWCVirtualAddr;
USHORT cursortype;
USHORT width;
USHORT height;
USHORT xhot;
USHORT yhot;
USHORT offset_x;
USHORT offset_y;
int iScreenOffset_x;
int iScreenOffset_y;
MONOHWC MonoHWC;
} HWCINFO, *PHWCINFO;
typedef struct {
ULONG ulHorMaxResolution;
ULONG ulVerMaxResolution;
} MONITORSIZE;
typedef struct {
Bool EnableHorScaler;
Bool EnableVerScaler;
int ulHorScalingFactor;
int ulVerScalingFactor;
} SCALER;
typedef struct {
UCHAR ucDeviceID;
UCHAR ucDisplayPath;
MONITORSIZE MonitorSize;
SCALER ScalerConfig;
/* current mode: uce pScrn->currentMode */
} DEVICEINFO;
typedef struct {
Bool bOverlayEnable;
int iSrcWidth;
int iSrcHeight;
int iDstLeft;
int iDstTop;
int iDstWidth;
int iDstHeight;
} OVERLAY_STATUS;
typedef struct _RDCRec {
EntityInfoPtr pEnt;
#if XSERVER_LIBPCIACCESS
struct pci_device *PciInfo;
#else
pciVideoPtr PciInfo;
PCITAG PciTag;
#endif
OptionInfoPtr Options;
DisplayModePtr ModePtr; /* duplicate of pScrn->currentMode, delete this one */
XAAInfoRecPtr AccelInfoPtr;
xf86CursorInfoPtr HWCInfoPtr;
VIDEOMODE VideoModeInfo; /* duplicate of pScrn->currentMode, delete this one */
RDCRegRec SavedReg;
CMDQINFO CMDQInfo;
HWCINFO HWCInfo;
OVERLAY_STATUS OverlayStatus;
DEVICEINFO DeviceInfo;
ULONG ulCMDReg;
Bool EnableClip;
/* adapter information */
UCHAR jChipType;
ULONG ENGCaps;
ULONG FBPhysAddr; /* Frame buffer physical address */
UCHAR *FBVirtualAddr; /* Map of frame buffer */
unsigned long FbMapSize;
unsigned long AvailableFBsize;
ULONG MMIOPhysAddr; /* MMIO region physical address */
UCHAR *MMIOVirtualAddr; /* Map of MMIO region */
unsigned long MMIOMapSize;
UCHAR *BIOSVirtualAddr; /* BIOS virtual address */
ULONG ulROMType; /* 0: no BIOS 1: VBIOS, 2: ROM file */
ULONG MemoryBandwidth; /* The unit is MB*/
IOADDRESS IODBase; /* Base of PIO memory area */
IOADDRESS PIOOffset;
IOADDRESS RelocateIO;
USHORT usSupportDevice;
Bool noAccel;
Bool noHWC;
Bool MMIO2D;
int DBGSelect;
CloseScreenProcPtr CloseScreen;
} RDCRec, *RDCRecPtr;
#define RDCPTR(p) ((RDCRecPtr)((p)->driverPrivate))
#define MODE_PRIVATE_PTR(p) ((MODE_PRIVATE*)(p->Private))
/* Include Files */
#include "rdc_mode.h"
#include "rdc_vgatool.h"
#include "rdc_2dtool.h"
#include "rdc_cursor.h"
#include "CInt10.h"
#include "rdc_video.h"
|