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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
/*
* Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
*
* 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 Marc Aurele La France not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Marc Aurele La France makes no representations
* about the suitability of this software for any purpose. It is provided
* "as-is" without express or implied warranty.
*
* MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL MARC AURELE LA FRANCE 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.
*
* DRI support by:
* Leif Delgass <ldelgass@retinalburn.net>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "ati.h"
#include "atichip.h"
#include "aticursor.h"
#include "atioption.h"
#include "atistruct.h"
#include "mach64_common.h"
#ifdef TV_OUT
/*
* List of supported TV standard names
*/
const char *ATITVStandardNames[ATI_TV_STDS_MAX_VALID+1] = {
"NTSC",
"PAL",
"PAL-M",
"PAL-60",
"NTSC-J",
"PAL-CN",
"PAL-N",
"Reserved1",
"Reserved2",
"SCART-PAL",
"None",
"Invalid"
};
#endif /* TV_OUT */
/*
* Recognised XF86Config options.
*/
static const OptionInfoRec ATIPublicOptions[] =
{
{
ATI_OPTION_PROBE_SPARSE,
"probe_sparse",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_ACCEL,
"accel",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_CRT_DISPLAY,
"crt_display",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_CSYNC,
"composite_sync",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_HWCURSOR,
"hw_cursor",
OPTV_BOOLEAN,
{0, },
FALSE,
},
#ifdef XF86DRI_DEVEL
{
ATI_OPTION_IS_PCI,
"force_pci_mode",
OPTV_BOOLEAN,
{0, },
FALSE,
},
{
ATI_OPTION_DMA_MODE,
"dma_mode",
OPTV_STRING,
{0, },
FALSE,
},
{
ATI_OPTION_AGP_MODE,
"agp_mode",
OPTV_INTEGER,
{0, },
FALSE,
},
{
ATI_OPTION_AGP_SIZE,
"agp_size",
OPTV_INTEGER,
{0, },
FALSE,
},
{
ATI_OPTION_LOCAL_TEXTURES,
"local_textures",
OPTV_BOOLEAN,
{0, },
FALSE,
},
{
ATI_OPTION_BUFFER_SIZE,
"buffer_size",
OPTV_INTEGER,
{0, },
FALSE,
},
#endif /* XF86DRI_DEVEL */
#ifdef TV_OUT
{
ATI_OPTION_TV_OUT,
"tv_out",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_TV_STD,
"tv_standard",
OPTV_STRING,
{0, },
FALSE
},
#endif /* TV_OUT */
{
ATI_OPTION_MMIO_CACHE,
"mmio_cache",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_TEST_MMIO_CACHE,
"test_mmio_cache",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_PANEL_DISPLAY,
"panel_display",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_REFERENCE_CLOCK,
"reference_clock",
OPTV_FREQ,
{0, },
FALSE
},
{
ATI_OPTION_SHADOW_FB,
"shadow_fb",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
ATI_OPTION_SWCURSOR,
"sw_cursor",
OPTV_BOOLEAN,
{0, },
FALSE,
},
{
ATI_OPTION_ACCELMETHOD,
"AccelMethod",
OPTV_STRING,
{0, },
FALSE
},
{
ATI_OPTION_RENDER_ACCEL,
"RenderAccel",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
-1,
NULL,
OPTV_NONE,
{0, },
FALSE
}
};
static const unsigned long ATIPublicOptionSize = SizeOf(ATIPublicOptions);
const OptionInfoRec *
ATIOptionsWeak(void) { return ATIPublicOptions; }
/*
* Non-publicised XF86Config options.
*/
typedef enum
{
ATI_OPTION_BIOS_DISPLAY, /* Allow BIOS interference */
ATI_OPTION_CRT_SCREEN, /* Legacy negation of "PanelDisplay" */
ATI_OPTION_DEVEL, /* Intentionally undocumented */
ATI_OPTION_BLEND, /* Force horizontal blending of small modes */
ATI_OPTION_LCDSYNC /* Use XF86Config panel mode porches */
} ATIPrivateOptionType;
/*
* ATIProcessOptions --
*
* This function extracts options from what was parsed out of the XF86Config
* file.
*/
void
ATIProcessOptions
(
ScrnInfoPtr pScreenInfo,
ATIPtr pATI
)
{
OptionInfoPtr PublicOption = XNFalloc(ATIPublicOptionSize);
OptionInfoRec PrivateOption[] =
{
{ /* ON: Let BIOS change display(s) */
ATI_OPTION_BIOS_DISPLAY, /* OFF: Don't */
"biosdisplay",
OPTV_BOOLEAN,
{0, },
FALSE
},
{ /* Negation of "PanelDisplay" public option */
ATI_OPTION_CRT_SCREEN,
"crtscreen",
OPTV_BOOLEAN,
{0, },
FALSE
},
{ /* ON: Ease exploration of loose ends */
ATI_OPTION_DEVEL, /* OFF: Fit for public consumption */
"tsi",
OPTV_BOOLEAN,
{0, },
FALSE
},
{ /* ON: Horizontally blend most modes */
ATI_OPTION_BLEND, /* OFF: Use pixel replication more often */
"lcdblend",
OPTV_BOOLEAN,
{0, },
FALSE
},
{ /* ON: Use XF86Config porch timings */
ATI_OPTION_LCDSYNC, /* OFF: Use porches from mode on entry */
"lcdsync",
OPTV_BOOLEAN,
{0, },
FALSE
},
{
-1,
NULL,
OPTV_NONE,
{0, },
FALSE
}
};
(void)memcpy(PublicOption, ATIPublicOptions, ATIPublicOptionSize);
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 25
# define boolean bool
#endif
# define ProbeSparse PublicOption[ATI_OPTION_PROBE_SPARSE].value.boolean
# define Accel PublicOption[ATI_OPTION_ACCEL].value.boolean
# define BIOSDisplay PrivateOption[ATI_OPTION_BIOS_DISPLAY].value.boolean
# define Blend PrivateOption[ATI_OPTION_BLEND].value.boolean
# define CRTDisplay PublicOption[ATI_OPTION_CRT_DISPLAY].value.boolean
# define CRTScreen PrivateOption[ATI_OPTION_CRT_SCREEN].value.boolean
# define CSync PublicOption[ATI_OPTION_CSYNC].value.boolean
# define Devel PrivateOption[ATI_OPTION_DEVEL].value.boolean
# define HWCursor PublicOption[ATI_OPTION_HWCURSOR].value.boolean
#ifdef XF86DRI_DEVEL
# define IsPCI PublicOption[ATI_OPTION_IS_PCI].value.boolean
# define DMAMode PublicOption[ATI_OPTION_DMA_MODE].value.str
# define AGPMode PublicOption[ATI_OPTION_AGP_MODE].value.num
# define AGPSize PublicOption[ATI_OPTION_AGP_SIZE].value.num
# define LocalTex PublicOption[ATI_OPTION_LOCAL_TEXTURES].value.boolean
# define BufferSize PublicOption[ATI_OPTION_BUFFER_SIZE].value.num
#endif /* XF86DRI_DEVEL */
#ifdef TV_OUT
# define TvOut PublicOption[ATI_OPTION_TV_OUT].value.boolean
# define TvStd PublicOption[ATI_OPTION_TV_STD].value.str
#endif /* TV_OUT */
# define CacheMMIO PublicOption[ATI_OPTION_MMIO_CACHE].value.boolean
# define TestCacheMMIO PublicOption[ATI_OPTION_TEST_MMIO_CACHE].value.boolean
# define PanelDisplay PublicOption[ATI_OPTION_PANEL_DISPLAY].value.boolean
# define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.boolean
# define SWCursor PublicOption[ATI_OPTION_SWCURSOR].value.boolean
# define AccelMethod PublicOption[ATI_OPTION_ACCELMETHOD].value.str
# define RenderAccel PublicOption[ATI_OPTION_RENDER_ACCEL].value.boolean
# define LCDSync PrivateOption[ATI_OPTION_LCDSYNC].value.boolean
# define ReferenceClock \
PublicOption[ATI_OPTION_REFERENCE_CLOCK].value.freq.freq
/* Pick up XF86Config options */
xf86CollectOptions(pScreenInfo, NULL);
/* Set non-zero defaults */
Accel = CacheMMIO = HWCursor = TRUE;
ReferenceClock = ((double)157500000.0) / ((double)11.0);
ShadowFB = TRUE;
Blend = PanelDisplay = TRUE;
#ifdef USE_EXA
RenderAccel = TRUE;
#endif
#ifdef XF86DRI_DEVEL
DMAMode = "async";
#endif
#ifdef TV_OUT
TvStd = "None"; /* No tv standard change requested */
#endif
xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
PublicOption);
xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
PrivateOption);
/* Move option values into driver private structure */
pATI->OptionProbeSparse = ProbeSparse;
pATI->OptionAccel = Accel;
pATI->OptionBIOSDisplay = BIOSDisplay;
pATI->OptionBlend = Blend;
pATI->OptionCRTDisplay = CRTDisplay;
pATI->OptionCSync = CSync;
pATI->OptionDevel = Devel;
#ifdef TV_OUT
if (TvOut && pATI->Chip < ATI_CHIP_264GT) {
/* Only allow this for 3D Rage (I) or greater chip ID
* AFAIK, no chips before this supported TV-Out
* mach64VT has support for TV tuner, but no TV-Out
*/
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"TV Out not supported for this chip.\n");
} else {
pATI->OptionTvOut = TvOut;
pATI->OptionTvStd = ATI_TV_STD_INVALID;
for (ATITVStandard std = 0; std < ATI_TV_STDS_MAX_VALID; std++) {
if (std != ATI_TV_STD_RESERVED1 && std != ATI_TV_STD_RESERVED2) {
if (strncasecmp(TvStd, ATITVStandardNames[std], ATI_TV_STDS_NAME_MAXLEN)==0) {
pATI->OptionTvStd = std;
break;
}
}
}
}
#endif /* TV_OUT */
pATI->OptionMMIOCache = CacheMMIO;
pATI->OptionTestMMIOCache = TestCacheMMIO;
pATI->OptionShadowFB = ShadowFB;
pATI->OptionLCDSync = LCDSync;
/* "CRTScreen" is now "NoPanelDisplay" */
if ((PanelDisplay != CRTScreen) ||
PublicOption[ATI_OPTION_PANEL_DISPLAY].found)
pATI->OptionPanelDisplay = PanelDisplay;
else
pATI->OptionPanelDisplay = !CRTScreen;
#ifdef XF86DRI_DEVEL
pATI->OptionIsPCI = IsPCI;
pATI->OptionAGPMode = AGPMode;
pATI->OptionAGPSize = AGPSize;
pATI->OptionLocalTextures = LocalTex;
pATI->OptionBufferSize = BufferSize;
if (strcasecmp(DMAMode, "async")==0)
pATI->OptionDMAMode = MACH64_MODE_DMA_ASYNC;
else if (strcasecmp(DMAMode, "sync")==0)
pATI->OptionDMAMode = MACH64_MODE_DMA_SYNC;
else if (strcasecmp(DMAMode, "mmio")==0 )
pATI->OptionDMAMode = MACH64_MODE_MMIO;
else {
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Unknown dma_mode: '%s'\n", DMAMode);
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Valid dma_mode options are: 'async','sync','mmio'\n");
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Defaulting to async DMA mode\n");
pATI->OptionDMAMode = MACH64_MODE_DMA_ASYNC;
}
#endif /* XF86DRI_DEVEL */
/* Validate and set cursor options */
pATI->Cursor = ATI_CURSOR_SOFTWARE;
if (SWCursor || !HWCursor)
{
if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Option \"sw_cursor\" overrides Option \"hw_cursor\".\n");
}
else if (pATI->Chip < ATI_CHIP_264CT)
{
if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Option \"hw_cursor\" not supported in this configuration.\n");
}
else
{
pATI->Cursor = ATI_CURSOR_HARDWARE;
}
pATI->refclk = (int)ReferenceClock;
pATI->useEXA = FALSE;
if (pATI->OptionAccel)
{
MessageType from = X_DEFAULT;
#if defined(USE_EXA)
#if defined(USE_XAA)
if (AccelMethod != NULL)
{
from = X_CONFIG;
if (xf86NameCmp(AccelMethod, "EXA") == 0)
pATI->useEXA = TRUE;
}
#else /* USE_XAA */
pATI->useEXA = TRUE;
#endif /* !USE_XAA */
#endif /* USE_EXA */
xf86DrvMsg(pScreenInfo->scrnIndex, from,
"Using %s acceleration architecture\n",
pATI->useEXA ? "EXA" : "XAA");
#if defined(USE_EXA)
if (pATI->useEXA && pATI->Chip >= ATI_CHIP_264GTPRO)
pATI->RenderAccelEnabled = TRUE;
if (pATI->useEXA && !RenderAccel)
pATI->RenderAccelEnabled = FALSE;
#endif
}
free(PublicOption);
}
|