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
|
/*
* $Id$
*
* Copyright 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.c,v 1.1 1999/11/19 13:53:57 hohndel Exp $ */
#include "s3reg.h"
#define CR00 S3_CR+0x00
#define CR01 S3_CR+0x01
#define CR02 S3_CR+0x02
#define CR03 S3_CR+0x03
#define CR04 S3_CR+0x04
#define CR05 S3_CR+0x05
#define CR06 S3_CR+0x06
#define CR07 S3_CR+0x07
#define CR08 S3_CR+0x08
#define CR09 S3_CR+0x09
#define CR0A S3_CR+0x0A
#define CR0B S3_CR+0x0B
#define CR0C S3_CR+0x0C
#define CR0D S3_CR+0x0D
#define CR0E S3_CR+0x0E
#define CR0F S3_CR+0x0F
#define CR10 S3_CR+0x10
#define CR11 S3_CR+0x11
#define CR12 S3_CR+0x12
#define CR13 S3_CR+0x13
#define CR14 S3_CR+0x14
#define CR15 S3_CR+0x15
#define CR16 S3_CR+0x16
#define CR17 S3_CR+0x17
#define CR18 S3_CR+0x18
#define CR19 S3_CR+0x19
#define CR1A S3_CR+0x1A
#define CR1B S3_CR+0x1B
#define CR1C S3_CR+0x1C
#define CR1D S3_CR+0x1D
#define CR1E S3_CR+0x1E
#define CR1F S3_CR+0x1F
#define CR20 S3_CR+0x20
#define CR21 S3_CR+0x21
#define CR22 S3_CR+0x22
#define CR23 S3_CR+0x23
#define CR24 S3_CR+0x24
#define CR25 S3_CR+0x25
#define CR26 S3_CR+0x26
#define CR27 S3_CR+0x27
#define CR28 S3_CR+0x28
#define CR29 S3_CR+0x29
#define CR2A S3_CR+0x2A
#define CR2B S3_CR+0x2B
#define CR2C S3_CR+0x2C
#define CR2D S3_CR+0x2D
#define CR2E S3_CR+0x2E
#define CR2F S3_CR+0x2F
#define CR30 S3_CR+0x30
#define CR31 S3_CR+0x31
#define CR32 S3_CR+0x32
#define CR33 S3_CR+0x33
#define CR34 S3_CR+0x34
#define CR35 S3_CR+0x35
#define CR36 S3_CR+0x36
#define CR37 S3_CR+0x37
#define CR38 S3_CR+0x38
#define CR39 S3_CR+0x39
#define CR3A S3_CR+0x3A
#define CR3B S3_CR+0x3B
#define CR3C S3_CR+0x3C
#define CR3D S3_CR+0x3D
#define CR3E S3_CR+0x3E
#define CR3F S3_CR+0x3F
#define CR40 S3_CR+0x40
#define CR41 S3_CR+0x41
#define CR42 S3_CR+0x42
#define CR43 S3_CR+0x43
#define CR44 S3_CR+0x44
#define CR45 S3_CR+0x45
#define CR46 S3_CR+0x46
#define CR47 S3_CR+0x47
#define CR48 S3_CR+0x48
#define CR49 S3_CR+0x49
#define CR4A S3_CR+0x4A
#define CR4B S3_CR+0x4B
#define CR4C S3_CR+0x4C
#define CR4D S3_CR+0x4D
#define CR4E S3_CR+0x4E
#define CR4F S3_CR+0x4F
#define CR50 S3_CR+0x50
#define CR51 S3_CR+0x51
#define CR52 S3_CR+0x52
#define CR53 S3_CR+0x53
#define CR54 S3_CR+0x54
#define CR55 S3_CR+0x55
#define CR56 S3_CR+0x56
#define CR57 S3_CR+0x57
#define CR58 S3_CR+0x58
#define CR59 S3_CR+0x59
#define CR5A S3_CR+0x5A
#define CR5B S3_CR+0x5B
#define CR5C S3_CR+0x5C
#define CR5D S3_CR+0x5D
#define CR5E S3_CR+0x5E
#define CR5F S3_CR+0x5F
#define CR60 S3_CR+0x60
#define CR61 S3_CR+0x61
#define CR62 S3_CR+0x62
#define CR63 S3_CR+0x63
#define CR64 S3_CR+0x64
#define CR65 S3_CR+0x65
#define CR66 S3_CR+0x66
#define CR67 S3_CR+0x67
#define CR68 S3_CR+0x68
#define CR69 S3_CR+0x69
#define CR6A S3_CR+0x6A
#define CR6B S3_CR+0x6B
#define CR6C S3_CR+0x6C
#define CR6D S3_CR+0x6D
#define CR6E S3_CR+0x6E
#define CR6F S3_CR+0x6F
#define CR70 S3_CR+0x70
#define CR71 S3_CR+0x71
#define CR72 S3_CR+0x72
#define CR73 S3_CR+0x73
#define CR74 S3_CR+0x74
#define CR75 S3_CR+0x75
#define CR76 S3_CR+0x76
#define CR77 S3_CR+0x77
#define CR78 S3_CR+0x78
#define CR79 S3_CR+0x79
#define CR7A S3_CR+0x7A
#define CR7B S3_CR+0x7B
#define CR7C S3_CR+0x7C
#define CR7D S3_CR+0x7D
#define CR7E S3_CR+0x7E
#define CR7F S3_CR+0x7F
#define CR80 S3_CR+0x80
#define CR81 S3_CR+0x81
#define CR82 S3_CR+0x82
#define CR83 S3_CR+0x83
#define CR84 S3_CR+0x84
#define CR85 S3_CR+0x85
#define CR86 S3_CR+0x86
#define CR87 S3_CR+0x87
#define CR88 S3_CR+0x88
#define CR89 S3_CR+0x89
#define CR8A S3_CR+0x8A
#define CR8B S3_CR+0x8B
#define CR8C S3_CR+0x8C
#define CR8D S3_CR+0x8D
#define CR8E S3_CR+0x8E
#define CR8F S3_CR+0x8F
#define CR90 S3_CR+0x90
#define CR91 S3_CR+0x91
#define CR92 S3_CR+0x92
#define CR93 S3_CR+0x93
#define CR94 S3_CR+0x94
#define CR95 S3_CR+0x95
#define CR96 S3_CR+0x96
#define CR97 S3_CR+0x97
#define CR98 S3_CR+0x98
#define CR99 S3_CR+0x99
#define CR9A S3_CR+0x9A
#define CR9B S3_CR+0x9B
#define CR9C S3_CR+0x9C
#define CR9D S3_CR+0x9D
#define CR9E S3_CR+0x9E
#define CR9F S3_CR+0x9F
#define CRA0 S3_CR+0xA0
#define CRA1 S3_CR+0xA1
#define CRA2 S3_CR+0xA2
#define CRA3 S3_CR+0xA3
#define CRA4 S3_CR+0xA4
#define CRA5 S3_CR+0xA5
#define CRA6 S3_CR+0xA6
#define CRA7 S3_CR+0xA7
#define CRA8 S3_CR+0xA8
#define CRA9 S3_CR+0xA9
#define CRAA S3_CR+0xAA
#define CRAB S3_CR+0xAB
#define CRAC S3_CR+0xAC
#define CRAD S3_CR+0xAD
#define CRAE S3_CR+0xAE
#define CRAF S3_CR+0xAF
#define CRB0 S3_CR+0xB0
#define CRB1 S3_CR+0xB1
#define CRB2 S3_CR+0xB2
#define CRB3 S3_CR+0xB3
#define CRB4 S3_CR+0xB4
#define CRB5 S3_CR+0xB5
#define CRB6 S3_CR+0xB6
#define CRB7 S3_CR+0xB7
#define CRB8 S3_CR+0xB8
#define CRB9 S3_CR+0xB9
#define CRBA S3_CR+0xBA
#define CRBB S3_CR+0xBB
#define CRBC S3_CR+0xBC
#define CRBD S3_CR+0xBD
#define CRBE S3_CR+0xBE
#define CRBF S3_CR+0xBF
#define CR_FIRST CR00
VgaReg s3_h_total[] = {
CR00, 0, 8,
CR5D, 0, 1,
CR5F, 0, 2,
VGA_REG_END
};
VgaReg s3_h_display_end[] = {
CR01, 0, 8,
CR5D, 1, 1,
CR5F, 2, 2,
VGA_REG_END
};
VgaReg s3_h_blank_start[] = {
CR02, 0, 8,
CR5D, 2, 1,
CR5F, 4, 2,
VGA_REG_END
};
VgaReg s3_h_blank_end[] = {
CR03, 0, 5,
CR05, 7, 1,
VGA_REG_END
};
VgaReg s3_display_skew[] = {
CR03, 5, 2,
VGA_REG_END
};
VgaReg s3_h_sync_start[] = {
CR04, 0, 8,
CR5D, 4, 1,
CR5F, 6, 2,
VGA_REG_END
};
VgaReg s3_h_sync_end[] = {
CR05, 0, 5,
VGA_REG_END
};
VgaReg s3_h_skew[] = {
CR05, 5, 2,
VGA_REG_END
};
VgaReg s3_v_total[] = {
CR06, 0, 8,
CR07, 0, 1,
CR07, 5, 1,
CR5E, 0, 1,
VGA_REG_END
};
VgaReg s3_preset_row_scan[] = {
CR08, 0, 8,
VGA_REG_END
};
VgaReg s3_max_scan_line[] = {
CR09, 0, 5,
VGA_REG_END
};
VgaReg s3_start_address[] = {
CR0D, 0, 8,
CR0C, 0, 8,
CR69, 0, 7,
VGA_REG_END
};
VgaReg s3_v_retrace_start[] = {
CR10, 0, 8,
CR07, 2, 1,
CR07, 7, 1,
CR5E, 4, 1,
VGA_REG_END
};
VgaReg s3_v_retrace_end[] = {
CR11, 0, 4,
VGA_REG_END
};
VgaReg s3_clear_v_retrace_int[] = {
CR11, 4, 1,
VGA_REG_END
};
VgaReg s3_disable_v_retrace_int[] = {
CR11, 5, 1,
VGA_REG_END
};
VgaReg s3_lock_crtc[] = {
CR11, 7, 1,
VGA_REG_END
};
VgaReg s3_v_display_end[] = {
CR12, 0, 8,
CR07, 1, 1,
CR07, 6, 1,
CR5E, 1, 1,
VGA_REG_END
};
VgaReg s3_screen_offset[] = {
CR13, 0, 8,
CR51, 4, 2,
VGA_REG_END
};
VgaReg s3_count_by_4_mode[] = {
CR14, 5, 1,
VGA_REG_END
};
VgaReg s3_doubleword_mode[] = {
CR14, 6, 1,
VGA_REG_END
};
VgaReg s3_v_blank_start[] = {
CR15, 0, 8,
CR07, 3, 1,
CR09, 5, 1,
CR5E, 2, 1,
VGA_REG_END
};
VgaReg s3_v_blank_end[] = {
CR16, 0, 8,
VGA_REG_END
};
VgaReg s3_2bk_cga[] = {
CR17, 0, 1,
VGA_REG_END
};
VgaReg s3_4bk_hga[] = {
CR17, 1, 1,
VGA_REG_END
};
VgaReg s3_v_total_double[] = {
CR17, 2, 1,
VGA_REG_END
};
VgaReg s3_word_mode[] = {
CR17, 3, 1,
VGA_REG_END
};
VgaReg s3_address_16k_wrap[] = {
CR17, 5, 1,
VGA_REG_END
};
VgaReg s3_byte_mode[] = {
CR17, 6, 1,
VGA_REG_END
};
VgaReg s3_hardware_reset[] = {
CR17, 7, 1,
VGA_REG_END
};
VgaReg s3_line_compare[] = {
CR18, 0, 8,
CR07, 4, 1,
CR09, 6, 1,
CR5E, 6, 1,
VGA_REG_END
};
VgaReg s3_device_id[] = {
CR2E, 0, 8,
CR2D, 0, 8,
VGA_REG_END
};
VgaReg s3_revision[] = {
CR2F, 0, 8,
VGA_REG_END
};
VgaReg s3_enable_vga_16bit[] = {
CR31, 2, 1,
VGA_REG_END
};
VgaReg s3_enhanced_memory_mapping[] = {
CR31, 3, 1,
VGA_REG_END
};
VgaReg s3_lock_dac_writes[] = {
CR33, 4, 1,
VGA_REG_END
};
VgaReg s3_border_select[] = {
CR33, 5, 1,
VGA_REG_END
};
VgaReg s3_lock_palette[] = {
CR33, 6, 1,
VGA_REG_END
};
VgaReg s3_enable_sff[] = {
CR34, 4, 1,
VGA_REG_END
};
VgaReg s3_lock_vert[] = {
CR35, 4, 1,
VGA_REG_END
};
VgaReg s3_lock_horz[] = {
CR35, 5, 1,
VGA_REG_END
};
VgaReg s3_io_disable[] = {
CR36, 4, 1,
VGA_REG_END
};
VgaReg s3_mem_size[] = {
CR36, 5, 3,
VGA_REG_END
};
VgaReg s3_register_lock_1 [] = {
CR38, 0, 8, /* load with 0x48 */
VGA_REG_END
};
VgaReg s3_register_lock_2 [] = {
CR39, 0, 8, /* load with 0xa0 */
VGA_REG_END
};
VgaReg s3_refresh_control[] = {
CR3A, 0, 2,
VGA_REG_END
};
VgaReg s3_enable_256[] = {
CR3A, 4, 1,
VGA_REG_END
};
VgaReg s3_disable_pci_read_bursts[] = {
CR3A, 7, 1,
VGA_REG_END
};
VgaReg s3_h_start_fifo_fetch[] = {
CR3B, 0, 8,
CR5D, 6, 1,
CR5B, 2, 2,
VGA_REG_END
};
VgaReg s3_enable_2d_access[] = {
CR40, 0, 1,
VGA_REG_END
};
VgaReg s3_interlace[] = {
CR42, 5, 1,
VGA_REG_END
};
VgaReg s3_old_screen_off_8[] = {
CR43, 2, 1,
VGA_REG_END
};
VgaReg s3_h_counter_double_mode[] = {
CR43, 7, 1,
VGA_REG_END
};
VgaReg s3_cursor_enable[] = {
CR45, 0, 1,
VGA_REG_END
};
VgaReg s3_cursor_right[] = {
CR45, 4, 1,
VGA_REG_END
};
VgaReg s3_cursor_xhigh[] = {
CR46, 0, 3,
VGA_REG_END
};
VgaReg s3_cursor_xlow[] = {
CR47, 0, 8,
VGA_REG_END
};
VgaReg s3_cursor_yhigh[] = {
CR48, 0, 3,
VGA_REG_END
};
VgaReg s3_cursor_ylow[] = {
CR49, 0, 8,
VGA_REG_END
};
VgaReg s3_cursor_fg[] = {
CR4A, 0, 8,
VGA_REG_END
};
VgaReg s3_cursor_bg[] = {
CR4B, 0, 8,
VGA_REG_END
};
VgaReg s3_cursor_address[] = {
CR4D, 0, 8,
CR4C, 0, 8,
VGA_REG_END
};
VgaReg s3_cursor_xoff[] = {
CR4E, 0, 6,
VGA_REG_END
};
VgaReg s3_cursor_yoff[] = {
CR4F, 0, 6,
VGA_REG_END
};
VgaReg s3_ge_screen_width[] = {
CR50, 6, 2,
CR50, 0, 1,
VGA_REG_END
};
VgaReg s3_pixel_length[] = {
CR50, 4, 2,
VGA_REG_END
};
VgaReg s3_big_endian_linear[] = {
CR53, 1, 2,
VGA_REG_END
};
VgaReg s3_mmio_select[] = {
CR53, 3, 2,
VGA_REG_END
};
VgaReg s3_mmio_window[] = {
CR53, 5, 1,
VGA_REG_END
};
VgaReg s3_swap_nibbles[] = {
CR53, 6, 1,
VGA_REG_END
};
VgaReg s3_cursor_ms_x11[] = {
CR55, 4, 1,
VGA_REG_END
};
VgaReg s3_linear_window_size[] = {
CR58, 0, 2,
VGA_REG_END
};
VgaReg s3_enable_linear[] = {
CR58, 4, 1,
VGA_REG_END
};
VgaReg s3_h_blank_extend[] = {
CR5D, 3, 1,
VGA_REG_END
};
VgaReg s3_h_sync_extend[] = {
CR5D, 5, 1,
VGA_REG_END
};
VgaReg s3_sdclk_skew[] = {
CR60, 0, 4,
VGA_REG_END
};
VgaReg s3_delay_blank[] = {
CR65, 3, 2,
VGA_REG_END
};
VgaReg s3_delay_h_enable[] = {
CR65, 6, 2,
CR65, 0, 1,
VGA_REG_END
};
VgaReg s3_enable_2d_3d[] = {
CR66, 0, 1,
VGA_REG_END
};
VgaReg s3_pci_disconnect_enable[] = {
CR66, 3, 1,
VGA_REG_END
};
VgaReg s3_pci_retry_enable[] = {
CR66, 7, 1,
VGA_REG_END
};
VgaReg s3_color_mode[] = {
CR67, 4, 4,
VGA_REG_END
};
VgaReg s3_primary_stream_timeout[] = {
CR71, 0, 8,
VGA_REG_END
};
VgaReg s3_master_control_unit_timeout[] = {
CR74, 0, 8,
VGA_REG_END
};
VgaReg s3_command_buffer_timeout[] = {
CR75, 0, 8,
VGA_REG_END
};
VgaReg s3_lpb_timeout[] = {
CR76, 0, 8,
VGA_REG_END
};
VgaReg s3_cpu_timeout[] = {
CR78, 0, 8,
VGA_REG_END
};
VgaReg s3_2d_graphics_engine_timeout[] = {
CR79, 0, 8,
VGA_REG_END
};
VgaReg s3_fifo_drain_delay[] = {
CR85, 0, 3,
VGA_REG_END
};
VgaReg s3_fifo_fetch_timing[] = {
CR85, 4, 1,
VGA_REG_END
};
VgaReg s3_dac_power_up_time[] = {
CR86, 0, 7,
VGA_REG_END
};
VgaReg s3_dac_power_saving_disable[] = {
CR86, 7, 1,
VGA_REG_END
};
VgaReg s3_primary_stream_l1[] = {
CR91, 0, 8,
CR90, 0, 3,
VGA_REG_END
};
#define CR_LAST CR91
#define SR00 S3_SR+0x00
#define SR01 S3_SR+0x01
#define SR02 S3_SR+0x02
#define SR03 S3_SR+0x03
#define SR04 S3_SR+0x04
#define SR05 S3_SR+0x05
#define SR06 S3_SR+0x06
#define SR07 S3_SR+0x07
#define SR08 S3_SR+0x08
#define SR09 S3_SR+0x09
#define SR0A S3_SR+0x0A
#define SR0B S3_SR+0x0B
#define SR0C S3_SR+0x0C
#define SR0D S3_SR+0x0D
#define SR0E S3_SR+0x0E
#define SR0F S3_SR+0x0F
#define SR10 S3_SR+0x10
#define SR11 S3_SR+0x11
#define SR12 S3_SR+0x12
#define SR13 S3_SR+0x13
#define SR14 S3_SR+0x14
#define SR15 S3_SR+0x15
#define SR16 S3_SR+0x16
#define SR17 S3_SR+0x17
#define SR18 S3_SR+0x18
#define SR19 S3_SR+0x19
#define SR1A S3_SR+0x1A
#define SR1B S3_SR+0x1B
#define SR1C S3_SR+0x1C
#define SR1D S3_SR+0x1D
#define SR1E S3_SR+0x1E
#define SR1F S3_SR+0x1F
#define SR20 S3_SR+0x20
#define SR21 S3_SR+0x21
#define SR22 S3_SR+0x22
#define SR23 S3_SR+0x23
#define SR24 S3_SR+0x24
#define SR25 S3_SR+0x25
#define SR26 S3_SR+0x26
#define SR27 S3_SR+0x27
#define SR28 S3_SR+0x28
#define SR29 S3_SR+0x29
#define SR2A S3_SR+0x2A
#define SR2B S3_SR+0x2B
#define SR2C S3_SR+0x2C
#define SR2D S3_SR+0x2D
#define SR2E S3_SR+0x2E
#define SR2F S3_SR+0x2F
#define SR30 S3_SR+0x30
#define SR31 S3_SR+0x31
#define SR32 S3_SR+0x32
#define SR33 S3_SR+0x33
#define SR34 S3_SR+0x34
#define SR35 S3_SR+0x35
#define SR36 S3_SR+0x36
#define SR37 S3_SR+0x37
#define SR38 S3_SR+0x38
#define SR39 S3_SR+0x39
#define SR3A S3_SR+0x3A
#define SR3B S3_SR+0x3B
#define SR3C S3_SR+0x3C
#define SR3D S3_SR+0x3D
#define SR3E S3_SR+0x3E
#define SR3F S3_SR+0x3F
#define SR40 S3_SR+0x40
#define SR41 S3_SR+0x41
#define SR42 S3_SR+0x42
#define SR43 S3_SR+0x43
#define SR44 S3_SR+0x44
#define SR45 S3_SR+0x45
#define SR46 S3_SR+0x46
#define SR47 S3_SR+0x47
#define SR48 S3_SR+0x48
#define SR49 S3_SR+0x49
#define SR4A S3_SR+0x4A
#define SR4B S3_SR+0x4B
#define SR4C S3_SR+0x4C
#define SR4D S3_SR+0x4D
#define SR4E S3_SR+0x4E
#define SR4F S3_SR+0x4F
#define SR50 S3_SR+0x50
#define SR51 S3_SR+0x51
#define SR52 S3_SR+0x52
#define SR53 S3_SR+0x53
#define SR54 S3_SR+0x54
#define SR55 S3_SR+0x55
#define SR56 S3_SR+0x56
#define SR57 S3_SR+0x57
#define SR58 S3_SR+0x58
#define SR59 S3_SR+0x59
#define SR5A S3_SR+0x5A
#define SR5B S3_SR+0x5B
#define SR5C S3_SR+0x5C
#define SR5D S3_SR+0x5D
#define SR5E S3_SR+0x5E
#define SR5F S3_SR+0x5F
#define SR60 S3_SR+0x60
#define SR61 S3_SR+0x61
#define SR62 S3_SR+0x62
#define SR63 S3_SR+0x63
#define SR64 S3_SR+0x64
#define SR65 S3_SR+0x65
#define SR66 S3_SR+0x66
#define SR67 S3_SR+0x67
#define SR68 S3_SR+0x68
#define SR69 S3_SR+0x69
#define SR6A S3_SR+0x6A
#define SR6B S3_SR+0x6B
#define SR6C S3_SR+0x6C
#define SR6D S3_SR+0x6D
#define SR6E S3_SR+0x6E
#define SR6F S3_SR+0x6F
#define SR_FIRST SR02
VgaReg s3_dot_clock_8[] = {
SR01, 0, 1,
VGA_REG_END
};
VgaReg s3_screen_off[] = {
SR01, 5, 1,
VGA_REG_END
};
VgaReg s3_enable_write_plane[] = {
SR02, 0, 4,
VGA_REG_END
};
VgaReg s3_extended_memory_access[] = {
SR04, 1, 1,
VGA_REG_END
};
VgaReg s3_sequential_addressing_mode[] = {
SR04, 2, 1,
VGA_REG_END
};
VgaReg s3_select_chain_4_mode[] = {
SR04, 3, 1,
VGA_REG_END
};
VgaReg s3_unlock_extended_sequencer[] = {
SR08, 0, 8, /* write 0x06 */
VGA_REG_END
};
VgaReg s3_linear_addressing_control[] = {
SR09, 0, 1,
VGA_REG_END
};
VgaReg s3_disable_io_ports[] = {
SR09, 7, 1,
VGA_REG_END
};
VgaReg s3_hsync_control[] = {
SR0D, 4, 2,
VGA_REG_END
};
VgaReg s3_vsync_control[] = {
SR0D, 6, 2,
VGA_REG_END
};
VgaReg s3_mclk_n[] = {
SR10, 0, 5,
VGA_REG_END
};
VgaReg s3_mclk_r[] = {
SR10, 5, 2,
VGA_REG_END
};
VgaReg s3_mclk_m[] = {
SR11, 0, 7,
VGA_REG_END
};
VgaReg s3_dclk_n[] = {
SR12, 0, 6,
SR29, 4, 1,
VGA_REG_END
};
VgaReg s3_dclk_r[] = {
SR12, 6, 2,
SR29, 2, 1,
VGA_REG_END
};
VgaReg s3_dclk_m[] = {
SR13, 0, 8,
SR29, 3, 1,
VGA_REG_END
};
VgaReg s3_mclk_load[] = {
SR15, 0, 1,
VGA_REG_END
};
VgaReg s3_dclk_load[] = {
SR15, 1, 1,
VGA_REG_END
};
VgaReg s3_dclk_over_2[] = {
SR15, 4, 1,
VGA_REG_END
};
VgaReg s3_clock_load_imm[] = {
SR15, 5, 1,
VGA_REG_END
};
VgaReg s3_dclk_invert[] = {
SR15, 6, 1,
VGA_REG_END
};
VgaReg s3_enable_clock_double[] = {
SR18, 7, 1,
VGA_REG_END
};
VgaReg s3_dclk_double_15_16_invert[] = {
SR1A, 0, 1,
VGA_REG_END
};
VgaReg s3_enable_gamma_correction[] = {
SR1B, 3, 1,
VGA_REG_END
};
VgaReg s3_enable_8_bit_luts[] = {
SR1B, 4, 1,
VGA_REG_END
};
VgaReg s3_dclk_control[] = {
SR1B, 7, 1,
VGA_REG_END
};
VgaReg s3_vga_dclk_n[] = {
SR36, 0, 6,
SR39, 4, 1,
VGA_REG_END
};
VgaReg s3_vga_dclk_r[] = {
SR36, 6, 2,
SR39, 2, 1,
VGA_REG_END
};
VgaReg s3_vga_dclk_m1[] = {
SR37, 0, 8,
SR39, 3, 1,
VGA_REG_END
};
VgaReg s3_vga_dclk_m2[] = {
SR38, 0, 8,
SR39, 3, 1,
VGA_REG_END
};
VgaReg s3_vga_clk_select[] = {
SR39, 0, 1,
VGA_REG_END
};
#define SR_LAST SR39
#define AR00 (S3_AR+0x00)
#define AR10 (S3_AR+0x10)
#define AR11 (S3_AR+0x11)
#define AR12 (S3_AR+0x12)
#define AR13 (S3_AR+0x13)
#define AR14 (S3_AR+0x14)
#define AR_FIRST AR00
VgaReg s3_select_graphics_mode[] = {
AR10, 0, 1,
VGA_REG_END
};
VgaReg s3_enable_blinking[] = {
AR10, 3, 1,
VGA_REG_END
};
VgaReg s3_border_color[] = {
AR11, 0, 8,
VGA_REG_END
};
#define AR_LAST AR11
VgaReg s3_io_addr_select[] = {
S3_MISC_OUT, 0, 1,
VGA_REG_END
};
VgaReg s3_enable_ram[] = {
S3_MISC_OUT, 1, 1,
VGA_REG_END
};
VgaReg s3_clock_select[] = {
S3_MISC_OUT, 2, 2,
VGA_REG_END
};
VgaReg s3_horz_sync_neg[] = {
S3_MISC_OUT, 6, 1,
VGA_REG_END
};
VgaReg s3_vert_sync_neg[] = {
S3_MISC_OUT, 7, 1,
VGA_REG_END
};
VgaReg s3_display_mode_inactive[] = {
S3_INPUT_STATUS_1, 0, 1,
VGA_REG_END
};
VgaReg s3_vertical_sync_active[] = {
S3_INPUT_STATUS_1, 3, 1,
VGA_REG_END
};
VgaReg s3_dac_mask[] = {
S3_DAC + 0, 0, 8,
VGA_REG_END
};
VgaReg s3_dac_read_index[] = {
S3_DAC + 1, 0, 8,
VGA_REG_END
};
VgaReg s3_dac_write_index[] = {
S3_DAC + 2, 0, 8,
VGA_REG_END
};
VgaReg s3_dac_data[] = {
S3_DAC + 3, 0, 8,
VGA_REG_END
};
VGA8
_s3Inb (VgaCard *card, VGA16 port)
{
VGAVOL8 *reg;
if (card->closure)
return VgaReadMemb ((VGA32) card->closure + port);
else
return VgaInb (port);
}
void
_s3Outb (VgaCard *card, VGA8 value, VGA16 port)
{
if (card->closure)
VgaWriteMemb (value, (VGA32) card->closure + port);
else
VgaOutb (value, port);
}
void
_s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
{
if (reg < S3_SR + S3_NSR)
{
map->access = VgaAccessIndIo;
map->port = 0x3c4;
map->addr = 0;
map->value = 1;
map->index = reg - S3_SR;
}
else if (reg < S3_GR + S3_NGR)
{
map->access = VgaAccessIndIo;
map->port = 0x3ce;
map->addr = 0;
map->value = 1;
map->index = reg - S3_GR;
}
else if (reg < S3_AR + S3_NAR)
{
reg -= S3_AR;
map->access = VgaAccessDone;
/* reset AFF to index */
(void) _s3Inb (card, 0x3da);
if (reg >= 16)
reg |= 0x20;
_s3Outb (card, reg, 0x3c0);
if (write)
_s3Outb (card, map->value, 0x3c0);
else
map->value = _s3Inb (card, 0x3c1);
if (!(reg & 0x20))
{
/* enable video display again */
(void) _s3Inb (card, 0x3da);
_s3Outb (card, 0x20, 0x3c0);
}
return;
}
else if (reg < S3_CR + S3_NCR)
{
map->access = VgaAccessIndIo;
map->port = 0x3d4;
map->addr = 0;
map->value = 1;
map->index = reg - S3_CR;
}
else if (reg < S3_DAC + S3_NDAC)
{
map->access = VgaAccessIo;
map->port = 0x3c6 + reg - S3_DAC;
}
else switch (reg) {
case S3_MISC_OUT:
map->access = VgaAccessIo;
if (write)
map->port = 0x3c2;
else
map->port = 0x3cc;
break;
case S3_INPUT_STATUS_1:
map->access = VgaAccessIo;
map->port = 0x3da;
break;
}
if (card->closure)
{
map->port = map->port + (VGA32) card->closure;
if (map->access == VgaAccessIo)
map->access = VgaAccessMem;
if (map->access == VgaAccessIndIo)
map->access = VgaAccessIndMem;
}
}
VgaSave s3Saves[] = {
CR_FIRST, CR18,
CR31, CR_LAST,
SR_FIRST, SR15,
SR18, SR_LAST,
AR_FIRST, AR_LAST,
S3_MISC_OUT, S3_MISC_OUT,
VGA_SAVE_END
};
void
s3RegInit (S3Vga *s3vga, VGAVOL8 *mmio)
{
s3vga->card.map = _s3RegMap;
s3vga->card.closure = (void *) mmio;
s3vga->card.max = S3_NREG;
s3vga->card.values = s3vga->values;
s3vga->card.saves = s3Saves;
}
void
s3Save (S3Vga *s3vga)
{
s3vga->save_lock_crtc = s3Get(s3vga, s3_lock_crtc);
s3SetImm (s3vga, s3_lock_crtc, 0);
s3vga->save_register_lock_1 = s3Get (s3vga, s3_register_lock_1);
s3SetImm (s3vga, s3_register_lock_1, 0x48);
s3vga->save_register_lock_2 = s3Get (s3vga, s3_register_lock_2);
s3SetImm (s3vga, s3_register_lock_2, 0xa5);
s3vga->save_unlock_extended_sequencer = s3Get (s3vga, s3_unlock_extended_sequencer);
s3SetImm (s3vga, s3_unlock_extended_sequencer, 0x06);
s3vga->save_lock_horz = s3Get (s3vga, s3_lock_horz);
s3SetImm (s3vga, s3_lock_horz, 0);
s3vga->save_lock_vert = s3Get (s3vga, s3_lock_vert);
s3SetImm (s3vga, s3_lock_vert, 0);
s3vga->save_dot_clock_8 = s3Get (s3vga, s3_dot_clock_8);
VgaPreserve (&s3vga->card);
}
void
s3Reset (S3Vga *s3vga)
{
VgaRestore (&s3vga->card);
s3SetImm (s3vga, s3_clock_load_imm, 1);
s3SetImm (s3vga, s3_clock_load_imm, 0);
s3SetImm (s3vga, s3_dot_clock_8, s3vga->save_dot_clock_8);
s3SetImm (s3vga, s3_lock_vert, s3vga->save_lock_vert);
s3SetImm (s3vga, s3_lock_horz, s3vga->save_lock_horz);
s3SetImm (s3vga, s3_lock_dac_writes, s3vga->save_lock_dac_writes);
s3SetImm (s3vga, s3_unlock_extended_sequencer, s3vga->save_unlock_extended_sequencer);
s3SetImm (s3vga, s3_register_lock_2, s3vga->save_register_lock_2);
s3SetImm (s3vga, s3_register_lock_1, s3vga->save_register_lock_1);
s3SetImm (s3vga, s3_lock_crtc, s3vga->save_lock_crtc);
VgaFinish (&s3vga->card);
}
|