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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c,v 1.50 2002/10/08 22:14:10 tsi Exp $ */
/*
* Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the XFree86 Project shall
* not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization from the
* XFree86 Project.
*/
/*
* This is essentially a transfer of the 3.3 sources written by
* Marc Langenbach and Tim Rowley.
*
* The initial port of this driver to XFree86 4.0 was done by
* Marc Langenbach <mlangen@studcs.uni-sb.de>
* Additions, updates and bugfixes by Dejan Ilic <dejan.ilic@home.se>
*/
/*
* Activate acceleration code or not.
*
* WARNING BUGGY !!!
* Yes, you activate it on your own risk.
*/
#define USE_ACCEL 0
/*
* includes
*/
#include "rendition.h"
#include "rendition_options.h"
#include "hwcursor.h"
#include "xf86int10.h"
#include "vtypes.h"
#include "vboard.h"
#include "vmodes.h"
#include "accel.h"
#include "vramdac.h"
#include "rendition_shadow.h"
#include "vbe.h"
/*
* defines
*/
#undef DEBUG
#define RENDITION_NAME "RENDITION"
#define RENDITION_DRIVER_NAME "rendition"
#define RENDITION_VERSION_NAME "4.0"
#define RENDITION_VERSION_MAJOR 4
#define RENDITION_VERSION_MINOR 0
#define RENDITION_PATCHLEVEL 0
#define RENDITION_VERSION_CURRENT ((RENDITION_VERSION_MAJOR << 24) | \
(RENDITION_VERSION_MINOR << 16) | RENDITION_PATCHLEVEL)
/*
* local function prototypes
*/
static const OptionInfoRec * renditionAvailableOptions(int, int);
static void renditionIdentify(int);
static Bool renditionProbe(DriverPtr, int);
static Bool renditionPreInit(ScrnInfoPtr, int);
static Bool renditionScreenInit(int, ScreenPtr, int, char **);
static Bool renditionSwitchMode(int, DisplayModePtr, int);
static void renditionAdjustFrame(int, int, int, int);
static Bool renditionEnterVT(int, int);
static void renditionLeaveVT(int, int);
static void renditionFreeScreen(int, int);
static ModeStatus renditionValidMode(int, DisplayModePtr, Bool, int);
static Bool renditionMapMem(ScrnInfoPtr pScreenInfo);
static Bool renditionUnmapMem(ScrnInfoPtr pScreenInfo);
#if 0
static xf86MonPtr renditionDDC(ScrnInfoPtr pScreenInfo);
static unsigned int renditionDDC1Read (ScrnInfoPtr pScreenInfo);
#endif
static xf86MonPtr renditionProbeDDC(ScrnInfoPtr pScrn, int index);
static void renditionLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
/*
* global data
*/
OptionInfoRec const renditionOptions[]={
{ OPTION_FBWC, "FramebufferWC", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SW_CURSOR, "SW_Cursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_OVERCLOCK_MEM,"Overclock_Mem", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_NO_DDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
DriverRec RENDITION={
RENDITION_VERSION_CURRENT,
"rendition",
renditionIdentify,
renditionProbe,
renditionAvailableOptions,
NULL,
0
};
static const char *vgahwSymbols[]={
"vgaHWBlankScreen",
"vgaHWDPMSSet",
"vgaHWFreeHWRec",
"vgaHWGetHWRec",
"vgaHWGetIOBase",
"vgaHWGetIndex",
"vgaHWLock",
"vgaHWMapMem",
"vgaHWProtect",
"vgaHWRestore",
"vgaHWSave",
"vgaHWSaveScreen",
"vgaHWUnlock",
"vgaHWHandleColormaps",
NULL
};
static const char *ramdacSymbols[] = {
"xf86CreateCursorInfoRec",
"xf86DestroyCursorInfoRec",
"xf86InitCursor",
NULL
};
static const char *xaaSymbols[] = {
"XAACreateInfoRec",
"XAADestroyInfoRec",
"XAAInit",
NULL
};
static const char *ddcSymbols[] = {
"xf86DoEDID_DDC1",
"xf86PrintEDID",
NULL
};
static const char *int10Symbols[] = {
"xf86FreeInt10",
"xf86InitInt10",
NULL
};
static const char *miscfbSymbols[]={
"xf1bppScreenInit",
"xf4bppScreenInit",
NULL
};
static const char *fbSymbols[]={
"fbScreenInit",
"fbPictureInit",
NULL
};
static const char *shadowfbSymbols[] = {
"ShadowFBInit",
NULL
};
static const char *vbeSymbols[] = {
"VBEInit",
"vbeDoEDID",
"vbeFree",
NULL
};
#ifdef XFree86LOADER
/* Module loader interface */
static MODULESETUPPROTO(renditionSetup);
static XF86ModuleVersionInfo renditionVersionRec = {
RENDITION_DRIVER_NAME,
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XF86_VERSION_CURRENT,
RENDITION_VERSION_MAJOR, RENDITION_VERSION_MINOR, RENDITION_PATCHLEVEL,
ABI_CLASS_VIDEODRV,
ABI_VIDEODRV_VERSION,
MOD_CLASS_VIDEODRV,
{0, 0, 0, 0}
};
XF86ModuleData renditionModuleData =
{ &renditionVersionRec, renditionSetup, NULL };
static pointer
renditionSetup(pointer Module, pointer Options, int *ErrorMajor,
int *ErrorMinor)
{
static Bool Initialised=FALSE;
if (!Initialised) {
Initialised=TRUE;
xf86AddDriver(&RENDITION, Module, 0);
LoaderRefSymLists(vgahwSymbols, ramdacSymbols, miscfbSymbols,
fbSymbols, xaaSymbols, ddcSymbols, int10Symbols,
shadowfbSymbols, vbeSymbols, NULL);
return (pointer)TRUE;
}
if (ErrorMajor)
*ErrorMajor=LDR_ONCEONLY;
return NULL;
}
#endif
enum renditionTypes {
CHIP_RENDITION_V1000,
CHIP_RENDITION_V2x00
};
/* supported chipsets */
static SymTabRec renditionChipsets[] = {
{CHIP_RENDITION_V1000, "V1000"},
{CHIP_RENDITION_V2x00, "V2100/V2200"},
{-1, NULL}
};
static PciChipsets renditionPCIchipsets[] = {
{ CHIP_RENDITION_V1000, PCI_CHIP_V1000, RES_SHARED_VGA },
{ CHIP_RENDITION_V2x00, PCI_CHIP_V2x00, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
/*
* functions
*/
static const OptionInfoRec *
renditionAvailableOptions(int chipid, int busid)
{
return renditionOptions;
}
static void
renditionIdentify(int flags)
{
xf86PrintChipsets(RENDITION_NAME,
"rendition driver (version " RENDITION_VERSION_NAME ") for chipsets",
renditionChipsets);
}
/*
* This function is called once, at the start of the first server generation to
* do a minimal probe for supported hardware.
*/
static Bool
renditionProbe(DriverPtr drv, int flags)
{
Bool foundScreen=FALSE;
int numDevSections, numUsed;
GDevPtr *devSections;
int *usedChips;
int c;
/* Find the config file Device sections that match this
* driver, and return if there are none. */
if ((numDevSections=xf86MatchDevice(RENDITION_DRIVER_NAME, &devSections)) <= 0)
return FALSE;
/* PCI BUS */
if (xf86GetPciVideoInfo()) {
numUsed=xf86MatchPciInstances(RENDITION_DRIVER_NAME, PCI_VENDOR_RENDITION,
renditionChipsets, renditionPCIchipsets,
devSections, numDevSections, drv, &usedChips);
xfree(devSections);
if (numUsed <= 0)
return FALSE;
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (c=0; c<numUsed; c++) {
ScrnInfoPtr pScrn;
/* Allocate a ScrnInfoRec and claim the slot */
pScrn=NULL;
if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[c],
renditionPCIchipsets, NULL,
NULL, NULL, NULL, NULL))) {
pScrn->driverVersion=RENDITION_VERSION_CURRENT;
pScrn->driverName =RENDITION_DRIVER_NAME;
pScrn->name =RENDITION_NAME;
pScrn->Probe =renditionProbe;
pScrn->PreInit =renditionPreInit;
pScrn->ScreenInit =renditionScreenInit;
pScrn->SwitchMode =renditionSwitchMode;
pScrn->AdjustFrame =renditionAdjustFrame;
pScrn->EnterVT =renditionEnterVT;
pScrn->LeaveVT =renditionLeaveVT;
pScrn->FreeScreen =renditionFreeScreen;
pScrn->ValidMode =renditionValidMode;
foundScreen=TRUE;
}
}
}
xfree(usedChips);
return foundScreen;
}
#if 0
static Bool
renditionClockSelect(ScrnInfoPtr pScreenInfo, int ClockNumber)
{
vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo);
static CARD8 save_misc;
switch (ClockNumber)
{
case CLK_REG_SAVE:
save_misc = inb(pvgaHW->PIOOffset + VGA_MISC_OUT_R);
break;
case CLK_REG_RESTORE:
outb(pvgaHW->PIOOffset + VGA_MISC_OUT_W, save_misc);
break;
default:
outb(pvgaHW->PIOOffset + VGA_MISC_OUT_W,
(save_misc & 0xF3) | ((ClockNumber << 2) & 0x0C));
break;
}
return TRUE;
}
#endif
static renditionPtr
renditionGetRec(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF("GetRec ...!!!!\n");
sleep(1);
#endif
if (!pScreenInfo->driverPrivate)
pScreenInfo->driverPrivate=xcalloc(sizeof(renditionRec), 1);
/* perhaps some initialization? <ml> */
#ifdef DEBUG
ErrorF("GetRec ...!!!!\n");
sleep(1);
#endif
return (renditionPtr)pScreenInfo->driverPrivate;
}
static void
renditionFreeRec(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF("FreeRec...!!!!\n");
sleep(1);
#endif
if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
vgaHWFreeHWRec(pScreenInfo);
xfree(pScreenInfo->driverPrivate);
pScreenInfo->driverPrivate=NULL;
#ifdef DEBUG
ErrorF("FreeRec OK...!!!!\n");
sleep(1);
#endif
}
#if 0
static void
renditionProtect(ScrnInfoPtr pScreenInfo, Bool On)
{
#ifdef DEBUG
ErrorF("Protect...!!!!\n");
sleep(1);
#endif
vgaHWProtect(pScreenInfo, On);
#ifdef DEBUG
ErrorF("Protect OK...!!!!\n");
sleep(1);
#endif
}
#endif
static Bool
renditionSaveScreen(ScreenPtr pScreen, int mode)
{
#ifdef DEBUG
ErrorF("Savescreen...!!!!\n");
sleep(1);
#endif
return vgaHWSaveScreen(pScreen, mode);
}
#if 0
static void
renditionBlankScreen(ScrnInfoPtr pScreenInfo, Bool Unblank)
{
#ifdef DEBUG
ErrorF("Blankscreen...!!!!\n");
sleep(1);
#endif
vgaHWBlankScreen(pScreenInfo, Unblank);
#ifdef DEBUG
ErrorF("Blankscreen OK...!!!!\n");
sleep(1);
#endif
}
#endif
/*
* This function is called once for each screen at the start of the first
* server generation to initialise the screen for all server generations.
*/
static Bool
renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
{
static ClockRange renditionClockRange = {NULL, 0, 135000, -1, FALSE, TRUE, 1, 1, 0};
MessageType From;
int videoRam, Rounding, nModes = 0;
renditionPtr pRendition;
char *in_string;
vgaHWPtr pvgaHW;
#ifdef DEBUG
ErrorF("Rendition: renditionPreInit() called\n");
#endif
/* Check the number of entities, and fail if it isn't one. */
if (pScreenInfo->numEntities != 1)
return FALSE;
/* allocate driver private structure */
if (!renditionGetRec(pScreenInfo))
return FALSE;
pRendition=RENDITIONPTR(pScreenInfo);
/* Get the entity, and make sure it is PCI. */
pRendition->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[0]);
if (pRendition->pEnt->location.type != BUS_PCI)
return FALSE;
if (flags & PROBE_DETECT) {
ConfiguredMonitor =
renditionProbeDDC(pScreenInfo, pRendition->pEnt->index);
return TRUE;
}
/* set the monitor */
pScreenInfo->monitor=pScreenInfo->confScreen->monitor;
/* Initialize the card through int10 interface if needed */
if (xf86LoadSubModule(pScreenInfo, "int10")){
xf86Int10InfoPtr pInt=NULL;
xf86LoaderReqSymLists(int10Symbols, NULL);
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Initializing int10\n");
pInt = xf86InitInt10(pRendition->pEnt->index);
xf86FreeInt10(pInt);
}
/* Find the PCI info for this screen */
pRendition->PciInfo = xf86GetPciInfoForEntity(pRendition->pEnt->index);
pRendition->pcitag= pciTag(pRendition->PciInfo->bus,
pRendition->PciInfo->device, pRendition->PciInfo->func);
/*
* XXX This could be refined if some VGA memory resources are not
* decoded in operating mode.
*/
xf86SetOperatingState(resVgaMem, pRendition->pEnt->index, ResUnusedOpr);
if (xf86RegisterResources(pRendition->pEnt->index, NULL, ResExclusive))
return FALSE;
/* Operations for which memory access is required. */
pScreenInfo->racMemFlags = RAC_FB | RAC_CURSOR;
/* Operations for which I/O access is required. (XXX Check this) */
pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
/* determine depth, bpp, etc. */
if (!xf86SetDepthBpp(pScreenInfo, 8, 8, 8, Support32bppFb))
return FALSE;
if (pScreenInfo->depth == 15)
{
if (PCI_CHIP_V1000 != pRendition->PciInfo->chipType) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Given depth (%d) is not supported by this chipset.\n",
pScreenInfo->depth);
return FALSE;
}
}
/* collect all of the options flags and process them */
xf86CollectOptions(pScreenInfo, NULL);
if (!(pRendition->Options = xalloc(sizeof(renditionOptions))))
return FALSE;
memcpy(pRendition->Options, renditionOptions, sizeof(renditionOptions));
xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
pRendition->Options);
/* Load fb */
if (!xf86LoadSubModule(pScreenInfo, "fb"))
return FALSE;
xf86LoaderReqSymLists(fbSymbols, NULL);
/* determine colour weights */
pScreenInfo->rgbBits=8;
if (pScreenInfo->depth > 8) {
rgb defaultWeight = {0, 0, 0};
rgb defaultMask = {0, 0, 0};
xf86PrintDepthBpp(pScreenInfo);
/* Standard defaults are OK if depths are OK */
if (!xf86SetWeight(pScreenInfo, defaultWeight, defaultMask))
return FALSE;
else{
/* XXX: Check that returned weight is supported */
}
}
/* determine default visual */
if (!xf86SetDefaultVisual(pScreenInfo, -1))
return FALSE;
/* the gamma fields must be initialised when using the new cmap code */
if (pScreenInfo->depth > 1) {
Gamma zeros = {0.0, 0.0, 0.0};
if (!xf86SetGamma(pScreenInfo, zeros))
return FALSE;
}
/* the Rendition chips have a programmable clock */
pScreenInfo->progClock=TRUE;
/* set various fields according to the given options */
/* to be filled in <ml> */
if (PCI_CHIP_V1000==pRendition->PciInfo->chipType){
pRendition->board.chip=V1000_DEVICE;
}
else {
pRendition->board.chip=V2000_DEVICE;
renditionClockRange.maxClock = 170000;
renditionClockRange.clockIndex = -1;
}
/***********************************************/
/* ensure vgahw private structure is allocated */
if (!vgaHWGetHWRec(pScreenInfo))
return FALSE;
pvgaHW = VGAHWPTR(pScreenInfo);
pvgaHW->MapSize = 0x00010000; /* Standard 64kB VGA window */
vgaHWGetIOBase(pvgaHW); /* Get VGA I/O base */
pRendition->board.accel=0;
pRendition->board.vgaio_base = pvgaHW->PIOOffset;
pRendition->board.io_base =
pRendition->board.vgaio_base + pRendition->PciInfo->ioBase[1];
pRendition->board.mmio_base=0;
pRendition->board.vmmio_base=0;
pRendition->board.mem_size=0;
pRendition->board.mem_base=(vu8 *)pRendition->PciInfo->memBase[0];
pRendition->board.vmem_base=NULL;
pRendition->board.init=0;
if (pScreenInfo->chipset)
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Chipset: \"%s\".\n",
pScreenInfo->chipset);
else
xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "Chipset: \"%s\".\n",
renditionChipsets[
pRendition->board.chip==V1000_DEVICE ? 0:1].name);
/* I do not get the IO base addres <ml> */
/* XXX Is this still true? If so, the wrong base is being checked */
xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED,
"Rendition %s @ %x/%x\n",
renditionChipsets[pRendition->board.chip==V1000_DEVICE ? 0:1]
.name,
pRendition->PciInfo->ioBase[1],
pRendition->PciInfo->memBase[0]);
/* First of all get a "clean" starting state */
verite_resetboard(pScreenInfo);
/* determine video ram -- to do so, we assume a full size memory of 16M,
* then map it and use verite_getmemorysize() to determine the real
* amount of memory */
pScreenInfo->videoRam = 16<<10;
pRendition->board.mem_size = pScreenInfo->videoRam * 1024;
renditionMapMem(pScreenInfo);
videoRam=verite_getmemorysize(pScreenInfo)>>10;
renditionUnmapMem(pScreenInfo);
From = X_PROBED;
xf86DrvMsg(pScreenInfo->scrnIndex, From, "videoRam: %d kBytes\n", videoRam);
pScreenInfo->videoRam=videoRam;
pRendition->board.mem_size=videoRam * 1024;
/* Load the needed symbols */
if (!xf86LoadSubModule(pScreenInfo, "vgahw")){
return FALSE;
}
xf86LoaderReqSymLists(vgahwSymbols, NULL);
pRendition->board.shadowfb=TRUE;
if ((in_string = xf86GetOptValString(pRendition->Options, OPTION_ROTATE))){
if(!xf86NameCmp(in_string, "CW")) {
/* accel is disabled below for shadowFB */
pRendition->board.shadowfb = TRUE;
pRendition->board.rotate = 1;
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
"Rotating screen clockwise - acceleration disabled\n");
} else if(!xf86NameCmp(in_string, "CCW")) {
pRendition->board.shadowfb = TRUE;
pRendition->board.rotate = -1;
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Rotating screen "
"counter clockwise - acceleration disabled\n");
} else {
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
"\"%s\" is not a valid value for Option \"Rotate\"\n",
in_string);
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"Valid options are \"CW\" or \"CCW\"\n");
}
}
if (xf86ReturnOptValBool(pRendition->Options, OPTION_SHADOW_FB,1)||
pRendition->board.rotate) {
if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Oops, \"ShadowFB\" module loading failed, disabling ShadowFB!\n");
}
else{
xf86LoaderReqSymLists(shadowfbSymbols, NULL);
pRendition->board.shadowfb=TRUE;
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"Using \"Shadow Framebuffer\"\n");
}
}
else {
pRendition->board.shadowfb=FALSE;
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
"\"Shadow Framebuffer\" disabled\n");
}
/* Load Ramdac module if needed */
if (!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0) &&
!pRendition->board.rotate){
if (!xf86LoadSubModule(pScreenInfo, "ramdac")) {
return FALSE;
}
xf86LoaderReqSymLists(ramdacSymbols, NULL);
}
#if 0
/* Load DDC module if needed */
if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NO_DDC,0)){
if (!xf86LoadSubModule(pScreenInfo, "ddc")) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
("Loading of DDC library failed, skipping DDC-probe\n"));
}
else {
xf86LoaderReqSymLists(ddcSymbols, NULL);
pScreenInfo->monitor->DDC = renditionDDC(pScreenInfo);
}
}
else {
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
("Skipping DDC probe on users request\n"));
}
#else
/* Load DDC module if needed */
if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NO_DDC,0)){
if (!xf86LoadSubModule(pScreenInfo, "vbe")) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
("Loading of DDC library failed, skipping DDC-probe\n"));
}
else {
xf86MonPtr mon;
xf86LoaderReqSymLists(vbeSymbols, NULL);
mon = renditionProbeDDC(pScreenInfo, pRendition->pEnt->index);
xf86PrintEDID(mon);
xf86SetDDCproperties(pScreenInfo, mon);
}
}
else {
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
("Skipping DDC probe on users request\n"));
}
#endif
/*
* Determine clocks. Limit them to the first four because that's all that
* can be addressed.
* XXX Aren't the clocks programmable? If so, this discrete clock stuff
* shouldn't be used.
*/
#if 0
if ((pScreenInfo->numClocks = pRendition->pEnt->device->numclocks))
{
if (pScreenInfo->numClocks > 4)
pScreenInfo->numClocks = 4;
for (i = 0; i < pScreenInfo->numClocks; i++)
pScreenInfo->clock[i] = pRendition->pEnt->device->clock[i];
From = X_CONFIG;
}
else
{
xf86GetClocks(pScreenInfo, 4,
renditionClockSelect, renditionProtect, renditionBlankScreen,
pvgaHW->PIOOffset + pvgaHW->IOBase + VGA_IN_STAT_1_OFFSET,
0x08, 1, 28322);
From = X_PROBED;
}
xf86ShowClocks(pScreenInfo, From);
#endif
/* Set the virtual X rounding (in bits) */
if (pScreenInfo->depth == 8)
Rounding = 16 * 8;
else
Rounding = 16;
/*
* Validate the modes. Note that the limits passed to
* xf86ValidateModes() are VGA CRTC architectural limits.
*/
pScreenInfo->maxHValue = 2080;
pScreenInfo->maxVValue = 1025;
nModes = xf86ValidateModes(pScreenInfo,
pScreenInfo->monitor->Modes, pScreenInfo->display->modes,
&renditionClockRange, NULL, 8, 2040, Rounding, 1, 1024,
pScreenInfo->display->virtualX, pScreenInfo->display->virtualY,
0x10000, LOOKUP_CLOSEST_CLOCK | LOOKUP_CLKDIV2);
if (nModes < 0)
return FALSE;
/* Remove invalid modes */
xf86PruneDriverModes(pScreenInfo);
/* Set CRTC values for the modes */
xf86SetCrtcForModes(pScreenInfo, 0);
/* Set current mode to the first in list */
pScreenInfo->currentMode = pScreenInfo->modes;
/* Print mode list */
xf86PrintModes(pScreenInfo);
/* Set display resolution */
xf86SetDpi(pScreenInfo, 0, 0);
/* Only one chipset here */
if (!pScreenInfo->chipset)
pScreenInfo->chipset = (char *)renditionChipsets[0].name;
if(!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0)){
if(!pRendition->board.rotate)
/* Do preemtive things for HW cursor */
RenditionHWCursorPreInit(pScreenInfo);
else{
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Hardware cursor not supported on rotated screen\n");
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"Software cursor activated\n");
}
}
else
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
"Software cursor selected\n");
/* Unmapping delayed until after micrcode loading */
/****************************************/
/* Reserve memory and load the microcode */
/****************************************/
#if USE_ACCEL
if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NOACCEL,0) &&
!pRendition->board.shadowfb) {
/* Load XAA if needed */
if (xf86LoadSubModule(pScreenInfo, "xaa")) {
xf86LoaderReqSymLists(xaaSymbols, NULL);
renditionMapMem(pScreenInfo);
RENDITIONAccelPreInit (pScreenInfo);
renditionUnmapMem(pScreenInfo);
pRendition->board.accel = TRUE;
} else xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
("XAA module not found: "
"Skipping acceleration\n"));
}
else
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
("Skipping acceleration on users request\n"));
#else
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
("Skipping acceleration\n"));
#endif
#ifdef DEBUG
ErrorF("PreInit OK...!!!!\n");
sleep(2);
#endif
return TRUE; /* Tada! */
}
/* Save mode on server entry */
static void
renditionSave(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF("Save...!!!!\n");
sleep(1);
#endif
vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg,VGA_SR_ALL);
#ifdef DEBUG
ErrorF("Save OK...!!!!\n");
sleep(1);
#endif
}
#if 0
/* Restore the mode that was saved on server entry */
static void
renditionRestore(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF("Restore...!!!!\n");
sleep(1);
#endif
vgaHWProtect(pScreenInfo, TRUE);
vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL);
vgaHWProtect(pScreenInfo, FALSE);
verite_setmode(pScreenInfo, &RENDITIONPTR(pScreenInfo)->mode);
#ifdef DEBUG
ErrorF("Restore OK...!!!!\n");
sleep(1);
#endif
}
#endif
/* Set a graphics mode */
static Bool
renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode)
{
struct verite_modeinfo_t *modeinfo=&RENDITIONPTR(pScreenInfo)->mode;
vgaHWPtr pvgaHW;
#ifdef DEBUG
ErrorF("RENDITION: renditionSetMode() called\n");
ErrorF("Setmode...!!!!\n");
sleep(1);
#endif
pvgaHW = VGAHWPTR(pScreenInfo);
/* construct a modeinfo for the verite_setmode function */
modeinfo->clock=pMode->SynthClock;
modeinfo->hdisplay=pMode->HDisplay;
modeinfo->hsyncstart=pMode->HSyncStart;
modeinfo->hsyncend=pMode->HSyncEnd;
modeinfo->htotal=pMode->HTotal;
modeinfo->hskew=pMode->HSkew;
modeinfo->vdisplay=pMode->VDisplay;
modeinfo->vsyncstart=pMode->VSyncStart;
modeinfo->vsyncend=pMode->VSyncEnd;
modeinfo->vtotal=pMode->VTotal;
modeinfo->screenwidth = pMode->HDisplay;
modeinfo->virtualwidth = pScreenInfo->virtualX & 0xfff8;
modeinfo->screenheight = pMode->VDisplay;
modeinfo->virtualheight = pScreenInfo->virtualY & 0xfff8;
if ((pMode->Flags&(V_PHSYNC|V_NHSYNC))
&& (pMode->Flags&(V_PVSYNC|V_NVSYNC))) {
modeinfo->hsynchi=((pMode->Flags&V_PHSYNC) == V_PHSYNC);
modeinfo->vsynchi=((pMode->Flags&V_PVSYNC) == V_PVSYNC);
}
else {
int VDisplay=pMode->VDisplay;
if (pMode->Flags & V_DBLSCAN)
VDisplay*=2;
if (VDisplay < 400) {
/* +hsync -vsync */
modeinfo->hsynchi=1;
modeinfo->vsynchi=0;
}
else if (VDisplay < 480) {
/* -hsync +vsync */
modeinfo->hsynchi=0;
modeinfo->vsynchi=1;
}
else if (VDisplay < 768) {
/* -hsync -vsync */
modeinfo->hsynchi=0;
modeinfo->vsynchi=0;
}
else {
/* +hsync +vsync */
modeinfo->hsynchi=1;
modeinfo->vsynchi=1;
}
}
switch (pScreenInfo->bitsPerPixel) {
case 8:
modeinfo->bitsperpixel=8;
modeinfo->pixelformat=V_PIXFMT_8I;
break;
case 16:
modeinfo->bitsperpixel=16;
if (pScreenInfo->weight.green == 5)
/* on a V1000, this looks too 'red/magenta' <ml> */
modeinfo->pixelformat=V_PIXFMT_1555;
else
modeinfo->pixelformat=V_PIXFMT_565;
break;
case 32:
modeinfo->bitsperpixel=32;
modeinfo->pixelformat=V_PIXFMT_8888;
break;
}
modeinfo->fifosize=128;
modeinfo->flags=pMode->Flags;
verite_setmode(pScreenInfo,&RENDITIONPTR(pScreenInfo)->mode);
#ifdef DEBUG
ErrorF("Setmode OK...!!!!\n");
sleep(1);
#endif
return TRUE;
}
static void
renditionLeaveGraphics(ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
#ifdef DEBUG
ErrorF("RENDITION: renditionLeaveGraphics() called\n");
sleep(1);
#endif
verite_restore(pScreenInfo, &pRendition->saveRegs);
vgaHWProtect(pScreenInfo, TRUE);
vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL);
vgaHWProtect(pScreenInfo, FALSE);
vgaHWLock(VGAHWPTR(pScreenInfo));
#ifdef DEBUG
ErrorF("Leavegraphics OK...!!!!\n");
sleep(1);
#endif
}
/* Unravel the screen */
static Bool
renditionCloseScreen(int scrnIndex, ScreenPtr pScreen)
{
ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
renditionPtr prenditionPriv=renditionGetRec(pScreenInfo);
Bool Closed = TRUE;
#ifdef DEBUG
ErrorF("RENDITION: renditionCloseScreen() called\n");
sleep(1);
#endif
if (prenditionPriv->board.hwcursor_used)
RenditionHWCursorRelease(pScreenInfo);
if (prenditionPriv->board.accel)
RENDITIONAccelNone(pScreenInfo);
if (prenditionPriv
&& (pScreen->CloseScreen = prenditionPriv->CloseScreen)) {
prenditionPriv->CloseScreen = NULL;
Closed = (*pScreen->CloseScreen)(scrnIndex, pScreen);
}
if (pScreenInfo->vtSema)
renditionLeaveGraphics(pScreenInfo);
pScreenInfo->vtSema = FALSE;
#ifdef DEBUG
ErrorF("Closescreen OK...!!!!\n");
sleep(1);
#endif
return Closed;
}
static void
renditionDPMSSet(ScrnInfoPtr pScreen, int mode, int flags)
{
#ifdef DEBUG
ErrorF("RENDITION: renditionDPMSSet() called\n");
#endif
vgaHWDPMSSet(pScreen, mode, flags);
}
static Bool
renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
{
ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
Bool Inited = FALSE;
unsigned char *FBBase;
VisualPtr visual;
vgaHWPtr pvgaHW;
int displayWidth,width,height;
#ifdef DEBUG
ErrorF("RENDITION: renditionScreenInit() called\n");
sleep(1);
#endif
/* Get vgahw private */
pvgaHW = VGAHWPTR(pScreenInfo);
/* Get driver private */
pRendition=renditionGetRec(pScreenInfo);
/* Save the current state and setup the current mode */
renditionSave(pScreenInfo);
/* Map VGA aperture */
if (!vgaHWMapMem(pScreenInfo))
return FALSE;
if (!renditionMapMem(pScreenInfo))
return FALSE;
/* Unlock VGA registers */
vgaHWUnlock(pvgaHW);
verite_save(pScreenInfo);
if (!renditionSetMode(pScreenInfo, pScreenInfo->currentMode))
return FALSE;
/* blank the screen */
renditionSaveScreen(pScreen, SCREEN_SAVER_ON);
(*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
miClearVisualTypes();
if (!miSetVisualTypes(pScreenInfo->depth,
miGetDefaultVisualMask(pScreenInfo->depth),
pScreenInfo->rgbBits, pScreenInfo->defaultVisual))
return FALSE;
miSetPixmapDepths ();
if (pRendition->board.rotate) {
height = pScreenInfo->virtualX;
width = pScreenInfo->virtualY;
} else {
width = pScreenInfo->virtualX;
height = pScreenInfo->virtualY;
}
if(pRendition->board.shadowfb) {
pRendition->board.shadowPitch
= BitmapBytePad(pScreenInfo->bitsPerPixel * width);
pRendition->board.shadowPtr
= xalloc(pRendition->board.shadowPitch * height);
displayWidth = pRendition->board.shadowPitch
/ (pScreenInfo->bitsPerPixel >> 3);
FBBase = pRendition->board.shadowPtr;
} else {
pRendition->board.shadowPtr = NULL;
FBBase = pRendition->board.vmem_base+pRendition->board.fbOffset;
displayWidth=pScreenInfo->displayWidth;
}
Inited = fbScreenInit(pScreen, FBBase,
width, height,
pScreenInfo->xDpi, pScreenInfo->yDpi,
displayWidth,
pScreenInfo->bitsPerPixel);
if (!Inited)
return FALSE;
if (pScreenInfo->bitsPerPixel > 8) {
/* Fixup RGB ordering */
visual=pScreen->visuals+pScreen->numVisuals;
while (--visual >= pScreen->visuals) {
if ((visual->class | DynamicClass) == DirectColor){
visual->offsetRed = pScreenInfo->offset.red;
visual->offsetGreen = pScreenInfo->offset.green;
visual->offsetBlue = pScreenInfo->offset.blue;
visual->redMask = pScreenInfo->mask.red;
visual->greenMask = pScreenInfo->mask.green;
visual->blueMask = pScreenInfo->mask.blue;
}
}
}
/* must be after RGB ordering fixed */
fbPictureInit (pScreen, 0, 0);
xf86SetBlackWhitePixels(pScreen);
miInitializeBackingStore(pScreen);
/*********************************************************/
/* The actual setup of the driver-specific code */
/* has to be after fbScreenInit and before cursor init */
/*********************************************************/
#if USE_ACCEL
if (pRendition->board.accel)
RENDITIONAccelXAAInit (pScreen);
#endif
/* Initialise cursor functions */
xf86SetSilkenMouse(pScreen);
miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
if(!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0)&&
!pRendition->board.rotate){
/* Initialise HW cursor */
if(!RenditionHWCursorInit(scrnIndex, pScreen)){
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Hardware Cursor initalization failed!!\n");
}
}
if (pRendition->board.shadowfb) {
RefreshAreaFuncPtr refreshArea = renditionRefreshArea;
if(pRendition->board.rotate) {
if (!pRendition->board.PointerMoved) {
pRendition->board.PointerMoved = pScreenInfo->PointerMoved;
pScreenInfo->PointerMoved = renditionPointerMoved;
}
switch(pScreenInfo->bitsPerPixel) {
case 8: refreshArea = renditionRefreshArea8; break;
case 16: refreshArea = renditionRefreshArea16; break;
case 24: refreshArea = renditionRefreshArea24; break;
case 32: refreshArea = renditionRefreshArea32; break;
}
}
ShadowFBInit(pScreen, refreshArea);
}
/* Setup default colourmap */
if (!miCreateDefColormap(pScreen))
return FALSE;
/* Try the new code based on the new colormap layer */
if (pScreenInfo->depth > 1)
if (!xf86HandleColormaps(pScreen, 256, pScreenInfo->rgbBits,
renditionLoadPalette, NULL,
CMAP_LOAD_EVEN_IF_OFFSCREEN|
CMAP_RELOAD_ON_MODE_SWITCH)) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Colormap initialization failed\n");
return FALSE;
}
xf86DPMSInit(pScreen, renditionDPMSSet, 0);
if (xf86ReturnOptValBool(pRendition->Options, OPTION_OVERCLOCK_MEM,0)) {
pRendition->board.overclock_mem=TRUE;
}
/* Wrap the screen's CloseScreen vector and set its SaveScreen vector */
pRendition->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = renditionCloseScreen;
pScreen->SaveScreen = renditionSaveScreen;
if (!Inited)
renditionCloseScreen(scrnIndex, pScreen);
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options);
#ifdef DEBUG
ErrorF("ScreenInit OK...!!!!\n");
sleep(1);
#endif
return Inited;
}
static Bool
renditionSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags)
{
#ifdef DEBUG
ErrorF("RENDITION: renditionSwitchMode() called\n");
#endif
return renditionSetMode(xf86Screens[scrnIndex], pMode);
}
static void
renditionAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScreenInfo=xf86Screens[scrnIndex];
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
int offset, virtualwidth, bitsPerPixel;
#ifdef DEBUG
ErrorF("RENDITION: renditionAdjustFrame() called\n");
#endif
bitsPerPixel=pScreenInfo->bitsPerPixel;
virtualwidth=pRendition->mode.virtualwidth;
offset=(y*virtualwidth+x)*(bitsPerPixel>>3);
offset+= pRendition->board.fbOffset;
#ifdef DEBUG
ErrorF ("MOVING SCREEN %d bytes!!\n",offset);
#endif
verite_setframebase(pScreenInfo, offset);
}
static Bool
renditionEnterVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex];
vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo);
#ifdef DEBUG
ErrorF("RENDITION: renditionEnterVT() called\n");
#endif
/* Map VGA aperture */
if (!vgaHWMapMem(pScreenInfo))
return FALSE;
/* Unlock VGA registers */
vgaHWUnlock(pvgaHW);
if (!renditionSetMode(pScreenInfo, pScreenInfo->currentMode))
return FALSE;
(*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
return TRUE;
}
static void
renditionLeaveVT(int scrnIndex, int flags)
{
#ifdef DEBUG
ErrorF("RENDITION: renditionLeaveVT() called\n");
#endif
renditionLeaveGraphics(xf86Screens[scrnIndex]);
}
static void
renditionFreeScreen(int scrnIndex, int flags)
{
renditionFreeRec(xf86Screens[scrnIndex]);
}
static ModeStatus
renditionValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose,
int flags)
{
if (pMode->Flags & V_INTERLACE)
return MODE_NO_INTERLACE;
return MODE_OK;
}
static Bool
renditionMapMem(ScrnInfoPtr pScreenInfo)
{
Bool WriteCombine;
int mapOption;
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
#ifdef DEBUG
ErrorF("Mapping ...\n");
ErrorF("%d %d %d %x %d\n", pScreenInfo->scrnIndex, VIDMEM_FRAMEBUFFER,
pRendition->pcitag,
pRendition->board.mem_base, pScreenInfo->videoRam * 1024);
#endif
if (pRendition->board.chip == V1000_DEVICE){
/* Some V1000 boards are known to have problems with Write-Combining */
/* V2x00 also found to have similar problems with memcpy & WC ! */
WriteCombine = 0;
} else {
/* Activate Write_Combine if possible */
WriteCombine = 1;
}
/* Override on users request */
WriteCombine
= xf86ReturnOptValBool(pRendition->Options, OPTION_FBWC, WriteCombine);
if (WriteCombine) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
("Requesting Write-Combined memory access\n"));
mapOption = VIDMEM_FRAMEBUFFER;
} else {
xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
("Requesting MMIO-style memory access\n"));
mapOption = VIDMEM_MMIO;
}
pRendition->board.vmem_base=
xf86MapPciMem(pScreenInfo->scrnIndex, mapOption,
pRendition->pcitag,
(unsigned long)pRendition->board.mem_base,
pScreenInfo->videoRam * 1024);
return TRUE;
#ifdef DEBUG0
ErrorF("Done\n");
#endif
}
static Bool
renditionUnmapMem(ScrnInfoPtr pScreenInfo)
{
#ifdef DEBUG
ErrorF("Unmapping ...\n");
#endif
xf86UnMapVidMem(pScreenInfo->scrnIndex,
RENDITIONPTR(pScreenInfo)->board.vmem_base,
pScreenInfo->videoRam * 1024);
return TRUE;
#ifdef DEBUG0
ErrorF("Done\n");
#endif
}
static void
renditionLoadPalette(ScrnInfoPtr pScreenInfo, int numColors,
int *indices, LOCO *colors,
VisualPtr pVisual)
{
verite_setpalette(pScreenInfo, numColors, indices, colors, pVisual);
}
xf86MonPtr
renditionProbeDDC(ScrnInfoPtr pScreenInfo, int index)
{
vbeInfoPtr pVbe;
xf86MonPtr mon = NULL;
if (xf86LoadSubModule(pScreenInfo, "vbe")) {
xf86LoaderReqSymLists(vbeSymbols, NULL);
pVbe = VBEInit(NULL,index);
mon = vbeDoEDID(pVbe, NULL);
vbeFree(pVbe);
}
return mon;
}
# if 0
static xf86MonPtr
renditionDDC (ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
IOADDRESS iob=pRendition->board.io_base;
vu32 temp;
xf86MonPtr MonInfo = NULL;
temp = verite_in32(iob+CRTCCTL); /* Remember original value */
/* Enable DDC1 */
verite_out32(iob+CRTCCTL,(temp|
CRTCCTL_ENABLEDDC|
CRTCCTL_VSYNCENABLE|
CRTCCTL_VIDEOENABLE));
MonInfo = xf86DoEDID_DDC1(pScreenInfo->scrnIndex,
vgaHWddc1SetSpeed,
renditionDDC1Read );
verite_out32(iob+CRTCCTL,temp); /* return the original values */
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"DDC Monitor info: %p\n", MonInfo);
xf86PrintEDID( MonInfo );
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"end of DDC Monitor info\n\n");
/* xf86SetDDCproperties(pScreenInfo, MonInfo); */
return MonInfo;
}
static unsigned int
renditionDDC1Read (ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
IOADDRESS iob=pRendition->board.io_base;
vu32 value = 0;
/* wait for Vsync */
while (!(verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC));
while (verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC);
/* Read the value */
value = verite_in32(iob+CRTCCTL) & CRTCCTL_DDCDATA;
return value;
}
void
renditionProbeDDC(ScrnInfoPtr pScreenInfo, int index)
{
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScreenInfo, "vbe")) {
xf86LoaderReqSymLists(vbeSymbols, NULL);
pVbe = VBEInit(NULL,index);
ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
vbeFree(pVbe);
}
}
#endif
|